From 486509d5b978de72b6a64a0504937bceda9455d5 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sat, 19 Oct 2024 10:37:16 +0200 Subject: [PATCH] Package and bump premake-core Treat premake like any other dependency and package it separately, this makes it much easier to bump it in future by making it easier to track modifications if any. Moving it to libraries as it is handled the same as other packages. An argument could be made to have it in build due to it's special nature. The issue with that approach would be how to handle clean-workspace.sh. If we split it out we would need a separate clean-premake.sh script and if we have it cleaned by clean-workspace we through away the download and already built binary. Also bump version to 5.0.0-beta2 and backport patch for macOS fix instead of the Makefile changes. The same fix is needed for gcc-14 (reported upstream), so add a patch injecting unistd.h for Unixes. Fixes: #6816 Fixes: #6632 Refs: #6847 Signed-off-by: Ralph Sennhauser --- .gitignore | 1 + build/workspaces/update-workspaces.sh | 5 +- libraries/build-macos-libs.sh | 5 ++ libraries/build-source-libs.sh | 6 ++ libraries/source/premake-core/build.sh | 56 +++++++++++++++++++ ...equire-unistd.h-for-macosx-in-libzip.patch | 21 +++++++ ...-Forceinclude-unistd.h-on-all-Unixes.patch | 25 +++++++++ 7 files changed, 115 insertions(+), 4 deletions(-) create mode 100755 libraries/source/premake-core/build.sh create mode 100644 libraries/source/premake-core/patches/0001-Require-unistd.h-for-macosx-in-libzip.patch create mode 100644 libraries/source/premake-core/patches/0002-Forceinclude-unistd.h-on-all-Unixes.patch diff --git a/.gitignore b/.gitignore index 1da37f36de..e6f336143d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ libraries/win32 libraries/source/cxxtest-4.4/* libraries/source/fcollada/* libraries/source/nvtt/* +libraries/source/premake-core/* libraries/source/spidermonkey/* libraries/source/spirv-reflect/* !libraries/source/**/build.sh diff --git a/build/workspaces/update-workspaces.sh b/build/workspaces/update-workspaces.sh index 7eafb028d5..783bb42d07 100755 --- a/build/workspaces/update-workspaces.sh +++ b/build/workspaces/update-workspaces.sh @@ -72,10 +72,7 @@ cd ../premake || die premake_command="premake5" if [ "$with_system_premake5" = "false" ]; then - # Build bundled premake - MAKE=${MAKE} JOBS=${JOBS} ./build.sh || die "Premake 5 build failed" - - premake_command="premake5/bin/release/premake5" + premake_command="../../libraries/source/premake-core/bin/premake5" fi echo diff --git a/libraries/build-macos-libs.sh b/libraries/build-macos-libs.sh index 29907189e1..b0a718cdae 100755 --- a/libraries/build-macos-libs.sh +++ b/libraries/build-macos-libs.sh @@ -1142,6 +1142,11 @@ echo "Building nvtt..." ./../source/nvtt/build.sh || die "NVTT build failed" +# -------------------------------------------------------------- +echo "Building Premake..." + +./../source/premake-core/build.sh || die "Premake build failed" + # -------------------------------------------------------------- echo "Building Spidermonkey..." diff --git a/libraries/build-source-libs.sh b/libraries/build-source-libs.sh index e01983a607..461a3e40e8 100755 --- a/libraries/build-source-libs.sh +++ b/libraries/build-source-libs.sh @@ -25,6 +25,7 @@ without_nvtt=false with_system_cxxtest=false with_system_nvtt=false with_system_mozjs=false +with_system_premake=false with_spirv_reflect=false JOBS=${JOBS:="-j2"} @@ -35,6 +36,7 @@ for i in "$@"; do --with-system-cxxtest) with_system_cxxtest=true ;; --with-system-nvtt) with_system_nvtt=true ;; --with-system-mozjs) with_system_mozjs=true ;; + --with-system-premake) with_system_mozjs=true ;; --with-spirv-reflect) with_spirv_reflect=true ;; -j*) JOBS=$i ;; esac @@ -68,6 +70,10 @@ if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then cp source/nvtt/bin/* ../binaries/system/ fi echo +if [ "$with_system_premake" = "false" ]; then + ./source/premake-core/build.sh || die "Premake build failed" +fi +echo if [ "$with_system_mozjs" = "false" ]; then ./source/spidermonkey/build.sh || die "SpiderMonkey build failed" cp source/spidermonkey/bin/* ../binaries/system/ diff --git a/libraries/source/premake-core/build.sh b/libraries/source/premake-core/build.sh new file mode 100755 index 0000000000..00bb4a354a --- /dev/null +++ b/libraries/source/premake-core/build.sh @@ -0,0 +1,56 @@ +#!/bin/sh +set -e + +: "${OS:=$(uname -s || true)}" +: "${MAKE:=make}" +: "${JOBS:=-j1}" + +cd "$(dirname "$0")" + +PV=5.0.0-beta2 +LIB_VERSION=${PV}+wfg1 + +if [ -e .already-built ] && [ "$(cat .already-built || true)" = "${LIB_VERSION}" ]; then + echo "premake is already up to date." + exit +fi + +# fetch +if [ ! -e "premake-core-${PV}.tar.gz" ]; then + curl -fLo "premake-core-${PV}.tar.gz" \ + "https://github.com/premake/premake-core/archive/refs/tags/v${PV}.tar.gz" +fi + +# unpack +rm -Rf "premake-core-${PV}" +tar -xf "premake-core-${PV}.tar.gz" + +#patch +patch -d "premake-core-${PV}" -p1 .already-built diff --git a/libraries/source/premake-core/patches/0001-Require-unistd.h-for-macosx-in-libzip.patch b/libraries/source/premake-core/patches/0001-Require-unistd.h-for-macosx-in-libzip.patch new file mode 100644 index 0000000000..7599149be0 --- /dev/null +++ b/libraries/source/premake-core/patches/0001-Require-unistd.h-for-macosx-in-libzip.patch @@ -0,0 +1,21 @@ +From 8eb0523a91a94c5c49a9ab7e0c9dac53e3a192ef Mon Sep 17 00:00:00 2001 +From: Nicholaus Clark +Date: Wed, 9 Aug 2023 10:32:45 -0400 +Subject: [PATCH 1/1] Require unistd.h for macosx in libzip + +--- + contrib/libzip/premake5.lua | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/contrib/libzip/premake5.lua b/contrib/libzip/premake5.lua +index 1532d518..c35592a5 100644 +--- a/contrib/libzip/premake5.lua ++++ b/contrib/libzip/premake5.lua +@@ -21,3 +21,4 @@ project "zip-lib" + + filter "system:macosx" + defines { "HAVE_SSIZE_T_LIBZIP" } ++ forceincludes { "unistd.h" } +-- +2.44.2 + diff --git a/libraries/source/premake-core/patches/0002-Forceinclude-unistd.h-on-all-Unixes.patch b/libraries/source/premake-core/patches/0002-Forceinclude-unistd.h-on-all-Unixes.patch new file mode 100644 index 0000000000..d7b7cddf71 --- /dev/null +++ b/libraries/source/premake-core/patches/0002-Forceinclude-unistd.h-on-all-Unixes.patch @@ -0,0 +1,25 @@ +From dca8ff71fc9ec29761d98ec0cdb5bd352ec8d295 Mon Sep 17 00:00:00 2001 +From: Ralph Sennhauser +Date: Mon, 30 Sep 2024 22:08:13 +0200 +Subject: [PATCH] Forceinclude unistd.h on all Unixes + +https://github.com/premake/premake-core/issues/2276 +--- + contrib/libzip/premake5.lua | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/contrib/libzip/premake5.lua b/contrib/libzip/premake5.lua +index c35592a5..f0b91b56 100644 +--- a/contrib/libzip/premake5.lua ++++ b/contrib/libzip/premake5.lua +@@ -13,6 +13,7 @@ project "zip-lib" + + filter "system:linux or bsd or solaris or haiku" + defines { "HAVE_SSIZE_T_LIBZIP", "HAVE_CONFIG_H" } ++ forceincludes { "unistd.h" } + + filter "system:windows" + defines { "_WINDOWS" } +-- +2.45.2 +