Skip to content

Commit

Permalink
Merge pull request #1980 from LORgames/ssurtees/uwp
Browse files Browse the repository at this point in the history
Added UWP support for VS projects
  • Loading branch information
nickclark2016 authored Oct 12, 2022
2 parents 845a18f + 2a2feac commit ff5328c
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 13 deletions.
42 changes: 42 additions & 0 deletions modules/vstudio/tests/sln2005/test_platforms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,48 @@ EndGlobalSection
]]
end

function suite.DeployConsoleApp_onUWP()
project "MyProject"
kind "ConsoleApp"
system "uwp"
prepare()
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Deploy.0 = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Deploy.0 = Release|Win32
EndGlobalSection
]]
end

function suite.DeployWindowedApp_onUWP()
project "MyProject"
kind "WindowedApp"
system "uwp"
prepare()
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Deploy.0 = Debug|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Deploy.0 = Release|Win32
EndGlobalSection
]]
end

function suite.onMixedLanguage_noPlatforms_noArchs()
project "MyProject1"
language "C#"
Expand Down
92 changes: 92 additions & 0 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,56 @@ end
end


function suite.windowsTargetPlatformVersion_latest_on2019_onUWP()
system "uwp"
p.action.set("vs2019")
systemversion "latest"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
]]
end


function suite.windowsTargetPlatformVersion_latestToLatest_on2019_onUWP()
system "uwp"
p.action.set("vs2019")
systemversion "latest:latest"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<WindowsTargetPlatformMinVersion>10.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
]]
end


function suite.windowsTargetPlatformVersion_versionToVersion_on2019_onUWP()
system "uwp"
p.action.set("vs2019")
systemversion "10.0.10240.0:10.0.10240.1"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0.10240.1</WindowsTargetPlatformVersion>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
]]
end


---
-- Check handling of per-configuration systemversion
---
Expand Down Expand Up @@ -399,6 +449,34 @@ end
end


function suite.windowsTargetPlatformVersion_perConfig_on2019_onUWP()
system "uwp"
p.action.set("vs2019")
systemversion "10.0.10240.0"
filter "Debug"
systemversion "10.0.10240.0:latest"
filter "Release"
systemversion "10.0.10240.0:10.0.10240.1"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0.10240.1</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end


function suite.disableFastUpToDateCheck()
fastuptodate "Off"
prepare()
Expand Down Expand Up @@ -443,3 +521,17 @@ end
</PropertyGroup>
]]
end


function suite.appContainerApplication2019UWP()
system "uwp"
p.action.set("vs2019")
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<AppContainerApplication>true</AppContainerApplication>
</PropertyGroup>
]]
end
22 changes: 22 additions & 0 deletions modules/vstudio/tests/vc2010/test_output_props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@
]]
end

function suite.outDir_onTargetDirUWP()
system "uwp"
targetdir "../bin"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\bin\</OutDir>
]]
end

--
-- The objeccts directory is applied, if specified.
--
Expand Down Expand Up @@ -146,6 +157,17 @@
]]
end

function suite.ignoreImportLib_onUWP()
system "uwp"
kind "SharedLib"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IgnoreImportLibrary>false</IgnoreImportLibrary>
]]
end

function suite.omitIgnoreImportLib_onNonSharedLib()
kind "ConsoleApp"
flags "NoImportLib"
Expand Down
8 changes: 8 additions & 0 deletions modules/vstudio/vs2005_solution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
return {
sln2005.activeCfg,
sln2005.build0,
sln2005.deploy0,
}
end

Expand Down Expand Up @@ -251,6 +252,13 @@
end
end


function sln2005.deploy0(cfg, context)
if context.prjCfg.system == p.UWP and not context.excluded and (context.prjCfg.kind == p.WINDOWEDAPP or context.prjCfg.kind == p.CONSOLEAPP) then
p.w('{%s}.%s.Deploy.0 = %s|%s', context.prj.uuid, context.descriptor, context.platform, context.architecture)
end
end

--
-- Write out the tables that map solution configurations to project configurations.
--
Expand Down
42 changes: 31 additions & 11 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
m.windowsTargetPlatformVersion,
m.fastUpToDateCheck,
m.toolsVersion,
m.appContainerApplication,
}
end

Expand Down Expand Up @@ -1660,6 +1661,13 @@
end


function m.appContainerApplication(prj)
if prj.system == p.UWP then
m.element("AppContainerApplication", nil, "true")
end
end


function m.compileAsManaged(fcfg, condition)
if fcfg.clr and fcfg ~= p.OFF then
m.element("CompileAsManaged", condition, "true")
Expand Down Expand Up @@ -2094,8 +2102,12 @@


function m.ignoreImportLibrary(cfg)
if cfg.kind == p.SHAREDLIB and cfg.flags.NoImportLib then
m.element("IgnoreImportLibrary", nil, "true")
if cfg.kind == p.SHAREDLIB then
if cfg.flags.NoImportLib then
m.element("IgnoreImportLibrary", nil, "true")
elseif cfg.system == p.UWP then
m.element("IgnoreImportLibrary", nil, "false")
end
end
end

Expand Down Expand Up @@ -2807,29 +2819,37 @@
end

local target = cfg or prj
local version = project.systemversion(target)
local minversion, maxversion = project.systemversion(target)

-- if this is a config, only emit if different from project
if cfg then
local prjVersion = project.systemversion(prj)
if not prjVersion or version == prjVersion then
local prjMinVersion, prjMaxVersion = project.systemversion(prj)
if not prjMinVersion or (minversion == prjMinVersion and maxversion == prjMaxVersion) then
return
end
end

-- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
if version == "latest" then
if minversion == "latest" then
if _ACTION == "vs2015" then
version = nil -- SDK v10 is not supported by VS2015
minversion = nil -- SDK v10 is not supported by VS2015
elseif _ACTION == "vs2017" then
version = "$(LatestTargetPlatformVersion)"
minversion = "$(LatestTargetPlatformVersion)"
else
version = "10.0"
minversion = "10.0"
end
end

if version then
m.element("WindowsTargetPlatformVersion", nil, version)
-- Max version is only supported in UWP projects
if maxversion == "latest" then
maxversion = "10.0"
end

if maxversion and target.system == p.UWP then
m.element("WindowsTargetPlatformMinVersion", nil, minversion)
m.element("WindowsTargetPlatformVersion", nil, maxversion)
elseif minversion then
m.element("WindowsTargetPlatformVersion", nil, minversion)
end
end

Expand Down
6 changes: 5 additions & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )

flags { "StaticRuntime", "MultiProcessorCompile" }
flags { "MultiProcessorCompile" }
warnings "Extra"

if not _OPTIONS["no-zlib"] then
Expand Down Expand Up @@ -190,6 +190,10 @@
filter { "system:windows", "configurations:Release", "toolset:not mingw" }
flags { "LinkTimeOptimization" }

filter { "system:uwp" }
systemversion "latest:latest"
consumewinrtextension "false"

project "Premake5"
targetname "premake5"
language "C"
Expand Down
4 changes: 3 additions & 1 deletion src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
"NoEditAndContinue", -- DEPRECATED
"NoFramePointer", -- DEPRECATED
"NoImplicitLink",
"NoImportLib",
"NoImportLib", -- DEPRECATED
"NoIncrementalLink",
"NoManifest",
"NoMinimalRebuild",
Expand Down Expand Up @@ -1203,6 +1203,7 @@
"linux",
"macosx",
"solaris",
"uwp",
"wii",
"windows",
},
Expand Down Expand Up @@ -1849,6 +1850,7 @@
{ "linux", "Linux" },
{ "macosx", "Apple Mac OS X" },
{ "solaris", "Solaris" },
{ "uwp", "Microsoft Univesral Windows Platform"},
{ "windows", "Microsoft Windows" },
}
}
Expand Down
1 change: 1 addition & 0 deletions src/base/_foundation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
premake.UNICODE = "Unicode"
premake.UNIVERSAL = "universal"
premake.UTILITY = "Utility"
premake.UWP = "uwp"
premake.PACKAGING = "Packaging"
premake.WINDOWEDAPP = "WindowedApp"
premake.WINDOWS = "windows"
Expand Down
1 change: 1 addition & 0 deletions src/base/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@
["linux"] = { "linux", "posix" },
["macosx"] = { "macosx", "darwin", "posix" },
["solaris"] = { "solaris", "posix" },
["uwp"] = { "uwp", "windows" },
["windows"] = { "windows", "win32" },
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ If no system is specified, Premake will identify and target the current operatin
* linux
* macosx
* solaris
* uwp
* wii
* windows
* xbox360
Expand Down

0 comments on commit ff5328c

Please sign in to comment.