Skip to content

Commit

Permalink
ci: Add Build workflow
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
trungnt2910 committed Nov 14, 2024
1 parent be8d24a commit 0e55a6d
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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

- 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
63 changes: 63 additions & 0 deletions pack.ps1
Original file line number Diff line number Diff line change
@@ -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

48 changes: 48 additions & 0 deletions setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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;
}
Copy-Item -Path $file.FullName -Destination $armFilePath -Force -Verbose
}
Pop-Location
}

0 comments on commit 0e55a6d

Please sign in to comment.