From 7488cd73ff477ad6e46804644cccd409edc50b45 Mon Sep 17 00:00:00 2001 From: tempura-sukiyaki <10625603+tempura-sukiyaki@users.noreply.github.com> Date: Tue, 25 May 2021 09:50:08 +0900 Subject: [PATCH] Add `--arch` to Premake build options --- .github/workflows/ci-workflow.yml | 4 +-- Bootstrap.mak | 6 ++--- premake5.lua | 42 +++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index ea9052e8..e734fd4c 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Build - run: make -f Bootstrap.mak linux CONFIG=${{ matrix.config }} + run: make -f Bootstrap.mak linux PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }} - name: Test run: bin/${{ matrix.config }}/premake5 test --test-all - name: Upload Artifacts @@ -32,7 +32,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Build - run: make -f Bootstrap.mak macosx CONFIG=${{ matrix.config }} + run: make -f Bootstrap.mak macosx PLATFORM=${{ matrix.platform }} CONFIG=${{ matrix.config }} - name: Test run: bin/${{ matrix.config }}/premake5 test --test-all - name: Upload Artifacts diff --git a/Bootstrap.mak b/Bootstrap.mak index 06e0f20c..9c6c32b3 100644 --- a/Bootstrap.mak +++ b/Bootstrap.mak @@ -87,7 +87,7 @@ mingw: mingw-clean if not exist build\bootstrap (mkdir build\bootstrap) $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $(SRC) -lole32 -lversion ./build/bootstrap/premake_bootstrap embed - ./build/bootstrap/premake_bootstrap --os=windows --to=build/bootstrap --cc=mingw gmake2 + ./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --os=windows --to=build/bootstrap --cc=mingw gmake2 $(MAKE) -C build/bootstrap config=$(CONFIG)_$(PLATFORM) macosx: osx @@ -100,7 +100,7 @@ osx: osx-clean mkdir -p build/bootstrap $(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_MACOSX -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" -framework CoreServices -framework Foundation -framework Security -lreadline $(SRC) ./build/bootstrap/premake_bootstrap embed - ./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake2 + ./build/bootstrap/premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap gmake2 $(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG) linux-clean: nix-clean @@ -143,7 +143,7 @@ windows-base: windows-clean if not exist build\bootstrap (mkdir build\bootstrap) cl /Fo.\build\bootstrap\ /Fe.\build\bootstrap\premake_bootstrap.exe /DPREMAKE_NO_BUILTIN_SCRIPTS /I"$(LUA_DIR)" /I"$(LUASHIM_DIR)" user32.lib ole32.lib advapi32.lib $(SRC) .\build\bootstrap\premake_bootstrap.exe embed - .\build\bootstrap\premake_bootstrap --to=build/bootstrap $(MSDEV) + .\build\bootstrap\premake_bootstrap --arch=$(PLATFORM) --to=build/bootstrap $(MSDEV) windows: windows-base devenv .\build\bootstrap\Premake5.sln /Upgrade diff --git a/premake5.lua b/premake5.lua index 9552f0ce..605cfcd1 100644 --- a/premake5.lua +++ b/premake5.lua @@ -90,6 +90,23 @@ description = "Embed scripts as bytecode instead of stripped souce code" } + newoption { + trigger = "arch", + value = "arch", + description = "Set the architecture of the binary to be built.", + allowed = { + { "ARM", "ARM (On macOS, same as ARM64.)" }, + { "ARM64", "ARM64" }, + { "x86", "x86 (On macOS, same as x86_64.)" }, + { "x86_64", "x86_64" }, + { "Universal", "Universal Binary (macOS only)" }, + -- + { "Win32", "Same as x86" }, + { "x64", "Same as x86_64" }, + }, + default = "x86", + } + -- -- Define the project. Put the release configuration first so it will be the -- default when folks build using the makefile. That way they don't have to @@ -116,8 +133,29 @@ defines { "CURL_STATICLIB", "PREMAKE_CURL"} end - filter { 'system:windows' } - platforms { 'x86', 'x64' } + filter { "system:macosx", "options:arch=ARM or arch=ARM64" } + buildoptions { "-arch arm64" } + linkoptions { "-arch arm64" } + + filter { "system:macosx", "options:arch=x86 or arch=x86_64 or arch=Win32 or arch=x64" } + buildoptions { "-arch x86_64" } + linkoptions { "-arch x86_64" } + + filter { "system:macosx", "options:arch=Universal" } + buildoptions { "-arch arm64", "-arch x86_64" } + linkoptions { "-arch arm64", "-arch x86_64" } + + filter { "system:windows", "options:arch=ARM" } + platforms { "ARM" } + + filter { "system:windows", "options:arch=ARM64" } + platforms { "ARM64" } + + filter { "system:windows", "options:arch=x86 or arch=Win32" } + platforms { "Win32" } + + filter { "system:windows", "options:arch=x86_64 or arch=x64" } + platforms { "x64" } filter "configurations:Debug" defines "_DEBUG"