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

117
BUILD.txt
View File

@ -1,61 +1,61 @@
PREMAKE BUILD INSTRUCTIONS
Premake is written in a mix of C and Lua. This mix enables many new
Premake is written in a mix of C and Lua. This mix enables many new
features, but also makes building Premake a bit more complicated than
your typical application.
If you downloaded a source code package from SourceForge (as opposed
to pulling the sources from the repository), you will find project
files for all of the currently supported toolsets in the build/ folder.
Build the release configuration (the default for the makefiles) and you
to pulling the sources from the repository), you will find project
files for all of the currently supported toolsets in the build/ folder.
Build the release configuration (the default for the makefiles) and you
will find the executable in bin/release ready to go.
If you want to use a debug build instead, or if you pulled the sources
from BitBucket instead of a SourceForge release, or if you plan on
making changes to Premake, read the next section to learn how to
from BitBucket instead of a SourceForge release, or if you plan on
making changes to Premake, read the next section to learn how to
prepare the project files.
If you find all of this very confusing and need some help, see the end
of this document for contact information. I'll be glad to help. And if
you have any suggestions for improving this process, we'd be glad to
If you find all of this very confusing and need some help, see the end
of this document for contact information. I'll be glad to help. And if
you have any suggestions for improving this process, we'd be glad to
hear them too.
GENERATING THE PROJECT FILES
If you downloaded a source code package from SourceForge, the project
files are already included (in build/) and you can skip ahead to the
next section.
If you pulled the sources from BitBucket, you'll need to generate your
own project files before you can build.
files are already included (in build/) and you can skip ahead to the
next section.
If you pulled the sources from BitBucket, you'll need to generate your
own project files before you can build.
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
system. You can get it as source code (with pre-generated project files
or eating our own dog food). So in order to generate the project files,
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
to do is to embed the Lua scripts into the application by running this
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
This creates a C file (at src/host/scripts.c) which contains all of the
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
executable, which is how we get away with shipping a single file instead
of one executable and whole bunch of scripts. See EMBEDDING THE SCRIPTS,
below, for more information.
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
Now you can generate project files for your toolset of choice by running
a command like:
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.
This will create a solution/makefile/workspace in the top-level folder,
which you can now go ahead and build.
@ -64,34 +64,34 @@ RELEASE vs. DEBUG BUILDS
Premake can be built in either "release" or "debug" modes. Makefile users
can choose which configuration to build with the "config" argument:
make config=debug -- build in debug mode
make config=release -- build in release mode
IDEs like Visual Studio provide their own mechanism for switching build
configurations.
In release mode you can build and run Premake like any other C application
(once you've embedded the scripts, see the next section).
In debug mode, Premake ignores the embedded Lua scripts and instead reads the
In debug mode, Premake ignores the embedded Lua scripts and instead reads the
latest versions from the disk at runtime. This allows you to change a script,
and then immediately test it without having to embed or compile first. Speedy!
But Premake needs some help to find the scripts.
But Premake needs some help to find the scripts.
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".
EMBEDDING THE SCRIPTS
One of the nice things about Premake is that it comes as a single file,
@ -100,24 +100,23 @@ EMBEDDING THE SCRIPTS
rather than an executable and a whole bunch of 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
string buffers. This file is then compiled as part of Premake's release
builds.
So: very important to embed the scripts before each release build!
CONFUSED?
I'll be glad to help you out. Stop by the main project website where
you can leave a note in the forums (the preferred approach), join the
you can leave a note in the forums (the preferred approach), join the
mailing list, or contact me directly.
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

@ -1,7 +1,7 @@
--
-- Embed the Lua scripts into src/host/scripts.c as static data buffers.
-- I embed the actual scripts, rather than Lua bytecodes, because the
-- bytecodes are not portable to different architectures, which causes
-- I embed the actual scripts, rather than Lua bytecodes, because the
-- bytecodes are not portable to different architectures, which causes
-- issues in Mac OS X Universal builds.
--
@ -12,16 +12,16 @@
-- strip tabs
s = s:gsub("[\t]", "")
-- strip any CRs
s = s:gsub("[\r]", "")
-- strip out block comments
s = s:gsub("%-%-%[%[.-%-%-%]%]", "")
-- strip out inline comments
s = s:gsub("\n%-%-[^\n]*", "")
-- escape backslashes
s = s:gsub("\\", "\\\\")
@ -33,10 +33,10 @@
-- escape line feeds
s = s:gsub("\n", "\\n")
-- escape double quote marks
s = s:gsub("\"", "\\\"")
return s
end
@ -46,14 +46,14 @@
out:write(s)
out:write(iif(continues, "\"\n", "\",\n"))
end
local function writefile(out, fname, contents)
local max = 1024
out:write("\t/* " .. fname .. " */\n")
-- break up large strings to fit in Visual Studio's string length limit
-- break up large strings to fit in Visual Studio's string length limit
local start = 1
local len = contents:len()
while start <= len do
@ -64,11 +64,11 @@
-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
end
end
writeline(out, contents:sub(start, finish), finish < len)
start = finish + 1
end
end
out:write("\n")
end
@ -77,23 +77,23 @@
function doembed()
-- load the manifest of script files
scripts = dofile("src/_manifest.lua")
-- main script always goes first
table.insert(scripts, 1, "_premake_main.lua")
-- open scripts.c and write the file header
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
print(fn)
local s = stripfile("src/" .. fn)
writefile(out, fn, s)
end
out:write("\t0\n};\n");
out:write("\t0\n};\n");
out:close()
end

View File

@ -2,7 +2,7 @@
-- Prepare a new Premake release. This is still incomplete and some manual
-- work is needed to get everything packaged up. See RELEASE.txt in this
-- folder for the full checklist.
--
--
-- Info on using Mercurial to manage releases:
-- http://hgbook.red-bean.com/read/managing-releases-and-branchy-development.html
-- http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
@ -12,7 +12,7 @@
function dorelease()
local z
--
--
-- Helper function: runs a command (formatted, with optional arguments) and
-- suppresses any output. Works on both Windows and POSIX. Might be a good
-- candidate for a core function.
@ -27,7 +27,7 @@ function dorelease()
end
--
-- Make sure a version was specified
--
@ -35,10 +35,10 @@ function dorelease()
if #_ARGS ~= 2 then
error("** Usage: release [version] [source | binary]", 0)
end
local version = _ARGS[1]
local kind = _ARGS[2]
local pkgname = "premake-" .. version
@ -75,21 +75,21 @@ function dorelease()
--
---------------------------------------------------------------------------
--
--
-- Check out the release tagged sources to releases/
--
print("Downloading release tag...")
os.mkdir("release")
os.chdir("release")
os.rmdir(pkgname)
z = exec( "hg clone -r %s .. %s", version, pkgname)
if z ~= 0 then
error("** Failed to download tagged sources", 0)
end
os.chdir(pkgname)
@ -113,12 +113,12 @@ 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
--
-- Generate source packaging
--
@ -137,26 +137,26 @@ function dorelease()
os.rmdir(".hgignore")
os.rmdir(".hgtags")
--
-- Generate project files to the build directory
--
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")
--
@ -174,20 +174,20 @@ function dorelease()
--
else
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)
@ -204,9 +204,9 @@ function dorelease()
--
-- Clean up
--
os.rmdir(pkgname)
print("")
print( "Finished.")

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,21 +1,21 @@
--
-- 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
--
function premake.showhelp()
-- display the basic usage
printf("Premake %s, a build script generator", _PREMAKE_VERSION)
printf(_PREMAKE_COPYRIGHT)
printf("%s %s", _VERSION, _COPYRIGHT)
printf("")
printf("Usage: premake4 [options] action [arguments]")
printf("Usage: premake5 [options] action [arguments]")
printf("")
-- display all options
printf("OPTIONS")
printf("")
@ -24,8 +24,8 @@
local description = option.description
if (option.value) then trigger = trigger .. "=" .. option.value end
if (option.allowed) then description = description .. "; one of:" end
printf(" --%-15s %s", trigger, description)
printf(" --%-15s %s", trigger, description)
if (option.allowed) then
for _, value in ipairs(option.allowed) do
printf(" %-14s %s", value[1], value[2])
@ -45,7 +45,7 @@
-- see more
printf("For additional information, see http://industriousone.com/premake")
end

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