From e6b972d4069fe63d66e59a94a789df1924e9215f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 19 May 2016 22:30:41 +0000 Subject: Adjustments to premake.c to allow the debug version to run by default without --script, if the scripts are inside the src/ subfolder Adjustments to both premake.c and premake4.rc in order to allow overriding the version number Fix to path_translate which could end up modifying the keys of the table it iterated --HG-- branch : WDS-build --- Premake4.vs8.vcproj | 477 +--------------------------------------------- premake4.lua | 15 +- src/host/path_translate.c | 10 +- src/host/premake.c | 40 +++- src/host/premake4.rc | 20 +- 5 files changed, 64 insertions(+), 498 deletions(-) diff --git a/Premake4.vs8.vcproj b/Premake4.vs8.vcproj index 4e13f0a..5c048fa 100644 --- a/Premake4.vs8.vcproj +++ b/Premake4.vs8.vcproj @@ -213,7 +213,7 @@ Name="VCCLCompilerTool" Optimization="1" AdditionalIncludeDirectories="src\host\lua-5.1.4\src" - PreprocessorDefinitions="NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_HGTIP" + PreprocessorDefinitions="NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_HGTIP;PREMAKE_VERSION=4.4-wds" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -229,7 +229,7 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/premake4.lua b/premake4.lua index f4887e7..1beadd0 100644 --- a/premake4.lua +++ b/premake4.lua @@ -41,7 +41,7 @@ do -- Name the project files after their VS version local orig_getbasename = premake.project.getbasename premake.project.getbasename = function(prjname, pattern) - -- The below is used to insert the .vs(8|9|10|11|12|14) into the file names for projects and solutions + -- The below is used to insert the .vs(8|9|10|11|12|14) into the file names for projects and solutions if _ACTION then name_map = {vs2005 = "vs8", vs2008 = "vs9", vs2010 = "vs10", vs2012 = "vs11", vs2013 = "vs12", vs2015 = "vs14"} if name_map[_ACTION] then @@ -88,9 +88,9 @@ end -- worry about the /scripts argument and all that. -- - solution "Premake4" - configurations { "Release", "Debug", "Publish" } - location ( _OPTIONS["to"] ) +solution "Premake4" + configurations { "Release", "Debug", "Publish" } + location ( _OPTIONS["to"] ) project "Premake4" local int_dir = "intermediate/" .. action .. "_$(" .. transformMN("Platform") .. ")_$(" .. transformMN("Configuration") .. ")" @@ -117,7 +117,10 @@ end "src/host/lua-5.1.4/src/print.c", "src/host/lua-5.1.4/**.lua", "src/host/lua-5.1.4/etc/*.c", - "src/host/hgtip.h" + "src/host/hgtip.h", + "packages/**", + "samples/**", + "tests/**", } configuration "Debug" @@ -142,7 +145,7 @@ end configuration {"windows", "Publish"} postbuildcommands { 'ollisign.cmd -a "$(TargetPath)" "https://bitbucket.org/windirstat/premake-stable" "premake4"' } - defines "HAVE_HGTIP" + defines { "HAVE_HGTIP", "PREMAKE_VERSION=4.4-wds"} configuration "linux or bsd" defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" } diff --git a/src/host/path_translate.c b/src/host/path_translate.c index 8996b37..bd0c2f1 100644 --- a/src/host/path_translate.c +++ b/src/host/path_translate.c @@ -43,12 +43,14 @@ int path_translate(lua_State* L) lua_newtable(L); lua_pushnil(L); while (lua_next(L, 1)) { - const char* value = luaL_checkstring(L, 4); - translate(buffer, value, sep[0]); - lua_pop(L, 1); + const char* key; + lua_pushvalue(L, 4); // copy the key + key = luaL_checkstring(L, 5); + translate(buffer, key, sep[0]); + lua_pop(L, 2); lua_pushstring(L, buffer); - lua_rawseti(L, -3, ++i); + lua_rawseti(L, -3, ++i); } return 1; } diff --git a/src/host/premake.c b/src/host/premake.c index e096bbc..6f9cc6d 100755 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -12,11 +12,25 @@ #include #endif -#ifdef HAVE_HGTIP +#ifndef PPSX +# define PPSX(s) #s +#endif +#ifndef PPS +# define PPS(s) PPSX(s) +#endif +#ifndef PREMAKE_VERSION +# define PREMAKE_VERSION 4.4-wds +#endif + +#if defined(HAVE_HGTIP) # include "hgtip.h" -# define VERSION HG_TIP_ID ":" HG_TIP_REVNO +# define HG_VERSION HG_TIP_ID ":" HG_TIP_REVNO +#endif + +#if defined(HG_VERSION) +# define VERSION PPS(PREMAKE_VERSION) " " HG_VERSION #else -#define VERSION "HEAD" +# define VERSION PPS(PREMAKE_VERSION) #endif #define COPYRIGHT "Copyright (C) 2002-2013 Jason Perkins and the Premake Project" #define ERROR_MESSAGE "%s\n" @@ -326,11 +340,21 @@ static int load_file_scripts(lua_State* L) if (lua_isnil(L, -1)) { - printf(ERROR_MESSAGE, - "Unable to find _premake_main.lua; use /scripts option when in debug mode!\n" - "Please refer to the documentation (or build in release mode instead)." - ); - return !OKAY; + /* call os.pathsearch() to locate _premake_main.lua */ + lua_pushcfunction(L, os_pathsearch); + lua_pushstring(L, "_premake_main.lua"); + lua_pushstring(L, "src"); + lua_pushstring(L, getenv("PREMAKE_PATH")); + lua_call(L, 3, 1); + + if (lua_isnil(L, -1)) + { + printf(ERROR_MESSAGE, + "Unable to find _premake_main.lua; use --scripts option when in debug mode!\n" + "Please refer to the documentation (or build in release mode instead)." + ); + return !OKAY; + } } /* run the bootstrapping script */ diff --git a/src/host/premake4.rc b/src/host/premake4.rc index 147f80f..deb8a51 100644 --- a/src/host/premake4.rc +++ b/src/host/premake4.rc @@ -17,6 +17,16 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 +#ifndef PPSX +# define PPSX(s) #s +#endif +#ifndef PPS +# define PPS(s) PPSX(s) +#endif +#ifndef PREMAKE_VERSION +# define PREMAKE_VERSION 4.4-wds +#endif + VS_VERSION_INFO VERSIONINFO FILEVERSION 4,4,0,0xFFFF PRODUCTVERSION 4,4,0,0 @@ -32,14 +42,14 @@ BEGIN BEGIN VALUE "CompanyName", "WDS Team" VALUE "FileDescription", "A build configuration tool" - VALUE "InternalName", "premake4-windirstat" + VALUE "InternalName", PPS(PREMAKE_VERSION) #ifdef HAVE_HGTIP - VALUE "FileVersion", "4.4-wds-" HG_TIP_REVNO - VALUE "ProductVersion", "4.4-wds-" HG_TIP_REVNO + VALUE "FileVersion", PPS(PREMAKE_VERSION) "-" HG_TIP_REVNO + VALUE "ProductVersion", PPS(PREMAKE_VERSION) "-" HG_TIP_REVNO VALUE "OriginalFilename", "premake4.rev-" HG_TIP_REVNO "-" HG_TIP_ID ".exe" #else - VALUE "FileVersion", "4.4-wds" - VALUE "ProductVersion", "4.4-wds" + VALUE "FileVersion", PPS(PREMAKE_VERSION) + VALUE "ProductVersion", PPS(PREMAKE_VERSION) VALUE "OriginalFilename", "premake4.exe" #endif VALUE "LegalCopyright", "Copyright (C) 2002-2013 by Jason Perkins, with minor customizations by WDS team" -- cgit v1.2.3