diff --git a/scripts/appveyor/coapp_make.ps1 b/scripts/appveyor/coapp_make.ps1 index b5a57aa1..33995906 100644 --- a/scripts/appveyor/coapp_make.ps1 +++ b/scripts/appveyor/coapp_make.ps1 @@ -1,41 +1,49 @@ -. .\scripts\appveyor\appveyor_get_build.ps1 -. .\scripts\appveyor\appveyor_get_artifacts.ps1 - -# get job artifacts -Write-Host "Start to download artifacts from other jobs" - -(Get-AppVeyorBuild).build.jobs | foreach-object { - $jobId = $_.jobId - if ($jobId -ne $env:APPVEYOR_JOB_ID) { - # Get job artifacts information - (Get-AppVeyorArtifacts -Job $jobId) | foreach-object { - # Create directory if not exists - $filePath = $_.fileName.Substring(0, $_.fileName.LastIndexOf('/')) - if (!(Test-Path -Path $filePath)) { - New-Item -ItemType "directory" -Path $filePath - } - # Download artifact from other job - Start-FileDownload "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/$($_.fileName)" -FileName $_.fileName - } - }; -} - -Write-Host "Start to build nupkg files" - -# This is the CoApp .autopkg file to create. -$autopkgFile = "scripts\coapp\kiwano.autopkg" - -# Create a copy of ".autopkg" file -Copy-Item -Path $autopkgFile -Destination ($autopkgFile + '.template') - -# Get the ".autopkg.template" file, replace "@appveyor_version" with the Appveyor version number, then save to the ".autopkg" file. -Get-Content ($autopkgFile + ".template") -Encoding UTF8 | ForEach-Object { $_ -replace "@appveyor_version", $env:appveyor_build_version } | Out-File $autopkgFile -Encoding UTF8 - -# Delete the copy file -Remove-Item -Path ($autopkgFile + '.template') - -# Use the CoApp tools to create NuGet native packages from the .autopkg. -Write-NuGetPackage $autopkgFile - -# Push all newly created .nupkg files as Appveyor artifacts for later deployment. -Get-ChildItem .\*.nupkg | ForEach-Object { Push-AppveyorArtifact $_.FullName -FileName $_.Name } +. .\scripts\appveyor\appveyor_get_build.ps1 +. .\scripts\appveyor\appveyor_get_artifacts.ps1 +. .\scripts\appveyor\copy_recurse.ps1 + +# get job artifacts +Write-Host "Start to download artifacts from other jobs" + +(Get-AppVeyorBuild).build.jobs | foreach-object { + $jobId = $_.jobId + if ($jobId -ne $env:APPVEYOR_JOB_ID) { + # Get job artifacts information + (Get-AppVeyorArtifacts -Job $jobId) | foreach-object { + # Create directory if not exists + $filePath = $_.fileName.Substring(0, $_.fileName.LastIndexOf('/')) + if (!(Test-Path -Path $filePath)) { + New-Item -ItemType "directory" -Path $filePath + } + # Download artifact from other job + Start-FileDownload "https://ci.appveyor.com/api/buildjobs/$jobId/artifacts/$($_.fileName)" -FileName $_.fileName + } + }; +} + +Write-Host "Start to build nupkg files" + +# This is the CoApp .autopkg file to create. +$autopkgFile = "scripts\coapp\kiwano.autopkg" + +# Copy include files +Copy-Recurse -Path "src\" -Destination "include\" -Filter "*.h" +Copy-Recurse -Path "src\" -Destination "include\" -Filter "*.hpp" +Remove-Item -Path "include\3rd-party" -Recurse +Copy-Recurse -Path "src\3rd-party\" -Destination "include\" -Filter "*.h" +Copy-Recurse -Path "src\3rd-party\" -Destination "include\" -Filter "*.hpp" + +# Create a copy of ".autopkg" file +Copy-Item -Path $autopkgFile -Destination ($autopkgFile + '.template') + +# Get the ".autopkg.template" file, replace "@appveyor_version" with the Appveyor version number, then save to the ".autopkg" file. +Get-Content ($autopkgFile + ".template") -Encoding UTF8 | ForEach-Object { $_ -replace "@appveyor_version", $env:appveyor_build_version } | Out-File $autopkgFile -Encoding UTF8 + +# Delete the copy file +Remove-Item -Path ($autopkgFile + '.template') + +# Use the CoApp tools to create NuGet native packages from the .autopkg. +Write-NuGetPackage $autopkgFile + +# Push all newly created .nupkg files as Appveyor artifacts for later deployment. +Get-ChildItem .\*.nupkg | ForEach-Object { Push-AppveyorArtifact $_.FullName -FileName $_.Name } diff --git a/scripts/appveyor/copy_recurse.ps1 b/scripts/appveyor/copy_recurse.ps1 new file mode 100644 index 00000000..a70c2db5 --- /dev/null +++ b/scripts/appveyor/copy_recurse.ps1 @@ -0,0 +1,23 @@ +function Copy-Recurse { + param( + [string]$Path, + [string]$Destination, + [string]$Filter + ) + + New-Item -ItemType Directory -Force -Path $Destination | Out-Null + + Get-ChildItem -Recurse -Path $Path -Filter $Filter | ForEach-Object { + $relativePath = $_.FullName.Replace((Resolve-Path $Path).Path, "") + $targetFile = Join-Path -Path $Destination -ChildPath $relativePath + + $targetFileDirectory = Split-Path -Path $targetFile -Parent + + if (!(Test-Path $targetFileDirectory)) + { + New-Item -ItemType Directory -Force -Path $targetFileDirectory | Out-Null + } + + Copy-Item -Path $_.FullName -Destination $targetFile -Force + } +} diff --git a/scripts/coapp/kiwano.autopkg b/scripts/coapp/kiwano.autopkg index cc2a8ec9..9412ec9b 100644 --- a/scripts/coapp/kiwano.autopkg +++ b/scripts/coapp/kiwano.autopkg @@ -51,7 +51,7 @@ nuget { // The nuspec file metadata. nuspec { id = Kiwano; - // "@appveyor_version" is replaced by the current Appveyor build number in the + // "appveyor_version" is replaced by the current Appveyor build number in the // pre-deployment script. version: @appveyor_version; title: Kiwano Game Framework; @@ -86,13 +86,14 @@ nuget { files { #defines { + INCLUDE_ROOT = ..\..\include; SRC_ROOT = ..\..\src; OUTPUT_DIR = ..\..\projects\output; } include: { - ${SRC_ROOT}\kiwano*\**\*.h, ${SRC_ROOT}\kiwano*\**\*.hpp, - ${SRC_ROOT}\3rd-party\**\*.h, ${SRC_ROOT}\3rd-party\**\*.hpp, + ${INCLUDE_ROOT}\**\*.h, + ${INCLUDE_ROOT}\**\*.hpp, }; // third patry