From e65bdb49cd2aec141fc339b23d745e2cf059302c Mon Sep 17 00:00:00 2001 From: zhangjianming Date: Mon, 5 Jan 2026 14:12:17 +0800 Subject: [PATCH] Add driver and supplemental file packaging support Signed-off-by: Zhang JianMing --- lib/rtoolsHCK.rb | 22 +++++++++++++++++- tools/toolsHCK.ps1 | 56 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/lib/rtoolsHCK.rb b/lib/rtoolsHCK.rb index 9fd61aa..e3fa91c 100755 --- a/lib/rtoolsHCK.rb +++ b/lib/rtoolsHCK.rb @@ -1037,7 +1037,9 @@ def handle_create_project_package(cmd_line, handler) # i. 'maximum': maximum progress counter value # i. 'message': progress info message # - def create_project_package(project, playlist = nil, handler = nil) + # +driver_path+:: Provide a driver path to include, (can be nil) + # +supplemental_path+:: Provide a supplemental path to include, (can be nil) + def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil) handle_action_exceptions(__method__) do cmd_line = ["createprojectpackage '#{project}' -rph"] cmd_line << 'json' if @json @@ -1047,6 +1049,9 @@ def create_project_package(project, playlist = nil, handler = nil) cmd_line << "-playlist #{r_playlist}" end + cmd_line << "-driver '#{driver_path}'" unless driver_path.nil? + cmd_line << "-supplemental '#{supplemental_path}'" unless supplemental_path.nil? + handler = dummy_package_progress_info_handler if handler.nil? handle_create_project_package(cmd_line.join(' '), handler) end @@ -1178,6 +1183,21 @@ def upload_to_machine(machine, l_directory, r_directory = nil) end end + # == Description + # + # Upload file/directory to the studio machine. + # + # == Params: + # + # +l_path+:: The local file/directory path + # +r_path+:: The remote destination path + def upload_to_studio(l_path, r_path) + handle_action_exceptions(__method__) do + @winrm_fs.upload(l_path, r_path) + @json ? { 'result' => 'Success' } : true + end + end + # == Description # # Download file or directory from the machine to local directory. diff --git a/tools/toolsHCK.ps1 b/tools/toolsHCK.ps1 index 8cc760c..c58067e 100644 --- a/tools/toolsHCK.ps1 +++ b/tools/toolsHCK.ps1 @@ -2076,7 +2076,7 @@ function ziptestresultlogs { # CreateProjectPackage function createprojectpackage { [CmdletBinding()] - param([Switch]$help, [Switch]$rph, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package) + param([Switch]$help, [Switch]$rph, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package, [String]$driver, [String]$supplemental) function Usage { Write-Output "createprojectpackage:" @@ -2167,6 +2167,60 @@ function createprojectpackage { $PackagePath = $env:TEMP + "\prometheus_packages\" + $(get-date).ToString("dd-MM-yyyy") + "_" + $(get-date).ToString("hh_mm_ss") + "_" + $WntdProject.Name + "." + $Studio + "x" } $PackageWriter = New-Object Microsoft.Windows.Kits.Hardware.ObjectModel.Submission.PackageWriter $WntdProject + + # Add driver files to package if specified + if (-Not [String]::IsNullOrEmpty($driver)) { + $driver = [System.IO.Path]::GetFullPath($driver) + if (Test-Path $driver) { + # Collect all targets from the project + $AllTargets = New-Object System.Collections.Generic.List[Microsoft.Windows.Kits.Hardware.ObjectModel.Target] + foreach ($Pi in $WntdProject.GetProductInstances()) { + foreach ($Target in $Pi.GetTargets()) { + $AllTargets.Add($Target) + } + } + + if ($AllTargets.Count -gt 0) { + # Create ReadOnlyCollection + $TargetArray = [Microsoft.Windows.Kits.Hardware.ObjectModel.Target[]]$AllTargets.ToArray() + $TargetList = New-Object 'System.Collections.ObjectModel.ReadOnlyCollection[Microsoft.Windows.Kits.Hardware.ObjectModel.Target]' (,$TargetArray) + + # Create ReadOnlyCollection for locales + $LocaleArray = [string[]]@("en-US") + $LocaleList = New-Object 'System.Collections.ObjectModel.ReadOnlyCollection[string]' (,$LocaleArray) + + # Create StringCollection instances for out parameters + $ErrorMessages = New-Object System.Collections.Specialized.StringCollection + $WarningMessages = New-Object System.Collections.Specialized.StringCollection + + # Separate symbols (.pdb files) from the driver directory + $symbolPath = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) + New-Item -ItemType Directory -Path $symbolPath | Out-Null + Get-ChildItem -Path $driver -Filter *.pdb -Recurse | ForEach-Object { Move-Item -Path $_.FullName -Destination $symbolPath -Force } + + $AddDriverResult = $PackageWriter.AddDriver($driver, $symbolPath, $TargetList, $LocaleList, [ref]$ErrorMessages, [ref]$WarningMessages) + + if (-Not $json) { + if ($AddDriverResult) { + Write-Output "Driver added to package from $driver" + } else { + Write-Output "Warning: Driver signability check did not pass" + foreach ($err in $ErrorMessages) { Write-Output " Error: $err" } + foreach ($warn in $WarningMessages) { Write-Output " Warning: $warn" } + } + } + } + } + } + + # Add supplemental files to package if specified + if (-Not [String]::IsNullOrEmpty($supplemental)) { + if (Test-Path $supplemental) { + $PackageWriter.AddSupplementalFiles($supplemental) + if (-Not $json) { Write-Output "Supplemental files added from $supplemental" } + } + } + if ($rph) { $PackageWriter.SetProgressActionHandler($action) } $PackageWriter.Save($PackagePath) $PackageWriter.Dispose()