[core] Use 'compileAs' API

This commit is contained in:
Tom van Dijck 2017-05-01 13:28:08 -07:00
parent b9fcad8102
commit 85b3e28de1
3 changed files with 42 additions and 10 deletions

View File

@ -183,6 +183,17 @@
kind = "boolean" kind = "boolean"
} }
api.register {
name = "compileas",
scope = "config",
kind = "string",
allowed = {
"Default",
"C",
"C++",
}
}
api.register { api.register {
name = "configmap", name = "configmap",
scope = "project", scope = "project",

View File

@ -1216,9 +1216,9 @@
function m.compileAs(cfg) function m.compileAs(cfg)
if p.languages.isc(cfg.language) then if p.languages.isc(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsC") m.element("CompileAs", nil, "CompileAsC")
elseif p.languages.iscpp(cfg.language) then elseif p.languages.iscpp(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsCpp") m.element("CompileAs", nil, "CompileAsCpp")
end end
end end

View File

@ -38,7 +38,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -224,7 +223,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -237,7 +235,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -462,7 +459,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -476,7 +472,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -490,7 +485,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -927,7 +921,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -1030,7 +1023,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<CompileAs>CompileAsC</CompileAs>
</ClCompile> </ClCompile>
]] ]]
end end
@ -1039,6 +1031,35 @@
language 'C++' language 'C++'
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
]]
end
--
-- Check handling of the compileAs api
--
function suite.onCompileAsC()
compileas 'C'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
]]
end
function suite.onCompileAsCpp()
compileas 'C++'
prepare()
test.capture [[
<ClCompile> <ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>