Skip to content

Commit 1e1e4eb

Browse files
zjmletangkostyanf14
authored andcommitted
Add driver and supplemental file packaging support
Signed-off-by: Zhang JianMing <[email protected]>
1 parent c59b7e6 commit 1e1e4eb

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

lib/rtoolsHCK.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,9 @@ def handle_create_project_package(cmd_line, handler)
10371037
# i. 'maximum': maximum progress counter value
10381038
# i. 'message': progress info message
10391039
#
1040-
def create_project_package(project, playlist = nil, handler = nil)
1040+
# +driver_path+:: Provide a driver path to include, (can be nil)
1041+
# +supplemental_path+:: Provide a supplemental path to include, (can be nil)
1042+
def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil)
10411043
handle_action_exceptions(__method__) do
10421044
cmd_line = ["createprojectpackage '#{project}' -rph"]
10431045
cmd_line << 'json' if @json
@@ -1047,6 +1049,9 @@ def create_project_package(project, playlist = nil, handler = nil)
10471049
cmd_line << "-playlist #{r_playlist}"
10481050
end
10491051

1052+
cmd_line << "-driver '#{driver_path}'" unless driver_path.nil?
1053+
cmd_line << "-supplemental '#{supplemental_path}'" unless supplemental_path.nil?
1054+
10501055
handler = dummy_package_progress_info_handler if handler.nil?
10511056
handle_create_project_package(cmd_line.join(' '), handler)
10521057
end
@@ -1178,6 +1183,21 @@ def upload_to_machine(machine, l_directory, r_directory = nil)
11781183
end
11791184
end
11801185

1186+
# == Description
1187+
#
1188+
# Upload file/directory to the studio machine.
1189+
#
1190+
# == Params:
1191+
#
1192+
# +l_path+:: The local file/directory path
1193+
# +r_path+:: The remote destination path
1194+
def upload_to_studio(l_path, r_path)
1195+
handle_action_exceptions(__method__) do
1196+
@winrm_fs.upload(l_path, r_path)
1197+
@json ? { 'result' => 'Success' } : true
1198+
end
1199+
end
1200+
11811201
# == Description
11821202
#
11831203
# Download file or directory from the machine to local directory.

tools/toolsHCK.ps1

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ function ziptestresultlogs {
20762076
# CreateProjectPackage
20772077
function createprojectpackage {
20782078
[CmdletBinding()]
2079-
param([Switch]$help, [Switch]$rph, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package)
2079+
param([Switch]$help, [Switch]$rph, [String]$playlist, [Parameter(Position=1)][String]$project, [Parameter(Position=2)][String]$package, [String]$driver, [String]$supplemental)
20802080

20812081
function Usage {
20822082
Write-Output "createprojectpackage:"
@@ -2167,6 +2167,60 @@ function createprojectpackage {
21672167
$PackagePath = $env:TEMP + "\prometheus_packages\" + $(get-date).ToString("dd-MM-yyyy") + "_" + $(get-date).ToString("hh_mm_ss") + "_" + $WntdProject.Name + "." + $Studio + "x"
21682168
}
21692169
$PackageWriter = New-Object Microsoft.Windows.Kits.Hardware.ObjectModel.Submission.PackageWriter $WntdProject
2170+
2171+
# Add driver files to package if specified
2172+
if (-Not [String]::IsNullOrEmpty($driver)) {
2173+
$driver = [System.IO.Path]::GetFullPath($driver)
2174+
if (Test-Path $driver) {
2175+
# Collect all targets from the project
2176+
$AllTargets = New-Object System.Collections.Generic.List[Microsoft.Windows.Kits.Hardware.ObjectModel.Target]
2177+
foreach ($Pi in $WntdProject.GetProductInstances()) {
2178+
foreach ($Target in $Pi.GetTargets()) {
2179+
$AllTargets.Add($Target)
2180+
}
2181+
}
2182+
2183+
if ($AllTargets.Count -gt 0) {
2184+
# Create ReadOnlyCollection<Target>
2185+
$TargetArray = [Microsoft.Windows.Kits.Hardware.ObjectModel.Target[]]$AllTargets.ToArray()
2186+
$TargetList = New-Object 'System.Collections.ObjectModel.ReadOnlyCollection[Microsoft.Windows.Kits.Hardware.ObjectModel.Target]' (,$TargetArray)
2187+
2188+
# Create ReadOnlyCollection<String> for locales
2189+
$LocaleArray = [string[]]@("en-US")
2190+
$LocaleList = New-Object 'System.Collections.ObjectModel.ReadOnlyCollection[string]' (,$LocaleArray)
2191+
2192+
# Create StringCollection instances for out parameters
2193+
$ErrorMessages = New-Object System.Collections.Specialized.StringCollection
2194+
$WarningMessages = New-Object System.Collections.Specialized.StringCollection
2195+
2196+
# Separate symbols (.pdb files) from the driver directory
2197+
$symbolPath = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
2198+
New-Item -ItemType Directory -Path $symbolPath | Out-Null
2199+
Get-ChildItem -Path $driver -Filter *.pdb -Recurse | ForEach-Object { Move-Item -Path $_.FullName -Destination $symbolPath -Force }
2200+
2201+
$AddDriverResult = $PackageWriter.AddDriver($driver, $symbolPath, $TargetList, $LocaleList, [ref]$ErrorMessages, [ref]$WarningMessages)
2202+
2203+
if (-Not $json) {
2204+
if ($AddDriverResult) {
2205+
Write-Output "Driver added to package from $driver"
2206+
} else {
2207+
Write-Output "Warning: Driver signability check did not pass"
2208+
foreach ($err in $ErrorMessages) { Write-Output " Error: $err" }
2209+
foreach ($warn in $WarningMessages) { Write-Output " Warning: $warn" }
2210+
}
2211+
}
2212+
}
2213+
}
2214+
}
2215+
2216+
# Add supplemental files to package if specified
2217+
if (-Not [String]::IsNullOrEmpty($supplemental)) {
2218+
if (Test-Path $supplemental) {
2219+
$PackageWriter.AddSupplementalFiles($supplemental)
2220+
if (-Not $json) { Write-Output "Supplemental files added from $supplemental" }
2221+
}
2222+
}
2223+
21702224
if ($rph) { $PackageWriter.SetProgressActionHandler($action) }
21712225
$PackageWriter.Save($PackagePath)
21722226
$PackageWriter.Dispose()

0 commit comments

Comments
 (0)