From 762fd2d035b62109dd44a3481bf6c8ac10dbfdbb Mon Sep 17 00:00:00 2001 From: tobil4sk Date: Tue, 2 Jul 2024 15:34:53 +0100 Subject: [PATCH] [ci] Make mac universal builds more universal (#11663) * [ci] Install arm64 neko for arm64 mac builds * [ci] Create universal binary for haxelib * [ci] Build native haxelib binary on arm64 mac * [make] Use universal neko binaries for mac package It can still be configured to specific architectures if needed, using `PACKAGE_INSTALLER_MAC_ARCH`. * [make] Default to host arch for mac installer * [make] Use neko version 2.4.0-rc * [make] Use neko version 2.4.0-rc.1 This version fixes a permission issue with universal mac binaries --- .github/workflows/main.yml | 7 +++---- Makefile | 20 +++++++++++++++----- extra/github-actions/workflows/main.yml | 7 +++---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 402098f50ab..4ee2f9c6107 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -585,7 +585,7 @@ jobs: os: [macos-latest, macos-14] runs-on: ${{ matrix.os }} env: - PLATFORM: mac + PLATFORM: mac${{ matrix.os == 'macos-14' && '-arm64' || '' }} OPAMYES: 1 MACOSX_DEPLOYMENT_TARGET: 10.13 OCAML_VERSION: 5.1.1 @@ -912,9 +912,8 @@ jobs: tar -xf macX64Binaries/*_bin.tar.gz -C macX64Binaries --strip-components=1 tar -xf macArmBinaries/*_bin.tar.gz -C macArmBinaries --strip-components=1 lipo -create -output haxe macX64Binaries/haxe macArmBinaries/haxe - # there is only x64 haxelib - mv macX64Binaries/haxelib . - make -s package_unix package_installer_mac + lipo -create -output haxelib macX64Binaries/haxelib macArmBinaries/haxelib + make -s package_unix package_installer_mac PACKAGE_INSTALLER_MAC_ARCH=universal ls -l out otool -L ./haxe otool -L ./haxelib diff --git a/Makefile b/Makefile index a369415b02b..a3b86a753a9 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ PACKAGE_FILE_NAME=haxe_$(COMMIT_DATE)_$(COMMIT_SHA) HAXE_VERSION=$(shell $(CURDIR)/$(HAXE_OUTPUT) -version 2>&1 | awk '{print $$1;}') HAXE_VERSION_SHORT=$(shell echo "$(HAXE_VERSION)" | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+") -NEKO_VERSION=2.3.0 +NEKO_VERSION=2.4.0-rc.1 NEKO_MAJOR_VERSION=$(shell echo "$(NEKO_VERSION)" | grep -oE "^[0-9]+") NEKO_VERSION_TAG=v$(shell echo "$(NEKO_VERSION)" | sed "s/\./-/g") @@ -168,19 +168,29 @@ xmldoc: $(INSTALLER_TMP_DIR): mkdir -p $(INSTALLER_TMP_DIR) -$(INSTALLER_TMP_DIR)/neko-osx64.tar.gz: $(INSTALLER_TMP_DIR) - wget -nv https://github.com/HaxeFoundation/neko/releases/download/$(NEKO_VERSION_TAG)/neko-$(NEKO_VERSION)-osx64.tar.gz -O installer/neko-osx64.tar.gz +# Can be 'universal', 'arm64', or 'x86_64' +ifndef PACKAGE_INSTALLER_MAC_ARCH +PACKAGE_INSTALLER_MAC_ARCH:=$(shell uname -m) +endif + +$(INSTALLER_TMP_DIR)/neko-osx.tar.gz: $(INSTALLER_TMP_DIR) + NEKO_ARCH_SUFFIX=$$(if [ "$(PACKAGE_INSTALLER_MAC_ARCH)" = "x86_64" ]; then \ + echo 64; \ + else \ + echo "-$(PACKAGE_INSTALLER_MAC_ARCH)"; \ + fi); \ + wget -nv https://github.com/HaxeFoundation/neko/releases/download/$(NEKO_VERSION_TAG)/neko-$(NEKO_VERSION)-osx$$NEKO_ARCH_SUFFIX.tar.gz -O installer/neko-osx.tar.gz # Installer -package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx64.tar.gz package_unix +package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx.tar.gz package_unix $(eval OUTFILE := $(shell pwd)/$(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_installer.tar.gz) $(eval PACKFILE := $(shell pwd)/$(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_bin.tar.gz) $(eval VERSION := $(shell $(CURDIR)/$(HAXE_OUTPUT) -version 2>&1)) bash -c "rm -rf $(INSTALLER_TMP_DIR)/{resources,pkg,tgz,haxe.tar.gz}" mkdir $(INSTALLER_TMP_DIR)/resources # neko - unpack to change the dir name - cd $(INSTALLER_TMP_DIR)/resources && tar -zxvf ../neko-osx64.tar.gz + cd $(INSTALLER_TMP_DIR)/resources && tar -zxvf ../neko-osx.tar.gz mv $(INSTALLER_TMP_DIR)/resources/neko* $(INSTALLER_TMP_DIR)/resources/neko cd $(INSTALLER_TMP_DIR)/resources && tar -zcvf neko.tar.gz neko # haxe - unpack to change the dir name diff --git a/extra/github-actions/workflows/main.yml b/extra/github-actions/workflows/main.yml index ede4a966ac7..93313a9b7ce 100644 --- a/extra/github-actions/workflows/main.yml +++ b/extra/github-actions/workflows/main.yml @@ -335,7 +335,7 @@ jobs: os: [macos-latest, macos-14] runs-on: ${{ matrix.os }} env: - PLATFORM: mac + PLATFORM: mac${{ matrix.os == 'macos-14' && '-arm64' || '' }} OPAMYES: 1 MACOSX_DEPLOYMENT_TARGET: 10.13 OCAML_VERSION: 5.1.1 @@ -429,9 +429,8 @@ jobs: tar -xf macX64Binaries/*_bin.tar.gz -C macX64Binaries --strip-components=1 tar -xf macArmBinaries/*_bin.tar.gz -C macArmBinaries --strip-components=1 lipo -create -output haxe macX64Binaries/haxe macArmBinaries/haxe - # there is only x64 haxelib - mv macX64Binaries/haxelib . - make -s package_unix package_installer_mac + lipo -create -output haxelib macX64Binaries/haxelib macArmBinaries/haxelib + make -s package_unix package_installer_mac PACKAGE_INSTALLER_MAC_ARCH=universal ls -l out otool -L ./haxe otool -L ./haxelib