Added per-config tool selection to C# makefiles; cleaned up tool selection for C++ makefiles
This commit is contained in:
parent
a7ec374f0c
commit
e3947d6535
@ -455,15 +455,19 @@
|
||||
--
|
||||
|
||||
function cpp.toolconfig(cfg, toolset)
|
||||
local sysflags = toolset.sysflags[cfg.architecture] or toolset.sysflags[cfg.system] or {}
|
||||
if sysflags.cc then
|
||||
_p(' CC = %s', sysflags.cc)
|
||||
local tool = toolset.gettoolname(cfg, "cc")
|
||||
if tool then
|
||||
_p(' CC = %s', tool)
|
||||
end
|
||||
if sysflags.cxx then
|
||||
_p(' CXX = %s', sysflags.cxx)
|
||||
|
||||
tool = toolset.gettoolname(cfg, "cxx")
|
||||
if tool then
|
||||
_p(' CXX = %s', tool)
|
||||
end
|
||||
if sysflags.ar then
|
||||
_p(' AR = %s', sysflags.ar)
|
||||
|
||||
tool = toolset.gettoolname(cfg, "ar")
|
||||
if tool then
|
||||
_p(' AR = %s', tool)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
premake.make.cs = {}
|
||||
local make = premake.make
|
||||
local cs = premake.make.cs
|
||||
local project = premake5.project
|
||||
|
||||
|
||||
--
|
||||
@ -16,10 +17,47 @@
|
||||
function make.generate_csharp(prj)
|
||||
make.header(prj)
|
||||
|
||||
-- main build rule(s)
|
||||
_p('.PHONY: clean prebuild prelink')
|
||||
_p('')
|
||||
|
||||
for cfg in project.eachconfig(prj) do
|
||||
cs.config(cfg)
|
||||
end
|
||||
|
||||
print("** Warning: GMake C# projects have not been ported yet")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Write out the settings for a particular configuration.
|
||||
--
|
||||
|
||||
function cs.config(cfg)
|
||||
-- I've only got one .NET toolset right now
|
||||
local toolset = premake.dotnet
|
||||
|
||||
_p('ifeq ($(config),%s)', make.esc(cfg.shortname))
|
||||
|
||||
-- write toolset specific configurations
|
||||
cs.toolconfig(cfg, toolset)
|
||||
|
||||
_p('endif')
|
||||
_p('')
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- System specific toolset configuration.
|
||||
--
|
||||
|
||||
function cs.toolconfig(cfg, toolset)
|
||||
_p(' CSC = %s', toolset.gettoolname(cfg, "csc"))
|
||||
_p(' RESGEN = %s', toolset.gettoolname(cfg, "resgen"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Everything below this point is a candidate for deprecation
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
|
||||
premake.dotnet = { }
|
||||
local dotnet = premake.dotnet
|
||||
|
||||
premake.dotnet.namestyle = "windows"
|
||||
|
||||
|
||||
@ -28,7 +30,7 @@
|
||||
-- Return the default build action for a given file, based on the file extension.
|
||||
--
|
||||
|
||||
function premake.dotnet.getbuildaction(fcfg)
|
||||
function dotnet.getbuildaction(fcfg)
|
||||
local ext = path.getextension(fcfg.name):lower()
|
||||
if fcfg.buildaction == "Compile" or ext == ".cs" then
|
||||
return "Compile"
|
||||
@ -42,24 +44,33 @@
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns the compiler filename (they all use the same arguments)
|
||||
-- Retrieves the executable command name for a tool, based on the
|
||||
-- provided configuration and the operating environment.
|
||||
--
|
||||
-- @param cfg
|
||||
-- The configuration to query.
|
||||
-- @param tool
|
||||
-- The tool to fetch, one of "csc" for the C# compiler, or
|
||||
-- "resgen" for the resource compiler.
|
||||
-- @return
|
||||
-- The executable command name for a tool, or nil if the system's
|
||||
-- default value should be used.
|
||||
--
|
||||
|
||||
function premake.dotnet.getcompilervar(cfg)
|
||||
if (_OPTIONS.dotnet == "msnet") then
|
||||
return "csc"
|
||||
elseif (_OPTIONS.dotnet == "mono") then
|
||||
if (cfg.framework <= "1.1") then
|
||||
return "mcs"
|
||||
elseif (cfg.framework >= "4.0") then
|
||||
return "dmcs"
|
||||
else
|
||||
return "gmcs"
|
||||
end
|
||||
function dotnet.gettoolname(cfg, tool)
|
||||
local compilers = {
|
||||
msnet = "csc",
|
||||
mono = "mcs",
|
||||
pnet = "cscc",
|
||||
}
|
||||
|
||||
if tool == "csc" then
|
||||
local toolset = _OPTIONS.dotnet or iif(os.is(premake.WINDOWS), "msnet", "mono")
|
||||
return compilers[toolset]
|
||||
else
|
||||
return "cscc"
|
||||
return "resgen"
|
||||
end
|
||||
end
|
||||
|
||||
@ -69,7 +80,7 @@
|
||||
-- Returns a list of compiler flags, based on the supplied configuration.
|
||||
--
|
||||
|
||||
function premake.dotnet.getflags(cfg)
|
||||
function dotnet.getflags(cfg)
|
||||
local result = table.translate(cfg.flags, flags)
|
||||
return result
|
||||
end
|
||||
@ -80,7 +91,7 @@
|
||||
-- Translates the Premake kind into the CSC kind string.
|
||||
--
|
||||
|
||||
function premake.dotnet.getkind(cfg)
|
||||
function dotnet.getkind(cfg)
|
||||
if (cfg.kind == "ConsoleApp") then
|
||||
return "Exe"
|
||||
elseif (cfg.kind == "WindowedApp") then
|
||||
|
@ -51,6 +51,7 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
function gcc.getsysflags(cfg, field)
|
||||
local result = {}
|
||||
|
||||
@ -245,6 +246,26 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Retrieves the executable command name for a tool, based on the
|
||||
-- provided configuration and the operating environment.
|
||||
--
|
||||
-- @param cfg
|
||||
-- The configuration to query.
|
||||
-- @param tool
|
||||
-- The tool to fetch, one of "cc" for the C compiler, "cxx" for
|
||||
-- the C++ compiler, or "ar" for the static linker.
|
||||
-- @return
|
||||
-- The executable command name for a tool, or nil if the system's
|
||||
-- default value should be used.
|
||||
--
|
||||
|
||||
function gcc.gettoolname(cfg, tool)
|
||||
local sysflags = gcc.sysflags[cfg.architecture] or gcc.sysflags[cfg.system] or {}
|
||||
return sysflags[tool]
|
||||
end
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Everything below this point is a candidate for deprecation
|
||||
|
@ -91,6 +91,7 @@
|
||||
dofile("oven/test_tokens.lua")
|
||||
|
||||
-- Toolset tests
|
||||
dofile("tools/test_dotnet.lua")
|
||||
dofile("tools/test_gcc.lua")
|
||||
dofile("tools/test_msc.lua")
|
||||
dofile("tools/test_snc.lua")
|
||||
|
48
tests/tools/test_dotnet.lua
Normal file
48
tests/tools/test_dotnet.lua
Normal file
@ -0,0 +1,48 @@
|
||||
--
|
||||
-- tests/tools/test_dotnet.lua
|
||||
-- Automated test suite for the .NET toolset interface.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.tools_dotnet = {}
|
||||
local suite = T.tools_dotnet
|
||||
|
||||
local dotnet = premake.dotnet
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = premake.solution.getproject_ng(sln, 1)
|
||||
cfg = premake5.project.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- On Windows, use Microsoft's CSC compiler by default.
|
||||
--
|
||||
|
||||
function suite.defaultCompiler_onWindows()
|
||||
_OS = "windows"
|
||||
prepare()
|
||||
test.isequal("csc", dotnet.gettoolname(cfg, "csc"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Everywhere other than Windows, use Mono by default.
|
||||
--
|
||||
|
||||
function suite.defaultCompiler_onMacOSX()
|
||||
_OS = "macosx"
|
||||
prepare()
|
||||
test.isequal("mcs", dotnet.gettoolname(cfg, "csc"))
|
||||
end
|
@ -28,6 +28,26 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the selection of tools based on the target system.
|
||||
--
|
||||
|
||||
function suite.tools_onDefaults()
|
||||
prepare()
|
||||
test.isnil(gcc.gettoolname(cfg, "cc"))
|
||||
test.isnil(gcc.gettoolname(cfg, "cxx"))
|
||||
test.isnil(gcc.gettoolname(cfg, "ar"))
|
||||
end
|
||||
|
||||
function suite.tools_onPS3()
|
||||
system "PS3"
|
||||
prepare()
|
||||
test.isequal("ppu-lv2-g++", gcc.gettoolname(cfg, "cc"))
|
||||
test.isequal("ppu-lv2-g++", gcc.gettoolname(cfg, "cxx"))
|
||||
test.isequal("ppu-lv2-ar", gcc.gettoolname(cfg, "ar"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- By default, the -MMD -MP are used to generate dependencies.
|
||||
--
|
||||
|
Reference in New Issue
Block a user