Make the version change from 4.x to 5.x official

- Rename executable to premake5
- Default to premake5.lua project script; fallback to premake4.lua if not found
- Clean up internal references to premake4 naming
This commit is contained in:
Jason Perkins 2013-09-10 16:24:39 -04:00
parent 20b324201e
commit 985c58103c
17 changed files with 287 additions and 161 deletions

View File

@ -32,15 +32,15 @@ GENERATING THE PROJECT FILES
We use Premake to generate the project files for Premake (bootstrapping,
or eating our own dog food). So in order to generate the project files,
you need to have a working version of Premake 4.x installed on your
you need to have a working version of Premake 5.x installed on your
system. You can get it as source code (with pre-generated project files
ready to build) or a prebuilt binary from the SourceForge download page.
Once you have a working Premake 4.x installed, the first thing you need
Once you have a working Premake 5.x installed, the first thing you need
to do is to embed the Lua scripts into the application by running this
command in the top-level Premake directory:
premake4 embed
premake5 embed
This creates a C file (at src/host/scripts.c) which contains all of the
Lua scripts as static string buffers. These then get compiled into the
@ -51,8 +51,8 @@ GENERATING THE PROJECT FILES
Now you can generate project files for your toolset of choice by running
a command like:
premake4 gmake -- for GNU makefiles using GCC
premake4 vs2008 -- for a Visual Studio 2008 solution
premake5 gmake -- for GNU makefiles using GCC
premake5 vs2008 -- for a Visual Studio 2008 solution
Use the "--help" option to see all of the available targets.
@ -82,11 +82,11 @@ RELEASE vs. DEBUG BUILDS
You can specify the location of the scripts in one of two ways: using
the /scripts command line argument, like so:
premake4 /scripts=~/Code/premake4/src gmake
premake5 /scripts=~/Code/premake5/src gmake
Or by setting a PREMAKE_PATH environment variable.
PREMAKE_PATH=~/Code/premake4/src
PREMAKE_PATH=~/Code/premake5/src
As you can see, you need to specify the location of the Premake "src"
directory, the one containing "_premake_main.lua".
@ -101,7 +101,7 @@ EMBEDDING THE SCRIPTS
Scripts are embedded by running the command
premake4 embed
premake5 embed
This copies all of the scripts listed in _manifest.lua into the file
src/host/scripts.c, where they are represented as a set of static C
@ -120,4 +120,3 @@ CONFUSED?
http://industriousone.com/premake
Enjoy!

View File

@ -1,5 +1,6 @@
--
-- Premake 4.x build configuration script
-- Premake 5.x build configuration script
-- Use this script to configure the project with Premake4.
--
--
@ -8,12 +9,12 @@
-- worry about the /scripts argument and all that.
--
solution "Premake4"
solution "Premake5"
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )
project "Premake4"
targetname "premake4"
project "Premake5"
targetname "premake5"
language "C"
kind "ConsoleApp"
flags { "No64BitChecks", "ExtraWarnings", "StaticRuntime" }
@ -59,10 +60,7 @@
links { "m" }
linkoptions { "-rdynamic" }
configuration "linux"
links { "dl" }
configuration "hurd"
configuration "linux or hurd"
links { "dl" }
configuration "macosx"

135
premake5.lua Normal file
View File

@ -0,0 +1,135 @@
--
-- Premake 5.x build configuration script
-- Use this script to configure the project with Premake5.
--
--
-- 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
-- worry about the /scripts argument and all that.
--
solution "Premake5"
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )
project "Premake5"
targetname "premake5"
language "C"
kind "ConsoleApp"
flags { "No64BitChecks", "ExtraWarnings", "StaticRuntime" }
includedirs { "src/host/lua-5.1.4/src" }
files
{
"*.txt", "**.lua",
"src/**.h", "src/**.c",
"src/host/scripts.c"
}
excludes
{
"src/host/lua-5.1.4/src/lua.c",
"src/host/lua-5.1.4/src/luac.c",
"src/host/lua-5.1.4/src/print.c",
"src/host/lua-5.1.4/**.lua",
"src/host/lua-5.1.4/etc/*.c"
}
configuration "Debug"
targetdir "bin/debug"
defines "_DEBUG"
flags { "Symbols" }
configuration "Release"
targetdir "bin/release"
defines "NDEBUG"
flags { "OptimizeSize" }
configuration "vs*"
defines { "_CRT_SECURE_NO_WARNINGS" }
configuration "vs2005"
defines {"_CRT_SECURE_NO_DEPRECATE" }
configuration "windows"
links { "ole32" }
configuration "linux or bsd or hurd"
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
links { "m" }
linkoptions { "-rdynamic" }
configuration "linux or hurd"
links { "dl" }
configuration "macosx"
defines { "LUA_USE_MACOSX" }
links { "CoreServices.framework" }
configuration { "macosx", "gmake" }
toolset "clang"
buildoptions { "-mmacosx-version-min=10.4" }
linkoptions { "-mmacosx-version-min=10.4" }
configuration { "solaris" }
linkoptions { "-Wl,--export-dynamic" }
configuration "aix"
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
links { "m" }
--
-- A more thorough cleanup.
--
if _ACTION == "clean" then
os.rmdir("bin")
os.rmdir("build")
end
--
-- Use the --to=path option to control where the project files get generated. I use
-- this to create project files for each supported toolset, each in their own folder,
-- in preparation for deployment.
--
newoption {
trigger = "to",
value = "path",
description = "Set the output location for the generated files"
}
--
-- Use the embed action to convert all of the Lua scripts into C strings, which
-- can then be built into the executable. Always embed the scripts before creating
-- a release build.
--
dofile("scripts/embed.lua")
newaction {
trigger = "embed",
description = "Embed scripts in scripts.c; required before release builds",
execute = doembed
}
--
-- Use the release action to prepare source and binary packages for a new release.
-- This action isn't complete yet; a release still requires some manual work.
--
dofile("scripts/release.lua")
newaction {
trigger = "release",
description = "Prepare a new release (incomplete)",
execute = dorelease
}

View File

@ -16,7 +16,7 @@ PREP
* Prep release announcement for forums
* Run `premake4 embed`
* Run `premake5 embed`
* Commit all changes to premake-stable
@ -27,9 +27,9 @@ PREP
BUILD
* On each platform, run `premake4 release {version} binary`
* On each platform, run `premake5 release {version} binary`
* On one platform, run `premake4 release {version} source`
* On one platform, run `premake5 release {version} source`
* If desired, copy binary to local path

View File

@ -85,7 +85,7 @@
local out = io.open("src/host/scripts.c", "w+b")
out:write("/* Premake's Lua scripts, as static data buffers for release mode builds */\n")
out:write("/* DO NOT EDIT - this file is autogenerated - see BUILD.txt */\n")
out:write("/* To regenerate this file, run: premake4 embed */ \n\n")
out:write("/* To regenerate this file, run: premake5 embed */ \n\n")
out:write("const char* builtin_scripts[] = {\n")
for i,fn in ipairs(scripts) do

View File

@ -113,7 +113,7 @@ function dorelease()
print("Updating embedded scripts...")
z = exec("premake4 embed")
z = exec("premake5 embed")
if z ~= 0 then
error("** Failed to update the embedded scripts", 0)
end
@ -144,19 +144,19 @@ function dorelease()
print("Generating project files...")
exec("premake4 /to=build/vs2005 vs2005")
exec("premake4 /to=build/vs2008 vs2008")
exec("premake4 /to=build/vs2010 vs2010")
exec("premake4 /to=build/gmake.windows /os=windows gmake")
exec("premake4 /to=build/gmake.unix /os=linux gmake")
exec("premake4 /to=build/gmake.macosx /os=macosx /platform=universal32 gmake")
exec("premake4 /to=build/codeblocks.windows /os=windows codeblocks")
exec("premake4 /to=build/codeblocks.unix /os=linux codeblocks")
exec("premake4 /to=build/codeblocks.macosx /os=macosx /platform=universal32 codeblocks")
exec("premake4 /to=build/codelite.windows /os=windows codelite")
exec("premake4 /to=build/codelite.unix /os=linux codelite")
exec("premake4 /to=build/codelite.macosx /os=macosx /platform=universal32 codelite")
exec("premake4 /to=build/xcode3 /platform=universal32 xcode3")
exec("premake5 /to=build/vs2005 vs2005")
exec("premake5 /to=build/vs2008 vs2008")
exec("premake5 /to=build/vs2010 vs2010")
exec("premake5 /to=build/gmake.windows /os=windows gmake")
exec("premake5 /to=build/gmake.unix /os=linux gmake")
exec("premake5 /to=build/gmake.macosx /os=macosx /platform=universal32 gmake")
exec("premake5 /to=build/codeblocks.windows /os=windows codeblocks")
exec("premake5 /to=build/codeblocks.unix /os=linux codeblocks")
exec("premake5 /to=build/codeblocks.macosx /os=macosx /platform=universal32 codeblocks")
exec("premake5 /to=build/codelite.windows /os=windows codelite")
exec("premake5 /to=build/codelite.unix /os=linux codelite")
exec("premake5 /to=build/codelite.macosx /os=macosx /platform=universal32 codelite")
exec("premake5 /to=build/xcode3 /platform=universal32 xcode3")
--
@ -177,17 +177,17 @@ function dorelease()
print("Building platform binary release...")
exec("premake4 /platform=universal32 gmake")
exec("premake5 /platform=universal32 gmake")
exec("make config=%s", iif(os.is("macosx"), "releaseuniv32", "release"))
local fname
os.chdir("bin/release")
if os.is("windows") then
fname = string.format("%s-windows.zip", pkgname)
exec("zip -9 %s premake4.exe", fname)
exec("zip -9 %s premake5.exe", fname)
else
fname = string.format("%s-%s.tar.gz", pkgname, os.get())
exec("tar czvf %s premake4", fname)
exec("tar czvf %s premake5", fname)
end
os.copyfile(fname, "../../../" .. fname)

View File

@ -105,7 +105,7 @@
{
trigger = "file",
value = "FILE",
description = "Read FILE as a Premake script; default is 'premake4.lua'"
description = "Read FILE as a Premake script; default is 'premake5.lua'"
}
newoption

View File

@ -4,10 +4,8 @@
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
--
local scriptfile = "premake4.lua"
local shorthelp = "Type 'premake4 --help' for help"
local versionhelp = "premake4 (Premake Build Script Generator) %s"
local shorthelp = "Type 'premake5 --help' for help"
local versionhelp = "premake5 (Premake Build Script Generator) %s"
_WORKING_DIR = os.getcwd()
@ -52,11 +50,7 @@
-- If there is a project script available, run it to get the
-- project information, available options and actions, etc.
local fname = _OPTIONS["file"] or scriptfile
if (os.isfile(fname)) then
dofile(fname)
end
local hasScript = dofileopt(_OPTIONS["file"] or { "premake5.lua", "premake4.lua" })
-- Process special options
@ -81,8 +75,8 @@
-- If there wasn't a project script I've got to bail now
if (not os.isfile(fname)) then
error("No Premake script ("..scriptfile..") found!", 2)
if not hasScript then
error("No Premake script (premake5.lua) found!", 0)
end
@ -90,12 +84,12 @@
-- script has run to allow for project-specific options
action = premake.action.current()
if (not action) then
if not action then
error("Error: no such action '" .. _ACTION .. "'", 0)
end
ok, err = premake.option.validate(_OPTIONS)
if (not ok) then error("Error: " .. err, 0) end
if not ok then error("Error: " .. err, 0) end
-- "Bake" the project information, preparing it for use by the action

View File

@ -141,7 +141,7 @@
-- file path or an array of file paths, in which case the first
-- file found is run.
-- @return
-- Any return values from the executed script are passed back.
-- True if a file was found and executed, nil otherwise.
--
function dofileopt(fname)
@ -149,7 +149,8 @@
for i = 1, #fname do
local found = locate(fname[i])
if found then
return dofile(found)
dofile(found)
return true
end
end
end
@ -173,7 +174,7 @@
--
-- Load and run an external script file, with a bit of extra logic to make
-- including projects easier. if "path" is a directory, will look for
-- path/premake4.lua. And each file is tracked, and loaded only once.
-- path/premake5.lua. And each file is tracked, and loaded only once.
--
io._includedFiles = {}

View File

@ -1,7 +1,7 @@
--
-- help.lua
-- User help, displayed on /help option.
-- Copyright (c) 2002-2008 Jason Perkins and the Premake project
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
--
@ -12,7 +12,7 @@
printf(_PREMAKE_COPYRIGHT)
printf("%s %s", _VERSION, _COPYRIGHT)
printf("")
printf("Usage: premake4 [options] action [arguments]")
printf("Usage: premake5 [options] action [arguments]")
printf("")

View File

@ -355,7 +355,7 @@ int load_builtin_scripts(lua_State* L)
/**
* When running in release mode, the scripts are loaded from a static data
* buffer, where they were stored by a preprocess. To update these embedded
* scripts, run `premake4 embed` then rebuild.
* scripts, run `premake5 embed` then rebuild.
*/
int load_builtin_scripts(lua_State* L)
{

View File

@ -1,7 +1,7 @@
--
-- tests/base/test_os.lua
-- Automated test suite for the new OS functions.
-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
--
local suite = test.declare("base_os")
@ -31,7 +31,7 @@
--
function suite.isfile_ReturnsTrue_OnExistingFile()
test.istrue(os.isfile("premake4.lua"))
test.istrue(os.isfile("premake5.lua"))
end
function suite.isfile_ReturnsFalse_OnNonexistantFile()
@ -93,13 +93,13 @@
end
function suite.pathsearch_ReturnsPath_OnFound()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", os.getcwd()))
test.isequal(os.getcwd(), os.pathsearch("premake5.lua", os.getcwd()))
end
function suite.pathsearch_FindsFile_OnComplexPath()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", "aaa;"..os.getcwd()..";bbb"))
test.isequal(os.getcwd(), os.pathsearch("premake5.lua", "aaa;"..os.getcwd()..";bbb"))
end
function suite.pathsearch_NilPathsAllowed()
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", nil, os.getcwd(), nil))
test.isequal(os.getcwd(), os.pathsearch("premake5.lua", nil, os.getcwd(), nil))
end

View File

@ -1,14 +1,13 @@
--
-- tests/base/test_premake_command.lua
-- Test the initialization of the _PREMAKE_COMMAND global.
-- Copyright (c) 2012 Jason Perkins and the Premake project
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
--
T.premake_command = { }
local suite = T.premake_command
local suite = test.declare("premake_command")
function suite.valueIsSet()
local filename = iif(os.is("windows"), "premake4.exe", "premake4")
local filename = iif(os.is("windows"), "premake5.exe", "premake5")
test.isequal(path.getabsolute("../bin/debug/" .. filename), _PREMAKE_COMMAND)
end

View File

@ -1,6 +1,6 @@
--
-- tests/premake4.lua
-- Automated test suite for Premake 4.x
-- tests/premake5.lua
-- Automated test suite for Premake 5.x
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
--

View File

@ -1,2 +1,2 @@
#!/bin/sh
../bin/debug/premake4 /scripts=../src /file=test_stress.lua stress
../bin/debug/premake5 /scripts=../src /file=test_stress.lua stress

View File

@ -1,2 +1,2 @@
#!/bin/sh
cd `dirname $0` && ../bin/debug/premake4 /scripts=../src $1 $2 $3 test
cd `dirname $0` && ../bin/debug/premake5 /scripts=../src $1 $2 $3 test

View File

@ -1,3 +1,3 @@
CALL ..\\bin\\debug\\premake4 /scripts=..\\src test
::CALL ..\\bin\\release\\premake4 /scripts=..\\src test
CALL ..\\bin\\debug\\premake5 /scripts=..\\src test
::CALL ..\\bin\\release\\premake5 /scripts=..\\src test