From 76c34c6d72bbdc6037d25572b03118b1cbfd04c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 23 Jul 2026 18:28:42 -0400 Subject: [PATCH 1/5] feat: add ARMv7 Linux sysroots Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/cbake-sysroots.yml | 6 ++ README.md | 11 +++- cbake.psm1 | 15 ++++- cmake/linux-arm.toolchain.cmake | 4 ++ cmake/linux.toolchain.cmake | 3 + tests/CBake.Tests.ps1 | 90 ++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 cmake/linux-arm.toolchain.cmake diff --git a/.github/workflows/cbake-sysroots.yml b/.github/workflows/cbake-sysroots.yml index 1cd4309..27ce1a4 100644 --- a/.github/workflows/cbake-sysroots.yml +++ b/.github/workflows/cbake-sysroots.yml @@ -24,6 +24,12 @@ jobs: include: - os: linux runner: ubuntu-22.04 + - distro: ubuntu-18.04 + arch: arm + runner: ubuntu-22.04 + - distro: alpine-3.17 + arch: arm + runner: ubuntu-22.04 steps: - name: Check out ${{ github.repository }} diff --git a/README.md b/README.md index 83273c6..725be26 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ You can also use the command wrapper: ## Supported Linux sysroot recipes -The GitHub Actions matrix currently builds each recipe for `amd64` and `arm64`: +The GitHub Actions matrix builds every recipe for `amd64` and `arm64`. It also builds the fixed ARMv7 compatibility baselines below with the `arm` label. `arm` is intentionally aligned with the `linux-arm` and `linux-musl-arm` runtime identifiers; CBake maps it to Docker buildx platform `linux/arm/v7`. | Family | Recipes | | --- | --- | @@ -76,6 +76,13 @@ The GitHub Actions matrix currently builds each recipe for `amd64` and `arm64`: | RHEL | `rhel8`, `rhel9` | | Alpine | `alpine-3.17`, `alpine-3.21` | +| Compatibility baseline | Archive | Imported sysroot | GCC and Clang target | GCC target directory | +| --- | --- | --- | --- | --- | +| Ubuntu 18.04 (glibc) | `ubuntu-18.04-arm-sysroot.tar.xz` | `sysroots\ubuntu-18.04-arm` | `arm-linux-gnueabihf` | `usr\lib\gcc\arm-linux-gnueabihf\` | +| Alpine 3.17 (musl) | `alpine-3.17-arm-sysroot.tar.xz` | `sysroots\alpine-3.17-arm` | `armv7-alpine-linux-musleabihf` | `usr\lib\gcc\armv7-alpine-linux-musleabihf\` | + +Import either archive with `Import-CBakeSysroot -Distro '' -Arch 'arm'`. Set `SYSROOT_NAME` to the imported directory name (for example, `ubuntu-18.04-arm`). The Linux toolchain finds the target triple from its `usr\lib\gcc\\` layout and applies `-march=armv7-a` for this architecture. + To add a distribution, create a new directory under `recipes\` with a Dockerfile and update the workflow matrix if CI should build it. ## Cross-compile a CMake project for Linux @@ -103,7 +110,7 @@ Use the target-specific files in `cmake\` when building for non-Linux platforms: | --- | --- | | Android | `android-arm.toolchain.cmake`, `android-arm64.toolchain.cmake`, `android-x86.toolchain.cmake`, `android-x86_64.toolchain.cmake` | | iOS | `ios-arm.toolchain.cmake`, `ios-arm64.toolchain.cmake`, `ios-armv7.toolchain.cmake`, `ios-x86_64.toolchain.cmake` | -| Linux | `linux-amd64.toolchain.cmake`, `linux-arm64.toolchain.cmake`, `linux.toolchain.cmake` | +| Linux | `linux-amd64.toolchain.cmake`, `linux-arm.toolchain.cmake`, `linux-arm64.toolchain.cmake`, `linux.toolchain.cmake` | | Windows | `windows-x86.toolchain.cmake`, `windows-x64.toolchain.cmake`, `windows-arm64.toolchain.cmake` | Example: diff --git a/cbake.psm1 b/cbake.psm1 index a36a62f..0b2e295 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -185,6 +185,19 @@ function Import-CBakeSysroot { Invoke-CBakeNativeCommand -FilePath 'tar' -ArgumentList @('xf', $PackageFile, '-C', $SysrootsPath) } +function Get-CBakeDockerPlatform { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] $Arch + ) + + switch ($Arch) { + 'arm' { 'linux/arm/v7' } + default { "linux/$Arch" } + } +} + function New-CBakeSysroot { param( [Parameter(Mandatory = $true)] @@ -214,7 +227,7 @@ function New-CBakeSysroot { $params = @('buildx', 'build', '.', '-t', "$distro-$arch-sysroot", - '--platform', "linux/$arch", + '--platform', (Get-CBakeDockerPlatform $Arch), '-o', "type=tar,dest=$ContainerTarFile") Invoke-CBakeNativeCommand -FilePath 'docker' -ArgumentList $Params New-Item -Path $ExportPath -ItemType Directory -ErrorAction 'SilentlyContinue' | Out-Null diff --git a/cmake/linux-arm.toolchain.cmake b/cmake/linux-arm.toolchain.cmake new file mode 100644 index 0000000..e1e6400 --- /dev/null +++ b/cmake/linux-arm.toolchain.cmake @@ -0,0 +1,4 @@ +set(CMAKE_SYSTEM_PROCESSOR armv7l) +set(CMAKE_SIZEOF_VOID_P 4) + +include("${CMAKE_CURRENT_LIST_DIR}/linux.toolchain.cmake") diff --git a/cmake/linux.toolchain.cmake b/cmake/linux.toolchain.cmake index 08c2703..7ca95da 100644 --- a/cmake/linux.toolchain.cmake +++ b/cmake/linux.toolchain.cmake @@ -31,6 +31,9 @@ if((SYSROOT_ARCH STREQUAL "amd64") OR (SYSROOT_ARCH STREQUAL "x86_64")) set(CMAKE_SYSTEM_PROCESSOR "x86_64") elseif((SYSROOT_ARCH STREQUAL "arm64") OR (SYSROOT_ARCH STREQUAL "aarch64")) set(CMAKE_SYSTEM_PROCESSOR "aarch64") +elseif((SYSROOT_ARCH STREQUAL "arm") OR (SYSROOT_ARCH STREQUAL "armv7")) + set(CMAKE_SYSTEM_PROCESSOR "armv7l") + set(CROSS_MACHINE_FLAGS "-march=armv7-a") else() message(FATAL_ERROR "Unknown sysroot architecture: ${SYSROOT_ARCH}") endif() diff --git a/tests/CBake.Tests.ps1 b/tests/CBake.Tests.ps1 index f95556d..c24d853 100644 --- a/tests/CBake.Tests.ps1 +++ b/tests/CBake.Tests.ps1 @@ -113,6 +113,20 @@ Describe 'Import-CBakeSysroot' { $ArgumentList[3] -eq $script:SysrootsPath } } + + It 'uses the ARMv7 compatibility-baseline archive name' { + $PackageFile = Join-Path $script:PackagesPath 'alpine-3.17-arm-sysroot.tar.xz' + New-Item -Path $PackageFile -ItemType File -Force | Out-Null + Mock -ModuleName cbake Invoke-CBakeNativeCommand {} + + Import-CBakeSysroot -Distro 'alpine-3.17' -Arch 'arm' + + Should -Invoke -CommandName Invoke-CBakeNativeCommand -ModuleName cbake -Exactly -Times 1 -ParameterFilter { + $FilePath -eq 'tar' -and + $ArgumentList[1] -eq $PackageFile -and + $ArgumentList[3] -eq $script:SysrootsPath + } + } } Describe 'New-CBakeSysroot' { @@ -120,6 +134,7 @@ Describe 'New-CBakeSysroot' { $script:RecipesPath = Join-Path $TestDrive 'recipes' $script:PackagesPath = Join-Path $TestDrive 'packages' New-Item -Path (Join-Path $script:RecipesPath 'ubuntu-24.04') -ItemType Directory -Force | Out-Null + New-Item -Path (Join-Path $script:RecipesPath 'ubuntu-18.04') -ItemType Directory -Force | Out-Null New-Item -Path $script:PackagesPath -ItemType Directory -Force | Out-Null $Env:CBAKE_RECIPES_DIR = $script:RecipesPath @@ -152,6 +167,25 @@ Describe 'New-CBakeSysroot' { Should -Invoke -CommandName Optimize-CBakeSysroot -ModuleName cbake -Exactly -Times 1 } + It 'maps the ARM compatibility label to the ARMv7 Docker platform' { + $PackageFile = Join-Path $script:PackagesPath 'ubuntu-18.04-arm-sysroot.tar.xz' + Mock -ModuleName cbake Invoke-CBakeNativeCommand {} + Mock -ModuleName cbake Optimize-CBakeSysroot {} + + New-CBakeSysroot -Distro 'ubuntu-18.04' -Arch 'arm' + + Should -Invoke -CommandName Invoke-CBakeNativeCommand -ModuleName cbake -Exactly -Times 1 -ParameterFilter { + $FilePath -eq 'docker' -and + $ArgumentList -contains 'linux/arm/v7' -and + $ArgumentList -contains 'type=tar,dest=ubuntu-18.04-arm.tar' + } + Should -Invoke -CommandName Invoke-CBakeNativeCommand -ModuleName cbake -Exactly -Times 1 -ParameterFilter { + $FilePath -eq 'tar' -and + $ArgumentList[0] -eq 'cfJ' -and + $ArgumentList[1] -eq $PackageFile + } + } + It 'restores the caller location when a checked native command fails' { $StartingLocation = (Get-Location).ProviderPath Mock -ModuleName cbake Invoke-CBakeNativeCommand { @@ -163,4 +197,60 @@ Describe 'New-CBakeSysroot' { (Get-Location).ProviderPath | Should -Be $StartingLocation } } + +Describe 'Linux ARMv7 toolchains' { + It 'defines an ARMv7 Linux entry point and ARMv7 compiler flags' { + $LinuxToolchain = Get-Content (Join-Path $script:RepoRoot 'cmake\linux.toolchain.cmake') -Raw + $LinuxArmToolchain = Join-Path $script:RepoRoot 'cmake\linux-arm.toolchain.cmake' + + Test-Path $LinuxArmToolchain | Should -BeTrue + Get-Content $LinuxArmToolchain -Raw | Should -Match 'set\(CMAKE_SYSTEM_PROCESSOR armv7l\)' + $LinuxToolchain | Should -Match 'SYSROOT_ARCH STREQUAL "arm"' + $LinuxToolchain | Should -Match 'set\(CROSS_MACHINE_FLAGS "-march=armv7-a"\)' + } + + It 'derives the ARMv7 target from the GCC layout' -TestCases @( + @{ + SysrootName = 'ubuntu-18.04-arm' + Target = 'arm-linux-gnueabihf' + }, + @{ + SysrootName = 'alpine-3.17-arm' + Target = 'armv7-alpine-linux-musleabihf' + } + ) { + param($SysrootName, $Target) + + $SysrootPath = Join-Path $TestDrive $SysrootName + $LLVMPath = Join-Path $TestDrive 'llvm' + $CMakeScriptPath = Join-Path $TestDrive 'verify-armv7.cmake' + New-Item -ItemType Directory -Force -Path (Join-Path $SysrootPath "usr\lib\gcc\$Target\12"), $LLVMPath | Out-Null + + $CMakeScript = @' +set(SYSROOT_NAME "__SYSROOT_NAME__") +set(CMAKE_SYSROOT "__SYSROOT_PATH__") +set(LLVM_PREFIX "__LLVM_PATH__") +include("__TOOLCHAIN_PATH__") +if(NOT CMAKE_C_COMPILER_TARGET STREQUAL "__TARGET__") + message(FATAL_ERROR "Unexpected compiler target: ${CMAKE_C_COMPILER_TARGET}") +endif() +if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") + message(FATAL_ERROR "Unexpected system processor: ${CMAKE_SYSTEM_PROCESSOR}") +endif() +string(FIND "${CMAKE_C_FLAGS}" "-march=armv7-a" ARMV7_FLAG_INDEX) +if(ARMV7_FLAG_INDEX EQUAL -1) + message(FATAL_ERROR "ARMv7 compiler flag is missing") +endif() +'@ + $CMakeScript = $CMakeScript.Replace('__SYSROOT_NAME__', $SysrootName). + Replace('__SYSROOT_PATH__', $SysrootPath.Replace('\', '/')). + Replace('__LLVM_PATH__', $LLVMPath.Replace('\', '/')). + Replace('__TOOLCHAIN_PATH__', (Join-Path $script:RepoRoot 'cmake\linux.toolchain.cmake').Replace('\', '/')). + Replace('__TARGET__', $Target) + Set-Content -Path $CMakeScriptPath -Value $CMakeScript -NoNewline + + & cmake -P $CMakeScriptPath | Out-Null + $LASTEXITCODE | Should -Be 0 + } +} } From b2be325d5f3334539383cefbf5a43f63f5a35e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 23 Jul 2026 22:30:19 -0400 Subject: [PATCH 2/5] ci: add ARMv7 sysroot build mode Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/cbake-sysroots.yml | 37 +++++++++------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cbake-sysroots.yml b/.github/workflows/cbake-sysroots.yml index 27ce1a4..6755182 100644 --- a/.github/workflows/cbake-sysroots.yml +++ b/.github/workflows/cbake-sysroots.yml @@ -1,35 +1,22 @@ name: cbake sysroots -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + armv7_only: + description: Build only the Ubuntu 18.04 and Alpine 3.17 ARMv7 compatibility sysroots + required: false + default: false + type: boolean jobs: build: name: cbake sysroot [${{matrix.distro}}-${{matrix.arch}}] - runs-on: ${{matrix.runner}} + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - arch: [ amd64, arm64 ] - distro: - - ubuntu-18.04 - - ubuntu-20.04 - - ubuntu-22.04 - - ubuntu-24.04 - - debian-10 - - debian-11 - - debian-12 - - rhel8 - - rhel9 - - alpine-3.17 - - alpine-3.21 - - include: - - os: linux - runner: ubuntu-22.04 - - distro: ubuntu-18.04 - arch: arm - runner: ubuntu-22.04 - - distro: alpine-3.17 - arch: arm - runner: ubuntu-22.04 + arch: ${{ fromJSON(inputs.armv7_only && '["arm"]' || '["amd64", "arm64"]') }} + distro: ${{ fromJSON(inputs.armv7_only && '["ubuntu-18.04", "alpine-3.17"]' || '["ubuntu-18.04", "ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04", "debian-10", "debian-11", "debian-12", "rhel8", "rhel9", "alpine-3.17", "alpine-3.21"]') }} + include: ${{ fromJSON(inputs.armv7_only && '[]' || '[{"distro":"ubuntu-18.04","arch":"arm"},{"distro":"alpine-3.17","arch":"arm"}]') }} steps: - name: Check out ${{ github.repository }} From 9f958962dbdaeada331afb4ce30dbc5191256dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 23 Jul 2026 22:39:05 -0400 Subject: [PATCH 3/5] fix: fail incomplete sysroot builds Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/cbake-sysroots.yml | 1 + build.ps1 | 2 ++ cbake.psm1 | 16 ++++++++-------- tests/CBake.Tests.ps1 | 10 ++++++++++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cbake-sysroots.yml b/.github/workflows/cbake-sysroots.yml index 6755182..3b356c7 100644 --- a/.github/workflows/cbake-sysroots.yml +++ b/.github/workflows/cbake-sysroots.yml @@ -43,3 +43,4 @@ jobs: with: name: ${{matrix.distro}}-${{matrix.arch}}-sysroot path: packages/${{matrix.distro}}-${{matrix.arch}}-sysroot.tar.xz + if-no-files-found: error diff --git a/build.ps1 b/build.ps1 index b208699..479ac65 100755 --- a/build.ps1 +++ b/build.ps1 @@ -1,5 +1,7 @@ #!/usr/bin/env pwsh +$ErrorActionPreference = 'Stop' + if (-Not (Test-Path Env:CBAKE_HOME)) { $Env:CBAKE_HOME = $PSScriptRoot } diff --git a/cbake.psm1 b/cbake.psm1 index 0b2e295..33f420d 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -6,19 +6,19 @@ function Convert-CBakeSymbolicLinks() { [string] $RootPath ) - $ReparsePoints = Get-ChildItem $RootPath -Recurse | + $ReparsePoints = Get-ChildItem -LiteralPath $RootPath -Recurse | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint } $AbsSymlinks = $ReparsePoints | Where-Object { $_.LinkTarget.StartsWith('/') } $AbsSymlinks | ForEach-Object { $Source = $_.FullName $Directory = $_.Directory $Target = Join-Path $RootPath $_.LinkTarget - if (Test-Path $Target) { + if (Test-Path -LiteralPath $Target) { Push-Location - Set-Location $Directory - $Target = Resolve-Path -Path $Target -Relative - Remove-Item $Source | Out-Null - New-Item -ItemType SymbolicLink -Path $Source -Target $Target | Out-Null + Set-Location -LiteralPath $Directory + $Target = Resolve-Path -LiteralPath $Target -Relative + Remove-Item -LiteralPath $Source | Out-Null + New-Item -ItemType SymbolicLink -LiteralPath $Source -Target $Target | Out-Null Pop-Location } else { Remove-Item -LiteralPath $Source -ErrorAction 'SilentlyContinue' | Out-Null @@ -33,7 +33,7 @@ function Remove-CBakeSymbolicLinks() { [string] $RootPath ) - $ReparsePoints = Get-ChildItem $RootPath -Recurse | + $ReparsePoints = Get-ChildItem -LiteralPath $RootPath -Recurse | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint } $ReparsePoints | ForEach-Object { $Source = $_.FullName @@ -102,7 +102,7 @@ function Remove-CBakeExcludedFiles() { $ExcludeDirs | ForEach-Object { $ExcludeDir = Join-Path $RootPath $_.TrimStart('/', '\') - Remove-Item -Path $ExcludeDir -Recurse -Force -ErrorAction 'SilentlyContinue' | Out-Null + Remove-Item -LiteralPath $ExcludeDir -Recurse -Force -ErrorAction 'SilentlyContinue' | Out-Null } } diff --git a/tests/CBake.Tests.ps1 b/tests/CBake.Tests.ps1 index c24d853..a175c7f 100644 --- a/tests/CBake.Tests.ps1 +++ b/tests/CBake.Tests.ps1 @@ -70,6 +70,16 @@ Describe 'Remove-CBakeExcludedFiles' { Test-Path $ExcludedPath | Should -BeFalse Test-Path $KeptPath | Should -BeTrue } + + It 'handles wildcard characters in the provided root path literally' { + $RootPath = Join-Path $TestDrive 'sysroot[arm]' + $ExcludedPath = Join-Path $RootPath 'usr\bin' + New-Item -Path $ExcludedPath -ItemType Directory -Force | Out-Null + + Remove-CBakeExcludedFiles $RootPath + + Test-Path -LiteralPath $ExcludedPath | Should -BeFalse + } } Describe 'Invoke-CBakeNativeCommand' { From 988b014f36739d0f858137d7e5e51d14caa67b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 23 Jul 2026 22:45:20 -0400 Subject: [PATCH 4/5] fix: recreate sysroot links literally Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- cbake.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cbake.psm1 b/cbake.psm1 index 33f420d..e3d34a9 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -12,13 +12,18 @@ function Convert-CBakeSymbolicLinks() { $AbsSymlinks | ForEach-Object { $Source = $_.FullName $Directory = $_.Directory + $IsDirectory = $_.PSIsContainer $Target = Join-Path $RootPath $_.LinkTarget if (Test-Path -LiteralPath $Target) { Push-Location Set-Location -LiteralPath $Directory $Target = Resolve-Path -LiteralPath $Target -Relative Remove-Item -LiteralPath $Source | Out-Null - New-Item -ItemType SymbolicLink -LiteralPath $Source -Target $Target | Out-Null + if ($IsDirectory) { + [IO.Directory]::CreateSymbolicLink($Source, $Target) | Out-Null + } else { + [IO.File]::CreateSymbolicLink($Source, $Target) | Out-Null + } Pop-Location } else { Remove-Item -LiteralPath $Source -ErrorAction 'SilentlyContinue' | Out-Null From ce05ba145cc5007d824b3763939be0f7c7f4dc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 23 Jul 2026 22:51:19 -0400 Subject: [PATCH 5/5] fix: resolve absolute sysroot links Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- cbake.psm1 | 17 ++++++++--------- tests/CBake.Tests.ps1 | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cbake.psm1 b/cbake.psm1 index e3d34a9..de6ef17 100644 --- a/cbake.psm1 +++ b/cbake.psm1 @@ -8,23 +8,22 @@ function Convert-CBakeSymbolicLinks() { $ReparsePoints = Get-ChildItem -LiteralPath $RootPath -Recurse | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint } - $AbsSymlinks = $ReparsePoints | Where-Object { $_.LinkTarget.StartsWith('/') } + $AbsSymlinks = $ReparsePoints | Where-Object { + -not [string]::IsNullOrEmpty($_.LinkTarget) -and $_.LinkTarget.StartsWith('/') + } $AbsSymlinks | ForEach-Object { $Source = $_.FullName - $Directory = $_.Directory + $Directory = [IO.Path]::GetDirectoryName($Source) $IsDirectory = $_.PSIsContainer - $Target = Join-Path $RootPath $_.LinkTarget + $Target = Join-Path $RootPath $_.LinkTarget.TrimStart('/') if (Test-Path -LiteralPath $Target) { - Push-Location - Set-Location -LiteralPath $Directory - $Target = Resolve-Path -LiteralPath $Target -Relative + $RelativeTarget = [IO.Path]::GetRelativePath($Directory, $Target) Remove-Item -LiteralPath $Source | Out-Null if ($IsDirectory) { - [IO.Directory]::CreateSymbolicLink($Source, $Target) | Out-Null + [IO.Directory]::CreateSymbolicLink($Source, $RelativeTarget) | Out-Null } else { - [IO.File]::CreateSymbolicLink($Source, $Target) | Out-Null + [IO.File]::CreateSymbolicLink($Source, $RelativeTarget) | Out-Null } - Pop-Location } else { Remove-Item -LiteralPath $Source -ErrorAction 'SilentlyContinue' | Out-Null } diff --git a/tests/CBake.Tests.ps1 b/tests/CBake.Tests.ps1 index a175c7f..fde2186 100644 --- a/tests/CBake.Tests.ps1 +++ b/tests/CBake.Tests.ps1 @@ -57,6 +57,22 @@ Describe 'Get-CBakePath' { } } +Describe 'Convert-CBakeSymbolicLinks' { + It 'converts absolute symlinks to relative targets with wildcard characters in their names' { + $RootPath = Join-Path $TestDrive 'sysroot' + $TargetPath = Join-Path $RootPath 'target' + $SourcePath = Join-Path $RootPath 'link[arm]' + New-Item -Path $TargetPath -ItemType Directory -Force | Out-Null + [IO.Directory]::CreateSymbolicLink($SourcePath, '/target') | Out-Null + + Convert-CBakeSymbolicLinks $RootPath + + $Link = Get-Item -LiteralPath $SourcePath + $Link.LinkTarget | Should -Be 'target' + $Link.ResolveLinkTarget($true).FullName | Should -Be $TargetPath + } +} + Describe 'Remove-CBakeExcludedFiles' { It 'removes excluded directories from the provided root path' { $RootPath = Join-Path $TestDrive 'sysroot'