Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/rtoolsHCK.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
56 changes: 55 additions & 1 deletion tools/toolsHCK.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -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<Target>
$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<String> 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()
Expand Down