Merge with premake-dev

This commit is contained in:
Jason Perkins 2011-12-13 16:14:14 -05:00
commit 94e29b7cf3
12 changed files with 276 additions and 115 deletions

34
.gitignore vendored Normal file
View File

@ -0,0 +1,34 @@
syntax: glob
.DS_Store
*.orig
*~
build
bin
obj
release
ipch
src/host/scripts.c
Makefile
*.make
*.xcodeproj
*.swp
*.sdf
*.sln
*.suo
*.ncb
*.vcproj*
*.vcxproj*
*.opensdf
*.workspace
*.project
*.tags
*.bbprojectsettings
Scratchpad.txt
Unix Worksheet.worksheet
project.bbprojectdata
Premake4.tmproj

View File

@ -57,6 +57,9 @@ Sony NGP (in progress)
* Patch 3429777: Support for DragonFly BSD (Joachim de Groot)
* Patch 3445049: Build fix for FreeBSD (Konstantin Tokarev)
* Bug 3121217: Test suite fails on Linux x86_64: os.findlib broken
* Patch 3428348: Add .gitignore file (Konstantin Tokarev)
* Patch 3430158: Reorder LINKCMD for Gmake (rjmyst3)
* Patch 3451212: Fix Visual Studio MFC with StaticRuntime
-------

View File

@ -7,15 +7,15 @@
premake.make.cpp = { }
local cpp = premake.make.cpp
local make = premake.make
function premake.make_cpp(prj)
-- create a shortcut to the compiler interface
local cc = premake.gettool(prj)
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(prj.solution, cc.platforms, "Native")
premake.gmake_cpp_header(prj, cc, platforms)
for _, platform in ipairs(platforms) do
@ -23,7 +23,7 @@
premake.gmake_cpp_config(cfg, cc)
end
end
-- list intermediate files
_p('OBJECTS := \\')
for _, file in ipairs(prj.files) do
@ -32,7 +32,7 @@
end
end
_p('')
_p('RESOURCES := \\')
for _, file in ipairs(prj.files) do
if path.isresourcefile(file) then
@ -40,7 +40,7 @@
end
end
_p('')
-- identify the shell type
_p('SHELLTYPE := msdos')
_p('ifeq (,$(ComSpec)$(COMSPEC))')
@ -50,7 +50,7 @@
_p(' SHELLTYPE := posix')
_p('endif')
_p('')
-- main build rule(s)
_p('.PHONY: clean prebuild prelink')
_p('')
@ -69,12 +69,12 @@
_p('\t$(SILENT) $(LINKCMD)')
_p('\t$(POSTBUILDCMDS)')
_p('')
-- Create destination directories. Can't use $@ for this because it loses the
-- escaping, causing issues with spaces and parenthesis
_p('$(TARGETDIR):')
premake.make_mkdirrule("$(TARGETDIR)")
_p('$(OBJDIR):')
premake.make_mkdirrule("$(OBJDIR)")
@ -101,14 +101,14 @@
_p('prebuild:')
_p('\t$(PREBUILDCMDS)')
_p('')
_p('prelink:')
_p('\t$(PRELINKCMDS)')
_p('')
-- precompiler header rule
cpp.pchrules(prj)
-- per-file rules
for _, file in ipairs(prj.files) do
if path.iscppfile(file) then
@ -122,7 +122,7 @@
end
end
_p('')
-- include the dependencies, built by GCC (with the -MMD flag)
_p('-include $(OBJECTS:%%.o=%%.d)')
end
@ -141,28 +141,28 @@
_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))
_p('endif')
_p('')
_p('ifndef verbose')
_p(' SILENT = @')
_p('endif')
_p('')
_p('ifndef CC')
_p(' CC = %s', cc.cc)
_p('endif')
_p('')
_p('ifndef CXX')
_p(' CXX = %s', cc.cxx)
_p('endif')
_p('')
_p('ifndef AR')
_p(' AR = %s', cc.ar)
_p('endif')
_p('')
end
--
-- Write a block of configuration settings.
@ -171,25 +171,25 @@
function premake.gmake_cpp_config(cfg, cc)
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
-- if this platform requires a special compiler or linker, list it here
cpp.platformtools(cfg, cc)
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))
_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
_p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " "))
_p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), " "))
-- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
-- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
cpp.flags(cfg, cc)
-- set up precompiled headers
cpp.pchconfig(cfg)
_p(' LIBS += %s', table.concat(cc.getlinkflags(cfg), " "))
_p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " "))
if cfg.kind == "StaticLib" then
if cfg.platform:startswith("Universal") then
_p(' LINKCMD = libtool -o $(TARGET) $(OBJECTS)')
@ -197,11 +197,13 @@
_p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)')
end
else
-- this was $(TARGET) $(LDFLAGS) $(OBJECTS) ... but was having trouble linking to certain
-- static libraries so $(OBJECTS) was moved up
_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)', iif(cfg.language == "C", "CC", "CXX"))
-- this was $(TARGET) $(LDFLAGS) $(OBJECTS)
-- but had trouble linking to certain static libs so $(OBJECTS) moved up
-- then $(LDFLAGS) moved to end
-- https://sourceforge.net/tracker/?func=detail&aid=3430158&group_id=71616&atid=531880
_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)', iif(cfg.language == "C", "CC", "CXX"))
end
_p(' define PREBUILDCMDS')
if #cfg.prebuildcommands > 0 then
_p('\t@echo Running pre-build commands')
@ -222,19 +224,19 @@
_p('\t%s', table.implode(cfg.postbuildcommands, "", "", "\n\t"))
end
_p(' endef')
-- write out config-level makesettings blocks
make.settings(cfg, cc)
_p('endif')
_p('')
end
--
-- Platform support
--
function cpp.platformtools(cfg, cc)
local platform = cc.platforms[cfg.platform]
if platform.cc then
@ -247,8 +249,8 @@
_p(' AR = %s', platform.ar)
end
end
--
-- Configurations
--
@ -257,16 +259,16 @@
_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " "))
_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " "))
_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " "))
-- Patch #3401184 changed the order
_p(' LDFLAGS += %s', table.concat(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions), " "))
_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
table.concat(table.join(cc.getdefines(cfg.resdefines),
cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " "))
end
--
-- Precompiled header support
--
@ -286,7 +288,7 @@
if not cfg.flags.NoPCH and cfg.pchheader then
_p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader)))
_p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
_p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
_p(' CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/%s', _MAKE.esc(path.getname(cfg.pchheader)))
end
end
@ -304,7 +306,7 @@
_p('endif')
_p('')
end
--
-- Build command for a single file.
@ -314,5 +316,5 @@
local flags = iif(iscfile, '$(CC) $(CFLAGS)', '$(CXX) $(CXXFLAGS)')
_p('\t$(SILENT) %s -o "$@" -MF $(@:%%.o=%%.d) -c "$<"', flags)
end

View File

@ -90,7 +90,7 @@
_p(3,'ConfigurationType="%s"', cfgtype)
if (cfg.flags.MFC) then
_p(3, 'UseOfMFC="2"')
_p(3, 'UseOfMFC="%d"', iif(cfg.flags.StaticRuntime, 1, 2))
end
_p(3,'CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
if cfg.flags.Managed then

View File

@ -66,24 +66,34 @@
return result
end
--
-- This property group describes a particular configuration: what
-- kind of binary it produces, and some global settings.
--
function vc2010.configurationPropertyGroup(cfg)
_p(1,'<PropertyGroup '..if_config_and_platform() ..' Label="Configuration">'
, premake.esc(cfg.name))
_p(2,'<ConfigurationType>%s</ConfigurationType>',vc2010.config_type(cfg))
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', iif(optimisation(cfg) == "Disabled","true","false"))
_p(2,'<CharacterSet>%s</CharacterSet>',iif(cfg.flags.Unicode,"Unicode","MultiByte"))
if cfg.flags.MFC then
_p(2,'<UseOfMfc>%s</UseOfMfc>', iif(cfg.flags.StaticRuntime, "Static", "Dynamic"))
end
if cfg.flags.Managed then
_p(2,'<CLRSupport>true</CLRSupport>')
end
_p(1,'</PropertyGroup>')
end
local function config_type_block(prj)
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
_p(1,'<PropertyGroup '..if_config_and_platform() ..' Label="Configuration">'
, premake.esc(cfginfo.name))
_p(2,'<ConfigurationType>%s</ConfigurationType>',vc2010.config_type(cfg))
_p(2,'<CharacterSet>%s</CharacterSet>',iif(cfg.flags.Unicode,"Unicode","MultiByte"))
if cfg.flags.MFC then
_p(2,'<UseOfMfc>Dynamic</UseOfMfc>')
end
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>'
,iif(optimisation(cfg) == "Disabled","true","false"))
if cfg.flags.Managed then
_p(2,'<CLRSupport>true</CLRSupport>')
end
_p(1,'</PropertyGroup>')
vc2010.configurationPropertyGroup(cfg)
end
end
@ -561,7 +571,10 @@
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />')
config_type_block(prj)
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
vc2010.configurationPropertyGroup(cfg)
end
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />')

View File

@ -21,7 +21,7 @@
function os.findlib(libname)
local path, formats
-- assemble a search path, depending on the platform
if os.is("windows") then
formats = { "%s.dll", "%s" }
@ -36,7 +36,7 @@
else
formats = { "lib%s.so", "%s.so" }
path = os.getenv("LD_LIBRARY_PATH") or ""
io.input("/etc/ld.so.conf")
if io.input() then
for line in io.lines() do
@ -45,24 +45,24 @@
io.input():close()
end
end
table.insert(formats, "%s")
path = path or ""
if os.is64bit() then
path = path .. ":/lib64:/usr/lib64/:usr/local/lib64"
end
path = ":/lib:/usr/lib:/usr/local/lib"
path = path .. ":/lib:/usr/lib:/usr/local/lib"
end
for _, fmt in ipairs(formats) do
local name = string.format(fmt, libname)
local result = os.pathsearch(name, path)
if result then return result end
end
end
--
-- Retrieve the current operating system ID string.
--
@ -70,9 +70,9 @@
function os.get()
return _OPTIONS.os or _OS
end
--
-- Check the current operating system; may be set with the /os command line flag.
--
@ -80,7 +80,7 @@
function os.is(id)
return (os.get():lower() == id:lower())
end
--
@ -95,14 +95,14 @@
"powerpc64",
"sparc64"
}
function os.is64bit()
-- Call the native code implementation. If this returns true then
-- we're 64-bit, otherwise do more checking locally
if (os._is64bit()) then
return true
end
-- Identify the system
local arch
if _OS == "windows" then
@ -116,8 +116,8 @@
-- Check our known 64-bit identifiers
arch = arch:lower()
for _, hosttype in ipairs(_64BitHostTypes) do
if arch:find(hosttype) then
return true
if arch:find(hosttype) then
return true
end
end
return false
@ -128,10 +128,10 @@
--
-- The os.matchdirs() and os.matchfiles() functions
--
local function domatch(result, mask, wantfiles)
-- need to remove extraneous path info from the mask to ensure a match
-- against the paths returned by the OS. Haven't come up with a good
-- against the paths returned by the OS. Haven't come up with a good
-- way to do it yet, so will handle cases as they come up
if mask:startswith("./") then
mask = mask:sub(3)
@ -149,13 +149,13 @@
-- recurse into subdirectories?
local recurse = mask:find("**", nil, true)
-- convert mask to a Lua pattern
mask = path.wildcards(mask)
local function matchwalker(basedir)
local wildcard = path.join(basedir, "*")
-- retrieve files from OS and test against mask
local m = os.matchstart(wildcard)
while (os.matchnext(m)) do
@ -184,7 +184,7 @@
matchwalker(basedir)
end
function os.matchdirs(...)
local result = { }
for _, mask in ipairs(arg) do
@ -192,7 +192,7 @@
end
return result
end
function os.matchfiles(...)
local result = { }
for _, mask in ipairs(arg) do
@ -200,9 +200,9 @@
end
return result
end
--
-- An overload of the os.mkdir() function, which will create any missing
-- subdirectories along the path.
@ -213,17 +213,17 @@
local dir = iif(p:startswith("/"), "/", "")
for part in p:gmatch("[^/]+") do
dir = dir .. part
if (part ~= "" and not path.isabsolute(part) and not os.isdir(dir)) then
local ok, err = builtin_mkdir(dir)
if (not ok) then
return nil, err
end
end
dir = dir .. "/"
end
return true
end
@ -257,8 +257,8 @@
for _, fname in ipairs(files) do
os.remove(fname)
end
-- remove this directory
builtin_rmdir(p)
end

View File

@ -142,9 +142,14 @@ void getversion(struct OsVersionInfo* info)
void getversion(struct OsVersionInfo* info)
{
Gestalt(gestaltSystemVersionMajor, &info->majorversion);
Gestalt(gestaltSystemVersionMinor, &info->minorversion);
Gestalt(gestaltSystemVersionBugFix, &info->revision);
SInt32 majorversion, minorversion, bugfix;
Gestalt(gestaltSystemVersionMajor, &majorversion);
Gestalt(gestaltSystemVersionMinor, &minorversion);
Gestalt(gestaltSystemVersionBugFix, &bugfix);
info->majorversion = majorversion;
info->minorversion = minorversion;
info->revision = bugfix;
info->description = "Mac OS X";
if (info->majorversion == 10)

View File

@ -235,27 +235,6 @@
end
--
-- Test the <Configuration> element
--
function suite.Configuration_OnMFCFlag()
flags { "MFC" }
prepare()
vc200x.Configuration("Debug|Win32", premake.getconfig(prj, "Debug"))
test.capture [[
<Configuration
Name="Debug|Win32"
OutputDirectory="."
IntermediateDirectory="obj\Debug\MyProject"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2"
>
]]
end
--
-- Test multiple platforms
--

View File

@ -0,0 +1,64 @@
--
-- tests/actions/vstudio/vc200x/test_mfc.lua
-- Validate MFC support in Visual Studio 200x C/C++ projects.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.vstudio_vs200x_mfc = { }
local suite = T.vstudio_vs200x_mfc
local vc200x = premake.vstudio.vc200x
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2008"
sln, prj = test.createsolution()
end
local function prepare(platform)
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cfg = premake.getconfig(prj, "Debug", platform)
vc200x.Configuration("Debug|Win32", cfg)
end
--
-- When MFC is enabled, it should match the runtime library linking
-- method (static or dynamic).
--
function suite.useOfMfc_isDynamic_onSharedRuntime()
flags { "MFC" }
prepare()
test.capture [[
<Configuration
Name="Debug|Win32"
OutputDirectory="."
IntermediateDirectory="obj\Debug"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2"
>
]]
end
function suite.useOfMfc_isStatic_onStaticRuntime()
flags { "MFC", "StaticRuntime" }
prepare()
test.capture [[
<Configuration
Name="Debug|Win32"
OutputDirectory="."
IntermediateDirectory="obj\Debug"
ConfigurationType="1"
UseOfMFC="1"
CharacterSet="2"
>
]]
end

View File

@ -0,0 +1,60 @@
--
-- tests/actions/vstudio/vc2010/test_mfc.lua
-- Validate MFC support in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.vstudio_vs2010_mfc = { }
local suite = T.vstudio_vs2010_mfc
local vc2010 = premake.vstudio.vc2010
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2010"
sln, prj = test.createsolution()
end
local function prepare(platform)
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cfg = premake.getconfig(prj, "Debug", platform)
vc2010.configurationPropertyGroup(cfg)
end
--
-- When MFC is enabled, it should match the runtime library linking
-- method (static or dynamic).
--
function suite.useOfMfc_isDynamic_onSharedRuntime()
flags { "MFC" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
]]
end
function suite.useOfMfc_isStatic_onStaticRuntime()
flags { "MFC", "StaticRuntime" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
]]
end

View File

@ -102,8 +102,8 @@
dofile("actions/vstudio/vc200x/header.lua")
dofile("actions/vstudio/vc200x/test_files.lua")
dofile("actions/vstudio/vc200x/test_filters.lua")
dofile("actions/vstudio/vc200x/header.lua")
dofile("actions/vstudio/vc200x/test_linker_block.lua")
dofile("actions/vstudio/vc200x/test_mfc.lua")
-- Visual Studio 2010 C/C++ projects
dofile("actions/vstudio/vc2010/test_compile_settings.lua")
@ -113,6 +113,7 @@
dofile("actions/vstudio/vc2010/test_filters.lua")
dofile("actions/vstudio/vc2010/test_link_settings.lua")
dofile("actions/vstudio/vc2010/test_links.lua")
dofile("actions/vstudio/vc2010/test_mfc.lua")
dofile("actions/vstudio/vc2010/test_pch.lua")
-- Makefile tests

View File

@ -85,7 +85,7 @@ ifeq ($(config),debug)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS
@ -119,7 +119,7 @@ ifeq ($(config),debugps3)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS
@ -150,7 +150,7 @@ ifeq ($(config),debug64)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS