Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-11-09 01:43:49 +0400
committerJason Perkins <starkos@industriousone.com>2011-11-09 01:43:49 +0400
commit94a054c1a0a83133189e9c2b6b939a8a8f8abf66 (patch)
tree34baf1e767703def8bc3c3bff002fc63e1a7cf60
parent66b9c9e785e1234a9fc825e73bf7c47d9fca53bd (diff)
Patch 3381066: Fix VS2010 project references
-rw-r--r--CHANGES.txt33
-rw-r--r--src/actions/vstudio/vs2010_vcxproj.lua232
-rw-r--r--tests/actions/vstudio/vc2010/test_links.lua87
-rw-r--r--tests/premake4.lua19
4 files changed, 244 insertions, 127 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 9d48fa8..4db923b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,7 +3,7 @@
-------
* Feature 1590022: Source file filtering and grouping
-* Feature 3100379: C# support for Visual Studio 2010
+* Feature 3100379: C# support for Visual Studio 2010
* Feature 1657833: Set working directory for debugging
* Added support for Haiku OS (Yuriy O'Donnell)
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
@@ -37,6 +37,7 @@
* Patch 3317329: Support vstudio CompileAs for mixed-language projects (xpol)
* Patch 3337372: Improved precompiled header support (Anders Ericsson)
* Patch 3401184: Fix Gmake LDFLAGS generation order (Adam Petrone)
+* Patch 3381066: Fix VS2010 project references
-------
@@ -196,7 +197,7 @@ RC4 -> Final
RC3 -> RC4
- Embed scripts instead of bytecodes to avoid portability issues
-- solution() and project() now only set the active object when
+- solution() and project() now only set the active object when
called with a name; remains unchanged otherwise
RC2 -> RC3
@@ -230,7 +231,7 @@ RC1 -> RC2
- Added new cb-ow (Code::Blocks Open Watcom) target (Tim Channon)
- Place OSX winexe's into Content/MacOS folder (William Burnson)
- Sibling executables may now be listed in package.links
-- Bug 1520012: Improper Makefiles when filenames have spaces
+- Bug 1520012: Improper Makefiles when filenames have spaces
(Diaa Sami)
- Bug 2045506: "no-exceptions" flag ignored for VS200x (Benoit Miller)
- Bug 2034470: Error in cmd line error handler
@@ -242,12 +243,12 @@ RC1 -> RC2
-----
- Patch 1946122: Add support for VS2008 (Ryan Pusztai)
-- Patch 1913448: Win32 crash when using '--clean --usetargetpath'
+- Patch 1913448: Win32 crash when using '--clean --usetargetpath'
(David Walters)
- Patch 1771168: luaL_getn speed optimization (Richard O'Grady)
- Bug 1939089: Premake segfault on Linux/PPC (Fabio Till)
- Fixed "bad argument #2 to 'chdir'" error
-- Disable -MMD on multiple -arch flags (poor man's Universal binary
+- Disable -MMD on multiple -arch flags (poor man's Universal binary
support)
@@ -257,12 +258,12 @@ RC1 -> RC2
- Prevent creation of import libraries on OS X
- Improved handling of dylibs on OS X
-- Patch 1771977: Ability to compile C source as C++ in Code::Blocks
+- Patch 1771977: Ability to compile C source as C++ in Code::Blocks
(Ryan Pusztai)
- Bug 1804810: out-implib not present in linux gnu compler toolchain
- Bug 1806949: .Net reference paths are broken when bindir is specified
- Bug 1806960: Make clean does not remove .mdb files
-- Bug 1831389: Makefiles stored in subdirs contain no targets on
+- Bug 1831389: Makefiles stored in subdirs contain no targets on
first run
@@ -310,7 +311,7 @@ RC1 -> RC2
- Bug 1655595: Compile/build problem on FreeBSD
- Bug: "gnu" clean rule doesn't work in cmd.exe
- Improved behavior of Linux findlib()
-- Updated Code::Blocks support to latest project version
+- Updated Code::Blocks support to latest project version
(major="1" minor="6")
- Patch 1681666: GNU targets always show the console if kind = 'winexe'
@@ -358,7 +359,7 @@ RC1 -> RC2
- Added unit test suite
- Merged Scott Graham unicode build flag patch
- Removed package.warninglevel in favor of extra-warnings flag
-- Added package.targetprefix
+- Added package.targetprefix
- Overhauled structure of generated GNU makefiles
- Added --os command line option
- Fixed bug 1268588: Use gcc to link C packages
@@ -394,7 +395,7 @@ RC1 -> RC2
- Worked around VS.NET bug for .NET assemblies > 64K.
- Added --very-verbose flag to GNU generator.
- GNU generator now supports assembly sources.
-
+
-----
2.1
@@ -461,13 +462,13 @@ RC1 -> RC2
- Added support for Digital Mars compiler.
--------
+-------
1.6.1
-------
- VS7 generator crashed if a package was built before one of its
dependencies. Now immediately assigns UUID before processing.
-
+
-----
1.6
@@ -475,20 +476,20 @@ RC1 -> RC2
- Added support for Visual Studio 2003 and SharpDevelop.
- Added binaries directory as a reference path for VS7.
-
+
-----
1.5
-----
- Added initial support for building static libraries.
-- Added "no-main" flag, prevents overriding WinMain() on
+- Added "no-main" flag, prevents overriding WinMain() on
Windows builds.
- Added "--no-rtti" and "no-exceptions" build flags to
disable those C++ features.
- Display error message when project has no packages.
- Moved VC7 *.pdb files into intermediates directory.
-
+
-----
1.4
@@ -496,7 +497,7 @@ RC1 -> RC2
- Bug fixes to the path manipulation routines.
- GNU makefiles are regenerated when premake scripts change.
-
+
-----
1.3
diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index e2af121..9038abe 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -6,9 +6,10 @@
premake.vstudio.vc2010 = { }
local vc2010 = premake.vstudio.vc2010
-
+ local vstudio = premake.vstudio
- local function vs2010_config(prj)
+
+ local function vs2010_config(prj)
_p(1,'<ItemGroup Label="ProjectConfigurations">')
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
_p(2,'<ProjectConfiguration Include="%s">', premake.esc(cfginfo.name))
@@ -18,7 +19,7 @@
end
_p(1,'</ItemGroup>')
end
-
+
local function vs2010_globals(prj)
_p(1,'<PropertyGroup Label="Globals">')
_p(2,'<ProjectGuid>{%s}</ProjectGuid>',prj.uuid)
@@ -33,10 +34,10 @@
end
_p(1,'</PropertyGroup>')
end
-
+
function vc2010.config_type(config)
local t =
- {
+ {
SharedLib = "DynamicLibrary",
StaticLib = "StaticLibrary",
ConsoleApp = "Application",
@@ -44,13 +45,13 @@
}
return t[config.kind]
end
-
-
-
+
+
+
local function if_config_and_platform()
return 'Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"'
- end
-
+ end
+
local function optimisation(cfg)
local result = "Disabled"
for _, value in ipairs(cfg.flags) do
@@ -64,7 +65,7 @@
end
return result
end
-
+
local function config_type_block(prj)
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
@@ -72,21 +73,21 @@
, premake.esc(cfginfo.name))
_p(2,'<ConfigurationType>%s</ConfigurationType>',vc2010.config_type(cfg))
_p(2,'<CharacterSet>%s</CharacterSet>',iif(cfg.flags.Unicode,"Unicode","MultiByte"))
-
+
if cfg.flags.MFC then
_p(2,'<UseOfMfc>Dynamic</UseOfMfc>')
end
-
+
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>'
,iif(optimisation(cfg) == "Disabled","true","false"))
if cfg.flags.Managed then
_p(2,'<CLRSupport>true</CLRSupport>')
- end
+ end
_p(1,'</PropertyGroup>')
end
end
-
+
local function import_props(prj)
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
@@ -104,8 +105,8 @@
,tostring(premake.config.isincrementallink(cfg)))
end
end
-
-
+
+
local function ignore_import_lib(cfg,cfginfo)
if cfg.kind == "SharedLib" then
local shouldIgnore = "false"
@@ -114,12 +115,12 @@
,premake.esc(cfginfo.name),shouldIgnore)
end
end
-
-
+
+
local function intermediate_and_out_dirs(prj)
_p(1,'<PropertyGroup>')
_p(2,'<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>')
-
+
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
_p(2,'<OutDir '..if_config_and_platform() ..'>%s\\</OutDir>'
@@ -139,7 +140,7 @@
_p(1,'</PropertyGroup>')
end
-
+
local function runtime(cfg)
local runtime
local flags = cfg.flags
@@ -150,7 +151,7 @@
end
return runtime
end
-
+
local function precompiled_header(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then
_p(3,'<PrecompiledHeader>Use</PrecompiledHeader>')
@@ -168,22 +169,22 @@
_p(indent,'<PreprocessorDefinitions></PreprocessorDefinitions>')
end
end
-
+
local function include_dirs(indent,cfg)
if #cfg.includedirs > 0 then
_p(indent,'<AdditionalIncludeDirectories>%s;%%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>'
,premake.esc(path.translate(table.concat(cfg.includedirs, ";"), '\\')))
end
end
-
+
local function resource_compile(cfg)
_p(2,'<ResourceCompile>')
preprocessor(3,cfg)
include_dirs(3,cfg)
_p(2,'</ResourceCompile>')
-
+
end
-
+
local function exceptions(cfg)
if cfg.flags.NoExceptions then
_p(2,'<ExceptionHandling>false</ExceptionHandling>')
@@ -192,13 +193,13 @@
--SEH is not required for Managed and is implied
end
end
-
+
local function rtti(cfg)
if cfg.flags.NoRTTI and not cfg.flags.Managed then
_p(3,'<RuntimeTypeInfo>false</RuntimeTypeInfo>')
end
end
-
+
local function wchar_t_buildin(cfg)
if cfg.flags.NativeWChar then
_p(3,'<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>')
@@ -206,7 +207,7 @@
_p(3,'<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>')
end
end
-
+
local function sse(cfg)
if cfg.flags.EnableSSE then
_p(3,'<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>')
@@ -214,7 +215,7 @@
_p(3,'<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>')
end
end
-
+
local function floating_point(cfg)
if cfg.flags.FloatFast then
_p(3,'<FloatingPointModel>Fast</FloatingPointModel>')
@@ -222,7 +223,7 @@
_p(3,'<FloatingPointModel>Strict</FloatingPointModel>')
end
end
-
+
local function debug_info(cfg)
--
@@ -233,7 +234,7 @@
local debug_info = ''
if cfg.flags.Symbols then
if cfg.platform == "x64"
- or cfg.flags.Managed
+ or cfg.flags.Managed
or premake.config.isoptimizedbuild(cfg.flags)
or cfg.flags.NoEditAndContinue
then
@@ -242,10 +243,10 @@
debug_info = "EditAndContinue"
end
end
-
+
_p(3,'<DebugInformationFormat>%s</DebugInformationFormat>',debug_info)
end
-
+
local function minimal_build(cfg)
if premake.config.isdebugbuild(cfg) and not cfg.flags.NoMinimalRebuild then
_p(3,'<MinimalRebuild>true</MinimalRebuild>')
@@ -253,62 +254,62 @@
_p(3,'<MinimalRebuild>false</MinimalRebuild>')
end
end
-
+
local function compile_language(cfg)
if cfg.language == "C" then
_p(3,'<CompileAs>CompileAsC</CompileAs>')
end
- end
-
+ end
+
local function vs10_clcompile(cfg)
_p(2,'<ClCompile>')
-
+
if #cfg.buildoptions > 0 then
_p(3,'<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>',
table.concat(premake.esc(cfg.buildoptions), " "))
end
-
+
_p(3,'<Optimization>%s</Optimization>',optimisation(cfg))
-
+
include_dirs(3,cfg)
preprocessor(3,cfg)
minimal_build(cfg)
-
+
if not premake.config.isoptimizedbuild(cfg.flags) then
if not cfg.flags.Managed then
_p(3,'<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>')
end
-
+
if cfg.flags.ExtraWarnings then
_p(3,'<SmallerTypeCheck>true</SmallerTypeCheck>')
end
else
_p(3,'<StringPooling>true</StringPooling>')
end
-
+
_p(3,'<RuntimeLibrary>%s</RuntimeLibrary>', runtime(cfg))
-
+
_p(3,'<FunctionLevelLinking>true</FunctionLevelLinking>')
-
+
precompiled_header(cfg)
-
+
if cfg.flags.ExtraWarnings then
_p(3,'<WarningLevel>Level4</WarningLevel>')
else
_p(3,'<WarningLevel>Level3</WarningLevel>')
end
-
+
if cfg.flags.FatalWarnings then
_p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
end
-
+
exceptions(cfg)
rtti(cfg)
wchar_t_buildin(cfg)
sse(cfg)
floating_point(cfg)
debug_info(cfg)
-
+
if cfg.flags.Symbols then
_p(3,'<ProgramDataBaseFileName>$(OutDir)%s.pdb</ProgramDataBaseFileName>'
, path.getbasename(cfg.buildtarget.name))
@@ -317,31 +318,31 @@
if cfg.flags.NoFramePointer then
_p(3,'<OmitFramePointers>true</OmitFramePointers>')
end
-
+
compile_language(cfg)
_p(2,'</ClCompile>')
end
- local function event_hooks(cfg)
+ local function event_hooks(cfg)
if #cfg.postbuildcommands> 0 then
_p(2,'<PostBuildEvent>')
_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.postbuildcommands, "", "", "\r\n")))
_p(2,'</PostBuildEvent>')
end
-
+
if #cfg.prebuildcommands> 0 then
_p(2,'<PreBuildEvent>')
_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prebuildcommands, "", "", "\r\n")))
_p(2,'</PreBuildEvent>')
end
-
+
if #cfg.prelinkcommands> 0 then
_p(2,'<PreLinkEvent>')
_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prelinkcommands, "", "", "\r\n")))
_p(2,'</PreLinkEvent>')
- end
+ end
end
local function additional_options(indent,cfg)
@@ -357,7 +358,7 @@
_p(index,'<TargetMachine>%s</TargetMachine>', platforms[cfg.platform])
end
end
-
+
local function item_def_lib(cfg)
if cfg.kind == 'StaticLib' then
_p(1,'<Lib>')
@@ -367,9 +368,9 @@
_p(1,'</Lib>')
end
end
-
-
+
+
local function import_lib(cfg)
--Prevent the generation of an import library for a Windows DLL.
if cfg.kind == "SharedLib" then
@@ -377,39 +378,45 @@
_p(3,'<ImportLibrary>%s</ImportLibrary>',iif(cfg.flags.NoImportLib, cfg.objectsdir .. "\\" .. path.getname(implibname), implibname))
end
end
-
+
local function common_link_section(cfg)
_p(3,'<SubSystem>%s</SubSystem>',iif(cfg.kind == "ConsoleApp","Console", "Windows"))
-
- if cfg.flags.Symbols then
+
+ if cfg.flags.Symbols then
_p(3,'<GenerateDebugInformation>true</GenerateDebugInformation>')
else
_p(3,'<GenerateDebugInformation>false</GenerateDebugInformation>')
end
-
+
if premake.config.isoptimizedbuild(cfg.flags) then
_p(3,'<OptimizeReferences>true</OptimizeReferences>')
_p(3,'<EnableCOMDATFolding>true</EnableCOMDATFolding>')
end
end
-
+
+
+ function vc2010.additionalDependencies(cfg)
+ local links = premake.getlinks(cfg, "system", "fullpath")
+ if #links > 0 then
+ _p(3,'<AdditionalDependencies>%s;%%(AdditionalDependencies)</AdditionalDependencies>',
+ table.concat(links, ";"))
+ end
+ end
+
+
local function item_link(cfg)
_p(2,'<Link>')
if cfg.kind ~= 'StaticLib' then
-
- if #cfg.links > 0 then
- _p(3,'<AdditionalDependencies>%s;%%(AdditionalDependencies)</AdditionalDependencies>',
- table.concat(premake.getlinks(cfg, "all", "fullpath"), ";"))
- end
- _p(3,'<OutputFile>$(OutDir)%s</OutputFile>', cfg.buildtarget.name)
-
- _p(3,'<AdditionalLibraryDirectories>%s%s%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>',
- table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";"),
- iif(cfg.libdirs and #cfg.libdirs >0,';',''))
-
+ vc2010.additionalDependencies(cfg)
+ _p(3,'<OutputFile>$(OutDir)%s</OutputFile>', cfg.buildtarget.name)
+
+ _p(3,'<AdditionalLibraryDirectories>%s%s%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>',
+ table.concat(premake.esc(path.translate(cfg.libdirs, '\\')) , ";"),
+ iif(cfg.libdirs and #cfg.libdirs > 0,';',''))
+
common_link_section(cfg)
-
+
if vc2010.config_type(cfg) == 'Application' and not cfg.flags.WinMain and not cfg.flags.Managed then
_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')
end
@@ -420,10 +427,11 @@
else
common_link_section(cfg)
end
-
+
_p(2,'</Link>')
end
-
+
+
local function item_definitions(prj)
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
@@ -436,11 +444,11 @@
event_hooks(cfg)
_p(1,'</ItemDefinitionGroup>')
-
+
end
end
-
-
+
+
--
-- Retrieve a list of files for a particular build group, one of
@@ -456,7 +464,7 @@
None = {},
ResourceCompile = {},
}
-
+
for file in premake.project.eachfile(prj) do
if path.iscppfile(file.name) then
table.insert(sortedfiles.ClCompile, file)
@@ -468,11 +476,11 @@
table.insert(sortedfiles.None, file)
end
end
-
+
-- Cache the sorted files; they are used several places
prj.vc2010sortedfiles = sortedfiles
end
-
+
return sortedfiles[group]
end
@@ -500,11 +508,11 @@
end
end
-
+
function vc2010.compilerfilesgroup(prj)
local configs = prj.solution.vstudio_configs
local files = vc2010.getfilegroup(prj, "ClCompile")
- if #files > 0 then
+ if #files > 0 then
local config_mappings = {}
for _, cfginfo in ipairs(configs) do
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
@@ -512,17 +520,17 @@
config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\")
end
end
-
+
_p(1,'<ItemGroup>')
for _, file in ipairs(files) do
local translatedpath = path.translate(file.name, "\\")
_p(2,'<ClCompile Include=\"%s\">', translatedpath)
for _, cfginfo in ipairs(configs) do
- if config_mappings[cfginfo] and translatedpath == config_mappings[cfginfo] then
+ if config_mappings[cfginfo] and translatedpath == config_mappings[cfginfo] then
_p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>', premake.esc(cfginfo.name))
config_mappings[cfginfo] = nil --only one source file per pch
end
- end
+ end
_p(2,'</ClCompile>')
end
_p(1,'</ItemGroup>')
@@ -537,12 +545,12 @@
function vc2010.header(targets)
io.eol = "\r\n"
_p('<?xml version="1.0" encoding="utf-8"?>')
-
+
local t = ""
if targets then
t = ' DefaultTargets="' .. targets .. '"'
end
-
+
_p('<Project%s ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">', t)
end
@@ -557,28 +565,29 @@
vs2010_config(prj)
vs2010_globals(prj)
-
+
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />')
-
+
config_type_block(prj)
-
+
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />')
-
+
--check what this section is doing
_p(1,'<ImportGroup Label="ExtensionSettings">')
_p(1,'</ImportGroup>')
-
-
+
+
import_props(prj)
-
+
--what type of macros are these?
_p(1,'<PropertyGroup Label="UserMacros" />')
-
+
intermediate_and_out_dirs(prj)
-
+
item_definitions(prj)
-
+
vc2010.files(prj)
+ vc2010.projectReferences(prj)
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />')
_p(1,'<ImportGroup Label="ExtensionTargets">')
@@ -586,7 +595,26 @@
_p('</Project>')
end
-
+
+
+--
+-- Generate the list of project dependencies.
+--
+
+ function vc2010.projectReferences(prj)
+ local deps = premake.getdependencies(prj)
+ if #deps > 0 then
+ _p(1,'<ItemGroup>')
+ for _, dep in ipairs(deps) do
+ local deppath = path.getrelative(prj.solution.location, vstudio.projectfile(dep))
+ _p(2,'<ProjectReference Include=\"%s\">', path.translate(deppath, "\\"))
+ _p(3,'<Project>{%s}</Project>', dep.uuid)
+ _p(2,'</ProjectReference>')
+ end
+ _p(1,'</ItemGroup>')
+ end
+ end
+
--
-- Generate the .vcxproj.user file
@@ -613,6 +641,6 @@
end
_p('</Project>')
end
-
-
+
+
diff --git a/tests/actions/vstudio/vc2010/test_links.lua b/tests/actions/vstudio/vc2010/test_links.lua
new file mode 100644
index 0000000..de642f5
--- /dev/null
+++ b/tests/actions/vstudio/vc2010/test_links.lua
@@ -0,0 +1,87 @@
+--
+-- tests/actions/vstudio/vc2010/test_links.lua
+-- Validate linking and project references in Visual Studio 2010 C/C++ projects.
+-- Copyright (c) 2011 Jason Perkins and the Premake project
+--
+
+ T.vstudio_vs2010_links = { }
+ local suite = T.vstudio_vs2010_links
+ local vc2010 = premake.vstudio.vc2010
+
+
+--
+-- Setup
+--
+
+ local sln, prj, prj2
+
+ function suite.setup()
+ os_uuid = os.uuid
+ os.uuid = function() return "00112233-4455-6677-8888-99AABBCCDDEE" end
+
+ sln = test.createsolution()
+ test.createproject(sln)
+ end
+
+ local function prepare()
+ premake.bake.buildconfigs()
+ prj = premake.solution.getproject(sln, 1)
+ prj2 = premake.solution.getproject(sln, 2)
+ sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
+ end
+
+
+--
+-- If there are no sibling projects listed in links(), then the
+-- entire project references item group should be skipped.
+--
+
+ function suite.noSectionWritten_onNoSiblingReferences()
+ prepare()
+ vc2010.projectReferences(prj2)
+ test.isemptycapture()
+ end
+
+
+--
+-- If a sibling project is listed in links(), an item group should
+-- be written with a reference to that sibling project.
+--
+
+ function suite.projectReferenceAdded_onSiblingProjectLink()
+ links { "MyProject" }
+ prepare()
+ vc2010.projectReferences(prj2)
+ test.capture [[
+ <ItemGroup>
+ <ProjectReference Include="MyProject.vcproj">
+ <Project>{00112233-4455-6677-8888-99AABBCCDDEE}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ ]]
+ end
+
+
+--
+-- If a sibling library is listed in links(), it should NOT appear in
+-- the additional dependencies element. Visual Studio will figure that
+-- out from the project reference item group.
+--
+
+ function suite.noDependencies_onOnlySiblingProjectLinks()
+ links { "MyProject" }
+ prepare()
+ vc2010.additionalDependencies(prj2)
+ test.isemptycapture()
+ end
+
+ function suite.onlySystemDependencies_OnSiblingProjectLink()
+ links { "MyProject", "kernel32" }
+ prepare()
+ vc2010.additionalDependencies(prj2)
+ test.capture [[
+ <AdditionalDependencies>kernel32;%(AdditionalDependencies)</AdditionalDependencies>
+ ]]
+ end
+
+
diff --git a/tests/premake4.lua b/tests/premake4.lua
index 9f5030e..1b5ab45 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -13,7 +13,7 @@
test.createsolution = function()
local sln = solution "MySolution"
configurations { "Debug", "Release" }
-
+
local prj = project "MyProject"
language "C++"
kind "ConsoleApp"
@@ -25,7 +25,7 @@
test.createproject = function(sln)
local n = #sln.projects + 1
if n == 1 then n = "" end
-
+
local prj = project ("MyProject" .. n)
language "C++"
kind "ConsoleApp"
@@ -60,14 +60,14 @@
dofile("test_project.lua")
dofile("project/test_eachfile.lua")
dofile("project/test_vpaths.lua")
-
+
-- Baking tests
dofile("base/test_baking.lua")
dofile("baking/test_merging.lua")
-
+
-- Clean tests
dofile("actions/test_clean.lua")
-
+
-- Visual Studio tests
dofile("test_vs2002_sln.lua")
dofile("test_vs2003_sln.lua")
@@ -100,12 +100,13 @@
dofile("actions/vstudio/vc200x/header.lua")
dofile("actions/vstudio/vc200x/files.lua")
dofile("actions/vstudio/vc200x/test_filters.lua")
-
+
-- Visual Studio 2010 C/C++ projects
dofile("actions/vstudio/vc2010/test_debugdir.lua")
dofile("actions/vstudio/vc2010/test_header.lua")
dofile("actions/vstudio/vc2010/test_files.lua")
dofile("actions/vstudio/vc2010/test_filters.lua")
+ dofile("actions/vstudio/vc2010/test_links.lua")
dofile("actions/vstudio/vc2010/test_pch.lua")
-- Makefile tests
@@ -123,10 +124,10 @@
-- Xcode4 tests
dofile("actions/xcode/test_xcode4_project.lua")
dofile("actions/xcode/test_xcode4_workspace.lua")
-
+
-- CodeLite tests
dofile("actions/codelite/codelite_files.lua")
-
+
-- CodeBlocks tests
dofile("actions/codeblocks/codeblocks_files.lua")
dofile("actions/codeblocks/test_filters.lua")
@@ -138,7 +139,7 @@
newaction {
trigger = "test",
description = "Run the automated test suite",
-
+
execute = function ()
passed, failed = test.runall()
msg = string.format("%d tests passed, %d failed", passed, failed)