From 088df1032f348a4a2d0602f53c933e4394dc698a Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 28 Feb 2021 10:56:48 -0800 Subject: [PATCH 1/5] enable building universal (x64,arm64) binaries for MacOS --- .gitignore | 3 +++ build.psm1 | 17 ++++++++++++++++- src/libpsl-native/macos.toolchain.cmake | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 src/libpsl-native/macos.toolchain.cmake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e06cb4c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +dotnet-install.sh +dotnet-uninstall-pkgs.sh +src/powershell-unix diff --git a/build.psm1 b/build.psm1 index 3864135..17b2fce 100644 --- a/build.psm1 +++ b/build.psm1 @@ -462,6 +462,11 @@ function Start-BuildNativeUnixBinaries { Start-NativeExecution { cmake -DCMAKE_TOOLCHAIN_FILE="./arm64.toolchain.cmake" . } Start-NativeExecution { make -j } } + elseif ($IsMacOS) { + Start-NativeExecution { cmake -DCMAKE_TOOLCHAIN_FILE="./macos.toolchain.cmake" . } + Start-NativeExecution { make -j } + Start-NativeExecution { ctest --verbose } + } else { Start-NativeExecution { cmake -DCMAKE_BUILD_TYPE=Debug . } Start-NativeExecution { make -j } @@ -774,6 +779,7 @@ function Start-PSBuild { # If this parameter is not provided it will get determined automatically. [ValidateSet("win7-x64", "win7-x86", + "osx-arm64", "osx-x64", "linux-x64", "linux-arm", @@ -1087,6 +1093,7 @@ function New-PSOptions { [ValidateSet("", "win7-x86", "win7-x64", + "osx-arm64", "osx-x64", "linux-x64", "linux-arm", @@ -1139,7 +1146,12 @@ function New-PSOptions { if ($Environment.IsLinux) { $Runtime = "linux-x64" } elseif ($Environment.IsMacOS) { - $Runtime = "osx-x64" + if ($PSVersionTable.OS.Contains('ARM64')) { + $Runtime = "osx-arm64" + } + else { + $Runtime = "osx-x64" + } } else { $RID = dotnet --info | ForEach-Object { if ($_ -match "RID") { @@ -2540,6 +2552,7 @@ function Start-CrossGen { [Parameter(Mandatory=$true)] [ValidateSet("win7-x86", "win7-x64", + "osx-arm64", "osx-x64", "linux-x64", "linux-arm", @@ -2610,6 +2623,8 @@ function Start-CrossGen { throw "crossgen is not available for 'linux-arm64'" } elseif ($Environment.IsLinux) { "linux-x64" + } elseif ($Runtime -eq "osx-arm64") { + "osx-arm64" } elseif ($Environment.IsMacOS) { "osx-x64" } diff --git a/src/libpsl-native/macos.toolchain.cmake b/src/libpsl-native/macos.toolchain.cmake new file mode 100644 index 0000000..549b219 --- /dev/null +++ b/src/libpsl-native/macos.toolchain.cmake @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.19) +SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE) + +add_compile_options(-g) + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE) +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE) +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) From f29d38f02452e83332f531370b20be06429c13bf Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 28 Feb 2021 15:19:37 -0800 Subject: [PATCH 2/5] set minimum osx version --- src/libpsl-native/macos.toolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libpsl-native/macos.toolchain.cmake b/src/libpsl-native/macos.toolchain.cmake index 549b219..2f9ccd2 100644 --- a/src/libpsl-native/macos.toolchain.cmake +++ b/src/libpsl-native/macos.toolchain.cmake @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.19) SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE) -add_compile_options(-g) +add_compile_options(-g -mmacosx-version-min=10.9) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE) From a9161b24c439d08df3efa9582475f6bfa5051af7 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 28 Feb 2021 15:30:30 -0800 Subject: [PATCH 3/5] specify latest macos --- .vsts-ci/mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vsts-ci/mac.yml b/.vsts-ci/mac.yml index af762aa..4b240de 100644 --- a/.vsts-ci/mac.yml +++ b/.vsts-ci/mac.yml @@ -13,7 +13,7 @@ phases: - phase: Build queue: - name: Hosted macOS + name: Hosted macOS-latest steps: - powershell: | tools/releaseBuild/PowershellNative.ps1 -Arch osx -Configuration Release -RepoRoot $(Build.SourcesDirectory) -TargetLocation "$(System.ArtifactsDirectory)/Packages" -Verbose From 9fef518e65081831514e16eb53a27e45716641cd Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 28 Feb 2021 16:05:31 -0800 Subject: [PATCH 4/5] change to vmimage pool --- .vsts-ci/mac.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.vsts-ci/mac.yml b/.vsts-ci/mac.yml index 4b240de..d5c130e 100644 --- a/.vsts-ci/mac.yml +++ b/.vsts-ci/mac.yml @@ -9,11 +9,13 @@ variables: resources: - repo: self clean: true -phases: -- phase: Build - queue: - name: Hosted macOS-latest +jobs: +- job: Build + + pool: + vmImage: macOs-latest + steps: - powershell: | tools/releaseBuild/PowershellNative.ps1 -Arch osx -Configuration Release -RepoRoot $(Build.SourcesDirectory) -TargetLocation "$(System.ArtifactsDirectory)/Packages" -Verbose From 5e3c01430444fd8c1ebd62ba52ebb941465545cf Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 8 Mar 2021 10:54:21 -0800 Subject: [PATCH 5/5] change release build to use macOS-latest vmimage which has xcode12 --- tools/releaseBuild/yaml/releaseBuild.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/releaseBuild/yaml/releaseBuild.yml b/tools/releaseBuild/yaml/releaseBuild.yml index 096ebc2..cc53a63 100644 --- a/tools/releaseBuild/yaml/releaseBuild.yml +++ b/tools/releaseBuild/yaml/releaseBuild.yml @@ -73,7 +73,8 @@ stages: - job: BuildMac displayName: Build Native Binaries on macOS - pool: Hosted Mac Internal + pool: + vmImage: macOS-Latest steps: - template: mac.yml