Skip to content

Commit

Permalink
WHY????
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyvct committed Nov 7, 2022
1 parent 410a931 commit 7d27969
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 22 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
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"cwd": "${cwd}"
},
{
"name": "ARM64",
"type": "PowerShell",
"request": "launch",
"script": "${workspaceFolder}/Build-Dependencies.ps1",
"args": ["-Configuration Release -Target ARM64 -Shared false -Debug"],
"cwd": "${cwd}"
},
{
"name": "x64",
"type": "PowerShell",
"request": "launch",
"script": "${workspaceFolder}/Build-Dependencies.ps1",
"args": ["-Configuration Release -Target x64 -Shared false -Debug"],
"cwd": "${cwd}"
},
]
}
28 changes: 19 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 Expand Up @@ -191,6 +200,7 @@ function Build-Main {
} else {
$DependencyFiles = $Dependencies | ForEach-Object {
$Item = $_
Write-Output $Item # TODO: wtf is happening here?
try {
Get-ChildItem $PSScriptRoot/${SubDir}/*$Item.ps1
} catch {
Expand Down
12 changes: 12 additions & 0 deletions deps.windows/40-luajit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ param(
)

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

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

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

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

Expand All @@ -24,6 +32,10 @@ function Build {
}

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

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

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

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

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

Expand All @@ -20,6 +24,10 @@ function Clean {
}

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

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

Expand All @@ -43,6 +51,10 @@ function Configure {
}

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

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

Expand All @@ -59,6 +71,10 @@ function Build {
}

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

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

Expand All @@ -75,6 +91,10 @@ function Install {
}

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

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

Expand Down
2 changes: 2 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
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
54 changes: 43 additions & 11 deletions utils.pwsh/Setup-Target.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,47 @@ 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}"
# TODO: add ARM64 here, reimplement as switch clause
# $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' {
return @{
Arch = 'ARM64'
UnixArch = 'aarch64'
CmakeArch = 'ARM64'
Bitness = '64'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
'x64' {
return @{
Arch = 'x64'
UnixArch = 'x86_64'
CmakeArch = 'x64'
Bitness = '64'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
'x86' {
return @{
Arch = 'x86'
UnixArch = 'x86'
CmakeArch = 'Win32'
Bitness = '32'
OutputPath = "${script:ProjectRoot}\windows\obs-${script:PackageName}-${script:Target}"
}
}
}


Log-Debug "
Architecture : $($script:ConfigData.Arch)
Expand Down Expand Up @@ -83,9 +115,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 7d27969

Please sign in to comment.