Skip to content

Commit

Permalink
Merge pull request #3139 from freddydk/master
Browse files Browse the repository at this point in the history
Support building on Linux
  • Loading branch information
freddydk committed Jul 30, 2023
2 parents c0e4e78 + 8b2cc51 commit 2261607
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 13 deletions.
33 changes: 22 additions & 11 deletions CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,33 @@ try {
}

Write-Host "Compiling..."
$alcParameters = @()
$binPath = Join-Path $compilerFolder 'compiler/extension/bin'
if ($isLinux) {
$alcPath = Join-Path $binPath 'linux'
$alcExe = 'alc'
$alcPath = Join-Path $binPath 'win32'
$alcExe = 'alc.exe'
$alcCmd = ".\$alcExe"
if (-not (Test-Path $alcPath)) {
$alcPath = $binPath
}
else {
$alcPath = Join-Path $binPath 'win32'
$alcExe = 'alc.exe'
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 {
$alcCmd = "dotnet"
$alcExe = 'alc.dll'
$alcParameters += @((Join-Path $alcPath $alcExe))
Write-Host "No Linux version of alc found. Using dotnet to run alc.dll."
}
}
$alcItem = Get-Item -Path (Join-Path $alcPath $alcExe)
[System.Version]$alcVersion = $alcItem.VersionInfo.FileVersion

$alcParameters = @("/project:""$($appProjectFolder.TrimEnd('/\'))""", "/packagecachepath:""$($appSymbolsFolder.TrimEnd('/\'))""", "/out:""$appOutputFile""")
$alcParameters += @("/project:""$($appProjectFolder.TrimEnd('/\'))""", "/packagecachepath:""$($appSymbolsFolder.TrimEnd('/\'))""", "/out:""$appOutputFile""")
if ($GenerateReportLayoutParam) {
$alcParameters += @($GenerateReportLayoutParam)
}
Expand Down Expand Up @@ -411,8 +422,8 @@ try {

Push-Location -Path $alcPath
try {
Write-Host ".\$alcExe $([string]::Join(' ', $alcParameters))"
$result = & ".\$alcExe" $alcParameters | Out-String
Write-Host "$alcCmd $([string]::Join(' ', $alcParameters))"
$result = & $alcCmd $alcParameters | Out-String
}
finally {
Pop-Location
Expand Down
30 changes: 28 additions & 2 deletions CompilerFolderHandling/New-BcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,34 @@ try {

if ($isLinux) {
$alcExePath = Join-Path $containerCompilerPath 'extension/bin/linux/alc'
# Set execute permissions on alc
& /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath"
if (Test-Path $alcExePath) {
# 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"
$alcConfigPath = Join-Path $containerCompilerPath 'extension/bin/win32/alc.runtimeconfig.json'
if (Test-Path $alcConfigPath) {
$oldAlcConfig = Get-Content -Path $alcConfigPath -Encoding UTF8 | ConvertFrom-Json
if ($oldAlcConfig.runtimeOptions.PSObject.Properties.Name -eq 'includedFrameworks') {
$newAlcConfig = @{
"runtimeOptions" = @{
"tfm" = "net6.0"
"framework" = @{
"name" = "Microsoft.NETCore.App"
"version" = $oldAlcConfig.runtimeOptions.includedFrameworks[0].version
}
"configProperties" = @{
"System.Reflection.Metadata.MetadataUpdater.IsSupported" = $false
}
}
}
$newAlcConfig | ConvertTo-Json | Set-Content -Path $alcConfigPath -Encoding utf8NoBOM
}
}
}
}
$compilerFolder
}
Expand Down

0 comments on commit 2261607

Please sign in to comment.