diff --git a/src/_manifest.lua b/src/_manifest.lua index c6fb43ef..1abddd9d 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -24,11 +24,6 @@ "base/bake.lua", "base/api.lua", "base/cmdline.lua", - "tools/dotnet.lua", - "tools/gcc.lua", - "tools/msc.lua", - "tools/ow.lua", - "tools/snc.lua", "base/validate.lua", "base/help.lua", "base/premake.lua", @@ -37,9 +32,15 @@ "project/project.lua", "project/config.lua", "project/oven.lua", - "base/solution.lua", + -- tool APIs + "tools/dotnet.lua", + "tools/gcc.lua", + "tools/msc.lua", + "tools/ow.lua", + "tools/snc.lua", + -- CodeBlocks action "actions/codeblocks/_codeblocks.lua", "actions/codeblocks/codeblocks_workspace.lua", diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index be486783..7886d683 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -48,6 +48,22 @@ } +-- +-- Translate the architecture settings for a configuration into a Visual +-- Studio compatible identifier. +-- + + function vstudio.architecture(cfg) + if cfg.system == premake.XBOX360 then + return "Xbox 360" + end + if cfg.architecture == "x32" then + return "Win32" + end + return cfg.architecture or "Win32" + end + + -- -- Returns the full, absolute path to the Visual Studio project file -- corresponding to a particular project object. @@ -114,20 +130,6 @@ end - --- --- Translate the architecture settings for a configuration into a Visual --- Studio compatible identifier. --- - - function vstudio.architecture(cfg) - if cfg.architecture == "x32" then - return "Win32" - end - return cfg.architecture or "Win32" - end - - -- -- Process the solution's list of configurations and platforms, creates a list -- of build configuration/platform pairs in a Visual Studio compatible format. diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index c340f8ff..e6432b88 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -1,7 +1,7 @@ -- -- vs200x_vcproj.lua -- Generate a Visual Studio 2002-2008 C/C++ project. --- Copyright (c) 2009-2011 Jason Perkins and the Premake project +-- Copyright (c) 2009-2012 Jason Perkins and the Premake project -- premake.vstudio.vc200x = { } @@ -31,15 +31,11 @@ _p(1,'') for cfg in project.eachconfig(prj) do vc200x.configuration(cfg) + vc200x.tools(cfg) end --[[ - for _, block in ipairs(getsections(_ACTION, cfginfo.src_platform)) do - - if blockmap[block] then - blockmap[block](cfg) - -- Build event blocks -- elseif block == "VCPreBuildEventTool" then vc200x.buildstepsblock("VCPreBuildEventTool", cfg.prebuildcommands) @@ -75,11 +71,7 @@ _p(3,'/>') -- End Xbox 360 custom sections -- - - else - _p(3,'') + end end @@ -104,6 +96,19 @@ end +-- +-- Return the version-specific text for a boolean value. +-- + + local function bool(value) + if (_ACTION < "vs2005") then + return iif(value, "TRUE", "FALSE") + else + return iif(value, "true", "false") + end + end + + -- -- Writes the opening XML declaration for both the project file -- and the project user file. @@ -204,31 +209,456 @@ end - - ------------------------------------------------------------------------------ --- Everything below this point is a candidate for deprecation ------------------------------------------------------------------------------ - -- --- Return the version-specific text for a boolean value. +-- Write out the tool elements for a specific configuration. -- - local function bool(value) - if (_ACTION < "vs2005") then - return iif(value, "TRUE", "FALSE") - else - return iif(value, "true", "false") + function vc200x.tools(cfg) + for _, tool in ipairs(vc200x.gettools(cfg)) do + if vc200x.toolmap[tool] then + vc200x.toolmap[tool](cfg) + else + vc200x.tool(tool) + end end end -- --- Return the optimization code. +-- Return the list of tools required to build a specific configuration. +-- Each tool gets represented by an XML element in the project file. +-- + + function vc200x.gettools(cfg) + if _ACTION == "vs2002" then + return { + "VCCLCompilerTool", + "VCCustomBuildTool", + "VCLinkerTool", + "VCMIDLTool", + "VCPostBuildEventTool", + "VCPreBuildEventTool", + "VCPreLinkEventTool", + "VCResourceCompilerTool", + "VCWebServiceProxyGeneratorTool", + "VCWebDeploymentTool" + } + end + if _ACTION == "vs2003" then + return { + "VCCLCompilerTool", + "VCCustomBuildTool", + "VCLinkerTool", + "VCMIDLTool", + "VCPostBuildEventTool", + "VCPreBuildEventTool", + "VCPreLinkEventTool", + "VCResourceCompilerTool", + "VCWebServiceProxyGeneratorTool", + "VCXMLDataGeneratorTool", + "VCWebDeploymentTool", + "VCManagedWrapperGeneratorTool", + "VCAuxiliaryManagedWrapperGeneratorTool" + } + end + if cfg.system == premake.XBOX360 then + return { + "VCPreBuildEventTool", + "VCCustomBuildTool", + "VCXMLDataGeneratorTool", + "VCWebServiceProxyGeneratorTool", + "VCMIDLTool", + "VCCLCompilerTool", + "VCManagedResourceCompilerTool", + "VCResourceCompilerTool", + "VCPreLinkEventTool", + "VCLinkerTool", + "VCALinkTool", + "VCX360ImageTool", + "VCBscMakeTool", + "VCX360DeploymentTool", + "VCPostBuildEventTool", + "DebuggerTool", + } + end + return { + "VCPreBuildEventTool", + "VCCustomBuildTool", + "VCXMLDataGeneratorTool", + "VCWebServiceProxyGeneratorTool", + "VCMIDLTool", + "VCCLCompilerTool", + "VCManagedResourceCompilerTool", + "VCResourceCompilerTool", + "VCPreLinkEventTool", + "VCLinkerTool", + "VCALinkTool", + "VCManifestTool", + "VCXDCMakeTool", + "VCBscMakeTool", + "VCFxCopTool", + "VCAppVerifierTool", + "VCWebDeploymentTool", + "VCPostBuildEventTool" + } + end + + +-- +-- Write out an empty tool element. +-- + + function vc200x.tool(name) + _p(3,'') + end + + +-- +-- Write out the VCCLCompilerTool element. +-- + + function vc200x.VCCLCompilerTool_ng(cfg) + _p(3,'') + end + + function vc200x.VCCLCompilerTool_windows(cfg) + if #cfg.buildoptions > 0 then + _x(4,'AdditionalOptions="%s"', table.concat(cfg.buildoptions, " ")) + end + + _p(4,'Optimization="%s"', vc200x.optimization(cfg)) + + if cfg.flags.NoFramePointer then + _p(4,'OmitFramePointers="%s"', bool(true)) + end + + if #cfg.includedirs > 0 then + _x(4,'AdditionalIncludeDirectories="%s"', path.translate(table.concat(cfg.includedirs, ";"))) + end + + if #cfg.defines > 0 then + _x(4,'PreprocessorDefinitions="%s"', table.concat(cfg.defines, ";")) + end + + if premake.config.isdebugbuild(cfg) and + cfg.debugformat ~= "c7" and + not cfg.flags.NoMinimalRebuild and + not cfg.flags.Managed + then + _p(4,'MinimalRebuild="%s"', bool(true)) + end + + if cfg.flags.NoExceptions then + _p(4,'ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0)) + elseif cfg.flags.SEH and _ACTION > "vs2003" then + _p(4,'ExceptionHandling="2"') + end + + if vc200x.optimization(cfg) == 0 and not cfg.flags.Managed then + _p(4,'BasicRuntimeChecks="3"') + end + + if vc200x.optimization(cfg) ~= 0 then + _p(4,'StringPooling="%s"', bool(true)) + end + + local runtime + if premake.config.isdebugbuild(cfg) then + runtime = iif(cfg.flags.StaticRuntime, 1, 3) + else + runtime = iif(cfg.flags.StaticRuntime, 0, 2) + end + _p(4,'RuntimeLibrary="%s"', runtime) + + _p(4,'EnableFunctionLevelLinking="%s"', bool(true)) + + if _ACTION > "vs2003" and cfg.system ~= "Xbox360" and cfg.architecture ~= "x64" then + if cfg.flags.EnableSSE then + _p(4,'EnableEnhancedInstructionSet="1"') + elseif cfg.flags.EnableSSE2 then + _p(4,'EnableEnhancedInstructionSet="2"') + end + end + + if _ACTION < "vs2005" then + if cfg.flags.FloatFast then + _p(4,'ImproveFloatingPointConsistency="%s"', bool(false)) + elseif cfg.flags.FloatStrict then + _p(4,'ImproveFloatingPointConsistency="%s"', bool(true)) + end + else + if cfg.flags.FloatFast then + _p(4,'FloatingPointModel="2"') + elseif cfg.flags.FloatStrict then + _p(4,'FloatingPointModel="1"') + end + end + + if _ACTION < "vs2005" and not cfg.flags.NoRTTI then + _p(4,'RuntimeTypeInfo="%s"', bool(true)) + elseif _ACTION > "vs2003" and cfg.flags.NoRTTI and not cfg.flags.Managed then + _p(4,'RuntimeTypeInfo="%s"', bool(false)) + end + + if cfg.flags.NativeWChar then + _p(4,'TreatWChar_tAsBuiltInType="%s"', bool(true)) + elseif cfg.flags.NoNativeWChar then + _p(4,'TreatWChar_tAsBuiltInType="%s"', bool(false)) + end + + if not cfg.flags.NoPCH and cfg.pchheader then + _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2)) + _x(4,'PrecompiledHeaderThrough="%s"', path.getname(cfg.pchheader)) + else + _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2)) + end + + _p(4,'WarningLevel="%s"', iif(cfg.flags.ExtraWarnings, 4, 3)) + + if cfg.flags.FatalWarnings then + _p(4,'WarnAsError="%s"', bool(true)) + end + + if _ACTION < "vs2008" and not cfg.flags.Managed then + _p(4,'Detect64BitPortabilityProblems="%s"', bool(not cfg.flags.No64BitChecks)) + end + + _x(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', config.gettargetinfo(cfg).basename) + + _p(4,'DebugInformationFormat="%s"', vc200x.symbols(cfg)) + + if cfg.project.language == "C" then + _p(4, 'CompileAs="1"') + end + end + + + function vc200x.VCCLCompilerTool_ps3_ng(cfg) + local buildoptions = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions) + + if not cfg.flags.NoPCH and cfg.pchheader then + _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2)) + _x(4,'PrecompiledHeaderThrough="%s"', path.getname(cfg.pchheader)) + table.insert(buildoptions, '--use_pch="$(IntDir)/$(TargetName).pch"') + else + _p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2)) + end + + _x(4,'AdditionalOptions="%s"', table.concat(buildoptions, " ")) + + if #cfg.includedirs > 0 then + _x(4,'AdditionalIncludeDirectories="%s"', path.translate(table.concat(cfg.includedirs, ";"))) + end + + if #cfg.defines > 0 then + _x(4,'PreprocessorDefinitions="%s"', table.concat(cfg.defines, ";")) + end + + _x(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', config.gettargetinfo(cfg).basename) + + _p(4,'DebugInformationFormat="0"') + _p(4,'CompileAs="0"') + end + + +-- +-- Write out the VCLinkerTool element. +-- + + function vc200x.VCLinkerTool_ng(cfg) + _p(3,'') + end + + + function vc200x.VCLinkerTool_windows(cfg) + if cfg.flags.NoImportLib then + _p(4,'IgnoreImportLibrary="%s"', bool(true)) + end + + if #cfg.linkoptions > 0 then + _x(4,'AdditionalOptions="%s"', table.concat(cfg.linkoptions, " ")) + end + + if #cfg.links > 0 then + _x(4,'AdditionalDependencies="%s"', table.concat(path.translate(config.getlinks(cfg, "all", "fullpath"), " "))) + end + + _x(4,'OutputFile="$(OutDir)\\%s"', config.gettargetinfo(cfg).name) + + _p(4,'LinkIncremental="%s"', iif(premake.config.isincrementallink(cfg) , 2, 1)) + + if #cfg.libdirs > 0 then + _x(4,'AdditionalLibraryDirectories="%s"', table.concat(path.translate(cfg.libdirs) , ";")) + end + + local deffile = config.findfile(cfg, ".def") + if deffile then + _p(4,'ModuleDefinitionFile="%s"', deffile) + end + + if cfg.flags.NoManifest then + _p(4,'GenerateManifest="%s"', bool(false)) + end + + _p(4,'GenerateDebugInformation="%s"', bool(vc200x.symbols(cfg) ~= 0)) + + if vc200x.symbols(cfg) >= 3 then + _x(4,'ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', config.gettargetinfo(cfg).basename) + end + + _p(4,'SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2)) + + if vc200x.optimization(cfg) ~= 0 then + _p(4,'OptimizeReferences="2"') + _p(4,'EnableCOMDATFolding="2"') + end + + if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and not cfg.flags.WinMain then + _p(4,'EntryPointSymbol="mainCRTStartup"') + end + + if cfg.kind == "SharedLib" then + local implibname = config.getlinkinfo(cfg).fullpath + -- I can't actually stop the import lib, but I can hide it in the objects directory + if cfg.flags.NoImportLib then + local objdir = config.getuniqueobjdir(cfg) + implibname = path.join(objdir, path.getname(implibname)) + end + _x(4,'ImportLibrary="%s"', path.translate(implibname)) + end + + _p(4,'TargetMachine="%d"', iif(cfg.architecture == "x64", 17, 1)) + end + + + function vc200x.VCLinkerTool_windows_static(cfg) + if #cfg.links > 0 then + _x(4,'AdditionalDependencies="%s"', table.concat(config.getlinks(cfg, "all", "fullpath"), " ")) + end + + _x(4,'OutputFile="$(OutDir)\\%s"', config.gettargetinfo(cfg).name) + + if #cfg.libdirs > 0 then + _x(4,'AdditionalLibraryDirectories="%s"', path.translate(table.concat(cfg.libdirs, ";"))) + end + + local opts = {} + if cfg.architecture == premake.X32 then + table.insert(opts, "/MACHINE:X86") + elseif cfg.architecture == premake.X64 then + table.insert(opts, "/MACHINE:X64") + end + opts = table.join(opts, cfg.linkoptions) + if #opts > 0 then + _x(4,'AdditionalOptions="%s"', table.concat(opts, " ")) + end + end + + + function vc200x.VCLinkerTool_ps3_ng(cfg) + local buildoptions = table.join(premake.snc.getldflags_ng(cfg), cfg.linkoptions) + if #buildoptions > 0 then + _x(4,'AdditionalOptions="%s"', table.concat(buildoptions, " ")) + end + + if #cfg.links > 0 then + _x(4,'AdditionalDependencies="%s"', table.concat(config.getlinks(cfg, "all", "fullpath"), " ")) + end + + _x(4,'OutputFile="$(OutDir)\\%s"', config.gettargetinfo(cfg).name) + + if cfg.kind ~= premake.STATICLIB then + _p(4,'LinkIncremental="0"') + end + + if #cfg.libdirs > 0 then + _x(4,'AdditionalLibraryDirectories="%s"', table.concat(path.translate(cfg.libdirs) , ";")) + end + + if cfg.kind ~= premake.STATICLIB then + _p(4,'GenerateManifest="%s"', bool(false)) + _p(4,'ProgramDatabaseFile=""') + _p(4,'RandomizedBaseAddress="1"') + _p(4,'DataExecutionPrevention="0"') + end + end + + +-- +-- Write out the element. +-- + + function vc200x.VCManifestTool_ng(cfg) + local manifests = {} + for _, fname in ipairs(cfg.files) do + if path.getextension(fname) == ".manifest" then + table.insert(manifests, project.getrelative(cfg.project, fname)) + end + end + + _p(3,' 0 then + _x(4,'AdditionalManifestFiles="%s"', table.concat(manifests, ";")) + end + _p(3,'/>') + end + + +-- +-- Map tool names to output functions. Tools that aren't listed will +-- output a standard empty tool element. +-- + + vc200x.toolmap = { + VCCLCompilerTool = vc200x.VCCLCompilerTool_ng, + VCLinkerTool = vc200x.VCLinkerTool_ng, + VCManifestTool = vc200x.VCManifestTool, + --[[ + VCMIDLTool = vc200x.VCMIDLTool, + VCResourceCompilerTool = vc200x.VCResourceCompilerTool, + --]] + } + + +-- +-- Translate Premake flags into a Visual Studio optimization value. -- function vc200x.optimization(cfg) local result = 0 + + -- step through the flags in the order they were specified, so + -- later flags can override an earlier value for _, value in ipairs(cfg.flags) do if (value == "Optimize") then result = 3 @@ -238,10 +668,40 @@ result = 2 end end + return result end +-- +-- Return the debugging symbols level for a configuration. +-- + + function vc200x.symbols(cfg) + if not cfg.flags.Symbols then + return 0 + elseif cfg.debugformat == "c7" then + return 1 + else + -- Edit-and-continue doesn't work for some configurations + if cfg.flags.NoEditAndContinue or + vc200x.optimization(cfg) ~= 0 or + cfg.flags.Managed or + cfg.system == "x64" or + cfg.platform == "x64" -- TODO: remove this when the _ng stuff goes live + then + return 3 + else + return 4 + end + end + end + + + +----------------------------------------------------------------------------- +-- Everything below this point is a candidate for deprecation +----------------------------------------------------------------------------- -- -- Write the project file header @@ -395,30 +855,6 @@ end --- --- Return the debugging symbols level for a configuration. --- - - function vc200x.symbols(cfg) - if not cfg.flags.Symbols then - return 0 - elseif cfg.debugformat == "c7" then - return 1 - else - -- Edit-and-continue doesn't work for some configurations - if cfg.flags.NoEditAndContinue or - vc200x.optimization(cfg) ~= 0 or - cfg.flags.Managed or - cfg.platform == "x64" - then - return 3 - else - return 4 - end - end - end - - -- -- Compiler block for Windows and XBox360 platforms. -- @@ -592,7 +1028,7 @@ end if cfg.kind == "SharedLib" then - local implibname = cfg.linktarget.fullpath + local implibname = config.getlinkinfo(cfg).fullpath _p(4,'ImportLibrary="%s"', iif(cfg.flags.NoImportLib, cfg.objectsdir .. "\\" .. path.getname(implibname), implibname)) end @@ -705,6 +1141,27 @@ +-- +-- Write out the element. +-- + + function vc200x.VCManifestTool(cfg) + local manifests = {} + for _, fname in ipairs(cfg.files) do + if path.getextension(fname) == ".manifest" then + table.insert(manifests, fname) + end + end + + _p(3,' 0 then + _x(4,'AdditionalManifestFiles="%s"', table.concat(manifests, ";")) + end + _p(3,'/>') + end + + -- -- Resource compiler block. -- @@ -728,30 +1185,6 @@ _p(3,'/>') end - - - --- --- Manifest block. --- - - function vc200x.VCManifestTool(cfg) - -- locate all manifest files - local manifests = { } - for _, fname in ipairs(cfg.files) do - if path.getextension(fname) == ".manifest" then - table.insert(manifests, fname) - end - end - - _p(3,' 0 then - _p(4,'AdditionalManifestFiles="%s"', premake.esc(table.concat(manifests, ";"))) - end - _p(3,'/>') - end - -- diff --git a/src/base/api.lua b/src/base/api.lua index 556687a2..18a843a7 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -359,6 +359,7 @@ "ps3", "solaris", "windows", + "xbox360" }, }, diff --git a/src/base/premake.lua b/src/base/premake.lua index 07066288..397238ff 100644 --- a/src/base/premake.lua +++ b/src/base/premake.lua @@ -17,6 +17,9 @@ premake.STATICLIB = "StaticLib" premake.WINDOWEDAPP = "WindowedApp" premake.WINDOWS = "windows" + premake.X32 = "x32" + premake.X64 = "x64" + premake.XBOX360 = "xbox360" -- diff --git a/src/base/solution.lua b/src/base/solution.lua index d3271e1d..68ec5ad4 100644 --- a/src/base/solution.lua +++ b/src/base/solution.lua @@ -98,6 +98,28 @@ end +-- +-- Locate a project by name, case insensitive. +-- +-- @param sln +-- The solution to query. +-- @param name +-- The name of the projec to find. +-- @return +-- The project object, or nil if a matching project could not be found. +-- + + function premake.solution.findproject(sln, name) + name = name:lower() + for _, prj in ipairs(sln.projects) do + if name == prj.name:lower() then + return prj + end + end + return nil + end + + -- -- Retrieve a solution by name or index. -- diff --git a/src/project/config.lua b/src/project/config.lua index 0de6cd27..57b0aeae 100755 --- a/src/project/config.lua +++ b/src/project/config.lua @@ -10,21 +10,244 @@ -- --- Figures out the right form for file paths returned from --- this configuration. +-- Helper function for getlinkinfo() and gettargetinfo(); builds the +-- name parts for a configuration, for building or linking. +-- +-- @param cfg +-- The configuration object being queried. +-- @param kind +-- The target kind (SharedLib, StaticLib). +-- @param field +-- One of "target" or "implib", used to locate the naming information +-- in the configuration object (i.e. targetdir, targetname, etc.) +-- @return +-- A target info object; see one of getlinkinfo() or gettargetinfo() +-- for more information. +-- + + local function buildtargetinfo(cfg, kind, field) + local basedir = project.getlocation(cfg.project) + + local directory = cfg[field.."dir"] or cfg.targetdir or basedir + directory = path.getrelative(basedir, directory) + + local basename = cfg[field.."name"] or cfg.targetname or cfg.project.name + + local bundlename = "" + local bundlepath = "" + local extension = "" + local prefix = "" + local suffix = "" + + if kind == premake.STATICLIB then + if cfg.system ~= premake.WINDOWS then + prefix = "lib" + extension = ".a" + else + extension = ".lib" + end + + elseif cfg.system == premake.WINDOWS then + if kind == premake.CONSOLEAPP or kind == premake.WINDOWEDAPP then + extension = ".exe" + elseif kind == premake.SHAREDLIB then + extension = ".dll" + end + + elseif cfg.system == premake.MACOSX then + if kind == premake.WINDOWEDAPP then + bundlename = basename .. ".app" + bundlepath = path.join(directory, bundlename) + bundlepath = path.join(bundlepath, "Contents/MacOS") + elseif kind == premake.SHAREDLIB then + prefix = "lib" + extension = ".dylib" + end + + elseif cfg.system == premake.PS3 then + if kind == premake.CONSOLEAPP or kind == premake.WINDOWEDAPP then + extension = ".elf" + end + + else + if kind == premake.SHAREDLIB then + prefix = "lib" + extension = ".so" + end + end + + prefix = cfg.targetprefix or prefix + suffix = cfg.targetsuffix or suffix + + local info = {} + info.directory = directory + info.basename = basename .. suffix + info.name = prefix .. info.basename .. extension + info.fullpath = path.join(info.directory, info.name) + info.bundlename = bundlename + info.bundlepath = bundlepath + info.prefix = prefix + info.suffix = suffix + return info + end + + +-- +-- Check a configuration for a source code file with the specified +-- extension. Used for locating special files, such as Windows +-- ".def" module definition files. +-- +-- @param cfg +-- The configuration object to query. +-- @param ext +-- The file extension for which to search. +-- @return +-- The full file name if found, nil otherwise. +-- + + function config.findfile(cfg, ext) + for _, fname in ipairs(cfg.files) do + if fname:endswith(ext) then + return project.getrelative(cfg.project, fname) + end + end + end + + +-- +-- Retrieve linking information for a specific configuration. That is, +-- the path information that is required to link against the library +-- built by this configuration. -- -- @param cfg -- The configuration object to query. -- @return --- One of "windows" or "posix". +-- A table with these values: +-- basename - the target with no directory or file extension +-- name - the target name and extension, with no directory +-- directory - relative path to the target, with no file name +-- prefix - the file name prefix +-- suffix - the file name suffix +-- fullpath - directory, name, and extension -- - function config.getpathstyle(cfg) - if premake.action.current().os == premake.WINDOWS then - return premake.WINDOWS - else - return premake.POSIX + function config.getlinkinfo(cfg) + -- have I cached results from a previous call? + if cfg.linkinfo then + return cfg.linkinfo end + + -- if an import library is in use, switch the target kind + local kind = cfg.kind + local field = "target" + if premake.iscppproject(cfg.project) then + if cfg.system == premake.WINDOWS and kind == premake.SHAREDLIB and not cfg.flags.NoImportLib then + kind = premake.STATICLIB + field = "implib" + end + end + + local info = buildtargetinfo(cfg, kind, field) + + -- cache the results for future calls + cfg.linktinfo = info + return info + end + + +-- +-- Retrieve a list of link targets from a configuration. +-- +-- @param cfg +-- The configuration object to query. +-- @param kind +-- The type of links to retrieve; one of: +-- siblings - linkable sibling projects +-- system - system (non-sibling) libraries +-- dependencies - all sibling dependencies, including non-linkable +-- all - return everything +-- @param part +-- How the link target should be expressed; one of: +-- name - the decorated library name with no directory +-- basename - the undecorated library name +-- directory - just the directory, no name +-- fullpath - full path with decorated name +-- object - return the project object of the dependency +-- @return +-- An array containing the requested link target information. +-- + + function config.getlinks(cfg, kind, part) + -- if I'm building a list of link directories, include libdirs + local result = iif (part == "directory" and kind == "all", cfg.libdirs, {}) + + local function canlink(source, target) + -- can't link executables + if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then + return false + end + -- can't link managed and unmanaged projects + if premake.iscppproject(source.project) then + return premake.iscppproject(target.project) + elseif premake.isdotnetproject(source.project) then + return premake.isdotnetproject(target.project) + end + end + + for _, link in ipairs(cfg.links) do + local item + + -- is this a sibling project? + local prj = premake.solution.findproject(cfg.solution, link) + if prj and kind ~= "system" then + + local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform) + if kind == "dependencies" or canlink(cfg, prjcfg) then + if part == "object" then + item = prjcfg + elseif part == "basename" then + item = config.getlinkinfo(prjcfg).basename + else + item = path.rebase(config.getlinkinfo(prjcfg).fullpath, + project.getlocation(prjcfg.project), + project.getlocation(cfg.project)) + if item == "directory" then + item = path.getdirectory(item) + end + end + end + + elseif not prj and (kind == "system" or kind == "all") then + + if part == "directory" then + local dir = path.getdirectory(link) + if dir ~= "." then + item = dir + end + elseif part == "fullpath" then + item = link + if cfg.system == premake.WINDOWS then + if premake.iscppproject(cfg.project) then + item = item .. ".lib" + elseif premake.isdotnetproject(cfg.project) then + item = item .. ".dll" + end + end + if item:find("/", nil, true) then + item = project.getrelative(cfg.project, item) + end + else + item = link + end + + end + + if item and not table.contains(result, item) then + table.insert(result, item) + end + end + + return result end @@ -50,68 +273,7 @@ return cfg.targetinfo end - local basedir = project.getlocation(cfg.project) - - local directory = cfg.targetdir or basedir - directory = path.getrelative(basedir, directory) - - local basename = cfg.targetname or cfg.project.name - - local bundlename = "" - local bundlepath = "" - local extension = "" - local prefix = "" - local suffix = "" - - if cfg.kind == premake.STATICLIB then - if cfg.system ~= premake.WINDOWS then - prefix = "lib" - extension = ".a" - else - extension = ".lib" - end - - elseif cfg.system == premake.WINDOWS then - if cfg.kind == premake.CONSOLEAPP or cfg.kind == premake.WINDOWEDAPP then - extension = ".exe" - elseif cfg.kind == premake.SHAREDLIB then - extension = ".dll" - end - - elseif cfg.system == premake.MACOSX then - if cfg.kind == premake.WINDOWEDAPP then - bundlename = basename .. ".app" - bundlepath = path.join(directory, bundlename) - bundlepath = path.join(bundlepath, "Contents/MacOS") - elseif cfg.kind == premake.SHAREDLIB then - prefix = "lib" - extension = ".dylib" - end - - elseif cfg.system == premake.PS3 then - if cfg.kind == premake.CONSOLEAPP or cfg.kind == premake.WINDOWEDAPP then - extension = ".elf" - end - - else - if cfg.kind == premake.SHAREDLIB then - prefix = "lib" - extension = ".so" - end - end - - prefix = cfg.targetprefix or prefix - suffix = cfg.targetsuffix or suffix - - local info = {} - info.directory = directory - info.basename = basename .. suffix - info.name = prefix .. info.basename .. extension - info.fullpath = path.join(info.directory, info.name) - info.bundlename = bundlename - info.bundlepath = bundlepath - info.prefix = prefix - info.suffix = suffix + local info = buildtargetinfo(cfg, cfg.kind, "target") -- cache the results for future calls cfg.targetinfo = info @@ -138,6 +300,11 @@ -- function config.getuniqueobjdir(cfg) + -- have I cached results from a previous call? + if cfg.uniqueobjdir then + return cfg.uniqueobjdir + end + -- compute the four options for a specific configuration local function getobjdirs(cfg) local dirs = { } @@ -166,9 +333,10 @@ -- first one that isn't in conflict local dirs = getobjdirs(cfg) for _, dir in ipairs(dirs) do - if counts[dir] == 1 then - local prjlocation = project.getlocation(cfg.project) - return path.getrelative(prjlocation, dir) + if counts[dir] == 1 then + -- cache the result before returning + cfg.uniqueobjdir = project.getrelative(cfg.project, dir) + return cfg.uniqueobjdir end end end diff --git a/src/project/oven.lua b/src/project/oven.lua index 0355c681..16e4af4e 100755 --- a/src/project/oven.lua +++ b/src/project/oven.lua @@ -145,7 +145,9 @@ function oven.merge(cfg, block, filterField) if filterField then - oven.mergefield(cfg, filterField, block[filterField]) + if block[filterField] then + oven.mergefield(cfg, filterField, block[filterField]) + end else for key, value in pairs(block) do if not nomerge[key] then diff --git a/src/project/project.lua b/src/project/project.lua index d94b85f2..1f552460 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -89,8 +89,9 @@ cfg.platform = platform -- For backward compatibility with the old platforms API, use platform - -- as the default architecture, if it would be a valid value. + -- as the default system or architecture if it would be a valid value. if cfg.platform then + cfg.system = premake.checkvalue(cfg.platform, premake.fields.system.allowed) cfg.architecture = premake.checkvalue(cfg.platform, premake.fields.architecture.allowed) end @@ -148,3 +149,19 @@ end return location end + + +-- +-- Return the relative path from the project to the specified file. +-- +-- @param prj +-- The project object to query. +-- @param filename +-- The full path to the file. +-- @return +-- The relative path from the project to the file. +-- + + function project.getrelative(prj, filename) + return path.getrelative(project.getlocation(prj), filename) + end diff --git a/src/tools/snc.lua b/src/tools/snc.lua index c4c7d422..cace409c 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -1,12 +1,13 @@ -- -- snc.lua -- Provides Sony SNC-specific configuration strings. --- Copyright (c) 2010 Jason Perkins and the Premake project +-- Copyright (c) 2010-2012 Jason Perkins and the Premake project -- premake.snc = { } - + local config = premake5.config + -- TODO: Will cfg.system == "windows" ever be true for SNC? If -- not, remove the conditional blocks that use this test. @@ -66,7 +67,7 @@ function premake.snc.getcflags(cfg) local result = table.translate(cfg.flags, cflags) - table.insert(result, platforms[cfg.platform].flags) + table.insert(result, platforms["PS3"].flags) if cfg.kind == "SharedLib" then table.insert(result, "-fPIC") end @@ -85,6 +86,27 @@ -- Returns a list of linker flags, based on the supplied configuration. -- + function premake.snc.getldflags_ng(cfg) + local result = { } + + if not cfg.flags.Symbols then + table.insert(result, "-s") + end + + if cfg.kind == "SharedLib" then + table.insert(result, "-shared") + if not cfg.flags.NoImportLib then + table.insert(result, '-Wl,--out-implib="' .. config.getlinkinfo(cfg).fullpath .. '"') + end + end + + local platform = platforms["PS3"] + table.insert(result, platform.flags) + table.insert(result, platform.ldflags) + + return result + end + function premake.snc.getldflags(cfg) local result = { } @@ -99,7 +121,7 @@ end end - local platform = platforms[cfg.platform] + local platform = platforms["PS3"] table.insert(result, platform.flags) table.insert(result, platform.ldflags) diff --git a/tests/actions/vstudio/test_vs200x_vcproj.lua b/tests/actions/vstudio/test_vs200x_vcproj.lua deleted file mode 100644 index b30824dd..00000000 --- a/tests/actions/vstudio/test_vs200x_vcproj.lua +++ /dev/null @@ -1,597 +0,0 @@ --- --- tests/test_vs200x_vcproj.lua --- Automated test suite for Visual Studio 2002-2008 C/C++ project generation. --- Copyright (c) 2009 Jason Perkins and the Premake project --- - - T.vs200x_vcproj = { } - local suite = T.vs200x_vcproj - local vc200x = premake.vstudio.vc200x - - --- --- Configure a solution for testing --- - - local sln, prj - function suite.setup() - _ACTION = "vs2005" - - sln = solution "MySolution" - configurations { "Debug", "Release" } - platforms {} - - project "DotNetProject" -- to test handling of .NET platform in solution - language "C#" - kind "ConsoleApp" - - prj = project "MyProject" - language "C++" - kind "ConsoleApp" - uuid "AE61726D-187C-E440-BD07-2556188A6565" - end - - local function prepare() - premake.bake.buildconfigs() - sln.vstudio_configs = premake.vstudio.buildconfigs(sln) - - local cfg = premake.getconfig(sln.projects[2]) - cfg.name = prj.name - cfg.blocks = prj.blocks - prj = cfg - end - - --- --- Make sure I've got the basic layout correct --- - - function suite.BasicLayout() - prepare() - vc200x.generate(prj) - test.capture [[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]] - end - - --- --- Test Xbox360 handling --- - - function suite.PlatformsList_OnXbox360() - platforms { "Native", "Xbox360" } - prepare() - vc200x.Platforms(prj) - test.capture [[ - - - - - ]] - end - - function suite.CompilerBlock_OnXbox360() - platforms { "Xbox360" } - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug", "Xbox360")) - test.capture [[ - - ]] - end - - --- --- Test PS3 handling --- - - function suite.PlatformsList_OnPS3() - platforms { "Native", "PS3" } - prepare() - vc200x.Platforms(prj) - test.capture [[ - - - - ]] - end - - function suite.CompilerBlock_OnPS3() - platforms { "PS3" } - flags { "Symbols" } - includedirs { "include/pkg1", "include/pkg2" } - defines { "DEFINE1", "DEFINE2" } - prepare() - vc200x.VCCLCompilerTool_PS3(premake.getconfig(prj, "Debug", "PS3")) - test.capture [[ - - ]] - end - - function suite.LinkerBlock_OnPS3ConsoleApp() - platforms { "PS3" } - prepare() - vc200x.VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3")) - test.capture [[ - - ]] - end - - function suite.LinkerBlock_OnPS3StaticLib() - platforms { "PS3" } - kind "StaticLib" - prepare() - vc200x.VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3")) - test.capture [[ - - ]] - end - - function suite.LinkerBlock_OnPS3SharedLink() - platforms { "PS3" } - links { "MyLibrary" } - project "MyLibrary" - language "C++" - kind "SharedLib" - prepare() - vc200x.VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3")) - - test.capture [[ - - ]] - end - - --- --- Test manifest file handling. --- - - function suite.VCManifestTool_OnNoManifests() - files { "hello.c", "goodbye.c" } - prepare() - vc200x.VCManifestTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - - function suite.VCManifestTool_OnNoManifests() - files { "hello.c", "project1.manifest", "goodbye.c", "project2.manifest" } - prepare() - vc200x.VCManifestTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- Test precompiled header handling --- - - function suite.CompilerBlock_OnPCH() - pchheader "source/common.h" - pchsource "source/common.cpp" - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- Floating point flag tests --- - - function suite.CompilerBlock_OnFpFast() - flags { "FloatFast" } - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - function suite.CompilerBlock_OnFpStrict() - flags { "FloatStrict" } - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- PDB file naming tests --- - - function suite.CompilerBlock_OnTargetName() - targetname "foob" - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- Compilation option tests --- - - function suite.CompilerBlock_OnNoMinimalRebuild() - flags { "Symbols", "NoMinimalRebuild" } - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- C language support --- - - function suite.CompilerBlock_RuntimeLibrary_IsDebug_OnSymbolsNoOptimize() - language "C" - flags { "Symbols" } - prepare() - vc200x.VCCLCompilerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - - function suite.noLinkIncrementalFlag_valueEqualsOne() - flags { "NoIncrementalLink" } - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - local result = io.endcapture() - test.string_contains(result,'LinkIncremental="1"') - end - - function suite.staticLib_platformX64_MachineX64SetInAdditionalOptions() - local sln1 = solution "sol" - configurations { "foo" } - platforms {'x64'} - - local prj1 = project "prj" - language 'C++' - kind 'StaticLib' - - premake.bake.buildconfigs() - sln1.vstudio_configs = premake.vstudio.buildconfigs(sln1) - prj1= premake.getconfig(sln1.projects[1]) - vc200x.generate(prj1) - local result = io.endcapture() - test.string_contains(result,'AdditionalOptions="/MACHINE:X64"') - end - - function suite.staticLib_platformX32_MachineX86SetInAdditionalOptions() - local sln1 = solution "sol" - configurations { "foo" } - platforms {'x32'} - - local prj1 = project "prj" - language 'C++' - kind 'StaticLib' - - premake.bake.buildconfigs() - sln1.vstudio_configs = premake.vstudio.buildconfigs(sln1) - prj1= premake.getconfig(sln1.projects[1]) - vc200x.generate(prj1) - local result = io.endcapture() - test.string_contains(result,'AdditionalOptions="/MACHINE:X86"') - end diff --git a/tests/actions/vstudio/test_vs200x_vcproj_linker.lua b/tests/actions/vstudio/test_vs200x_vcproj_linker.lua deleted file mode 100755 index e8327f78..00000000 --- a/tests/actions/vstudio/test_vs200x_vcproj_linker.lua +++ /dev/null @@ -1,116 +0,0 @@ --- --- tests/actions/vstudio/test_vs200x_vcproj_linker.lua --- Automated tests for Visual Studio 2002-2008 C/C++ linker block. --- Copyright (c) 2009-2011 Jason Perkins and the Premake project --- - - T.vs200x_vcproj_linker = { } - local suite = T.vs200x_vcproj_linker - local vc200x = premake.vstudio.vc200x - - --- --- Setup/Teardown --- - - local sln, prj - function suite.setup() - _ACTION = "vs2005" - sln, prj = test.createsolution() - end - - local function prepare() - premake.bake.buildconfigs() - end - - --- --- Test default linker blocks for each target kind --- (ConsoleApp, StaticLib, etc.) --- - - function suite.DefaultLinkerBlock_OnConsoleApp() - kind "ConsoleApp" - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - function suite.DefaultLinkerBlock_OnWindowedApp() - kind "WindowedApp" - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - function suite.DefaultLinkerBlock_OnSharedLib() - kind "SharedLib" - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - function suite.DefaultLinkerBlock_OnStaticLib() - kind "StaticLib" - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - - --- --- linkoptions tests --- - - function suite.AdditionalOptions_OnStaticLib() - kind "StaticLib" - linkoptions { "/ltcg", "/lZ" } - prepare() - vc200x.VCLinkerTool(premake.getconfig(prj, "Debug")) - test.capture [[ - - ]] - end - diff --git a/tests/actions/vstudio/vc200x/test_compiler_block.lua b/tests/actions/vstudio/vc200x/test_compiler_block.lua index d253ef5c..2cbc0b56 100644 --- a/tests/actions/vstudio/vc200x/test_compiler_block.lua +++ b/tests/actions/vstudio/vc200x/test_compiler_block.lua @@ -1,7 +1,7 @@ -- -- tests/actions/vstudio/vc200x/test_compiler_block.lua -- Validate generation of filter blocks in Visual Studio 200x C/C++ projects. --- Copyright (c) 2011 Jason Perkins and the Premake project +-- Copyright (c) 2011-2012 Jason Perkins and the Premake project -- T.vs200x_compiler_block = { } @@ -21,10 +21,8 @@ end local function prepare() - premake.bake.buildconfigs() - sln.vstudio_configs = premake.vstudio.buildconfigs(sln) - local cfg = premake.getconfig(prj, "Debug") - vc200x.VCCLCompilerTool(cfg) + local cfg = premake5.project.getconfig(prj, "Debug") + vc200x.VCCLCompilerTool_ng(cfg) end @@ -32,7 +30,7 @@ -- Verify the basic structure of the compiler block with no flags or settings. -- - function suite.defaultSettings() + function suite.looksGood_onDefaultSettings() prepare() test.capture [[ ]] end + + +-- +-- Verify the handling of precompiled headers. +-- + + function suite.compilerBlock_OnPCH() + pchheader "source/common.h" + pchsource "source/common.cpp" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Floating point flag tests +-- + + function suite.compilerBlock_OnFpFast() + flags { "FloatFast" } + prepare() + test.capture [[ + + ]] + end + + function suite.compilerBlock_OnFpStrict() + flags { "FloatStrict" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify that the PDB file uses the target name if specified. +-- + + function suite.pdfUsesTargetName_onTargetName() + targetname "foob" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Check that the "minimal rebuild" flag is applied correctly. +-- + + function suite.minimalRebuildFlagsSet_onMinimalRebuildAndSymbols() + flags { "Symbols", "NoMinimalRebuild" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Check that the CompileAs value is set correctly for C language projects. +-- + + function suite.compileAsSet_onC() + language "C" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct runtime library is used when symbols are enabled. +-- + + function suite.runtimeLibraryIsDebug_onSymbolsNoOptimize() + flags { "Symbols" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure when targeting the Xbox360. +-- + + function suite.looksGood_onXbox360() + system "Xbox360" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure when targeting the PS3. +-- + + function suite.looksGood_onPS3() + system "PS3" + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/vc200x/test_linker_block.lua b/tests/actions/vstudio/vc200x/test_linker_block.lua index a0aee84b..74bc39ec 100644 --- a/tests/actions/vstudio/vc200x/test_linker_block.lua +++ b/tests/actions/vstudio/vc200x/test_linker_block.lua @@ -1,95 +1,274 @@ --- --- tests/actions/vstudio/vc200x/test_linker_block.lua --- Validate generation of filter blocks in Visual Studio 200x C/C++ projects. --- Copyright (c) 2011 Jason Perkins and the Premake project --- - - T.vs200x_linker_block = { } - local suite = T.vs200x_linker_block - local vc200x = premake.vstudio.vc200x - - --- --- Setup/teardown --- - - local sln, prj - - function suite.setup() - _ACTION = "vs2008" - sln, prj = test.createsolution() - end - - local function prepare() - premake.bake.buildconfigs() - sln.vstudio_configs = premake.vstudio.buildconfigs(sln) - local cfg = premake.getconfig(prj, "Debug") - vc200x.VCLinkerTool(cfg) - end - - --- --- Verify the basic structure of the linker block with no flags or settings. --- - - function suite.defaultSettings() - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the handling of the Symbols flag. --- - - function suite.onSymbolsFlag() - flags "Symbols" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the handling of the C7 debug information format. --- - - function suite.onC7DebugFormat() - flags "Symbols" - debugformat "C7" - prepare() - test.capture [[ - - ]] - end +-- +-- tests/actions/vstudio/vc200x/test_linker_block.lua +-- Validate generation of VCLinkerTool blocks in Visual Studio 200x C/C++ projects. +-- Copyright (c) 2009-2012 Jason Perkins and the Premake project +-- + + T.vs200x_linker_block = { } + local suite = T.vs200x_linker_block + local vc200x = premake.vstudio.vc200x + + +-- +-- Setup/teardown +-- + + local sln, prj + + function suite.setup() + _ACTION = "vs2008" + sln, prj = test.createsolution() + end + + local function prepare() + local cfg = premake5.project.getconfig(prj, "Debug") + vc200x.VCLinkerTool_ng(cfg) + end + + +-- +-- Verify the basic structure of the console app linker block. +-- + + function suite.onConsoleApp() + kind "ConsoleApp" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure of windowed app linker block. +-- + + function suite.onWindowedApp() + kind "WindowedApp" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure of static library linker block. +-- + + function suite.onSharedLib() + kind "SharedLib" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure of static library linker block. +-- + + function suite.onStaticLib() + kind "StaticLib" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the handling of the Symbols flag. +-- + + function suite.onSymbolsFlag() + flags "Symbols" + prepare() + test.capture [[ + + ]] + end + + +-- +-- If a module definition file is present, make sure it is specified. +-- + + function suite.onModuleDefinitionFile() + files { "MyProject.def" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify machine option settings for 32-bit builds. +-- + + function suite.machineOptionSet_on32BitStaticLib() + kind "StaticLib" + architecture "x32" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify machine option settings for 64-bit builds. +-- + + function suite.machineOptionSet_on64BitStaticLib() + kind "StaticLib" + architecture "x64" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the structure of a PS3 console application. +-- + + function suite.looksGood_onPS3ConsoleApp() + system "PS3" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the structure of a PS3 static library. +-- + + function suite.looksGood_onPS3StaticLib() + system "PS3" + kind "StaticLib" + prepare() + test.capture [[ + + ]] + end + + diff --git a/tests/actions/vstudio/vc200x/test_manifest_block.lua b/tests/actions/vstudio/vc200x/test_manifest_block.lua new file mode 100755 index 00000000..e0d7b256 --- /dev/null +++ b/tests/actions/vstudio/vc200x/test_manifest_block.lua @@ -0,0 +1,57 @@ +-- +-- tests/actions/vstudio/vc200x/test_manifest_block.lua +-- Validate generation of VCManifest elements Visual Studio 200x C/C++ projects. +-- Copyright (c) 2090-2012 Jason Perkins and the Premake project +-- + + T.vs200x_manifest_block = { } + local suite = T.vs200x_manifest_block + local vc200x = premake.vstudio.vc200x + + +-- +-- Setup/teardown +-- + + local sln, prj + + function suite.setup() + _ACTION = "vs2008" + sln, prj = test.createsolution() + end + + local function prepare() + local cfg = premake5.project.getconfig(prj, "Debug") + vc200x.VCManifestTool_ng(cfg) + end + + +-- +-- The manifest tool should empty if there are no manifest files. +-- + + function suite.isEmpty_onNoManifests() + files { "hello.c" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- If manifest file(s) are present, they should be listed. +-- + + function suite.listsFiles_onManifests() + files { "hello.c", "project1.manifest", "goodbye.c", "project2.manifest" } + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/vc200x/test_platforms.lua b/tests/actions/vstudio/vc200x/test_platforms.lua index 031f1265..fe9bd966 100755 --- a/tests/actions/vstudio/vc200x/test_platforms.lua +++ b/tests/actions/vstudio/vc200x/test_platforms.lua @@ -32,11 +32,11 @@ function suite.win32Listed_onNoPlatforms() prepare() test.capture [[ - - - + + + ]] end @@ -50,11 +50,11 @@ platforms { "Static", "Dynamic" } prepare() test.capture [[ - - - + + + ]] end @@ -67,13 +67,47 @@ platforms { "x32", "x64" } prepare() test.capture [[ + + + + + ]] + end + + +-- +-- Verify the PS3 platform. +-- + + function suite.platformIsCorrect_onPS3() + platforms { "PS3" } + prepare() + test.capture [[ - - ]] + ]] + end + + +-- +-- Verify the Xbox360 platform. +-- + + function suite.platformIsCorrect_onXbox360() + platforms { "Xbox360" } + prepare() + test.capture [[ + + + + ]] end diff --git a/tests/actions/vstudio/vc200x/test_project.lua b/tests/actions/vstudio/vc200x/test_project.lua index f52df15a..e4563c76 100644 --- a/tests/actions/vstudio/vc200x/test_project.lua +++ b/tests/actions/vstudio/vc200x/test_project.lua @@ -114,7 +114,7 @@ -- Use the correct keyword for Managed C++ projects. -- - function suite.structureIsCorrect_onDefaultValues() + function suite.keywordIsCorrect_onManagedC() flags { "Managed" } prepare() test.capture [[ diff --git a/tests/premake4.lua b/tests/premake4.lua index d3889d04..29c47f41 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -75,8 +75,6 @@ -- Visual Studio tests dofile("test_vs2002_sln.lua") dofile("test_vs2003_sln.lua") - dofile("actions/vstudio/test_vs200x_vcproj.lua") - dofile("actions/vstudio/test_vs200x_vcproj_linker.lua") dofile("actions/vstudio/test_vs2010_vcxproj.lua") dofile("actions/vstudio/test_vs2010_flags.lua") dofile("actions/vstudio/test_vs2010_project_kinds.lua") @@ -106,6 +104,7 @@ dofile("actions/vstudio/vc200x/test_files.lua") dofile("actions/vstudio/vc200x/test_filters.lua") dofile("actions/vstudio/vc200x/test_linker_block.lua") + dofile("actions/vstudio/vc200x/test_manifest_block.lua") dofile("actions/vstudio/vc200x/test_mfc.lua") dofile("actions/vstudio/vc200x/test_platforms.lua") dofile("actions/vstudio/vc200x/test_project.lua") diff --git a/tests/project/test_baking.lua b/tests/project/test_baking.lua index fedbaa95..316e9d18 100755 --- a/tests/project/test_baking.lua +++ b/tests/project/test_baking.lua @@ -232,3 +232,12 @@ cfg = oven.merge(oven.merge({}, sln), prj) test.isequal({"*.prj","*.prjx"}, cfg.vpaths["Project"]) end + + + + function suite.testInProgress() + kind("ConsoleApp") + prj = project("MyProject") + local cfg = premake5.oven.bake(prj, { "Debug", nil }, "kind") + test.isequal("ConsoleApp", cfg.kind) + end diff --git a/tests/project/test_eachconfig.lua b/tests/project/test_eachconfig.lua index d614a753..4ff13110 100755 --- a/tests/project/test_eachconfig.lua +++ b/tests/project/test_eachconfig.lua @@ -23,10 +23,10 @@ prj = project("MyProject") end - local function collect(fn) + local function collect(fn, field) prepare() local result = { } - for cfg in premake.project.eachconfig(prj) do + for cfg in premake.project.eachconfig(prj, field) do table.insert(result, fn(cfg)) end return result @@ -106,3 +106,16 @@ local r = collect(function(cfg) return (cfg.architecture or "nil") end) test.isequal("x32|x64|nil", table.concat(r, "|")) end + + +-- +-- If a filter field is used, that field's value should be returned. +-- + + function suite.returnsFieldValue_onFilterField() + configurations { "Debug" } + kind "ConsoleApp" + local r = collect(function(cfg) return cfg.kind end, "kind") + test.isequal("ConsoleApp", table.concat(r)) + end +