Added API for CompileAsWinRT
This commit is contained in:
parent
b1d477ff33
commit
12ca8f45b6
@ -1626,4 +1626,59 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
]]
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- If consumewinrtextension flag is set, add <CompileAsWinRT> element
|
||||
--
|
||||
|
||||
function suite.onconsumewinrtextensionOff()
|
||||
p.action.set("vs2019")
|
||||
consumewinrtextension "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<CompileAsWinRT>false</CompileAsWinRT>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onconsumewinrtextensionOn()
|
||||
p.action.set("vs2019")
|
||||
consumewinrtextension "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onconsumewinrtextensionNotSpecified()
|
||||
p.action.set("vs2019")
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onconsumewinrtextensionOn_BeforeVS2019()
|
||||
p.action.set("vs2017")
|
||||
consumewinrtextension "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
</ClCompile>
|
||||
]]
|
||||
end
|
||||
|
@ -903,3 +903,37 @@
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- test consumewinrtextension set for a single file
|
||||
--
|
||||
|
||||
function suite.consumewinrtextensionPerFile()
|
||||
p.action.set("vs2019")
|
||||
files { "hello.cpp", "hello2.cpp" }
|
||||
filter { "files:hello.cpp" }
|
||||
consumewinrtextension 'On'
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hello2.cpp" />
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.consumewinrtextensionPerFile_BeforeVS2019()
|
||||
p.action.set("vs2017")
|
||||
files { "hello.cpp", "hello2.cpp" }
|
||||
filter { "files:hello.cpp" }
|
||||
consumewinrtextension 'On'
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp" />
|
||||
<ClCompile Include="hello2.cpp" />
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
@ -392,7 +392,8 @@
|
||||
m.conformanceMode,
|
||||
m.structMemberAlignment,
|
||||
m.useFullPaths,
|
||||
m.removeUnreferencedCodeData
|
||||
m.removeUnreferencedCodeData,
|
||||
m.compileAsWinRT,
|
||||
}
|
||||
|
||||
if cfg.kind == p.STATICLIB then
|
||||
@ -815,6 +816,7 @@
|
||||
m.compileAs,
|
||||
m.runtimeTypeInfo,
|
||||
m.warningLevelFile,
|
||||
m.compileAsWinRT,
|
||||
}
|
||||
else
|
||||
return {
|
||||
@ -1531,6 +1533,14 @@
|
||||
end
|
||||
end
|
||||
|
||||
function m.compileAsWinRT(cfg, condition)
|
||||
if _ACTION >= "vs2019" then
|
||||
if cfg and cfg.consumewinrtextension ~= nil then
|
||||
m.element("CompileAsWinRT", condition, iif(cfg.consumewinrtextension, "true", "false"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function m.additionalCompileOptions(cfg, condition)
|
||||
local opts = cfg.buildoptions
|
||||
if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then
|
||||
|
@ -203,6 +203,12 @@
|
||||
kind = "list:string",
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "consumewinrtextension",
|
||||
scope = "config",
|
||||
kind = "boolean",
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "copylocal",
|
||||
scope = "config",
|
||||
|
28
website/docs/consumewinrtextension.md
Normal file
28
website/docs/consumewinrtextension.md
Normal file
@ -0,0 +1,28 @@
|
||||
Enables the WinRT extension, C++/CX, for the specified projects/files.
|
||||
|
||||
```lua
|
||||
consumewinrtextension "value"
|
||||
```
|
||||
|
||||
### Parameters ###
|
||||
|
||||
`value` is one of:
|
||||
* `Default` - Compiles the file using the default for the toolset. (Default is `Off`)
|
||||
* `On` - Compiles the file with the WinRT extension enabled.
|
||||
* `Off` - Compiles the file without the WinRT extension enabled.
|
||||
|
||||
### Applies To ###
|
||||
|
||||
The `workspace`, `project` or `file` scope.
|
||||
|
||||
### Availability ###
|
||||
|
||||
Premake 5.0.0 Beta 2 or later and only implemented for Visual Studio 2019+.
|
||||
|
||||
### Examples ###
|
||||
|
||||
```lua
|
||||
filter { "files:**_winrt.cpp" }
|
||||
consumewinrtextension "On"
|
||||
```
|
||||
|
@ -94,6 +94,7 @@ module.exports = {
|
||||
'configuration',
|
||||
'configurations',
|
||||
'conformancemode',
|
||||
'consumewinrtextension',
|
||||
'copylocal',
|
||||
'cppdialect',
|
||||
'csversion',
|
||||
|
Reference in New Issue
Block a user