From 00c914fb22a303333822e86eab342425fcb6c8e6 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Sat, 28 Sep 2024 12:03:30 +0100 Subject: [PATCH 1/7] Remove `premake.callarray`. --- modules/gmake/tests/cpp/test_flags.lua | 22 ++++++------- modules/gmake/tests/cpp/test_make_linking.lua | 30 +++++++++--------- modules/gmake2/tests/test_gmake2_flags.lua | 23 +++++++------- modules/gmake2/tests/test_gmake2_linking.lua | 31 ++++++++++--------- src/base/_foundation.lua | 16 ---------- 5 files changed, 54 insertions(+), 68 deletions(-) diff --git a/modules/gmake/tests/cpp/test_flags.lua b/modules/gmake/tests/cpp/test_flags.lua index 9326eebb7b..209c4493ad 100644 --- a/modules/gmake/tests/cpp/test_flags.lua +++ b/modules/gmake/tests/cpp/test_flags.lua @@ -23,7 +23,7 @@ local function prepare(calls) local cfg = test.getconfig(prj, "Debug") local toolset = p.tools.gcc - p.callarray(make, calls, cfg, toolset) + p.callArray(calls, cfg, toolset) end @@ -33,7 +33,7 @@ function suite.includeDirs() includedirs { "src/include", "../include" } - prepare { "includes" } + prepare { make.includes } test.capture [[ INCLUDES += -Isrc/include -I../include ]] @@ -45,7 +45,7 @@ -- function suite.symbols_on() symbols "on" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -57,7 +57,7 @@ -- function suite.symbols_default() symbols "default" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) @@ -69,7 +69,7 @@ -- function suite.symbols_fastlink() symbols "FastLink" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -78,7 +78,7 @@ function suite.symbols_full() symbols "full" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -90,7 +90,7 @@ -- function suite.symbols_off() symbols "off" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) @@ -103,7 +103,7 @@ function suite.symbols_on_default() symbols "on" debugformat "Default" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -113,7 +113,7 @@ function suite.symbols_on_dwarf() symbols "on" debugformat "Dwarf" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gdwarf ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf @@ -123,7 +123,7 @@ function suite.symbols_on_split_dwarf() symbols "on" debugformat "SplitDwarf" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf @@ -136,7 +136,7 @@ function suite.symbols_off_dwarf() symbols "off" debugformat "Dwarf" - prepare { "cFlags", "cxxFlags" } + prepare { make.cFlags, make.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) diff --git a/modules/gmake/tests/cpp/test_make_linking.lua b/modules/gmake/tests/cpp/test_make_linking.lua index ce1b2ce915..63463096cf 100644 --- a/modules/gmake/tests/cpp/test_make_linking.lua +++ b/modules/gmake/tests/cpp/test_make_linking.lua @@ -24,7 +24,7 @@ local function prepare(calls) local cfg = test.getconfig(prj, "Debug") local toolset = p.tools.gcc - p.callarray(make, calls, cfg, toolset) + p.callArray(calls, cfg, toolset) end @@ -34,7 +34,7 @@ function suite.links_onCppSharedLib() kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { make.ldFlags, make.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -44,7 +44,7 @@ function suite.links_onMacOSXCppSharedLib() _TARGET_OS = "macosx" kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { make.ldFlags, make.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -dynamiclib -Wl,-install_name,@rpath/libMyProject.dylib -Wl,-x LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -58,7 +58,7 @@ function suite.links_onCSharedLib() language "C" kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { make.ldFlags, make.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -72,7 +72,7 @@ function suite.links_onStaticLib() kind "StaticLib" - prepare { "ldFlags", "linkCmd" } + prepare { make.ldFlags, make.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LINKCMD = $(AR) -rcs "$@" $(OBJECTS) @@ -88,7 +88,7 @@ function suite.links_onUtility() kind "Utility" - prepare { "linkCmd" } + prepare { make.linkCmd } test.capture [[ LINKCMD = ]] @@ -102,7 +102,7 @@ function suite.links_onMacUniversalStaticLib() architecture "universal" kind "StaticLib" - prepare { "ldFlags", "linkCmd" } + prepare { make.ldFlags, make.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LINKCMD = libtool -o "$@" $(OBJECTS) @@ -121,7 +121,7 @@ kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += build/bin/Debug/libMyProject2.a @@ -141,7 +141,7 @@ kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s LIBS += build/bin/Debug/libMyProject2.so @@ -161,7 +161,7 @@ kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s LIBS += -lMyProject2 @@ -178,7 +178,7 @@ kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'@loader_path/../../build/bin/Debug' -Wl,-x LIBS += -lMyProject2 @@ -202,7 +202,7 @@ kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a @@ -227,7 +227,7 @@ kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { make.ldFlags, make.libs, make.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += -Wl,--start-group build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a -Wl,--end-group @@ -244,7 +244,7 @@ function suite.onExternalLibraryWithPath() location "MyProject" links { "libs/SomeLib" } - prepare { "ldFlags", "libs" } + prepare { make.ldFlags, make.libs } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -L../libs -s LIBS += -lSomeLib @@ -263,7 +263,7 @@ function suite.onExternalLibraryWithPathAndVersion() location "MyProject" links { "libs/SomeLib-1.1" } - prepare { "libs", } + prepare { make.libs } test.capture [[ LIBS += -lSomeLib-1.1 ]] diff --git a/modules/gmake2/tests/test_gmake2_flags.lua b/modules/gmake2/tests/test_gmake2_flags.lua index d74c8239ee..21e46a2402 100644 --- a/modules/gmake2/tests/test_gmake2_flags.lua +++ b/modules/gmake2/tests/test_gmake2_flags.lua @@ -8,6 +8,7 @@ local p = premake local gmake2 = p.modules.gmake2 + local cpp = gmake2.cpp local project = p.project @@ -25,7 +26,7 @@ local function prepare(calls) local cfg = test.getconfig(prj, "Debug") local toolset = p.tools.gcc - p.callarray(gmake2.cpp, calls, cfg, toolset) + p.callArray(calls, cfg, toolset) end @@ -35,7 +36,7 @@ function suite.includeDirs() includedirs { "src/include", "../include" } - prepare { "includes" } + prepare { cpp.includes } test.capture [[ INCLUDES += -Isrc/include -I../include ]] @@ -46,7 +47,7 @@ INCLUDES += -Isrc/include -I../include -- function suite.symbols_on() symbols "on" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -58,7 +59,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -- function suite.symbols_default() symbols "default" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) @@ -70,7 +71,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -- function suite.symbols_off() symbols "off" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) @@ -82,7 +83,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -- function suite.symbols_fastlink() symbols "FastLink" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -91,7 +92,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g function suite.symbols_full() symbols "full" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -104,7 +105,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g function suite.symbols_on_default() symbols "on" debugformat "Default" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g @@ -114,7 +115,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g function suite.symbols_on_dwarf() symbols "on" debugformat "Dwarf" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gdwarf ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf @@ -124,7 +125,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gdwarf function suite.symbols_on_split_dwarf() symbols "on" debugformat "SplitDwarf" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf @@ -137,7 +138,7 @@ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -gsplit-dwarf function suite.symbols_off_dwarf() symbols "off" debugformat "Dwarf" - prepare { "cFlags", "cxxFlags" } + prepare { cpp.cFlags, cpp.cxxFlags } test.capture [[ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) diff --git a/modules/gmake2/tests/test_gmake2_linking.lua b/modules/gmake2/tests/test_gmake2_linking.lua index 4943980b69..3229fd7f6d 100644 --- a/modules/gmake2/tests/test_gmake2_linking.lua +++ b/modules/gmake2/tests/test_gmake2_linking.lua @@ -8,6 +8,7 @@ local p = premake local gmake2 = p.modules.gmake2 + local cpp = gmake2.cpp local project = p.project @@ -26,7 +27,7 @@ local function prepare(calls) local cfg = test.getconfig(prj, "Debug") local toolset = p.tools.gcc - p.callarray(gmake2.cpp, calls, cfg, toolset) + p.callArray(calls, cfg, toolset) end @@ -36,7 +37,7 @@ function suite.links_onCppSharedLib() kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { cpp.ldFlags, cpp.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -46,7 +47,7 @@ LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) function suite.links_onMacOSXCppSharedLib() _OS = "macosx" kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { cpp.ldFlags, cpp.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -dynamiclib -Wl,-install_name,@rpath/libMyProject.dylib -Wl,-x LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -60,7 +61,7 @@ LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) function suite.links_onCSharedLib() language "C" kind "SharedLib" - prepare { "ldFlags", "linkCmd" } + prepare { cpp.ldFlags, cpp.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -shared -Wl,-soname=libMyProject.so -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -74,7 +75,7 @@ LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) function suite.links_onStaticLib() kind "StaticLib" - prepare { "ldFlags", "linkCmd" } + prepare { cpp.ldFlags, cpp.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LINKCMD = $(AR) -rcs "$@" $(OBJECTS) @@ -90,7 +91,7 @@ LINKCMD = $(AR) -rcs "$@" $(OBJECTS) function suite.links_onUtility() kind "Utility" - prepare { "linkCmd" } + prepare { cpp.linkCmd } test.capture [[ LINKCMD = ]] @@ -104,7 +105,7 @@ LINKCMD = function suite.links_onMacUniversalStaticLib() architecture "universal" kind "StaticLib" - prepare { "ldFlags", "linkCmd" } + prepare { cpp.ldFlags, cpp.linkCmd } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LINKCMD = libtool -o "$@" $(OBJECTS) @@ -123,7 +124,7 @@ LINKCMD = libtool -o "$@" $(OBJECTS) kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += build/bin/Debug/libMyProject2.a @@ -143,7 +144,7 @@ LDDEPS += build/bin/Debug/libMyProject2.a kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s LIBS += build/bin/Debug/libMyProject2.so @@ -163,7 +164,7 @@ LDDEPS += build/bin/Debug/libMyProject2.so kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s LIBS += -lMyProject2 @@ -180,7 +181,7 @@ LDDEPS += build/bin/Debug/libMyProject2.so kind "SharedLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Lbuild/bin/Debug -Wl,-rpath,'@loader_path/../../build/bin/Debug' -Wl,-x LIBS += -lMyProject2 @@ -204,7 +205,7 @@ LDDEPS += build/bin/Debug/libMyProject2.dylib kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a @@ -229,7 +230,7 @@ LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a kind "StaticLib" location "build" - prepare { "ldFlags", "libs", "ldDeps" } + prepare { cpp.ldFlags, cpp.libs, cpp.ldDeps } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s LIBS += -Wl,--start-group build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a -Wl,--end-group @@ -246,7 +247,7 @@ LDDEPS += build/bin/Debug/libMyProject2.a build/bin/Debug/libMyProject3.a function suite.onExternalLibraryWithPath() location "MyProject" links { "libs/SomeLib" } - prepare { "ldFlags", "libs" } + prepare { cpp.ldFlags, cpp.libs } test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -L../libs -s LIBS += -lSomeLib @@ -265,7 +266,7 @@ LIBS += -lSomeLib function suite.onExternalLibraryWithPathAndVersion() location "MyProject" links { "libs/SomeLib-1.1" } - prepare { "libs", } + prepare { cpp.libs } test.capture [[ LIBS += -lSomeLib-1.1 ]] diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index a32d01d098..a911cfc541 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -119,22 +119,6 @@ end - -- TODO: THIS IMPLEMENTATION IS GOING AWAY - - function premake.callarray(namespace, array, ...) - local n = #array - for i = 1, n do - local fn = namespace[array[i]] - if not fn then - error(string.format("Unable to find function '%s'", array[i])) - end - fn(...) - end - - end - - - --- -- Compare a version string that uses semver semantics against a -- version comparison string. Comparisons take the form of ">=5.0" (5.0 or From 75d33a58dcb631f25af58ad8dc9fe0ea214a7f65 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Sat, 28 Sep 2024 12:04:08 +0100 Subject: [PATCH 2/7] Remove deprecated `configuration`. --- modules/android/android.lua | 2 +- modules/d/tests/test_gmake.lua | 6 +++--- modules/vstudio/tests/cs2005/test_files.lua | 2 +- .../xcode/tests/test_xcode_dependencies.lua | 2 +- modules/xcode/tests/test_xcode_project.lua | 2 +- src/base/api.lua | 19 ------------------- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/modules/android/android.lua b/modules/android/android.lua index dfef1f6c99..6435bbb5c6 100644 --- a/modules/android/android.lua +++ b/modules/android/android.lua @@ -9,7 +9,7 @@ if not p.modules.android then p.modules.android = {} if _ACTION < "vs2015" then - configuration { "Android" } + filter { "configurations:Android" } system "android" toolset "gcc" end diff --git a/modules/d/tests/test_gmake.lua b/modules/d/tests/test_gmake.lua index 21bd03b53f..54d48cb891 100644 --- a/modules/d/tests/test_gmake.lua +++ b/modules/d/tests/test_gmake.lua @@ -66,7 +66,7 @@ $(TARGET): $(OBJECTS) $(LDDEPS) end function suite.make_targetRules_mixedCompilation() - configuration { "Release" } + filter { "configurations:Release" } compilationmodel "File" prepare() m.make.targetRules(prj) @@ -111,7 +111,7 @@ $(OBJDIR)/blah.o: blah.d function suite.make_fileRules_mixedCompilation() files { "blah.d" } - configuration { "Release" } + filter { "configurations:Release" } compilationmodel "File" prepare() m.make.dFileRules(prj) @@ -148,7 +148,7 @@ OBJECTS := \ function suite.make_objects_mixedCompilation() files { "blah.d" } - configuration { "Release" } + filter { "configurations:Release" } compilationmodel "File" files { "blah2.d" } prepare() diff --git a/modules/vstudio/tests/cs2005/test_files.lua b/modules/vstudio/tests/cs2005/test_files.lua index 52836630c5..db7b42ad95 100644 --- a/modules/vstudio/tests/cs2005/test_files.lua +++ b/modules/vstudio/tests/cs2005/test_files.lua @@ -49,7 +49,7 @@ function suite.PerConfigFile() files { "Hello.cs" } - configuration { 'debug' } + filter { 'configurations:debug' } files { "HelloTwo.cs" } prepare() test.capture [[ diff --git a/modules/xcode/tests/test_xcode_dependencies.lua b/modules/xcode/tests/test_xcode_dependencies.lua index 829c6c7334..8f96c39116 100644 --- a/modules/xcode/tests/test_xcode_dependencies.lua +++ b/modules/xcode/tests/test_xcode_dependencies.lua @@ -31,7 +31,7 @@ prj2 = test.createproject(wks) kind "StaticLib" - configuration "Debug" + filter { "configurations:Debug" } targetsuffix "-d" end diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 0c343b180d..a519477072 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -1318,7 +1318,7 @@ function suite.PBXShellScriptBuildPhase_OnPerConfigCmds() prebuildcommands { 'ls src' } - configuration "Debug" + filter { "configurations:Debug" } prebuildcommands { 'cp a b' } prepare() xcode.PBXShellScriptBuildPhase(tr) diff --git a/src/base/api.lua b/src/base/api.lua index 9fac4ec049..a6864814d8 100755 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -1142,25 +1142,6 @@ ---- --- Start a new block of configuration settings, using the old, "open" --- style of matching without field prefixes. ---- - - function configuration(terms) - -- Sep 16 2021 - premake.warnOnce("configuration", "`configuration` has been deprecated; use `filter` instead (https://premake.github.io/docs/Filters/)") - if terms then - if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or (terms == "*") then - terms = nil - end - configset.addblock(api.scope.current, {terms}, os.getcwd()) - end - return api.scope.current - end - - - --- -- Start a new block of configuration settings, using the new prefixed -- style of pattern matching. From e880ff8c13be5caa12dd0ce1d0da06cb6394cc8d Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Sat, 28 Sep 2024 12:28:40 +0100 Subject: [PATCH 3/7] Fix handling of and use documented "c7" debug format option. --- modules/vstudio/tests/vc200x/test_compiler_block.lua | 2 +- modules/vstudio/tests/vc200x/test_linker_block.lua | 2 +- modules/vstudio/tests/vc2010/test_compile_settings.lua | 7 ++++--- modules/vstudio/vs2010_vcxproj.lua | 2 +- src/base/_foundation.lua | 1 - 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/vstudio/tests/vc200x/test_compiler_block.lua b/modules/vstudio/tests/vc200x/test_compiler_block.lua index 30c4a3ddce..a05b071eab 100644 --- a/modules/vstudio/tests/vc200x/test_compiler_block.lua +++ b/modules/vstudio/tests/vc200x/test_compiler_block.lua @@ -135,7 +135,7 @@ function suite.looksGood_onC7DebugFormat() symbols "On" - debugformat "C7" + debugformat("c7") prepare() test.capture [[ @@ -627,7 +627,7 @@ function suite.onC7DebugFormat() symbols "On" - debugformat "c7" + debugformat("c7") prepare() test.capture [[ @@ -635,7 +635,8 @@ Level3 OldStyle Disabled - ]] + false + ]] end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index fce560c9df..4ac30c24b5 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2606,7 +2606,7 @@ if config.isOptimizedBuild(cfg) or cfg.flags.NoMinimalRebuild or cfg.flags.MultiProcessorCompile or - cfg.debugformat == p.C7 + cfg.debugformat == "c7" then m.element("MinimalRebuild", nil, "false") end diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index a911cfc541..696262b0d2 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -27,7 +27,6 @@ -- premake.C = "C" - premake.C7 = "c7" premake.CLANG = "clang" premake.CONSOLEAPP = "ConsoleApp" premake.CPP = "C++" From 532b3606960fd33c7f42df81c525664b13e650bd Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Sun, 29 Sep 2024 00:43:14 +0100 Subject: [PATCH 4/7] Improve documentation for `systemversion`. --- src/tools/clang.lua | 2 +- website/docs/systemversion.md | 42 ++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 241896a968..2b41af82be 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -89,7 +89,7 @@ end -- --- Returns C/C++ system version related build flags +-- Returns system version related build flags -- function clang.getsystemversionflags(cfg) diff --git a/website/docs/systemversion.md b/website/docs/systemversion.md index 6f84aff0ca..63c1d13b45 100644 --- a/website/docs/systemversion.md +++ b/website/docs/systemversion.md @@ -8,6 +8,10 @@ systemversion ("value") `value` is a colon-delimited string specifying the min and max version, `min:max`. +Ranges are currently only supported by the Windows targets with the Visual Studio actions. + +Otherwise, only a minimum version can be set for macOS/iOS targets with `xcode` and `gmake`-based actions. + ### Applies To ### Project. @@ -19,23 +23,41 @@ Premake 5.0 or later. ### Examples ### ```lua -workspace "MyWorkspace" - configurations { "Debug", "Release" } - platforms { "Windows" } +filter "system:windows" + systemversion "10.0.10240.0" -- To specify the version of the SDK you want +``` - filter "system:Windows" - systemversion "10.0.10240.0" -- To specify the version of the SDK you want +```lua +filter "system:windows" + systemversion "latest" -- To use the latest version of the SDK available ``` ```lua -workspace "MyWorkspace" - configurations { "Debug", "Release" } - platforms { "Windows" } +filter "system:windows" + systemversion "10.0.10240.0:latest" -- To specify a range of minumum and maximum versions +``` - filter "system:Windows" - systemversion "latest" -- To use the latest version of the SDK available +```lua +filter "system:macosx" + systemversion "13.0" -- To target a minimum macOS deployment version of 13.0 ``` +### Apple Targets ### + +Under macOS this sets the minimum version of the operating system required for the app to run and is equivalent to setting the `-macosx-version-min` (or newer `-macos-version-min`) compiler flag. + +The same is true for iOS, iPadOS, tvOS, and watchOS system targets except it is equivalent to setting the `-miphoneos-version-min` (or newer `ios-version-min`) compiler flag. + +:::warning +There is also a `-miphonesimulator-version` or `mios-simulator-version-min` compiler flag, but iOS simulator targets are not yet supported by Premake. +::: + +For the `xcode` action this is equivalent to the `MACOSX_DEPLOYMENT_TARGET` Xcode setting. + +### Windows Targets ### + +Under Windows and Visual Studio actions, this is equivalent to setting the `WindowsTargetPlatformVersion` (and `WindowsTargetPlatformMinVersion` if targetting `UWP`) MSBuild properties. + ### See Also ### * [system](system.md) From 40ff4cffe8d6126c251f9d53b28a1b0451ea7f83 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Thu, 3 Oct 2024 08:42:15 +0100 Subject: [PATCH 5/7] Cleanup string clone in `getversion`. --- src/host/os_getversion.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/host/os_getversion.c b/src/host/os_getversion.c index a6cd9740fe..d6eff6c3dc 100644 --- a/src/host/os_getversion.c +++ b/src/host/os_getversion.c @@ -297,8 +297,7 @@ int getversion(struct OsVersionInfo* info) // When using glibc, info->description gets set to u.sysname, // but it isn't passed out of this function, so we need to copy // the string. - info->description = malloc(strlen(u.sysname) + 1); - strcpy((char*)info->description, u.sysname); + info->description = strdup(u.sysname); info->isalloc = 1; #else info->description = u.sysname; From 88f83c41672732abe5498ced50ab80623ed46e9d Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Sat, 28 Sep 2024 12:07:19 +0100 Subject: [PATCH 6/7] Get rid of double "Error" in error message from `premake.error`. --- src/base/_foundation.lua | 30 ++++++++++++++---------------- src/host/curl_utils.c | 2 +- src/host/premake.c | 10 ++++++---- src/host/premake.h | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index 696262b0d2..9bfa9fe61a 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -195,22 +195,6 @@ end - --- --- Raise an error, with a formatted message built from the provided --- arguments. --- --- @param message --- The error message, which may contain string formatting tokens. --- @param ... --- Values to fill in the string formatting tokens. --- - - function premake.error(message, ...) - error(string.format("** Error: " .. message, ...), 0) - end - - -- -- Finds the correct premake script filename to be run. -- @@ -340,6 +324,20 @@ end +-- +-- Raise an error, with a formatted message built from the provided +-- arguments. +-- +-- @param message +-- The error message, which may contain string formatting tokens. +-- @param ... +-- Values to fill in the string formatting tokens. +-- + +function premake.error(message, ...) + error(string.format("** Error: " .. message, ...), 0) +end + -- -- Display a warning, with a formatted message built from the provided diff --git a/src/host/curl_utils.c b/src/host/curl_utils.c index 1fc4ac5b0e..d1309e8391 100644 --- a/src/host/curl_utils.c +++ b/src/host/curl_utils.c @@ -28,7 +28,7 @@ int curlProgressCallback(curl_state* state, double dltotal, double dlnow, double lua_pushnumber(L, (lua_Number)dlnow); int ret = premake_pcall(L, 2, LUA_MULTRET); if (ret != LUA_OK) { - printLastError(L); + premake_handle_lua_error(L); return -1; // abort download } diff --git a/src/host/premake.c b/src/host/premake.c index 44f4761c9a..71758be93f 100644 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -287,12 +287,14 @@ static void setErrorColor(lua_State* L) -void printLastError(lua_State* L) +void premake_handle_lua_error(lua_State* L) { const char* message = lua_tostring(L, -1); int oldColor = term_doGetTextColor(); setErrorColor(L); - printf(ERROR_MESSAGE, message); + /* avoid printing a double Error: prefix for premake.error() messages */ + int has_error_prefix = strncmp(message, "** Error:", 9) == 0; + printf(has_error_prefix ? "%s\n" : ERROR_MESSAGE, message); term_doSetTextColor(oldColor); } @@ -342,14 +344,14 @@ int premake_execute(lua_State* L, int argc, const char** argv, const char* scrip /* Find and run the main Premake bootstrapping script */ if (run_premake_main(L, script) != OKAY) { - printLastError(L); + premake_handle_lua_error(L); return !OKAY; } /* and call the main entry point */ lua_getglobal(L, "_premake_main"); if (premake_pcall(L, 0, 1) != OKAY) { - printLastError(L); + premake_handle_lua_error(L); return !OKAY; } else { diff --git a/src/host/premake.h b/src/host/premake.h index 26423ebcce..09d4358ad0 100644 --- a/src/host/premake.h +++ b/src/host/premake.h @@ -114,7 +114,6 @@ void do_translate(char* value, const char sep); int term_doGetTextColor(); void term_doSetTextColor(int color); -void printLastError(lua_State* L); /* Built-in functions */ int criteria_compile(lua_State* L); @@ -216,3 +215,4 @@ const buildin_mapping* premake_find_embedded_script(const char* filename); int premake_locate_executable(lua_State* L, const char* argv0); int premake_test_file(lua_State* L, const char* filename, int searchMask); +void premake_handle_lua_error(lua_State* L); From 64b2ec6d2620764aff0e46b119420dd0a18f6b06 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Wed, 2 Oct 2024 16:28:16 +0100 Subject: [PATCH 7/7] Fixed truncation warning in `path_join`. ../../src/host/path_join.c:164:9: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] --- src/host/path_join.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/host/path_join.c b/src/host/path_join.c index c41f1e0b8b..fa8d08400d 100644 --- a/src/host/path_join.c +++ b/src/host/path_join.c @@ -5,6 +5,7 @@ */ #include "premake.h" +#include #include #include "path_isabsolute.h" @@ -150,6 +151,17 @@ int path_has_deferred_join(lua_State* L) return 1; } +// Copy string "in" with at most "insz" chars to buffer "out", which +// is "outsz" bytes long. The output is always 0-terminated. Unlike +// strncpy(), strncpy_t() does not zero fill remaining space in the +// output buffer: +// Credit: https://stackoverflow.com/a/58237928 +static char* strncpy_t(char* out, size_t outsz, const char* in, size_t insz){ + assert(outsz > 0); + while(--outsz > 0 && insz > 0 && *in) { *out++ = *in++; insz--; } + *out = 0; + return out; +} int path_resolve_deferred_join(lua_State* L) { @@ -161,8 +173,7 @@ int path_resolve_deferred_join(lua_State* L) size_t len = strlen(path); int i; int numParts = 0; - strncpy(inBuffer, path, len); - inBuffer[len] = '\0'; + strncpy_t(inBuffer, sizeof(inBuffer), path, len); char *parts[0x200]; // break up the string into parts and index the start of each part nextPart = strchr(inBuffer, DEFERRED_JOIN_DELIMITER);