Browse Source

Simplified the Premake build files.

pull/1/head
triton 13 years ago
parent
commit
c751f417dc
  1. 10
      build/GenerateProjects.bat
  2. 77
      build/Helpers.lua
  3. 50
      build/premake4.lua
  4. 71
      examples/Hello/premake4.lua
  5. 16
      src/Bridge/Bridge.lua
  6. 19
      src/Generator/Generator.lua
  7. 30
      src/Parser/Parser.lua

10
build/GenerateProjects.bat

@ -7,14 +7,12 @@ echo.
echo [0] Clean echo [0] Clean
echo [1] Visual C++ 2010 echo [1] Visual C++ 2010
echo [2] Visual C++ 2012 echo [2] Visual C++ 2012
echo [3] CodeLite echo [3] GNU Make
echo [4] GNU Make
echo. echo.
:choice :choice
set /P C="Choice: " set /P C="Choice: "
if "%C%"=="4" goto gmake if "%C%"=="3" goto gmake
if "%C%"=="3" goto codelite
if "%C%"=="2" goto vs2012 if "%C%"=="2" goto vs2012
if "%C%"=="1" goto vs2010 if "%C%"=="1" goto vs2010
if "%C%"=="0" goto clean if "%C%"=="0" goto clean
@ -31,10 +29,6 @@ goto quit
"premake4" --file=premake4.lua vs2012 "premake4" --file=premake4.lua vs2012
goto quit goto quit
:codelite
"premake4" --file=premake4.lua codelite
goto quit
:gmake :gmake
"premake4" --file=premake4.lua gmake "premake4" --file=premake4.lua gmake
goto quit goto quit

77
build/Helpers.lua

@ -0,0 +1,77 @@
-- This module checks for the all the project dependencies.
action = _ACTION or ""
depsdir = path.getabsolute("../deps");
srcdir = path.getabsolute("../src");
incdir = path.getabsolute("../inc");
bindir = path.getabsolute("../bin");
examplesdir = path.getabsolute("../examples");
testsdir = path.getabsolute("../tests");
builddir = path.getabsolute("./" .. action);
libdir = path.join(builddir, "lib");
common_flags = { "Unicode", "Symbols" }
msvc_buildflags = { } -- "/wd4190", "/wd4996", "/wd4530"
gcc_buildflags = { "-std=gnu++11" }
msvc_cpp_defines = { }
function SetupNativeProject()
location (path.join(builddir, "projects"))
c = configuration "Debug"
defines { "DEBUG" }
targetsuffix "_d"
configuration "Release"
defines { "NDEBUG" }
-- Compiler-specific options
configuration "vs*"
buildoptions { msvc_buildflags }
defines { msvc_cpp_defines }
configuration "gcc"
buildoptions { gcc_buildflags }
-- OS-specific options
configuration "Windows"
defines { "WIN32", "_WINDOWS" }
configuration(c)
end
function IncludeDir(dir)
local deps = os.matchdirs(dir .. "/*")
for i,dep in ipairs(deps) do
local fp = path.join(dep, "premake4.lua")
fp = path.join(os.getcwd(), fp)
if os.isfile(fp) then
print(string.format(" including %s", dep))
include(dep)
end
end
end
-- Examples helpers
function SetupExampleProject()
SetupNativeProjects()
location (path.join(builddir, "deps"))
end
function IncludeExamples()
print("Searching for examples...")
IncludeDir(examplesdir)
end
function IncludeTests()
print("Searching for tests...")
IncludeDir(testsdir)
end

50
build/premake4.lua

@ -2,38 +2,38 @@
-- It defines the common build settings that all the projects share -- It defines the common build settings that all the projects share
-- and calls the build scripts of all the sub-projects. -- and calls the build scripts of all the sub-projects.
action = _ACTION or "" dofile "Helpers.lua"
common_flags = { "Unicode", "Symbols" }
common_msvc_copts =
{
"/wd4146", "/wd4244", "/wd4800", "/wd4345",
"/wd4355", "/wd4996", "/wd4624", "/wd4291"
}
solution "Cxxi" solution "Cxxi"
configurations configurations { "Debug", "Release" }
{
"Debug",
"Release"
}
platforms { "x32" } platforms { "x32" }
flags { common_flags }
objdir ( "obj/" .. action) location (builddir)
objdir (builddir .. "/obj/")
targetdir ("../bin/") targetdir (libdir)
debugdir ( "../bin/") libdirs { libdir }
debugdir (bindir)
configuration "Debug"
defines { "DEBUG" } -- startproject "Generator"
configuration "Release" configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" } flags { "Optimize" }
configuration "vs2012"
framework "4.5"
configuration {}
group "Examples"
IncludeExamples()
group "Tests"
IncludeTests()
include "../src/Parser/Parser.lua" group "Cxxi"
include "../src/Bridge/Bridge.lua" include (srcdir .. "/Bridge/Bridge.lua")
include "../src/Generator/Generator.lua" include (srcdir .. "/Generator/Generator.lua")
include (srcdir .. "/Parser/Parser.lua")

71
examples/Hello/premake4.lua

@ -1,55 +1,34 @@
common_flags = { } -- Otherwise /clr won't be enabled - bug ?
solution "Hello"
platforms { "x32" }
configurations { "Debug", "Release" }
objdir ( "./obj/" )
targetdir ("./bin/")
debugdir ( "./bin/")
configuration "Debug"
defines { "DEBUG", "WIN32" }
configuration "Release"
defines { "NDEBUG", "WIN32" }
flags { "Optimize" }
project "Hello" project "Hello"
kind "SharedLib"
language "C++"
location "."
platforms { "x32" }
flags { common_flags, "Managed" } SetupNativeProject()
kind "SharedLib"
language "C++"
configuration "*" flags { common_flags, "Managed" }
buildoptions { common_msvc_copts, "/clr" }
files { "**.h", "**.cpp", "./*.lua" } files { "**.h", "**.cpp", "./*.lua" }
-- Autogenerated files, so not available on first build - specify them manually -- Autogenerated files, so not available on first build - specify them manually
excludes { "CppCsBind/*.*" } excludes { "CppCsBind/*.*" }
files { "CppCsBind/hello_wrapper.h", "CppCsBind/hello_wrapper.cpp" } files { "CppCsBind/hello_wrapper.h", "CppCsBind/hello_wrapper.cpp" }
configuration "hello.h" configuration "hello.h"
buildrule { buildrule {
description = "Compiling $(InputFile)...", description = "Compiling $(InputFile)...",
commands = { commands = {
'..\\..\\bin\\generator.exe -D=WIN32 -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h', '..\\..\\bin\\generator.exe -D=WIN32 -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h',
}, },
outputs = { "CppCsBind\\hello_wrapper.cpp" } outputs = { "CppCsBind\\hello_wrapper.cpp" }
} }
project "SayHello" project "SayHello"
kind "ConsoleApp"
language "C#"
location "."
platforms { "x32" }
files { "**.cs", "./*.lua" } kind "ConsoleApp"
language "C#"
location "."
files { "**.cs", "./*.lua" }
links { "Hello" }
links { "Hello" }

16
src/Bridge/Bridge.lua

@ -1,18 +1,12 @@
project "Bridge" project "Bridge"
kind "SharedLib" kind "SharedLib"
language "C#" language "C#"
location "." location "."
files { "*.cs" }
platforms { "x32" }
configuration "Debug"
targetdir "../../bin"
configuration "Release"
targetdir "../../bin"
files { "*.cs" }
links { "System" }
if _ACTION == "clean" then if _ACTION == "clean" then
os.rmdir("lib") os.rmdir("lib")
end end

19
src/Generator/Generator.lua

@ -1,15 +1,10 @@
project "Generator" project "Generator"
kind "ConsoleApp"
language "C#"
location "."
files { "**.cs", "**.bmp", "**.resx", "**.config" }
excludes { "Filter.cs" }
links { "Bridge", "System", "System.Core", "Parser" }
platforms { "x32" }
configuration "Debug" kind "ConsoleApp"
targetdir "../../bin" language "C#"
location "."
configuration "Release"
targetdir "../../bin"
files { "**.cs", "**.bmp", "**.resx", "**.config" }
excludes { "Filter.cs" }
links { "System", "System.Core", "Bridge", "Parser" }

30
src/Parser/Parser.lua

@ -1,33 +1,41 @@
clang_msvc_flags =
{
"/wd4146", "/wd4244", "/wd4800", "/wd4345",
"/wd4355", "/wd4996", "/wd4624", "/wd4291"
}
project "Parser" project "Parser"
kind "SharedLib" kind "SharedLib"
language "C++" language "C++"
location "." SetupNativeProject()
platforms { "x32" }
dependson "Bridge"
flags { common_flags, "Managed" } flags { common_flags, "Managed" }
configuration "vs*"
buildoptions { common_msvc_copts }
-- usingdirs is only supported in per-file configs in our -- usingdirs is only supported in per-file configs in our
-- premake build. remove this once this support is added -- premake build. remove this once this support is added
-- at the project level. -- at the project level.
configuration { "Main.cpp" } configuration { "*Main.cpp" }
flags { "Managed" } flags { "Managed" }
usingdirs { "../../bin/" } usingdirs { libdir }
configuration { "Parser.cpp" } configuration { "*Parser.cpp" }
flags { "Managed" } flags { "Managed" }
usingdirs { "../../bin/" } usingdirs { libdir }
configuration "vs*"
buildoptions { clang_msvc_flags }
files { "VSLookup.cpp" }
configuration "*" configuration "*"
files files
{ {
"**.h", "**.h",
"**.cpp", "Main.cpp",
"Parser.cpp",
"**.lua" "**.lua"
} }

Loading…
Cancel
Save