Skip to content

Commit

Permalink
Merge pull request #771 from Blizzard/compileAs-API
Browse files Browse the repository at this point in the history
[core] Use 'compileAs' API
  • Loading branch information
tvandijck authored May 25, 2017
2 parents 4a872d6 + 85b3e28 commit 0ec61b4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@
kind = "boolean"
}

api.register {
name = "compileas",
scope = "config",
kind = "string",
allowed = {
"Default",
"C",
"C++",
}
}

api.register {
name = "configmap",
scope = "project",
Expand Down
4 changes: 2 additions & 2 deletions src/actions/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,9 @@


function m.compileAs(cfg)
if p.languages.isc(cfg.language) then
if p.languages.isc(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsC")
elseif p.languages.iscpp(cfg.language) then
elseif p.languages.iscpp(cfg.compileas) then
m.element("CompileAs", nil, "CompileAsCpp")
end
end
Expand Down
37 changes: 29 additions & 8 deletions tests/actions/vstudio/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand Down Expand Up @@ -224,7 +223,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand All @@ -237,7 +235,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand Down Expand Up @@ -462,7 +459,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand All @@ -476,7 +472,6 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand All @@ -490,7 +485,6 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand Down Expand Up @@ -927,7 +921,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
]]
end
Expand Down Expand Up @@ -1030,7 +1023,6 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
]]
end
Expand All @@ -1039,6 +1031,35 @@
language 'C++'
prepare()
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>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
Expand Down

0 comments on commit 0ec61b4

Please sign in to comment.