Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable limited features of BcContainerHelper on macOS #3439

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions BC.HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ if ($isWindows) {
$programDataFolder = 'C:\ProgramData\BcContainerHelper'
$artifactsCacheFolder = "c:\bcartifacts.cache"
}
elseif ($isMacOS) {
$programDataFolder = "/Users/$myUsername/.bccontainerhelper"
$artifactsCacheFolder = "/Users/$myUsername/.bcartifacts.cache"
}
else {
$programDataFolder = "/home/$myUsername/.bccontainerhelper"
$artifactsCacheFolder = "/home/$myUsername/.bcartifacts.cache"
Expand Down
3 changes: 2 additions & 1 deletion BcContainerHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ param(
. (Join-Path $PSScriptRoot "BC.HelperFunctions.ps1")

if ($isMacOS) {
throw "BcContainerHelper isn't supported on MacOS"
Write-Host "Running on macOS, PowerShell $($PSVersionTable.PSVersion)"
Write-Host -ForegroundColor Red "BcContainerHelper is not supported on macOS, only limited features are available"
}
elseif ($isLinux) {
Write-Host "Running on Linux, PowerShell $($PSVersionTable.PSVersion)"
Expand Down
32 changes: 18 additions & 14 deletions CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ try {
if (Test-Path $sharedFolder) {
$probingPaths = @((Join-Path $dllsPath "OpenXML"), $sharedFolder) + $probingPaths
}
elseif ($isLinux) {
elseif ($isLinux -or $isMacOS) {
$probingPaths = @((Join-Path $dllsPath "OpenXML")) + $probingPaths
}
elseif ($platformversion.Major -ge 22) {
Expand All @@ -324,27 +324,31 @@ try {
Write-Host "Compiling..."
$alcParameters = @()
$binPath = Join-Path $compilerFolder 'compiler/extension/bin'
$alcPath = Join-Path $binPath 'win32'
$alcExe = 'alc.exe'
$alcCmd = ".\$alcExe"

$compilerPlatform = 'win32'
switch ($true) {
($isLinux) { $compilerPlatform = 'linux' }
($isMacOS) { $compilerPlatform = 'darwin' }
}
$alcPath = Join-Path $binPath $compilerPlatform
if (-not (Test-Path $alcPath)) {
$alcPath = $binPath
}

if ($isLinux) {
$linuxPath = Join-Path $binPath 'linux'
if (Test-Path $linuxPath) {
$alcPath = $linuxPath
$alcExe = 'alc'
$alcCmd = "./$alcExe"
}
else {
$alcExe = 'alc.exe'
$alcCmd = ".\$alcExe"
if ($isLinux -or $isMacOS) {
if ($alcPath -eq $binPath) {
$alcCmd = "dotnet"
$alcExe = 'alc.dll'
$alcParameters += @((Join-Path $alcPath $alcExe))
Write-Host "No Linux version of alc found. Using dotnet to run alc.dll."
Write-Host "No $($compilerPlatform) version of alc found. Using dotnet to run alc.dll."
} else {
$alcExe = 'alc'
$alcCmd = "./$alcExe"
}
}
}

$alcItem = Get-Item -Path (Join-Path $alcPath $alcExe)
[System.Version]$alcVersion = $alcItem.VersionInfo.FileVersion

Expand Down
38 changes: 25 additions & 13 deletions CompilerFolderHandling/New-BcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,34 @@ try {
Copy-Item -Path $symbolsPath -Filter '*.app' -Destination $packagesFolder -Force -Recurse
}

if ($isLinux) {
$alToolExePath = Join-Path $containerCompilerPath 'extension/bin/linux/altool'
if (Test-Path $alToolExePath) {
# Set execute permissions on altool
Write-Host "Setting execute permissions on altool"
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExePath"
if ($isLinux -or $isMacOS) {
$compilerPlatform = 'linux'
if ($isMacOS) {
$compilerPlatform = 'darwin'
}
$alcExePath = Join-Path $containerCompilerPath 'extension/bin/linux/alc'
$alcExePath = Join-Path $containerCompilerPath "extension/bin/$($compilerPlatform)/alc"
$alToolExePath = Join-Path $containerCompilerPath "extension/bin/$($compilerPlatform)/altool"

if (Test-Path $alcExePath) {
if (Test-Path $alToolExePath) {
# Set execute permissions on altool
Write-Host "Setting execute permissions on altool"
if ($isLinux) {
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExePath"
} else {
& chmod +x $alToolExePath
}
}
# Set execute permissions on alc
Write-Host "Setting execute permissions on alc"
& /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath"
}
else {
# Patch alc.runtimeconfig.json for use with Linux
Write-Host "Patching alc.runtimeconfig.json for use with Linux"
if ($isLinux) {
& /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath"
} else {
& chmod +x $alcExePath
}
} else {
# Patch alc.runtimeconfig.json for use with Linux or macOS
Write-Host "Patching alc.runtimeconfig.json for use with $($compilerPlatform)"
$alcConfigPath = Join-Path $containerCompilerPath 'extension/bin/win32/alc.runtimeconfig.json'
if (Test-Path $alcConfigPath) {
$oldAlcConfig = Get-Content -Path $alcConfigPath -Encoding UTF8 | ConvertFrom-Json
Expand All @@ -250,7 +262,7 @@ try {
$newAlcConfig | ConvertTo-Json | Set-Content -Path $alcConfigPath -Encoding utf8NoBOM
}
}
}
}
}
$compilerFolder
}
Expand Down
13 changes: 12 additions & 1 deletion HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,12 @@ function GetAppInfo {
Write-Host "Setting execute permissions on altool"
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe"
}
elseif ($isMacOS) {
$alcPath = Join-Path $binPath 'darwin'
$alToolExe = Join-Path $alcPath 'altool'
Write-Host "Setting execute permissions on altool"
& chmod +x $alToolExe
}
else {
$alcPath = Join-Path $binPath 'win32'
$alToolExe = Join-Path $alcPath 'altool.exe'
Expand All @@ -1145,7 +1151,7 @@ function GetAppInfo {
}
$alToolExists = Test-Path -Path $alToolExe -PathType Leaf
$alcDllPath = $alcPath
if (!$isLinux -and !$isPsCore) {
if (!($isLinux -or $isMacOS) -and !$isPsCore) {
$alcDllPath = $binPath
}

Expand Down Expand Up @@ -1351,6 +1357,11 @@ function RunAlTool {
$alToolExe = Join-Path $path 'extension/bin/linux/altool'
Write-Host "Setting execute permissions on altool"
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe"
}
elseif ($isMacOS) {
$alToolExe = Join-Path $path 'extension/bin/darwin/altool'
Write-Host "Setting execute permissions on altool"
& chmod +x $alToolExe
}
else {
$alToolExe = Join-Path $path 'extension/bin/win32/altool.exe'
Expand Down