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:
-rw-r--r--CHANGES.txt45
-rw-r--r--src/action/make/gmake.c9
-rw-r--r--src/action/tests/action_tests.h1
-rw-r--r--src/action/vs200x/tests/vs2002_config_tests.cpp29
-rw-r--r--src/action/vs200x/tests/vs2002_project_tests.cpp88
-rw-r--r--src/action/vs200x/tests/vs2003_config_tests.cpp29
-rw-r--r--src/action/vs200x/tests/vs2003_project_tests.cpp90
-rw-r--r--src/action/vs200x/tests/vs2005_config_tests.cpp29
-rw-r--r--src/action/vs200x/tests/vs2005_project_tests.cpp95
-rw-r--r--src/action/vs200x/tests/vs2008_config_tests.cpp29
-rw-r--r--src/action/vs200x/tests/vs2008_project_tests.cpp95
-rw-r--r--src/action/vs200x/tests/vs200x_project_tests.cpp250
-rw-r--r--src/action/vs200x/tests/vs200x_tests.cpp26
-rw-r--r--src/action/vs200x/tests/vs200x_xml_tests.cpp159
-rw-r--r--src/action/vs200x/vs2002.c30
-rw-r--r--src/action/vs200x/vs2002_project.c34
-rw-r--r--src/action/vs200x/vs2003.c31
-rw-r--r--src/action/vs200x/vs2005.c38
-rw-r--r--src/action/vs200x/vs2008.c37
-rw-r--r--src/action/vs200x/vs200x.c105
-rw-r--r--src/action/vs200x/vs200x.h4
-rw-r--r--src/action/vs200x/vs200x_config.c48
-rw-r--r--src/action/vs200x/vs200x_config.h16
-rw-r--r--src/action/vs200x/vs200x_project.c408
-rw-r--r--src/action/vs200x/vs200x_project.h29
-rw-r--r--src/base/stream.c28
-rw-r--r--src/base/stream.h3
-rw-r--r--src/base/tests/xml_tests.cpp64
-rw-r--r--src/base/xml.c120
-rw-r--r--src/base/xml.h19
-rw-r--r--src/engine/session.c89
-rw-r--r--src/engine/session.h4
-rw-r--r--src/engine/tests/session_tests.cpp115
-rw-r--r--src/project/project.c28
-rw-r--r--src/project/project.h2
-rw-r--r--src/project/tests/project_tests.cpp18
36 files changed, 2111 insertions, 133 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 3048487..4505c0e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,3 @@
---------------------
4.0 (in progress)
--------------------
This version is a complete rewrite of Premake.
@@ -8,10 +7,8 @@ This version is a complete rewrite of Premake.
- Standardized path handling across all project settings
- Upgraded to Lua 5.1.2
---------------------
3.5
--------------------
-
- 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 (Ryan Pusztai)
@@ -21,10 +18,8 @@ This version is a complete rewrite of Premake.
- Bug 1806960: Make clean does not remove .mdb files
- Bug 1831389: Makefiles stored in subdirs contain no targets on first run
---------------------
3.4
--------------------
-
- Added `no-pch` flag to suppress precompiled headers
- Added App.config support to GNU makefiles
- Add os.mkdir() to script environment
@@ -42,10 +37,8 @@ This version is a complete rewrite of Premake.
- Patch 1746563: Ability to specify GUID for VS targets (Ryan Pusztai)
- Patch 1754867: Creating import lib of different name (Ryan Pusztai)
---------------------
3.3
--------------------
-
- Added support for prebuild, prelink, and postbuild commands
- Added `target` global variable to script environment
- Added build flag `no-edit-and-continue`
@@ -67,10 +60,8 @@ This version is a complete rewrite of Premake.
- Updated Code::Blocks support to latest project version (major="1" minor="6")
- Patch 1681666: GNU targets always show the console if kind = 'winexe'
---------------------
3.2
--------------------
-
- Added support for Code::Blocks
- Updated MonoDevelop support
- Upgraded Lua to 5.0.3
@@ -79,10 +70,8 @@ This version is a complete rewrite of Premake.
- Turn off edit-and-continue in release builds with symbols
- Bug 1559873: libpaths inserts extra space after -L
---------------------
3.1
--------------------
-
- Added support for Visual Studio 2005
- Added support for Windows resources to GNU make target
- Added path handling functions to Lua environment
@@ -97,10 +86,8 @@ This version is a complete rewrite of Premake.
- Bug 1422068: package.path="." causes bad makefiles
- Bug 1431530: makefile target fails when project path specified
---------------------
3.0
--------------------
-
- Upgraded Lua interpreter to version 5.0.1
- The options table now stores simple values, rather than tables
- Completed MonoDevelop support
@@ -114,46 +101,36 @@ This version is a complete rewrite of Premake.
- Fixed bug 1268588: Use gcc to link C packages
- Fixed bug 1363306: GNU C# should copy referenced DLLs
---------------------
2.4
--------------------
-
- Added chdir() to Lua script environment
- Merged Thomas Harning's patch for .NET resources on GNU
- Fixed bug 1194702: Can't put multiple packages in same directory
- Fixed bug in GNU shared library builds (doh!)
- Added target 'vs2002' to replace 'vs7'
---------------------
2.3
--------------------
-
- Added 'project.config[]' with 'bindir' and 'libdir'
- Merged Scott Graham's "warninglevel" patch.
- Fixed bug 1153484: Import lib in wrong directory.
- Fixed bug 1013352: Stack overflow with large projects.
- Fixed bug 945406: package.files, bad value = crash
---------------------
2.2
--------------------
-
- Worked around VS.NET bug for .NET assemblies > 64K.
- Added --very-verbose flag to GNU generator.
- GNU generator now supports assembly sources.
---------------------
2.1
--------------------
-
- File extension of generated binaries can now be set
with config.targetextension.
- Windows targets now handle .def files for DLLs.
---------------------
2.0
--------------------
-
- Can now specify build actions per file
- Include paths are now passed to VC7 resource compiler
- Removed _WIN32 define from Cygwin makefiles
@@ -161,10 +138,8 @@ This version is a complete rewrite of Premake.
- Added rmdir() to Lua script environment
- A big bag of bug fixes
---------------------
1.9
--------------------
-
- Made verbose mode even more verbose.
- posix.c now builds properly as C.
- Fixed package dependency generation for GNU and VS2003.
@@ -176,20 +151,16 @@ This version is a complete rewrite of Premake.
- Bin and Lib paths can now be arbitrarily long.
- linkoptions are now applied in VC6 and VC7 projects.
---------------------
1.8
--------------------
-
- Added support for ASP.NET projects.
- Fixed a bug in VC6 support for static libraries.
- matchfiles() now uses package path instead of script path.
- Added --verbose option.
- No longer apply no-rtti and no-exceptions to *.c files.
---------------------
1.7
--------------------
-
- Location of generated project files can now be specified with
the project.path variable.
- Inter-package dependencies are fixed for GNU makefiles.
@@ -202,19 +173,15 @@ This version is a complete rewrite of Premake.
- Started support for OS X.
- Added support for Digital Mars compiler.
---------------------
1.6
--------------------
-
- VS7 generator crashed if a package was built before one of its
dependencies. Now immediately assigns UUID before processing.
- 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
Windows builds.
@@ -223,27 +190,21 @@ This version is a complete rewrite of Premake.
- Display error message when project has no packages.
- Moved VC7 *.pdb files into intermediates directory.
---------------------
1.4
--------------------
-
- Bug fixes to the path manipulation routines.
- GNU makefiles are regenerated when premake scripts change.
---------------------
1.3
--------------------
-
- Added support for the Cygwin environment.
- Added "static-runtime" build flag to statically link against C/C++
standard runtime libraries.
- Bug fixes to Visual Studio 6 and 7 generators and path reversing
algorithm.
---------------------
1.2
--------------------
-
- Standardized format of command-line options.
- Can now handle custom command-line options in script.
- Added new function findlib().
@@ -251,10 +212,8 @@ This version is a complete rewrite of Premake.
- Can now use open-source C# compilers in VS6 generator.
- Several bug fixes to the VS7 generator.
---------------------
1.1
--------------------
-
- Added support for custom build configurations. Added "optimize",
"optimize-size", "optimize-speed", and "no-symbols" flags to control
build settings.
@@ -267,10 +226,8 @@ This version is a complete rewrite of Premake.
eventually.
- Major cleanup of the source code.
---------------------
1.0
--------------------
-
- Fixed a bug related to the reference paths in VS7 C# projects.
- Display a warning message if a reference path can't be found.
- Automatically create bin and lib directories if they do not exist.
@@ -283,8 +240,6 @@ This version is a complete rewrite of Premake.
- Changed 'conexe' to 'exe' because I liked it better.
- Changed 'library' to 'dll' for C# projects to keep things consistent.
---------------------
0.9
--------------------
-
- Initial public release.
diff --git a/src/action/make/gmake.c b/src/action/make/gmake.c
index ad71fd1..54a3172 100644
--- a/src/action/make/gmake.c
+++ b/src/action/make/gmake.c
@@ -31,6 +31,13 @@ static SessionProjectCallback ProjectCallbacks[] =
};
+/** The GNU make configuration writing process, for session_enumerate_configurations() */
+static SessionProjectCallback ConfigCallbacks[] =
+{
+ NULL
+};
+
+
/**
* The GNU make action handler.
* \param sess The active session object.
@@ -45,6 +52,6 @@ int gmake_action(Session sess)
}
stream_writeline(Console, "Generating project files for GNU make...");
- return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks);
+ return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks, ConfigCallbacks);
}
diff --git a/src/action/tests/action_tests.h b/src/action/tests/action_tests.h
index 30a57c6..f2069fb 100644
--- a/src/action/tests/action_tests.h
+++ b/src/action/tests/action_tests.h
@@ -24,6 +24,7 @@ struct FxAction
strm = stream_create_null();
stream_set_buffer(strm, buffer);
+ session_set_active_stream(sess, strm);
sln = solution_create();
session_add_solution(sess, sln);
diff --git a/src/action/vs200x/tests/vs2002_config_tests.cpp b/src/action/vs200x/tests/vs2002_config_tests.cpp
new file mode 100644
index 0000000..9642ad7
--- /dev/null
+++ b/src/action/vs200x/tests/vs2002_config_tests.cpp
@@ -0,0 +1,29 @@
+/**
+ * \file vs2002_config_tests.cpp
+ * \brief Automated tests for VS2002 configuration processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_config.h"
+}
+
+struct Fx2002Config : FxAction
+{
+ Fx2002Config()
+ {
+ session_set_action(sess, "vs2002");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2002Config, CharacterSet_Default)
+ {
+ vs200x_config_character_set(sess);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2002_project_tests.cpp b/src/action/vs200x/tests/vs2002_project_tests.cpp
new file mode 100644
index 0000000..aeb2006
--- /dev/null
+++ b/src/action/vs200x/tests/vs2002_project_tests.cpp
@@ -0,0 +1,88 @@
+/**
+ * \file vs2002_project_tests.cpp
+ * \brief Automated tests for VS2002 project processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_project.h"
+}
+
+struct Fx2002Project : FxAction
+{
+ Fx2002Project()
+ {
+ session_set_action(sess, "vs2002");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2002Project, Vs2002_VisualStudioProject)
+ {
+ vs200x_project_element(sess, prj, strm);
+ CHECK_EQUAL(
+ "<VisualStudioProject\n"
+ "\tProjectType=\"Visual C++\"\n"
+ "\tVersion=\"7.00\"\n"
+ "\tName=\"MyProject\"\n"
+ "\tProjectGUID=\"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
+ "\tKeyword=\"Win32Proj\">\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2002Project, Vs2002_ToolFiles)
+ {
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2002Project, VCCLCompilerTool)
+ {
+ vs200x_project_vc_cl_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCCLCompilerTool\"\n"
+ "\t\t\t\tOptimization=\"0\"\n"
+ "\t\t\t\tMinimalRebuild=\"TRUE\"\n"
+ "\t\t\t\tBasicRuntimeChecks=\"3\"\n"
+ "\t\t\t\tRuntimeLibrary=\"3\"\n"
+ "\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n"
+ "\t\t\t\tUsePrecompiledHeader=\"2\"\n"
+ "\t\t\t\tWarningLevel=\"3\"\n"
+ "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n"
+ "\t\t\t\tDebugInformationFormat=\"4\"/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2002Project, VCLinkerTool)
+ {
+ vs200x_project_vc_linker_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCLinkerTool\"\n"
+ "\t\t\t\tLinkIncremental=\"2\"\n"
+ "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"
+ "\t\t\t\tSubSystem=\"1\"\n"
+ "\t\t\t\tEntryPointSymbol=\"mainCRTStartup\"\n"
+ "\t\t\t\tTargetMachine=\"1\"/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2002Project, References)
+ {
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n",
+ buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2003_config_tests.cpp b/src/action/vs200x/tests/vs2003_config_tests.cpp
new file mode 100644
index 0000000..af37c7e
--- /dev/null
+++ b/src/action/vs200x/tests/vs2003_config_tests.cpp
@@ -0,0 +1,29 @@
+/**
+ * \file vs2003_config_tests.cpp
+ * \brief Automated tests for VS2003 configuration processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_config.h"
+}
+
+struct Fx2003Config : FxAction
+{
+ Fx2003Config()
+ {
+ session_set_action(sess, "vs2003");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2003Config, CharacterSet_Default)
+ {
+ vs200x_config_character_set(sess);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2003_project_tests.cpp b/src/action/vs200x/tests/vs2003_project_tests.cpp
new file mode 100644
index 0000000..c86043e
--- /dev/null
+++ b/src/action/vs200x/tests/vs2003_project_tests.cpp
@@ -0,0 +1,90 @@
+/**
+ * \file vs2003_project_tests.cpp
+ * \brief Automated tests for VS2003 project processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_project.h"
+}
+
+struct Fx2003Project : FxAction
+{
+ Fx2003Project()
+ {
+ session_set_action(sess, "vs2003");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2003Project, Vs2003_VisualStudioProject)
+ {
+ vs200x_project_element(sess, prj, strm);
+ CHECK_EQUAL(
+ "<VisualStudioProject\n"
+ "\tProjectType=\"Visual C++\"\n"
+ "\tVersion=\"7.10\"\n"
+ "\tName=\"MyProject\"\n"
+ "\tProjectGUID=\"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
+ "\tKeyword=\"Win32Proj\">\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2003Project, Vs2003_ToolFiles)
+ {
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2003Project, VCCLCompilerTool)
+ {
+ vs200x_project_vc_cl_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCCLCompilerTool\"\n"
+ "\t\t\t\tOptimization=\"0\"\n"
+ "\t\t\t\tMinimalRebuild=\"TRUE\"\n"
+ "\t\t\t\tBasicRuntimeChecks=\"3\"\n"
+ "\t\t\t\tRuntimeLibrary=\"3\"\n"
+ "\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n"
+ "\t\t\t\tUsePrecompiledHeader=\"2\"\n"
+ "\t\t\t\tWarningLevel=\"3\"\n"
+ "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n"
+ "\t\t\t\tDebugInformationFormat=\"4\"/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2003Project, VCLinkerTool)
+ {
+ vs200x_project_vc_linker_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCLinkerTool\"\n"
+ "\t\t\t\tLinkIncremental=\"2\"\n"
+ "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"
+ "\t\t\t\tSubSystem=\"1\"\n"
+ "\t\t\t\tEntryPointSymbol=\"mainCRTStartup\"\n"
+ "\t\t\t\tTargetMachine=\"1\"/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2003Project, References)
+ {
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2005_config_tests.cpp b/src/action/vs200x/tests/vs2005_config_tests.cpp
new file mode 100644
index 0000000..e754e59
--- /dev/null
+++ b/src/action/vs200x/tests/vs2005_config_tests.cpp
@@ -0,0 +1,29 @@
+/**
+ * \file vs2005_config_tests.cpp
+ * \brief Automated tests for VS2005 configuration processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_config.h"
+}
+
+struct Fx2005Config : FxAction
+{
+ Fx2005Config()
+ {
+ session_set_action(sess, "vs2005");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2005Config, CharacterSet_Default)
+ {
+ vs200x_config_character_set(sess);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2005_project_tests.cpp b/src/action/vs200x/tests/vs2005_project_tests.cpp
new file mode 100644
index 0000000..8729316
--- /dev/null
+++ b/src/action/vs200x/tests/vs2005_project_tests.cpp
@@ -0,0 +1,95 @@
+/**
+ * \file vs2005_project_tests.cpp
+ * \brief Automated tests for VS2005 project processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_project.h"
+}
+
+struct Fx2005Project : FxAction
+{
+ Fx2005Project()
+ {
+ session_set_action(sess, "vs2005");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2005Project, Vs2005_VisualStudioProject)
+ {
+ vs200x_project_element(sess, prj, strm);
+ CHECK_EQUAL(
+ "<VisualStudioProject\n"
+ "\tProjectType=\"Visual C++\"\n"
+ "\tVersion=\"8.00\"\n"
+ "\tName=\"MyProject\"\n"
+ "\tProjectGUID=\"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
+ "\tRootNamespace=\"MyProject\"\n"
+ "\tKeyword=\"Win32Proj\"\n"
+ "\t>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2005Project, Vs2005_ToolFiles)
+ {
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<ToolFiles>\n"
+ "\t</ToolFiles>\n"
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2005Project, VCCLCompilerTool)
+ {
+ vs200x_project_vc_cl_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCCLCompilerTool\"\n"
+ "\t\t\t\tOptimization=\"0\"\n"
+ "\t\t\t\tMinimalRebuild=\"true\"\n"
+ "\t\t\t\tBasicRuntimeChecks=\"3\"\n"
+ "\t\t\t\tRuntimeLibrary=\"3\"\n"
+ "\t\t\t\tUsePrecompiledHeader=\"0\"\n"
+ "\t\t\t\tWarningLevel=\"3\"\n"
+ "\t\t\t\tDetect64BitPortabilityProblems=\"true\"\n"
+ "\t\t\t\tDebugInformationFormat=\"4\"\n"
+ "\t\t\t/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2005Project, VCLinkerTool)
+ {
+ vs200x_project_vc_linker_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCLinkerTool\"\n"
+ "\t\t\t\tLinkIncremental=\"2\"\n"
+ "\t\t\t\tGenerateDebugInformation=\"true\"\n"
+ "\t\t\t\tSubSystem=\"1\"\n"
+ "\t\t\t\tEntryPointSymbol=\"mainCRTStartup\"\n"
+ "\t\t\t\tTargetMachine=\"1\"\n"
+ "\t\t\t/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2005Project, References)
+ {
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2008_config_tests.cpp b/src/action/vs200x/tests/vs2008_config_tests.cpp
new file mode 100644
index 0000000..32d59c6
--- /dev/null
+++ b/src/action/vs200x/tests/vs2008_config_tests.cpp
@@ -0,0 +1,29 @@
+/**
+ * \file vs2008_config_tests.cpp
+ * \brief Automated tests for VS2008 configuration processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_config.h"
+}
+
+struct Fx2008Config : FxAction
+{
+ Fx2008Config()
+ {
+ session_set_action(sess, "vs2008");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2008Config, CharacterSet_Default)
+ {
+ vs200x_config_character_set(sess);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs2008_project_tests.cpp b/src/action/vs200x/tests/vs2008_project_tests.cpp
new file mode 100644
index 0000000..8b665c6
--- /dev/null
+++ b/src/action/vs200x/tests/vs2008_project_tests.cpp
@@ -0,0 +1,95 @@
+/**
+ * \file vs2008_project_tests.cpp
+ * \brief Automated tests for VS2008 project processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_project.h"
+}
+
+struct Fx2008Project : FxAction
+{
+ Fx2008Project()
+ {
+ session_set_action(sess, "vs2008");
+ }
+};
+
+
+SUITE(action)
+{
+ TEST_FIXTURE(Fx2008Project, Vs2008_VisualStudioProject)
+ {
+ vs200x_project_element(sess, prj, strm);
+ CHECK_EQUAL(
+ "<VisualStudioProject\n"
+ "\tProjectType=\"Visual C++\"\n"
+ "\tVersion=\"9.00\"\n"
+ "\tName=\"MyProject\"\n"
+ "\tProjectGUID=\"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
+ "\tRootNamespace=\"MyProject\"\n"
+ "\tKeyword=\"Win32Proj\"\n"
+ "\tTargetFrameworkVersion=\"196613\"\n"
+ "\t>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2008Project, Vs2008_ToolFiles)
+ {
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<ToolFiles>\n"
+ "\t</ToolFiles>\n"
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2008Project, VCCLCompilerTool)
+ {
+ vs200x_project_vc_cl_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCCLCompilerTool\"\n"
+ "\t\t\t\tOptimization=\"0\"\n"
+ "\t\t\t\tMinimalRebuild=\"true\"\n"
+ "\t\t\t\tBasicRuntimeChecks=\"3\"\n"
+ "\t\t\t\tRuntimeLibrary=\"3\"\n"
+ "\t\t\t\tUsePrecompiledHeader=\"0\"\n"
+ "\t\t\t\tWarningLevel=\"3\"\n"
+ "\t\t\t\tDebugInformationFormat=\"4\"\n"
+ "\t\t\t/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2008Project, VCLinkerTool)
+ {
+ vs200x_project_vc_linker_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCLinkerTool\"\n"
+ "\t\t\t\tLinkIncremental=\"2\"\n"
+ "\t\t\t\tGenerateDebugInformation=\"true\"\n"
+ "\t\t\t\tSubSystem=\"1\"\n"
+ "\t\t\t\tEntryPointSymbol=\"mainCRTStartup\"\n"
+ "\t\t\t\tTargetMachine=\"1\"\n"
+ "\t\t\t/>\n",
+ buffer);
+ }
+
+
+ TEST_FIXTURE(Fx2008Project, References)
+ {
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+}
diff --git a/src/action/vs200x/tests/vs200x_project_tests.cpp b/src/action/vs200x/tests/vs200x_project_tests.cpp
new file mode 100644
index 0000000..dd57a2d
--- /dev/null
+++ b/src/action/vs200x/tests/vs200x_project_tests.cpp
@@ -0,0 +1,250 @@
+/**
+ * \file vs200x_project_tests.cpp
+ * \brief Automated tests for Visual Studio project processing.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x_project.h"
+}
+
+
+struct FxVsProject : FxAction
+{
+ FxVsProject()
+ {
+ session_set_action(sess, "vs2002");
+ project_set_configuration_filter(prj, "Debug");
+ }
+};
+
+
+SUITE(action)
+{
+ /**********************************************************************
+ * Configuration element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxVsProject, Vs200x_Configuration)
+ {
+ vs200x_project_config_element(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t<Configuration\n"
+ "\t\t\tName=\"Debug|Win32\"\n"
+ "\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\n"
+ "\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\n"
+ "\t\t\tConfigurationType=\"1\"\n"
+ "\t\t\tCharacterSet=\"2\">\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Encoding tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_Encoding)
+ {
+ vs200x_project_encoding(sess, prj, strm);
+ CHECK_EQUAL(
+ "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Platforms tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxVsProject, Vs200x_Platforms)
+ {
+ vs200x_project_platforms(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Platforms>\n"
+ "\t\t<Platform\n"
+ "\t\t\tName=\"Win32\"/>\n"
+ "\t</Platforms>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Tool element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCALinkTool)
+ {
+ vs200x_project_vc_alink_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCALinkTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCAppVerifierTool)
+ {
+ vs200x_project_vc_app_verifier_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCAppVerifierTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCBscMakeTool)
+ {
+ vs200x_project_vc_bsc_make_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCBscMakeTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCCustomBuildTool)
+ {
+ vs200x_project_vc_custom_build_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCCustomBuildTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCFxCopTool)
+ {
+ vs200x_project_vc_fx_cop_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCFxCopTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCManagedResourceCompilerTool)
+ {
+ vs200x_project_vc_managed_resource_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCManagedResourceCompilerTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCManifestTool)
+ {
+ vs200x_project_vc_manifest_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCManifestTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCMIDLTool)
+ {
+ vs200x_project_vc_midl_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCMIDLTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCPreBuildEventTool)
+ {
+ vs200x_project_vc_pre_build_event_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCPreBuildEventTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCPreLinkEventTool)
+ {
+ vs200x_project_vc_pre_link_event_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCPreLinkEventTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCPostBuildEventTool)
+ {
+ vs200x_project_vc_post_build_event_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCPostBuildEventTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCResourceCompilerTool)
+ {
+ vs200x_project_vc_resource_compiler_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCResourceCompilerTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCWebDeploymentTool)
+ {
+ vs200x_project_vc_web_deployment_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCWebDeploymentTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCWebServiceProxyGeneratorTool)
+ {
+ vs200x_project_vc_web_service_proxy_generator_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCXDCMakeTool)
+ {
+ vs200x_project_vc_xdc_make_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCXDCMakeTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxVsProject, Vs200x_VCXMLDataGeneratorTool)
+ {
+ vs200x_project_vc_xml_data_generator_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Files section tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxVsProject, Vs200x_Files)
+ {
+ vs200x_project_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Files>\n"
+ "\t</Files>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Globals section tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxVsProject, Vs200x_Globals)
+ {
+ vs200x_project_globals(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Globals>\n"
+ "\t</Globals>\n"
+ "</VisualStudioProject>\n",
+ buffer);
+ }
+
+}
diff --git a/src/action/vs200x/tests/vs200x_tests.cpp b/src/action/vs200x/tests/vs200x_tests.cpp
index 13bf93c..f6b4073 100644
--- a/src/action/vs200x/tests/vs200x_tests.cpp
+++ b/src/action/vs200x/tests/vs200x_tests.cpp
@@ -14,32 +14,6 @@ extern "C" {
SUITE(action)
{
/**********************************************************************
- * Version identification tests
- **********************************************************************/
-
- TEST_FIXTURE(FxAction, GetTargetVersion_Returns2002_OnVs2002)
- {
- session_set_action(sess, "vs2002");
- int result = vs200x_get_target_version(sess);
- CHECK(result == 2002);
- }
-
- TEST_FIXTURE(FxAction, GetTargetVersion_Returns2003_OnVs2003)
- {
- session_set_action(sess, "vs2003");
- int result = vs200x_get_target_version(sess);
- CHECK(result == 2003);
- }
-
- TEST_FIXTURE(FxAction, GetTargetVersion_Returns2005_OnVs2005)
- {
- session_set_action(sess, "vs2005");
- int result = vs200x_get_target_version(sess);
- CHECK(result == 2005);
- }
-
-
- /**********************************************************************
* Language GUID tests
**********************************************************************/
diff --git a/src/action/vs200x/tests/vs200x_xml_tests.cpp b/src/action/vs200x/tests/vs200x_xml_tests.cpp
new file mode 100644
index 0000000..dfb3d5f
--- /dev/null
+++ b/src/action/vs200x/tests/vs200x_xml_tests.cpp
@@ -0,0 +1,159 @@
+/**
+ * \file vs200x_xml_tests.cpp
+ * \brief Automated tests for Visual Studio XML output functions.
+ * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "action/tests/action_tests.h"
+extern "C" {
+#include "action/vs200x/vs200x.h"
+}
+
+
+SUITE(action)
+{
+ /**********************************************************************
+ * Element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Element_OnLevel0)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element(sess, 0, "VisualStudioProject");
+ CHECK_EQUAL("<VisualStudioProject>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Element_OnLevel1)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element(sess, 1, "VisualStudioProject");
+ CHECK_EQUAL("\t<VisualStudioProject>\n", buffer);
+ }
+
+ /**********************************************************************
+ * Element start tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, ElementStart_OnLevel0)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element_start(sess, 0, "VisualStudioProject");
+ CHECK_EQUAL("<VisualStudioProject", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementStart_OnLevel1)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element_start(sess, 1, "VisualStudioProject");
+ CHECK_EQUAL("\t<VisualStudioProject", buffer);
+ }
+
+
+ /**********************************************************************
+ * Element end tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element_end(sess, 0, "/>");
+ CHECK_EQUAL("/>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_element_end(sess, 0, "/>");
+ CHECK_EQUAL("/>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_element_end(sess, 0, "/>");
+ CHECK_EQUAL("\n/>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_element_end(sess, 0, "/>");
+ CHECK_EQUAL("\n/>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_element_end(sess, 0, ">");
+ CHECK_EQUAL(">\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_element_end(sess, 0, ">");
+ CHECK_EQUAL(">\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_element_end(sess, 0, ">");
+ CHECK_EQUAL("\n\t>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_element_end(sess, 0, ">");
+ CHECK_EQUAL("\n\t>\n", buffer);
+ }
+
+
+ /**********************************************************************
+ * Attribute tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Attribute_OnLevel0)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_attribute(sess, 0, "ProjectType", "Visual C++");
+ CHECK_EQUAL("\n\tProjectType=\"Visual C++\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Attribute_OnLevel1)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_attribute(sess, 1, "ProjectType", "Visual C++");
+ CHECK_EQUAL("\n\t\tProjectType=\"Visual C++\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Attribute_BooleanValue_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_attribute(sess, 0, "RuntimeTypeInfo", "true");
+ CHECK_EQUAL("\n\tRuntimeTypeInfo=\"TRUE\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Attribute_BooleanValue_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_attribute(sess, 0, "RuntimeTypeInfo", "true");
+ CHECK_EQUAL("\n\tRuntimeTypeInfo=\"TRUE\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Attribute_BooleanValue_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_attribute(sess, 0, "RuntimeTypeInfo", "true");
+ CHECK_EQUAL("\n\tRuntimeTypeInfo=\"true\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Attribute_BooleanValue_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_attribute(sess, 0, "RuntimeTypeInfo", "true");
+ CHECK_EQUAL("\n\tRuntimeTypeInfo=\"true\"", buffer);
+ }
+}
diff --git a/src/action/vs200x/vs2002.c b/src/action/vs200x/vs2002.c
index 045b635..2895863 100644
--- a/src/action/vs200x/vs2002.c
+++ b/src/action/vs200x/vs2002.c
@@ -28,7 +28,33 @@ static SessionSolutionCallback SolutionCallbacks[] =
/** The VS2002 project writing process, for session_enumerate_objects() */
static SessionProjectCallback ProjectCallbacks[] =
{
- vs2002_project_create,
+ vs200x_project_create,
+ vs200x_project_encoding,
+ vs200x_project_element,
+ vs200x_project_platforms,
+ vs200x_project_tool_files,
+ session_enumerate_configurations,
+ vs200x_project_references,
+ vs200x_project_files,
+ vs200x_project_globals,
+ NULL
+};
+
+/** The VS2002 configuration writing process, for session_enumerate_configurations() */
+static SessionProjectCallback ConfigCallbacks[] =
+{
+ vs200x_project_config_element,
+ vs200x_project_vc_cl_compiler_tool,
+ vs200x_project_vc_custom_build_tool,
+ vs200x_project_vc_linker_tool,
+ vs200x_project_vc_midl_tool,
+ vs200x_project_vc_post_build_event_tool,
+ vs200x_project_vc_pre_build_event_tool,
+ vs200x_project_vc_pre_link_event_tool,
+ vs200x_project_vc_resource_compiler_tool,
+ vs200x_project_vc_web_service_proxy_generator_tool,
+ vs200x_project_vc_web_deployment_tool,
+ vs200x_project_config_end,
NULL
};
@@ -47,6 +73,6 @@ int vs2002_action(Session sess)
}
stream_writeline(Console, "Generating project files for Visual Studio 2002...");
- return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks);
+ return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks, ConfigCallbacks);
}
diff --git a/src/action/vs200x/vs2002_project.c b/src/action/vs200x/vs2002_project.c
deleted file mode 100644
index 3247958..0000000
--- a/src/action/vs200x/vs2002_project.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * \file vs2002_project.c
- * \brief Visual Studio 2002 project generation functions.
- * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
- */
-
-#include <stdlib.h>
-#include "premake.h"
-#include "vs200x.h"
-#include "vs200x_project.h"
-
-
-/**
- * Create a new output stream for a project, and make it active for subsequent writes.
- * \param sess The execution session context.
- * \param prj The current project.
- * \param strm The currently active stream; set with session_set_active_stream().
- * \returns OKAY if successful.
- */
-int vs2002_project_create(Session sess, Project prj, Stream strm)
-{
- /* create the project file */
- const char* extension = vs200x_project_file_extension(prj);
- const char* filename = project_get_filename(prj, NULL, extension);
- strm = stream_create_file(filename);
- if (!strm)
- {
- return !OKAY;
- }
-
- /* make the stream active for the functions that come after */
- session_set_active_stream(sess, strm);
- return OKAY;
-}
diff --git a/src/action/vs200x/vs2003.c b/src/action/vs200x/vs2003.c
index 8f4e6ff..75dc927 100644
--- a/src/action/vs200x/vs2003.c
+++ b/src/action/vs200x/vs2003.c
@@ -9,6 +9,7 @@
#include "action/action.h"
#include "vs200x.h"
#include "vs200x_solution.h"
+#include "vs200x_project.h"
/** The VS2003 solution writing process, for session_enumerate_objects() */
@@ -26,6 +27,34 @@ static SessionSolutionCallback SolutionCallbacks[] =
/** The VS2003 project writing process, for session_enumerate_objects() */
static SessionProjectCallback ProjectCallbacks[] =
{
+ vs200x_project_create,
+ vs200x_project_encoding,
+ vs200x_project_element,
+ vs200x_project_platforms,
+ vs200x_project_tool_files,
+ session_enumerate_configurations,
+ vs200x_project_references,
+ vs200x_project_files,
+ vs200x_project_globals,
+ NULL
+};
+
+/** The VS2003 configuration writing process, for session_enumerate_configurations() */
+static SessionProjectCallback ConfigCallbacks[] =
+{
+ vs200x_project_config_element,
+ vs200x_project_vc_cl_compiler_tool,
+ vs200x_project_vc_custom_build_tool,
+ vs200x_project_vc_linker_tool,
+ vs200x_project_vc_midl_tool,
+ vs200x_project_vc_post_build_event_tool,
+ vs200x_project_vc_pre_build_event_tool,
+ vs200x_project_vc_pre_link_event_tool,
+ vs200x_project_vc_resource_compiler_tool,
+ vs200x_project_vc_web_service_proxy_generator_tool,
+ vs200x_project_vc_xml_data_generator_tool,
+ vs200x_project_vc_web_deployment_tool,
+ vs200x_project_config_end,
NULL
};
@@ -44,5 +73,5 @@ int vs2003_action(Session sess)
}
stream_writeline(Console, "Generating project files for Visual Studio 2003...");
- return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks);
+ return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks, ConfigCallbacks);
}
diff --git a/src/action/vs200x/vs2005.c b/src/action/vs200x/vs2005.c
index bec13e9..5689438 100644
--- a/src/action/vs200x/vs2005.c
+++ b/src/action/vs200x/vs2005.c
@@ -9,6 +9,7 @@
#include "action/action.h"
#include "vs200x.h"
#include "vs200x_solution.h"
+#include "vs200x_project.h"
/** The VS2005 solution writing process, for session_enumerate_objects() */
@@ -26,6 +27,41 @@ static SessionSolutionCallback SolutionCallbacks[] =
/** The VS2005 project writing process, for session_enumerate_objects() */
static SessionProjectCallback ProjectCallbacks[] =
{
+ vs200x_project_create,
+ vs200x_project_encoding,
+ vs200x_project_element,
+ vs200x_project_platforms,
+ vs200x_project_tool_files,
+ session_enumerate_configurations,
+ vs200x_project_references,
+ vs200x_project_files,
+ vs200x_project_globals,
+ NULL
+};
+
+/** The VS2005 configuration writing process, for session_enumerate_configurations() */
+static SessionProjectCallback ConfigCallbacks[] =
+{
+ vs200x_project_config_element,
+ vs200x_project_vc_pre_build_event_tool,
+ vs200x_project_vc_custom_build_tool,
+ vs200x_project_vc_xml_data_generator_tool,
+ vs200x_project_vc_web_service_proxy_generator_tool,
+ vs200x_project_vc_midl_tool,
+ vs200x_project_vc_cl_compiler_tool,
+ vs200x_project_vc_managed_resource_compiler_tool,
+ vs200x_project_vc_resource_compiler_tool,
+ vs200x_project_vc_pre_link_event_tool,
+ vs200x_project_vc_linker_tool,
+ vs200x_project_vc_alink_tool,
+ vs200x_project_vc_manifest_tool,
+ vs200x_project_vc_xdc_make_tool,
+ vs200x_project_vc_bsc_make_tool,
+ vs200x_project_vc_fx_cop_tool,
+ vs200x_project_vc_app_verifier_tool,
+ vs200x_project_vc_web_deployment_tool,
+ vs200x_project_vc_post_build_event_tool,
+ vs200x_project_config_end,
NULL
};
@@ -44,6 +80,6 @@ int vs2005_action(Session sess)
}
stream_writeline(Console, "Generating project files for Visual Studio 2005...");
- return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks);
+ return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks, ConfigCallbacks);
}
diff --git a/src/action/vs200x/vs2008.c b/src/action/vs200x/vs2008.c
index 942cd87..8429819 100644
--- a/src/action/vs200x/vs2008.c
+++ b/src/action/vs200x/vs2008.c
@@ -9,6 +9,7 @@
#include "action/action.h"
#include "vs200x.h"
#include "vs200x_solution.h"
+#include "vs200x_project.h"
/** The VS2008 solution writing process, for session_enumerate_objects() */
@@ -26,6 +27,40 @@ static SessionSolutionCallback SolutionCallbacks[] =
/** The VS2008 project writing process, for session_enumerate_objects() */
static SessionProjectCallback ProjectCallbacks[] =
{
+ vs200x_project_create,
+ vs200x_project_encoding,
+ vs200x_project_element,
+ vs200x_project_platforms,
+ vs200x_project_tool_files,
+ session_enumerate_configurations,
+ vs200x_project_references,
+ vs200x_project_files,
+ vs200x_project_globals,
+ NULL
+};
+
+/** The VS2008 configuration writing process, for session_enumerate_configurations() */
+static SessionProjectCallback ConfigCallbacks[] =
+{
+ vs200x_project_config_element,
+ vs200x_project_vc_pre_build_event_tool,
+ vs200x_project_vc_custom_build_tool,
+ vs200x_project_vc_xml_data_generator_tool,
+ vs200x_project_vc_web_service_proxy_generator_tool,
+ vs200x_project_vc_midl_tool,
+ vs200x_project_vc_cl_compiler_tool,
+ vs200x_project_vc_managed_resource_compiler_tool,
+ vs200x_project_vc_resource_compiler_tool,
+ vs200x_project_vc_pre_link_event_tool,
+ vs200x_project_vc_linker_tool,
+ vs200x_project_vc_alink_tool,
+ vs200x_project_vc_manifest_tool,
+ vs200x_project_vc_xdc_make_tool,
+ vs200x_project_vc_bsc_make_tool,
+ vs200x_project_vc_fx_cop_tool,
+ vs200x_project_vc_app_verifier_tool,
+ vs200x_project_vc_post_build_event_tool,
+ vs200x_project_config_end,
NULL
};
@@ -44,6 +79,6 @@ int vs2008_action(Session sess)
}
stream_writeline(Console, "Generating project files for Visual Studio 2008...");
- return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks);
+ return session_enumerate_objects(sess, SolutionCallbacks, ProjectCallbacks, ConfigCallbacks);
}
diff --git a/src/action/vs200x/vs200x.c b/src/action/vs200x/vs200x.c
index af4d6db..86f55bc 100644
--- a/src/action/vs200x/vs200x.c
+++ b/src/action/vs200x/vs200x.c
@@ -13,6 +13,107 @@
/**
+ * Write an XML attribute, adjusting for the differing Visual Studio formats.
+ * \param sess The current execution session.
+ * \param level The XML element nesting level.
+ * \param name The attribute name.
+ * \param value The attribute value.
+ * \returns OKAY if successful.
+ */
+int vs200x_attribute(Session sess, int level, const char* name, const char* value, ...)
+{
+ int z;
+ va_list args;
+ Stream strm = session_get_active_stream(sess);
+
+ if (vs200x_get_target_version(sess) < 2005)
+ {
+ if (cstr_eq(value, "true"))
+ {
+ value = "TRUE";
+ }
+ else if (cstr_eq(value, "false"))
+ {
+ value = "FALSE";
+ }
+ }
+
+ va_start(args, value);
+ z = stream_writeline(strm, "");
+ z |= stream_write_n(strm, "\t", level + 1);
+ z |= stream_write(strm, "%s=\"", name);
+ z |= stream_vprintf(strm, value, args);
+ z |= stream_write(strm, "\"");
+ va_end(args);
+ return z;
+}
+
+
+/**
+ * Write out an element tag.
+ * \param sess The current execution session.
+ * \param level The XML element nesting level.
+ * \param name The element name.
+ * \returns OKAY if successful.
+ */
+int vs200x_element(Session sess, int level, const char* name)
+{
+ int z;
+ Stream strm = session_get_active_stream(sess);
+ z = stream_write_n(strm, "\t", level);
+ z |= stream_writeline(strm, "<%s>", name);
+ return z;
+}
+
+
+/**
+ * Write the ending part of an XML tag, adjust for the differing Visual Studio formats.
+ * \param sess The current execution session.
+ * \param level The XML element nesting level.
+ * \param markup The end tag markup.
+ * \returns OKAY if successful.
+ */
+int vs200x_element_end(Session sess, int level, const char* markup)
+{
+ int z;
+ Stream strm = session_get_active_stream(sess);
+ int version = vs200x_get_target_version(sess);
+ if (version >= 2005)
+ {
+ z = stream_writeline(strm, "");
+ if (markup[0] == '>')
+ {
+ level++;
+ }
+ z |= stream_write_n(strm, "\t", level);
+ z |= stream_writeline(strm, "%s", markup);
+ }
+ else
+ {
+ z = stream_writeline(strm, markup);
+ }
+ return z;
+}
+
+
+/**
+ * Write out the starting part of an XML element tag: "<MyElement".
+ * \param sess The current execution session.
+ * \param level The XML element nesting level.
+ * \param name The element name.
+ * \returns OKAY if successful.
+ */
+int vs200x_element_start(Session sess, int level, const char* name)
+{
+ int z;
+ Stream strm = session_get_active_stream(sess);
+ z = stream_write_n(strm, "\t", level);
+ z |= stream_write(strm, "<%s", name);
+ return z;
+}
+
+
+/**
* Converts the session action string to a Visual Studio version number.
* \param sess The current execution session.
* \returns The Visual Studio version number corresponding to the current action.
@@ -32,6 +133,10 @@ int vs200x_get_target_version(Session sess)
{
return 2005;
}
+ else if (cstr_eq(action, "vs2008"))
+ {
+ return 2008;
+ }
else
{
assert(0);
diff --git a/src/action/vs200x/vs200x.h b/src/action/vs200x/vs200x.h
index 6c7fcc2..dca7bdc 100644
--- a/src/action/vs200x/vs200x.h
+++ b/src/action/vs200x/vs200x.h
@@ -8,6 +8,10 @@
#include "engine/session.h"
+int vs200x_attribute(Session sess, int level, const char* name, const char* value, ...);
+int vs200x_element(Session sess, int level, const char* name);
+int vs200x_element_end(Session sess, int level, const char* markup);
+int vs200x_element_start(Session sess, int level, const char* name);
int vs200x_get_target_version(Session sess);
const char* vs200x_project_file_extension(Project prj);
const char* vs200x_tool_guid(const char* language);
diff --git a/src/action/vs200x/vs200x_config.c b/src/action/vs200x/vs200x_config.c
new file mode 100644
index 0000000..c0f6af3
--- /dev/null
+++ b/src/action/vs200x/vs200x_config.c
@@ -0,0 +1,48 @@
+/**
+ * \file vs200x_config.c
+ * \brief Visual Studio 200x configuration generation functions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "vs200x.h"
+#include "vs200x_config.h"
+
+
+int vs200x_config_character_set(Session sess)
+{
+ int version = vs200x_get_target_version(sess);
+ return vs200x_attribute(sess, 2, "CharacterSet", version > 2003 ? "1" : "2");
+}
+
+
+int vs200x_config_detect_64bit_portability(Session sess, Project prj)
+{
+ int version = vs200x_get_target_version(sess);
+ UNUSED(prj);
+ if (version < 2008)
+ {
+ return vs200x_attribute(sess, 3, "Detect64BitPortabilityProblems", "true");
+ }
+ return OKAY;
+}
+
+
+int vs200x_config_runtime_type_info(Session sess, Project prj)
+{
+ int version = vs200x_get_target_version(sess);
+ UNUSED(prj);
+ if (version < 2005)
+ {
+ return vs200x_attribute(sess, 3, "RuntimeTypeInfo", "true");
+ }
+ return OKAY;
+}
+
+
+int vs200x_config_use_precompiled_header(Session sess, Project prj)
+{
+ int version = vs200x_get_target_version(sess);
+ UNUSED(prj);
+ return vs200x_attribute(sess, 3, "UsePrecompiledHeader", (version > 2003) ? "0" : "2");
+}
diff --git a/src/action/vs200x/vs200x_config.h b/src/action/vs200x/vs200x_config.h
new file mode 100644
index 0000000..cd5c5da
--- /dev/null
+++ b/src/action/vs200x/vs200x_config.h
@@ -0,0 +1,16 @@
+/**
+ * \file vs200x_config.h
+ * \brief Visual Studio 200x configuration generation functions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+#if !defined(PREMAKE_VS200X_CONFIG_H)
+#define PREMAKE_VS200X_CONFIG_H
+
+#include "engine/session.h"
+
+int vs200x_config_character_set(Session sess);
+int vs200x_config_detect_64bit_portability(Session sess, Project prj);
+int vs200x_config_runtime_type_info(Session sess, Project prj);
+int vs200x_config_use_precompiled_header(Session sess, Project prj);
+
+#endif
diff --git a/src/action/vs200x/vs200x_project.c b/src/action/vs200x/vs200x_project.c
new file mode 100644
index 0000000..a906c24
--- /dev/null
+++ b/src/action/vs200x/vs200x_project.c
@@ -0,0 +1,408 @@
+/**
+ * \file vs200x_project.c
+ * \brief Visual Studio multiple-version project generation functions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <stdlib.h>
+#include "premake.h"
+#include "vs200x.h"
+#include "vs200x_project.h"
+#include "vs200x_config.h"
+
+
+/**
+ * Write the opening <Configuration> element and attributes.
+ */
+int vs200x_project_config_element(Session sess, Project prj, Stream strm)
+{
+ int z;
+ const char* cfg_name = project_get_configuration_filter(prj);
+
+ UNUSED(prj);
+ UNUSED(strm);
+
+ z = vs200x_element_start(sess, 2, "Configuration");
+ z |= vs200x_attribute(sess, 2, "Name", "%s|Win32", cfg_name);
+ z |= vs200x_attribute(sess, 2, "OutputDirectory", "$(SolutionDir)$(ConfigurationName)");
+ z |= vs200x_attribute(sess, 2, "IntermediateDirectory", "$(ConfigurationName)");
+ z |= vs200x_attribute(sess, 2, "ConfigurationType", "1");
+ z |= vs200x_config_character_set(sess);
+ z |= vs200x_element_end(sess, 2, ">");
+ return z;
+}
+
+
+/**
+ * Write the closing <Configuration> element.
+ */
+int vs200x_project_config_end(Session sess, Project prj, Stream strm)
+{
+ UNUSED(prj);
+ UNUSED(strm);
+ return vs200x_element(sess, 2, "/Configuration");
+}
+
+
+/**
+ * Create a new output stream for a project, and make it active for subsequent writes.
+ */
+int vs200x_project_create(Session sess, Project prj, Stream strm)
+{
+ /* create the project file */
+ const char* extension = vs200x_project_file_extension(prj);
+ const char* filename = project_get_filename(prj, NULL, extension);
+ strm = stream_create_file(filename);
+ if (!strm)
+ {
+ return !OKAY;
+ }
+
+ /* make the stream active for the functions that come after */
+ session_set_active_stream(sess, strm);
+ return OKAY;
+}
+
+
+/**
+ * Write the root <VisualStudioProject> element and attributes.
+ */
+int vs200x_project_element(Session sess, Project prj, Stream strm)
+{
+ int version, z;
+ const char* prj_ver;
+ const char* prj_name = project_get_name(prj);
+ const char* prj_guid = project_get_guid(prj);
+
+ UNUSED(strm);
+
+ version = vs200x_get_target_version(sess);
+ switch (version)
+ {
+ default:
+ prj_ver = "7.00"; break;
+ case 2003:
+ prj_ver = "7.10"; break;
+ case 2005:
+ prj_ver = "8.00"; break;
+ case 2008:
+ prj_ver = "9.00"; break;
+ }
+
+ z = vs200x_element_start(sess, 0, "VisualStudioProject");
+ z |= vs200x_attribute(sess, 0, "ProjectType", "Visual C++");
+ z |= vs200x_attribute(sess, 0, "Version", prj_ver);
+ z |= vs200x_attribute(sess, 0, "Name", prj_name);
+ z |= vs200x_attribute(sess, 0, "ProjectGUID", "{%s}", prj_guid);
+ if (version > 2003)
+ {
+ z |= vs200x_attribute(sess, 0, "RootNamespace", prj_name);
+ }
+ z |= vs200x_attribute(sess, 0, "Keyword", "Win32Proj");
+ if (version > 2005)
+ {
+ z |= vs200x_attribute(sess, 0, "TargetFrameworkVersion", "196613");
+ }
+ z |= vs200x_element_end(sess, 0, ">");
+ return z;
+}
+
+
+/**
+ * Write the file encoding at the start of the project file.
+ */
+int vs200x_project_encoding(Session sess, Project prj, Stream strm)
+{
+ UNUSED(sess);
+ UNUSED(prj);
+ stream_set_newline(strm, "\r\n");
+ return stream_writeline(strm, "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>");
+}
+
+
+/**
+ * Write out the <Files> element.
+ */
+int vs200x_project_files(Session sess, Project prj, Stream strm)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element(sess, 1, "Files");
+ z |= vs200x_element(sess, 1, "/Files");
+ return z;
+}
+
+
+/**
+ * Write out the <Globals> element.
+ */
+int vs200x_project_globals(Session sess, Project prj, Stream strm)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element(sess, 1, "Globals");
+ z |= vs200x_element(sess, 1, "/Globals");
+ z |= vs200x_element(sess, 0, "/VisualStudioProject");
+ return z;
+}
+
+
+/**
+ * Write out the platforms section of a project file.
+ */
+int vs200x_project_platforms(Session sess, Project prj, Stream strm)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element(sess, 1, "Platforms");
+ z |= vs200x_element_start(sess, 2, "Platform");
+ z |= vs200x_attribute(sess, 2, "Name", "Win32");
+ z |= vs200x_element_end(sess, 2, "/>");
+ z |= vs200x_element(sess, 1, "/Platforms");
+ return OKAY;
+}
+
+
+/**
+ * Write out the <References> element and attributes.
+ */
+int vs200x_project_references(Session sess, Project prj, Stream strm)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element(sess, 1, "/Configurations");
+ if (vs200x_get_target_version(sess) > 2002)
+ {
+ z |= vs200x_element(sess, 1, "References");
+ z |= vs200x_element(sess, 1, "/References");
+ }
+ return z;
+}
+
+
+/**
+ * Write out the <ToolFiles> section of a Visual Studio project.
+ */
+int vs200x_project_tool_files(Session sess, Project prj, Stream strm)
+{
+ int version, z = OKAY;
+ UNUSED(prj);
+ UNUSED(strm);
+
+ version = vs200x_get_target_version(sess);
+ if (version > 2003)
+ {
+ z |= vs200x_element(sess, 1, "ToolFiles");
+ z |= vs200x_element(sess, 1, "/ToolFiles");
+ }
+ z |= vs200x_element(sess, 1, "Configurations");
+ return z;
+}
+
+
+/**
+ * Common function to write an empty <Tool> element.
+ */
+static int vs200x_project_vc_empty_tool(Session sess, Project prj, Stream strm, const char* name)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element_start(sess, 3, "Tool");
+ z |= vs200x_attribute(sess, 3, "Name", name);
+ z |= vs200x_element_end(sess, 3, "/>");
+ return z;
+}
+
+
+/**
+ * Write the VCALinkTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_alink_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCALinkTool");
+}
+
+
+/**
+ * Write the VCAppVerifierTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_app_verifier_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCAppVerifierTool");
+}
+
+
+/**
+ * Write the VCBscMakeTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_bsc_make_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCBscMakeTool");
+}
+
+
+/**
+ * Write the VCCLCompilerTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_cl_compiler_tool(Session sess, Project prj, Stream strm)
+{
+ int version, z;
+ UNUSED(prj);
+ UNUSED(strm);
+ version = vs200x_get_target_version(sess);
+ z = vs200x_element_start(sess, 3, "Tool");
+ z |= vs200x_attribute(sess, 3, "Name", "VCCLCompilerTool");
+ z |= vs200x_attribute(sess, 3, "Optimization", "0");
+ z |= vs200x_attribute(sess, 3, "MinimalRebuild", "true");
+ z |= vs200x_attribute(sess, 3, "BasicRuntimeChecks", "3");
+ z |= vs200x_attribute(sess, 3, "RuntimeLibrary", "3");
+ z |= vs200x_config_runtime_type_info(sess, prj);
+ z |= vs200x_config_use_precompiled_header(sess, prj);
+ z |= vs200x_attribute(sess, 3, "WarningLevel", "3");
+ z |= vs200x_config_detect_64bit_portability(sess, prj);
+ z |= vs200x_attribute(sess, 3, "DebugInformationFormat", "4");
+ z |= vs200x_element_end(sess, 3, "/>");
+ return z;
+}
+
+
+/**
+ * Write the VCCustomBuildTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_custom_build_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCCustomBuildTool");
+}
+
+
+/**
+ * Write the VCFxCopTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_fx_cop_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCFxCopTool");
+}
+
+
+/**
+ * Write the VCLinkerTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_linker_tool(Session sess, Project prj, Stream strm)
+{
+ int z;
+ UNUSED(prj);
+ UNUSED(strm);
+ z = vs200x_element_start(sess, 3, "Tool");
+ z |= vs200x_attribute(sess, 3, "Name", "VCLinkerTool");
+ z |= vs200x_attribute(sess, 3, "LinkIncremental", "2");
+ z |= vs200x_attribute(sess, 3, "GenerateDebugInformation", "true");
+ z |= vs200x_attribute(sess, 3, "SubSystem", "1");
+ z |= vs200x_attribute(sess, 3, "EntryPointSymbol", "mainCRTStartup");
+ z |= vs200x_attribute(sess, 3, "TargetMachine", "1");
+ z |= vs200x_element_end(sess, 3, "/>");
+ return z;
+}
+
+
+/**
+ * Write the VCManagedResourceCompilerTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_managed_resource_compiler_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCManagedResourceCompilerTool");
+}
+
+
+/**
+ * Write the VCManifestTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_manifest_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCManifestTool");
+}
+
+
+/**
+ * Write the VCMIDLTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_midl_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCMIDLTool");
+}
+
+
+/**
+ * Write the VCPreBuildEventTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_pre_build_event_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPreBuildEventTool");
+}
+
+
+/**
+ * Write the VCPreLinkEventTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_pre_link_event_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPreLinkEventTool");
+}
+
+
+/**
+ * Write the VCPostBuildEventTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_post_build_event_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPostBuildEventTool");
+}
+
+
+/**
+ * Write the VCResourceCompiler <Tool> element and attributes.
+ */
+int vs200x_project_vc_resource_compiler_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCResourceCompilerTool");
+}
+
+
+/**
+ * Write the VCWebDeploymentTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_web_deployment_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCWebDeploymentTool");
+}
+
+
+/**
+ * Write the VCWebServiceProxyGeneratorTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_web_service_proxy_generator_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCWebServiceProxyGeneratorTool");
+}
+
+
+/**
+ * Write the VCXDCMakeTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_xdc_make_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCXDCMakeTool");
+}
+
+
+/**
+ * Write the VCXMLDataGeneratorTool <Tool> element and attributes.
+ */
+int vs200x_project_vc_xml_data_generator_tool(Session sess, Project prj, Stream strm)
+{
+ return vs200x_project_vc_empty_tool(sess, prj, strm, "VCXMLDataGeneratorTool");
+}
diff --git a/src/action/vs200x/vs200x_project.h b/src/action/vs200x/vs200x_project.h
index 6b1737d..276a48f 100644
--- a/src/action/vs200x/vs200x_project.h
+++ b/src/action/vs200x/vs200x_project.h
@@ -8,6 +8,33 @@
#include "engine/session.h"
-int vs2002_project_create(Session sess, Project prj, Stream strm);
+int vs200x_project_config_element(Session sess, Project prj, Stream strm);
+int vs200x_project_config_end(Session sess, Project prj, Stream strm);
+int vs200x_project_create(Session sess, Project prj, Stream strm);
+int vs200x_project_element(Session sess, Project prj, Stream strm);
+int vs200x_project_encoding(Session sess, Project prj, Stream strm);
+int vs200x_project_files(Session sess, Project prj, Stream strm);
+int vs200x_project_globals(Session sess, Project prj, Stream strm);
+int vs200x_project_platforms(Session sess, Project prj, Stream strm);
+int vs200x_project_references(Session sess, Project prj, Stream strm);
+int vs200x_project_tool_files(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_alink_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_app_verifier_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_bsc_make_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_cl_compiler_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_custom_build_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_fx_cop_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_midl_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_linker_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_managed_resource_compiler_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_manifest_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_pre_build_event_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_pre_link_event_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_post_build_event_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_resource_compiler_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_web_deployment_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_web_service_proxy_generator_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_xdc_make_tool(Session sess, Project prj, Stream strm);
+int vs200x_project_vc_xml_data_generator_tool(Session sess, Project prj, Stream strm);
#endif
diff --git a/src/base/stream.c b/src/base/stream.c
index dfc3139..b93a517 100644
--- a/src/base/stream.c
+++ b/src/base/stream.c
@@ -5,7 +5,6 @@
*/
#include <assert.h>
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -196,7 +195,14 @@ int stream_writeline_strings(Stream strm, Strings strs, const char* start, const
}
-static int stream_vprintf(Stream strm, const char* value, va_list args)
+/**
+ * Format and print a string using printf-style codes and a variable argument list.
+ * \param strm The stream to which to write.
+ * \param value The value to print; may contain printf-style formatting codes.
+ * \param args A variable argument list to populate the printf-style codes in `value`.
+ * \returns OKAY if successful.
+ */
+int stream_vprintf(Stream strm, const char* value, va_list args)
{
if (strm->buffer)
{
@@ -236,6 +242,24 @@ int stream_write(Stream strm, const char* value, ...)
/**
+ * Write N copies of a string to a stream.
+ * \param strm The stream to which to write.
+ * \param value The string to write.
+ * \param n The number of copies to write.
+ * \returns OKAY if successful.
+ */
+int stream_write_n(Stream strm, const char* value, int n)
+{
+ int i, z = OKAY;
+ for (i = 0; i < n; ++i)
+ {
+ z |= stream_write(strm, value);
+ }
+ return z;
+}
+
+
+/**
* Writes the Unicode encoding marker sequence into the stream.
* \param strm The stream to which to write.
*/
diff --git a/src/base/stream.h b/src/base/stream.h
index 595cd7d..47c0a93 100644
--- a/src/base/stream.h
+++ b/src/base/stream.h
@@ -6,6 +6,7 @@
#if !defined(PREMAKE_STREAM_H)
#define PREMAKE_STREAM_H
+#include <stdarg.h>
#include "strings.h"
DECLARE_CLASS(Stream);
@@ -17,7 +18,9 @@ Stream stream_create_null(void);
void stream_destroy(Stream stream);
void stream_set_buffer(Stream strm, char* buffer);
void stream_set_newline(Stream strm, const char* newline);
+int stream_vprintf(Stream strm, const char* value, va_list args);
int stream_write(Stream strm, const char* value, ...);
+int stream_write_n(Stream strm, const char* value, int n);
int stream_write_strings(Stream strm, Strings strs, const char* start, const char* prefix, const char* postfix, const char* infix, const char* end);
int stream_write_unicode_marker(Stream strm);
int stream_writeline(Stream strm, const char* value, ...);
diff --git a/src/base/tests/xml_tests.cpp b/src/base/tests/xml_tests.cpp
new file mode 100644
index 0000000..1131382
--- /dev/null
+++ b/src/base/tests/xml_tests.cpp
@@ -0,0 +1,64 @@
+/**
+ * \file xml_tests.cpp
+ * \brief XML output tests.
+ * \author Copyright (c) 2007-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "testing/testing.h"
+extern "C" {
+#include "base/stream.h"
+#include "base/xml.h"
+}
+
+struct FxXml
+{
+ Stream strm;
+ Xml xml;
+ char buffer[1024];
+
+ FxXml()
+ {
+ strm = stream_create_null();
+ stream_set_buffer(strm, buffer);
+
+ xml = xml_create(strm);
+ }
+
+ ~FxXml()
+ {
+ xml_destroy(xml);
+ stream_destroy(strm);
+ }
+};
+
+
+SUITE(base)
+{
+ TEST_FIXTURE(FxXml, EndElement_Short)
+ {
+ xml_element_start(xml, "MyElement");
+ xml_element_end(xml, "MyElement");
+ CHECK_EQUAL("<MyElement/>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxXml, EndElement_Full)
+ {
+ xml_element_start(xml, "MyElement");
+ xml_element_end_full(xml, "MyElement");
+ CHECK_EQUAL("<MyElement>\n</MyElement>\n", buffer);
+ }
+
+ TEST_FIXTURE(FxXml, ElementNesting_OneDeep)
+ {
+ xml_element_start(xml, "Element0");
+ xml_element_start(xml, "Element1");
+ xml_element_end(xml, "Element1");
+ xml_element_end(xml, "Element0");
+ CHECK_EQUAL(
+ "<Element0>\n"
+ "\t<Element1/>\n"
+ "</Element0>\n",
+ buffer);
+ }
+} \ No newline at end of file
diff --git a/src/base/xml.c b/src/base/xml.c
new file mode 100644
index 0000000..2d09f4a
--- /dev/null
+++ b/src/base/xml.c
@@ -0,0 +1,120 @@
+/**
+ * \file xml.c
+ * \brief XML output handling.
+ * \author Copyright (c) 2007-2008 Jason Perkins and the Premake project
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include "premake.h"
+#include "xml.h"
+
+
+DEFINE_CLASS(Xml)
+{
+ Stream strm;
+ int element_depth;
+ int has_children;
+};
+
+
+/**
+ * Create a new XML output object around a stream.
+ * \param strm The stream to which to write XML output.
+ * \returns A new XML output object.
+ */
+Xml xml_create(Stream strm)
+{
+ Xml xml;
+ assert(strm);
+ xml = ALLOC_CLASS(Xml);
+ xml->strm = strm;
+ xml->element_depth = 0;
+ xml->has_children = 0;
+ return xml;
+}
+
+
+/**
+ * Destroy an XML output object and release the associated memory. The stream associated
+ * with the object is left intact, and not closed or destroyed.
+ * \param xml The XML output object to destroy.
+ */
+void xml_destroy(Xml xml)
+{
+ assert(xml);
+ free(xml);
+}
+
+
+/**
+ * Close the current element tag.
+ * \param xml The XML output object.
+ * \param element_name The name of the element being ended.
+ * \returns OKAY if successful.
+ */
+int xml_element_end(Xml xml, const char* element_name)
+{
+ int z = OKAY;
+
+ assert(xml);
+ assert(element_name);
+
+ if (xml->has_children)
+ {
+ z |= stream_writeline(xml->strm, "</%s>", element_name);
+ }
+ else
+ {
+ z |= stream_writeline(xml->strm, "/>");
+ }
+
+ xml->element_depth--;
+ xml->has_children = 1;
+ return z;
+}
+
+
+/**
+ * Close the current element tag, using the full (</ElementName>) form.
+ * \param xml The XML output object.
+ * \param element_name The name of the element being ended.
+ * \returns OKAY if successful.
+ */
+int xml_element_end_full(Xml xml, const char* element_name)
+{
+ int z;
+ assert(xml);
+ z = stream_writeline(xml->strm, ">");
+ z |= stream_writeline(xml->strm, "</%s>", element_name);
+ return z;
+}
+
+
+/**
+ * Start writing a new element tag.
+ * \param xml The XML output object.
+ * \param element_name The name of the new element.
+ * \returns OKAY if successful.
+ */
+int xml_element_start(Xml xml, const char* element_name)
+{
+ int i, z = OKAY;
+
+ assert(xml);
+ assert(element_name);
+
+ if (xml->element_depth > 0)
+ {
+ z |= stream_writeline(xml->strm, ">");
+ }
+
+ for (i = 0; i < xml->element_depth; ++i)
+ {
+ z |= stream_write(xml->strm, "\t");
+ }
+
+ xml->element_depth++;
+ z |= stream_write(xml->strm, "<%s", element_name);
+ return z;
+}
diff --git a/src/base/xml.h b/src/base/xml.h
new file mode 100644
index 0000000..ed1d1d8
--- /dev/null
+++ b/src/base/xml.h
@@ -0,0 +1,19 @@
+/**
+ * \file xml.h
+ * \brief XML output handling.
+ * \author Copyright (c) 2007-2008 Jason Perkins and the Premake project
+ */
+#if !defined(PREMAKE_XML_H)
+#define PREMAKE_XML_H
+
+#include "base/stream.h"
+
+DECLARE_CLASS(Xml);
+
+Xml xml_create(Stream strm);
+void xml_destroy(Xml xml);
+int xml_element_end(Xml xml, const char* element_name);
+int xml_element_end_full(Xml xml, const char* element_name);
+int xml_element_start(Xml xml, const char* element_name);
+
+#endif
diff --git a/src/engine/session.c b/src/engine/session.c
index 93fd02a..c1129d1 100644
--- a/src/engine/session.c
+++ b/src/engine/session.c
@@ -121,30 +121,85 @@ void session_add_solution(Session sess, Solution sln)
/**
- * Iterate the project objects contained by the session and hand them off to handler callbacks.
+ * A bit of black magic: this function acts as a special token for the project handler
+ * function list to indicate where configurations should appear. For more details, see
+ * the implementation of session_enumerate_objects().
* \param sess The session object.
- * \param sln_funcs A per-solution object callback.
- * \param prj_funcs A per-project object callback.
+ * \param prj The target project.
+ * \param strm The currently active output stream.
+ * \returns OKAY.
+ */
+int session_enumerate_configurations(Session sess, Project prj, Stream strm)
+{
+ UNUSED(sess);
+ UNUSED(prj);
+ UNUSED(strm);
+ return OKAY;
+}
+
+
+/**
+ * Iterate the project objects contained by the session and hand them off to handler callbacks.
+ * \param sess The session object.
+ * \param sln_funcs A list of per-solution object callbacks.
+ * \param prj_funcs A list of per-project object callbacks.
+ * \param cfg_funcs A list of per-configuration callbacks.
* \returns OKAY if successful.
*/
-int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs)
+int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs, SessionProjectCallback* cfg_funcs)
{
- int si;
+ int si, sn;
int result = OKAY;
assert(sess);
assert(sln_funcs);
assert(prj_funcs);
+ assert(cfg_funcs);
- prj_funcs = 0;
-
- for (si = 0; si < session_num_solutions(sess); ++si)
+ /* enumerate solutions */
+ sn = session_num_solutions(sess);
+ for (si = 0; si < sn; ++si)
{
- int sfi;
+ /* call all solution functions */
+ int fi, pi, pn;
Solution sln = session_get_solution(sess, si);
- for (sfi = 0; result == OKAY && sln_funcs[sfi] != NULL; ++sfi)
+ for (fi = 0; result == OKAY && sln_funcs[fi] != NULL; ++fi)
{
- result = sln_funcs[sfi](sess, sln, sess->active_stream);
+ result = sln_funcs[fi](sess, sln, sess->active_stream);
+ }
+
+ /* enumerate projects */
+ pn = solution_num_projects(sln);
+ for (pi = 0; pi < pn; ++pi)
+ {
+ Project prj = solution_get_project(sln, pi);
+ for (fi = 0; result == OKAY && prj_funcs[fi]; ++fi)
+ {
+ /* A bit of black magic here - I use the "session_enumerate_configurations"
+ * token to indicate where the list of configurations should appear in the
+ * project file. */
+ if (prj_funcs[fi] == session_enumerate_configurations)
+ {
+ int ci, cn;
+ cn = solution_num_configs(sln);
+ for (ci = 0; result == OKAY && ci < cn; ++ci)
+ {
+ int cfi;
+ const char* cfg_name = solution_get_config_name(sln, ci);
+ project_set_configuration_filter(prj, cfg_name);
+
+ /* enumerate configurations */
+ for (cfi = 0; result == OKAY && cfg_funcs[cfi]; ++cfi)
+ {
+ result = cfg_funcs[cfi](sess, prj, sess->active_stream);
+ }
+ }
+ }
+ else
+ {
+ result = prj_funcs[fi](sess, prj, sess->active_stream);
+ }
+ }
}
}
@@ -176,6 +231,18 @@ const char* session_get_action(Session sess)
/**
+ * Retrieve the currently active output stream.
+ * \param sess The session object.
+ * \return The currently active stream, or NULL if no stream is active.
+ */
+Stream session_get_active_stream(Session sess)
+{
+ assert(sess);
+ return sess->active_stream;
+}
+
+
+/**
* Retrieve the Lua engine state for this session; used for internal testing.
*/
lua_State* session_get_lua_state(Session sess)
diff --git a/src/engine/session.h b/src/engine/session.h
index a3b7a9f..df58553 100644
--- a/src/engine/session.h
+++ b/src/engine/session.h
@@ -59,8 +59,10 @@ typedef struct struct_SessionAction
Session session_create(void);
void session_destroy(Session sess);
void session_add_solution(Session sess, Solution sln);
-int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs);
+int session_enumerate_configurations(Session sess, Project prj, Stream strm);
+int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs, SessionProjectCallback* cfg_funcs);
const char* session_get_action(Session sess);
+Stream session_get_active_stream(Session sess);
Solution session_get_solution(Session sess, int index);
int session_num_solutions(Session sess);
const char* session_run_file(Session sess, const char* filename);
diff --git a/src/engine/tests/session_tests.cpp b/src/engine/tests/session_tests.cpp
index f8f0a29..34553af 100644
--- a/src/engine/tests/session_tests.cpp
+++ b/src/engine/tests/session_tests.cpp
@@ -17,20 +17,44 @@ extern "C" {
static int num_solution_calls;
static int num_project_calls;
+static int num_config_calls;
+static const char* last_config_filter;
+
static int test_solution_okay(Session sess, Solution sln, Stream strm)
{
- sess = NULL; sln = NULL; strm = NULL;
+ UNUSED(sess); UNUSED(sln); UNUSED(strm);
num_solution_calls++;
return OKAY;
}
static int test_solution_fail(Session sess, Solution sln, Stream strm)
{
- sess = NULL; sln = NULL; strm = NULL;
+ UNUSED(sess); UNUSED(sln); UNUSED(strm);
return !OKAY;
}
+static int test_project_okay(Session sess, Project prj, Stream strm)
+{
+ UNUSED(sess); UNUSED(prj); UNUSED(strm);
+ num_project_calls++;
+ return OKAY;
+}
+
+static int test_project_fail(Session sess, Project prj, Stream strm)
+{
+ UNUSED(sess); UNUSED(prj); UNUSED(strm);
+ return !OKAY;
+}
+
+static int test_config_okay(Session sess, Project prj, Stream strm)
+{
+ UNUSED(sess); UNUSED(strm);
+ num_config_calls++;
+ last_config_filter = project_get_configuration_filter(prj);
+ return OKAY;
+}
+
struct FxSession
{
@@ -43,6 +67,8 @@ struct FxSession
sess = session_create();
num_solution_calls = 0;
num_project_calls = 0;
+ num_config_calls = 0;
+ last_config_filter = NULL;
}
~FxSession()
@@ -167,7 +193,8 @@ SUITE(session)
{
SessionSolutionCallback sln_funcs[] = { NULL };
SessionProjectCallback prj_funcs[] = { NULL };
- int result = session_enumerate_objects(sess, sln_funcs, prj_funcs);
+ SessionProjectCallback cfg_funcs[] = { NULL };
+ int result = session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
CHECK(result == OKAY);
}
@@ -175,8 +202,9 @@ SUITE(session)
{
SessionSolutionCallback sln_funcs[] = { test_solution_okay, test_solution_okay, NULL };
SessionProjectCallback prj_funcs[] = { NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
AddSolution();
- session_enumerate_objects(sess, sln_funcs, prj_funcs);
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
CHECK(num_solution_calls == 2);
}
@@ -184,9 +212,10 @@ SUITE(session)
{
SessionSolutionCallback sln_funcs[] = { test_solution_okay, NULL };
SessionProjectCallback prj_funcs[] = { NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
AddSolution();
AddSolution();
- session_enumerate_objects(sess, sln_funcs, prj_funcs);
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
CHECK(num_solution_calls == 2);
}
@@ -194,8 +223,9 @@ SUITE(session)
{
SessionSolutionCallback sln_funcs[] = { test_solution_fail, NULL };
SessionProjectCallback prj_funcs[] = { NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
AddSolution();
- int result = session_enumerate_objects(sess, sln_funcs, prj_funcs);
+ int result = session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
CHECK(result != OKAY);
}
@@ -203,12 +233,83 @@ SUITE(session)
{
SessionSolutionCallback sln_funcs[] = { test_solution_fail, test_solution_okay, NULL };
SessionProjectCallback prj_funcs[] = { NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
AddSolution();
AddSolution();
- session_enumerate_objects(sess, sln_funcs, prj_funcs);
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
CHECK(num_solution_calls == 0);
}
+ TEST_FIXTURE(FxSession, Enumerate_CallsAllProjectFuncs_OnProject)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { test_project_okay, test_project_okay, NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
+ AddSolution();
+ AddProject();
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK(num_project_calls == 2);
+ }
+
+ TEST_FIXTURE(FxSession, Enumerate_CallsProjectFunc_OnEachProject)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { test_project_okay, NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
+ AddSolution();
+ AddProject();
+ AddProject();
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK(num_project_calls == 2);
+ }
+
+ TEST_FIXTURE(FxSession, Enumerate_ReturnsNotOkay_OnProjectError)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { test_project_fail, NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
+ AddSolution();
+ AddProject();
+ int result = session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK(result != OKAY);
+ }
+
+ TEST_FIXTURE(FxSession, Enumerate_StopsProcessing_OnProjectError)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { test_project_fail, test_project_okay, NULL };
+ SessionProjectCallback cfg_funcs[] = { NULL };
+ AddSolution();
+ AddProject();
+ AddProject();
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK(num_project_calls == 0);
+ }
+
+ TEST_FIXTURE(FxSession, Enumerate_CallsAllConfigFuncs_OnConfig)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { session_enumerate_configurations, NULL };
+ SessionProjectCallback cfg_funcs[] = { test_config_okay, test_config_okay, NULL };
+ AddSolution();
+ AddProject();
+ solution_add_config_name(sln, "Debug");
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK(num_config_calls == 2);
+ }
+
+ TEST_FIXTURE(FxSession, Enumerate_SetsConfigFilter_OnConfig)
+ {
+ SessionSolutionCallback sln_funcs[] = { NULL };
+ SessionProjectCallback prj_funcs[] = { session_enumerate_configurations, NULL };
+ SessionProjectCallback cfg_funcs[] = { test_config_okay, test_config_okay, NULL };
+ AddSolution();
+ AddProject();
+ solution_add_config_name(sln, "Debug");
+ session_enumerate_objects(sess, sln_funcs, prj_funcs, cfg_funcs);
+ CHECK_EQUAL("Debug", last_config_filter);
+ }
+
/**********************************************************************
* Unload tests - most unload testing is done elsewhere
diff --git a/src/project/project.c b/src/project/project.c
index 151dacd..d6806f3 100644
--- a/src/project/project.c
+++ b/src/project/project.c
@@ -28,6 +28,7 @@ struct FieldInfo ProjectFieldInfo[] =
DEFINE_CLASS(Project)
{
Fields fields;
+ const char* config_filter;
};
@@ -39,6 +40,7 @@ Project project_create()
{
Project prj = ALLOC_CLASS(Project);
prj->fields = fields_create(ProjectFieldInfo);
+ prj->config_filter = NULL;
return prj;
}
@@ -68,6 +70,19 @@ const char* project_get_base_dir(Project prj)
/**
+ * Retrieve the current configuration filter. All subsequent requests for configuration
+ * values will return settings from this configuration only.
+ * \param prj The project object to query.
+ * \returns The current configuration filter, or NULL if no filter has been set.
+ */
+const char* project_get_configuration_filter(Project prj)
+{
+ assert(prj);
+ return prj->config_filter;
+}
+
+
+/**
* Get the path to the project output file, using the provided file extension.
* \param prj The project object to query.
* \param basename The base filename; if NULL the project name will be used.
@@ -186,6 +201,19 @@ void project_set_base_dir(Project prj, const char* base_dir)
/**
+ * Set the current configuration filter. All subsequent requests for configuration
+ * values will return settings from this configuration only.
+ * \param prj The project object to query.
+ * \param cfg_name The name of the configuration on which to filter.
+ */
+void project_set_configuration_filter(Project prj, const char* cfg_name)
+{
+ assert(prj);
+ prj->config_filter = cfg_name;
+}
+
+
+/**
* Set the GUID associated with a project. The GUID is required by the Visual
* Studio generators, and must be unique per project.
* \param prj The project to modify.
diff --git a/src/project/project.h b/src/project/project.h
index 6cd4a0c..b25425c 100644
--- a/src/project/project.h
+++ b/src/project/project.h
@@ -32,6 +32,7 @@ Project project_create(void);
void project_destroy(Project prj);
const char* project_get_base_dir(Project prj);
+const char* project_get_configuration_filter(Project prj);
const char* project_get_filename(Project prj, const char* basename, const char* ext);
const char* project_get_guid(Project prj);
const char* project_get_language(Project prj);
@@ -40,6 +41,7 @@ const char* project_get_name(Project prj);
const char* project_get_value(Project prj, enum ProjectField field);
int project_is_valid_language(const char* language);
void project_set_base_dir(Project prj, const char* base_dir);
+void project_set_configuration_filter(Project prj, const char* cfg_name);
void project_set_guid(Project prj, const char* guid);
void project_set_language(Project prj, const char* language);
void project_set_location(Project prj, const char* location);
diff --git a/src/project/tests/project_tests.cpp b/src/project/tests/project_tests.cpp
index 76473ea..29dce46 100644
--- a/src/project/tests/project_tests.cpp
+++ b/src/project/tests/project_tests.cpp
@@ -85,6 +85,24 @@ SUITE(project)
/**********************************************************************
+ * Configuration filter tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxProject, ConfigurationFilter_ReturnsNull_OnStartup)
+ {
+ const char* result = project_get_configuration_filter(prj);
+ CHECK(result == NULL);
+ }
+
+ TEST_FIXTURE(FxProject, ConfigurationFilter_CanRoundtrip)
+ {
+ project_set_configuration_filter(prj, "Debug");
+ const char* result = project_get_configuration_filter(prj);
+ CHECK_EQUAL("Debug", result);
+ }
+
+
+ /**********************************************************************
* GUID tests
**********************************************************************/