Merge new clr() function, replacement for Managed and Unsafe flags

This commit is contained in:
Jason Perkins 2014-11-12 16:06:51 -05:00
commit c4ab787b51
20 changed files with 203 additions and 49 deletions

View File

@ -130,18 +130,35 @@
tokens = true,
}
api.register {
name = "cleanExtensions",
scope = "config",
kind = "list:string",
}
api.register {
name = "clr",
scope = "config",
kind = "string",
allowed = {
"Off",
"On",
"Pure",
"Safe",
"Unsafe",
}
}
api.register {
name = "configmap",
scope = "config",
kind = "list:keyed:array:string",
}
api.register {
name = "configFile",
scope = "config",
@ -285,7 +302,7 @@
"FloatFast", -- DEPRECATED
"FloatStrict", -- DEPRECATED
"LinkTimeOptimization",
"Managed",
"Managed", -- DEPRECATED
"Maps",
"MFC",
"MultiProcessorCompile",
@ -317,7 +334,7 @@
"Symbols",
"UndefinedIdentifiers",
"Unicode",
"Unsafe",
"Unsafe", -- DEPRECATED
"WinMain",
"WPF",
},
@ -793,6 +810,7 @@
buildoutputs(value.outputs)
end)
-- 17 Jun 2013
api.deprecateValue("flags", "Component", nil,
@ -800,6 +818,7 @@
buildaction "Component"
end)
-- 26 Sep 2013
api.deprecateValue("flags", { "EnableSSE", "EnableSSE2" }, nil,
@ -810,6 +829,7 @@
vectorextension "Default"
end)
api.deprecateValue("flags", { "FloatFast", "FloatStrict" }, nil,
function(value)
floatingpoint(value:sub(6))
@ -818,6 +838,7 @@
floatingpoint "Default"
end)
api.deprecateValue("flags", { "NativeWChar", "NoNativeWChar" }, nil,
function(value)
local map = { NativeWChar = "On", NoNativeWChar = "Off" }
@ -827,6 +848,7 @@
nativewchar "Default"
end)
api.deprecateValue("flags", { "Optimize", "OptimizeSize", "OptimizeSpeed" }, nil,
function(value)
local map = { Optimize = "On", OptimizeSize = "Size", OptimizeSpeed = "Speed" }
@ -836,6 +858,7 @@
optimize "Off"
end)
api.deprecateValue("flags", { "Optimise", "OptimiseSize", "OptimiseSpeed" }, nil,
function(value)
local map = { Optimise = "On", OptimiseSize = "Size", OptimiseSpeed = "Speed" }
@ -845,6 +868,7 @@
optimize "Off"
end)
api.deprecateValue("flags", { "ExtraWarnings", "NoWarnings" }, nil,
function(value)
local map = { ExtraWarnings = "Extra", NoWarnings = "Off" }
@ -854,8 +878,18 @@
warnings "Default"
end)
-- 10 Nov 2014
api.deprecateValue("flags", "Managed", nil,
function(value)
clr "On"
end,
function(value)
clr "Off"
end)
api.deprecateValue("flags", "NoEditAndContinue", nil,
function(value)
editAndContinue "Off"
@ -865,6 +899,15 @@
end)
api.deprecateValue("flags", "Unsafe", nil,
function(value)
clr "Unsafe"
end,
function(value)
clr "On"
end)
-----------------------------------------------------------------------------
--
@ -965,6 +1008,7 @@
--
-----------------------------------------------------------------------------
clr "Off"
editAndContinue "On"
-- Setting a default language makes some validation easier later

View File

@ -222,7 +222,7 @@
_p(2,'<ErrorReport>prompt</ErrorReport>')
_p(2,'<WarningLevel>4</WarningLevel>')
if cfg.flags.Unsafe then
if cfg.clr == "Unsafe" then
_p(2,'<AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end

View File

@ -751,7 +751,7 @@
-- Edit-and-continue doesn't work for some configurations
if not cfg.editAndContinue or
config.isOptimizedBuild(cfg) or
cfg.flags.Managed or
cfg.clr ~= p.OFF or
cfg.system == "x64"
then
return 3
@ -922,7 +922,7 @@
local cfg, filecfg = config.normalize(cfg)
if not filecfg
and not config.isOptimizedBuild(cfg)
and not cfg.flags.Managed
and cfg.clr == p.OFF
and not cfg.flags.NoRuntimeChecks
then
p.w('BasicRuntimeChecks="3"')
@ -1062,7 +1062,7 @@
function m.detect64BitPortabilityProblems(cfg)
local prjcfg, filecfg = config.normalize(cfg)
if _ACTION < "vs2008" and not cfg.flags.Managed and cfg.warnings ~= "Off" and not filecfg then
if _ACTION < "vs2008" and cfg.clr == p.OFF and cfg.warnings ~= p.OFF and not filecfg then
p.w('Detect64BitPortabilityProblems="%s"', tostring(not cfg.flags.No64BitChecks))
end
end
@ -1164,7 +1164,7 @@
local windows, managed, makefile
for cfg in project.eachconfig(prj) do
if cfg.system == p.WINDOWS then windows = true end
if cfg.flags.Managed then managed = true end
if cfg.clr ~= p.OFF then managed = true end
if vstudio.isMakefile(cfg) then makefile = true end
end
@ -1261,7 +1261,7 @@
function m.managedExtensions(cfg)
if cfg.flags.Managed then
if cfg.clr ~= p.OFF then
p.w('ManagedExtensions="1"')
end
end
@ -1272,7 +1272,7 @@
if config.isDebugBuild(cfg) and
cfg.debugformat ~= "c7" and
not cfg.flags.NoMinimalRebuild and
not cfg.flags.Managed and
cfg.clr == p.OFF and
not cfg.flags.MultiProcessorCompile
then
p.w('MinimalRebuild="true"')
@ -1500,7 +1500,7 @@
function m.runtimeTypeInfo(cfg)
if cfg.flags.NoRTTI and not cfg.flags.Managed then
if cfg.flags.NoRTTI and cfg.clr == p.OFF then
p.w('RuntimeTypeInfo="false"')
end
end
@ -1607,7 +1607,7 @@
function m.warnAsError(cfg)
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= "Off" then
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then
p.w('WarnAsError="true"')
end
end
@ -1618,7 +1618,7 @@
local prjcfg, filecfg = config.normalize(cfg)
local level
if cfg.warnings == "Off" then
if cfg.warnings == p.OFF then
level = "0"
elseif cfg.warnings == "Extra" then
level = "4"

View File

@ -817,7 +817,7 @@
--
m.elements.projectReferences = function(prj, ref)
if prj.flags.Managed then
if prj.clr ~= p.OFF then
return {
m.referenceProject,
m.referencePrivate,
@ -951,8 +951,14 @@
function m.clrSupport(cfg)
if cfg.flags.Managed then
_p(2,'<CLRSupport>true</CLRSupport>')
local value
if cfg.clr == "On" or cfg.clr == "Unsafe" then
value = "true"
elseif cfg.clr ~= p.OFF then
value = cfg.clr
end
if value then
p.w('<CLRSupport>%s</CLRSupport>', value)
end
end
@ -992,7 +998,7 @@
if cfg.debugformat == "c7" then
value = "OldStyle"
elseif cfg.architecture == "x64" or
cfg.flags.Managed or
cfg.clr ~= p.OFF or
config.isOptimizedBuild(cfg) or
not cfg.editAndContinue
then
@ -1039,7 +1045,7 @@
function m.entryPointSymbol(cfg)
if (cfg.kind == premake.CONSOLEAPP or cfg.kind == premake.WINDOWEDAPP) and
not cfg.flags.WinMain and
not cfg.flags.Managed and
cfg.clr == p.OFF and
cfg.system ~= premake.XBOX360
then
_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')
@ -1210,7 +1216,7 @@
if cfg.system == premake.WINDOWS then
isWin = true
end
if cfg.flags.Managed then
if cfg.clr ~= p.OFF then
isManaged = true
end
if vstudio.isMakefile(cfg) then
@ -1484,7 +1490,7 @@
function m.runtimeTypeInfo(cfg)
if cfg.flags.NoRTTI and not cfg.flags.Managed then
if cfg.flags.NoRTTI and cfg.clr == p.OFF then
_p(3,'<RuntimeTypeInfo>false</RuntimeTypeInfo>')
end
end
@ -1544,7 +1550,7 @@
function m.treatWarningAsError(cfg)
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= "Off" then
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then
p.w('<TreatWarningAsError>true</TreatWarningAsError>')
end
end

View File

@ -4,9 +4,12 @@
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
--
premake.config = {}
local project = premake.project
local config = premake.config
local p = premake
p.config = {}
local project = p.project
local config = p.config
---
@ -91,8 +94,8 @@
-- Can't link managed and unmanaged projects
local cfgManaged = project.isdotnet(cfg.project) or (cfg.flags.Managed ~= nil)
local tgtManaged = project.isdotnet(target.project) or (target.flags.Managed ~= nil)
local cfgManaged = project.isdotnet(cfg.project) or (cfg.clr ~= p.OFF)
local tgtManaged = project.isdotnet(target.project) or (target.clr ~= p.OFF)
return (cfgManaged == tgtManaged)
end
@ -111,7 +114,7 @@
-- Unmanaged projects can never link managed assemblies
if isManaged and not cfg.flags.Managed then
if isManaged and cfg.clr == p.OFF then
return false
end
@ -438,7 +441,7 @@
--
function config.isOptimizedBuild(cfg)
return cfg.optimize ~= nil and cfg.optimize ~= "Off" and cfg.optimize ~= "Debug"
return cfg.optimize ~= nil and cfg.optimize ~= p.OFF and cfg.optimize ~= "Debug"
end

View File

@ -200,10 +200,12 @@
--
dotnet.flags = {
clr = {
Unsafe = "/unsafe",
},
flags = {
FatalWarning = "/warnaserror",
Symbols = "/debug",
Unsafe = "/unsafe"
},
optimize = {
On = "/optimize",

View File

@ -25,6 +25,12 @@
--
msc.cflags = {
clr = {
On = "/clr",
Unsafe = "/clr",
Pure = "/clr:pure",
Safe = "/clr:safe",
},
flags = {
FatalCompileWarnings = "/WX",
MultiProcessorCompile = "/MP",

View File

@ -43,7 +43,7 @@
--
function suite.onUnsafe()
flags { "Unsafe" }
clr "Unsafe"
prepare()
test.capture [[
FLAGS = /unsafe /noconfig

View File

@ -44,7 +44,7 @@
--
function suite.allowUnsafeBlocks_onUnsafeFlag()
flags { "Unsafe" }
clr "Unsafe"
prepare()
test.capture [[
<DefineConstants></DefineConstants>

View File

@ -16,7 +16,7 @@
function suite.setup()
sln = test.createsolution()
flags { "Managed" }
clr "On"
end
local function prepare(platform)

View File

@ -364,7 +364,7 @@
-- Verify the correct Detect64BitPortabilityProblems settings are used when _ACTION < "VS2008".
--
function suite.runtimeLibraryIsDebug_onVS2005()
function suite._64BitPortabilityOn_onVS2005()
_ACTION = "vs2005"
prepare()
test.capture [[
@ -382,6 +382,23 @@
]]
end
function suite._64BitPortabilityOff_onVS2005_andCLR()
_ACTION = "vs2005"
clr "On"
prepare()
test.capture [[
<Tool
Name="VCCLCompilerTool"
Optimization="0"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="0"
/>
]]
end
--
-- Verify the correct warnings settings are used when no warnings are enabled.

View File

@ -76,7 +76,7 @@
--
function suite.keywordIsCorrect_onManagedC()
flags { "Managed" }
clr "On"
prepare()
test.capture [[
<VisualStudioProject

View File

@ -16,7 +16,7 @@
function suite.setup()
sln = test.createsolution()
flags { "Managed" }
clr "On"
end
local function prepare(platform)

View File

@ -607,7 +607,8 @@
--
function suite.debugFormat_onManagedCode()
flags { "Symbols", "Managed" }
flags "Symbols"
clr "On"
prepare()
test.capture [[
<ClCompile>

View File

@ -110,12 +110,13 @@
]]
end
--
-- Check the support for Managed C++.
--
function suite.clrSupport_onManaged()
flags "Managed"
function suite.clrSupport_onClrOn()
clr "On"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -125,6 +126,50 @@
]]
end
function suite.clrSupport_onClrOff()
clr "Off"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
]]
end
function suite.clrSupport_onClrUnsafe()
clr "Unsafe"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CLRSupport>true</CLRSupport>
]]
end
function suite.clrSupport_onClrSafe()
clr "Safe"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CLRSupport>Safe</CLRSupport>
]]
end
function suite.clrSupport_onClrPure()
clr "Pure"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CLRSupport>Pure</CLRSupport>
]]
end
--
-- Check the support for building with MFC.
--

View File

@ -46,7 +46,7 @@
--
function suite.keywordIsCorrect_onManagedC()
flags { "Managed" }
clr "On"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
@ -64,7 +64,7 @@
--
function suite.frameworkVersionIsCorrect_onManagedC()
flags { "Managed" }
clr "On"
framework "4.5"
prepare()
test.capture [[

View File

@ -82,7 +82,7 @@
function suite.referencesAreRelative_onDifferentProjectLocation()
links { "MyProject" }
flags { "Managed" }
clr "On"
prepare()
test.capture [[
<ItemGroup>

View File

@ -175,16 +175,16 @@
function suite.remove_onExactValueMatch()
local f = field.get("flags")
configset.store(cset, f, { "Symbols", "Unsafe", "NoRTTI" })
configset.remove(cset, f, { "Unsafe" })
configset.store(cset, f, { "Symbols", "WinMain", "NoRTTI" })
configset.remove(cset, f, { "WinMain" })
test.isequal({ "Symbols", "NoRTTI" }, configset.fetch(cset, f, {}))
end
function suite.remove_onMultipleValues()
local f = field.get("flags")
configset.store(cset, f, { "Symbols", "NoExceptions", "Unsafe", "NoRTTI" })
configset.store(cset, f, { "Symbols", "NoExceptions", "WinMain", "NoRTTI" })
configset.remove(cset, f, { "NoExceptions", "NoRTTI" })
test.isequal({ "Symbols", "Unsafe" }, configset.fetch(cset, f, {}))
test.isequal({ "Symbols", "WinMain" }, configset.fetch(cset, f, {}))
end

View File

@ -111,7 +111,7 @@
function suite.skipsAssemblies_onManagedCpp()
system "windows"
flags { "Managed" }
clr "On"
links { "user32", "System.dll" }
local r = prepare("all", "fullpath")
test.isequal({ "user32.lib" }, r)
@ -125,7 +125,7 @@
function suite.skipsUnmanagedLibs_onManagedLinkage()
system "windows"
flags { "Managed" }
clr "On"
links { "user32", "System.dll" }
local r = prepare("all", "fullpath", "managed")
test.isequal({ "System.dll" }, r)
@ -161,20 +161,20 @@
end
function suite.canLink_ManagedCppAndManagedCpp()
flags { "Managed" }
clr "On"
links { "MyProject2" }
project "MyProject2"
kind "StaticLib"
language "C++"
flags { "Managed" }
clr "On"
local r = prepare("all", "fullpath")
test.isequal({ "MyProject2.lib" }, r)
end
function suite.canLink_ManagedCppAndCs()
flags { "Managed" }
clr "On"
links { "MyProject2" }
project "MyProject2"

View File

@ -235,3 +235,33 @@
prepare()
test.contains("/DLL", msc.getldflags(cfg))
end
--
-- Check handling of CLR settings.
--
function suite.cflags_onClrOn()
clr "On"
prepare()
test.contains("/clr", msc.getcflags(cfg))
end
function suite.cflags_onClrUnsafe()
clr "Unsafe"
prepare()
test.contains("/clr", msc.getcflags(cfg))
end
function suite.cflags_onClrSafe()
clr "Safe"
prepare()
test.contains("/clr:safe", msc.getcflags(cfg))
end
function suite.cflags_onClrPure()
clr "Pure"
prepare()
test.contains("/clr:pure", msc.getcflags(cfg))
end