Skip to content

Commit

Permalink
deps.windows: Add support for Windows ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyvct committed Nov 8, 2022
1 parent 410a931 commit a7c6fb9
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,17 @@ jobs:
strategy:
fail-fast: true
matrix:
target: [x64, x86]
target: [x64, x86, arm64]
include:
- target: x64
config: 'Release'
type: 'static'
- target: x86
config: 'Release'
type: 'static'
- target: arm64
config: 'Release'
type: 'static'
env:
CACHE_REVISION: '3'
defaults:
Expand Down
27 changes: 18 additions & 9 deletions Build-Dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param(
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
[string] $Configuration = 'Release',
[string[]] $Dependencies,
[ValidateSet('x86', 'x64')]
[ValidateSet('x86', 'x64', 'arm64')]
[string] $Target,
[switch] $Clean,
[switch] $Quiet,
Expand All @@ -27,6 +27,15 @@ if ( $PSVersionTable.PSVersion -lt '7.0.0' ) {
}

function Run-Stages {
# trap {
# Write-Host '---------------------------------------------------------------------------------------------------'
# Write-Host -NoNewLine '[OBS-DEPS] '
# Write-Host -ForegroundColor Red 'Error(s) occurred:'
# Write-Host '---------------------------------------------------------------------------------------------------'
# Write-Error $_
# exit 2
# }

$Stages = @('Setup')

if ( ( $SkipAll ) -or ( $SkipBuild ) ) {
Expand Down Expand Up @@ -151,14 +160,14 @@ function Package-Dependencies {
}

function Build-Main {
trap {
Write-Host '---------------------------------------------------------------------------------------------------'
Write-Host -NoNewLine '[OBS-DEPS] '
Write-Host -ForegroundColor Red 'Error(s) occurred:'
Write-Host '---------------------------------------------------------------------------------------------------'
Write-Error $_
exit 2
}
# trap {
# Write-Host '---------------------------------------------------------------------------------------------------'
# Write-Host -NoNewLine '[OBS-DEPS] '
# Write-Host -ForegroundColor Red 'Error(s) occurred:'
# Write-Host '---------------------------------------------------------------------------------------------------'
# Write-Error $_
# exit 2
# }

$script:PackageName = ((Get-Item $PSCommandPath).Basename).Split('-')[1]
if ( $script:PackageName -eq 'Dependencies' ) {
Expand Down
4 changes: 2 additions & 2 deletions deps.windows/40-detours.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ param(
[string] $Name = 'detours',
[string] $Version = '4.0.1',
[string] $Uri = 'https://github.com/microsoft/detours.git',
[string] $Hash = 'e4bfd6b03e50de46b47abfbd1e46b384f0c5f833'
[string] $Hash = '734ac64899c44933151c1335f6ef54a590219221'
)

function Setup {
Expand Down Expand Up @@ -34,7 +34,7 @@ function Build {
BuildPath = "src"
BuildCommand = "nmake"
Target = $Target
HostArchitecture = $Target
# HostArchitecture = $Target
}

Invoke-DevShell @Params
Expand Down
15 changes: 15 additions & 0 deletions deps.windows/40-luajit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ param(
)

function Setup {
if (${Target} -eq "arm64") {
Log-Information "Skipping Setup ${Name} for Windows ARM64"
return
}

Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath $Path
}

function Build {
if (${Target} -eq "arm64") {
Log-Information "Skipping Build ${Name} for Windows ARM64"
return
}

Log-Information "Build (${Target})"
Set-Location $Path

Expand All @@ -24,6 +34,11 @@ function Build {
}

function Install {
if (${Target} -eq "arm64") {
Log-Information "Skipping Install ${Name} for Windows ARM64"
return
}

Log-Information "Install (${Target})"
Set-Location $Path

Expand Down
25 changes: 25 additions & 0 deletions deps.windows/60-ntv2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ param(
)

function Setup {
if (${Target} -eq "arm64") {
Log-Information "Skipping Setup ${Name} for Windows ARM64"
return
}

Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath $Path
}

Expand All @@ -20,6 +25,11 @@ function Clean {
}

function Configure {
if (${Target} -eq "arm64") {
Log-Information "Skipping Configure ${Name} for Windows ARM64"
return
}

Log-Information "Configure (${Target})"
Set-Location $Path

Expand All @@ -43,6 +53,11 @@ function Configure {
}

function Build {
if (${Target} -eq "arm64") {
Log-Information "Skipping Build ${Name} for Windows ARM64"
return
}

Log-Information "Build (${Target})"
Set-Location $Path

Expand All @@ -59,6 +74,11 @@ function Build {
}

function Install {
if (${Target} -eq "arm64") {
Log-Information "Skipping Install ${Name} for Windows ARM64"
return
}

Log-Information "Install (${Target})"
Set-Location $Path

Expand All @@ -75,6 +95,11 @@ function Install {
}

function Fixup {
if (${Target} -eq "arm64") {
Log-Information "Skipping Fixup ${Name} for Windows ARM64"
return
}

Log-Information "Fixup (${Target})"
Set-Location $Path

Expand Down
7 changes: 7 additions & 0 deletions deps.windows/60-python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ param(
}
)

# TODO: download ARM64 version of python instead of using pyenv

function Enable-PyEnv {
$Env:PYENV = "$(Get-Location | Convert-Path)\pyenv-win"
$Env:PYENV_ROOT = $Env:PYENV
Expand Down Expand Up @@ -37,6 +39,11 @@ function Disable-PyEnv {
}

function Setup {
if (${Target} -eq "arm64") {
Log-Information "Skipping Setup ${Name} for Windows ARM64"
return
}

Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath $Path
}

Expand Down
2 changes: 1 addition & 1 deletion utils.pwsh/Invoke-DevShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Invoke-DevShell {
[Parameter(Mandatory)]
[string] $BuildCommand,
[Parameter(Mandatory)]
[ValidateSet('x86', 'x64')]
[ValidateSet('x86', 'x64', 'arm64')]
[string] $Target,
[string] $HostArchitecture = ( 'x86', 'x64' )[ [System.Environment]::Is64BitOperatingSystem ]
)
Expand Down
44 changes: 32 additions & 12 deletions utils.pwsh/Setup-Target.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@ function Setup-Target {
. $PSScriptRoot/Logger.ps1
}

$Target64Bit = ( $script:Target -eq 'x64' )

$script:ConfigData = @{
Arch = ('x86', 'x64')[$Target64Bit]
UnixArch = ('x86', 'x86_64')[$Target64Bit]
CmakeArch = ('Win32', 'x64')[$Target64Bit]
Bitness = ('32', '64')[$Target64Bit]
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
$script:ConfigData = switch ($script:Target) {
'arm64' {
@{
Arch = 'arm64'
UnixArch = 'aarch64'
CmakeArch = 'ARM64'
Bitness = '64'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
'x64' {
@{
Arch = 'x64'
UnixArch = 'x86_64'
CmakeArch = 'x64'
Bitness = '64'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
'x86' {
@{
Arch = 'x86'
UnixArch = 'x86'
CmakeArch = 'Win32'
Bitness = '32'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
}

Log-Debug "
Architecture : $($script:ConfigData.Arch)
CMake arch : $($script:ConfigData.CmakeArch)
Expand Down Expand Up @@ -83,9 +103,9 @@ function Find-VisualStudio {
# 2. VS2022 Preview
# 3. VS2019 Release
[string[]]$SupportedVSVersions =
"VisualStudio.17.Release",
"VisualStudio.17.Preview",
"VisualStudio.16.Release"
"VisualStudio.17.Release",
"VisualStudio.17.Preview",
"VisualStudio.16.Release"
$NumSupportedVSVersions = $SupportedVSVersions.length

if ( $VisualStudioData.GetType() -eq [object[]] ) {
Expand Down

0 comments on commit a7c6fb9

Please sign in to comment.