From 877221dc4b27cba796a608e5b99e65f1803ec425 Mon Sep 17 00:00:00 2001 From: Trung <57174311+trungnt2910@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:10:03 +1100 Subject: [PATCH] ci: Add Build workflow `lxmonika` and the `monika.exe` CLI will be built and packed for all supported architectures for each commit. Monix is not included. This workflow only includes a basic build. No testing is carried out yet. --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++ pack.ps1 | 63 +++++++++++++++++++++++++++++++++++++ setup.ps1 | 49 +++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 pack.ps1 create mode 100644 setup.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9335980 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build + +on: + push: + branches: + - "master" + - "staging" + - "dev/**" + pull_request: + branches: + - "master" + +jobs: + build: + strategy: + matrix: + platform: [x86, x64, ARM, ARM64] + configuration: [Debug, Release] + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # Fetch everything for build metadata to work + fetch-depth: 0 + + - name: Install build dependencies + run: powershell.exe -File ${{ github.workspace }}\setup.ps1 + shell: cmd + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: Build + run: | + msbuild ${{ github.workspace }}\lxmonika.sln ^ + /p:Platform=${{ matrix.platform }} ^ + /p:Configuration=${{ matrix.configuration }} + shell: cmd + + - name: Pack build artifacts + run: | + powershell.exe -File ${{ github.workspace }}\pack.ps1 ^ + -Platform ${{ matrix.platform }} ^ + -Configuration ${{ matrix.configuration }} + shell: cmd + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: monika_${{ matrix.platform }}_${{ matrix.configuration }} + path: out diff --git a/pack.ps1 b/pack.ps1 new file mode 100644 index 0000000..b690015 --- /dev/null +++ b/pack.ps1 @@ -0,0 +1,63 @@ +param( + [Parameter(Mandatory=$true)] + [string]$Platform, + [Parameter(Mandatory=$true)] + [string]$Configuration +) + +$outDir = (Join-Path $PSScriptRoot "out") + +Remove-Item -Recurse -Path $outDir +mkdir $outDir | Out-Null + +function Get-LxMonikaArtifact( + [string]$Project, + [string]$File +) +{ + return Join-Path "$PSScriptRoot\$Project\bin\$Configuration\$Platform" $File +} + +# monika.exe + +Copy-Item ` + -Path (Get-LxMonikaArtifact "monika" "monika.exe") ` + -Destination $outDir + +# lxmonika + +$usefulExts = @(".sys", ".lib", ".cer") + +foreach ($ext in $usefulExts) +{ + Copy-Item ` + -Path (Get-LxMonikaArtifact "lxmonika" "lxmonika$ext") ` + -Destination $outDir +} + +# lxstub + +foreach ($ext in $usefulExts) +{ + Copy-Item ` + -Path (Get-LxMonikaArtifact "lxstub" "LXCORE$ext") ` + -Destination $outDir +} + +# PDBs + +$pdbDir = (Join-Path $outDir "pdb") +mkdir $pdbDir | Out-Null + +Copy-Item ` + -Path (Get-LxMonikaArtifact "monika" "monika.pdb") ` + -Destination $pdbDir + +Copy-Item ` + -Path (Get-LxMonikaArtifact "lxmonika" "lxmonika.pdb") ` + -Destination $pdbDir + +Copy-Item ` + -Path (Get-LxMonikaArtifact "lxstub" "LXCORE.pdb") ` + -Destination $pdbDir + diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..6a07e4f --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,49 @@ +# Setup WDK and corresponding SDK + +curl.exe ` + -SL https://download.microsoft.com/download/C/D/8/CD8533F8-5324-4D30-824C-B834C5AD51F9/standalonesdk/sdksetup.exe ` + -o sdksetup_14393.exe +Start-Process .\sdksetup_14393.exe -Wait -ArgumentList '/ceip off /features + /q' +Remove-Item sdksetup_14393.exe + +curl.exe ` + -SL https://download.microsoft.com/download/8/1/6/816FE939-15C7-4185-9767-42ED05524A95/wdk/wdksetup.exe ` + -o wdksetup_14393.exe +Start-Process .\wdksetup_14393.exe -Wait -ArgumentList '/ceip off /features + /q' +Remove-Item wdksetup_14393.exe + +curl.exe ` + -SL https://download.microsoft.com/download/5/A/0/5A08CEF4-3EC9-494A-9578-AB687E716C12/windowssdk/winsdksetup.exe ` + -o sdksetup_17134.exe +Start-Process .\sdksetup_17134.exe -Wait -ArgumentList '/ceip off /features + /q' +Remove-Item sdksetup_17134.exe + +curl.exe ` + -SL https://download.microsoft.com/download/B/5/8/B58D625D-17D6-47A8-B3D3-668670B6D1EB/wdk/wdksetup.exe ` + -o wdksetup_17134.exe +Start-Process .\wdksetup_17134.exe -Wait -ArgumentList '/ceip off /features + /q' +Remove-Item wdksetup_17134.exe + +# Hacks to enable ARM32 builds + +$vsPath = (vswhere -property installationPath | Out-String).Trim(); + +$arm64Path = (Join-Path $vsPath "\MSBuild\Microsoft\VC\v170\Platforms\ARM64"); +$armPath = (Join-Path $vsPath "\MSBuild\Microsoft\VC\v170\Platforms\ARM") + +if (Test-Path $arm64Path) +{ + Push-Location $arm64Path + foreach ($file in (Get-ChildItem -Recurse $arm64Path -File)) + { + $relativePath = Resolve-Path -Path $file.FullName -Relative + $armFilePath = Join-Path $armPath $relativePath + if (Test-Path (Join-Path $armPath $relativePath)) + { + continue; + } + New-Item -ItemType File -Path $armFilePath -Force + Copy-Item -Path $file.FullName -Destination $armFilePath -Force -Verbose + } + Pop-Location +}