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--samples/vs2005/CppExe/CppExe.vcproj52
-rw-r--r--src/action/action.h57
-rw-r--r--src/action/make/make_solution.c34
-rw-r--r--src/action/make/make_solution.h20
-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.cpp294
-rw-r--r--src/actions/actions.c20
-rw-r--r--src/actions/actions.h31
-rw-r--r--src/actions/make/gmake.c (renamed from src/action/make/gmake.c)14
-rw-r--r--src/actions/make/gmake_project.c (renamed from src/action/make/gmake_project.c)0
-rw-r--r--src/actions/make/gmake_solution.c19
-rw-r--r--src/actions/make/make.c (renamed from src/action/make/make.c)0
-rw-r--r--src/actions/make/make.h (renamed from src/action/make/make.h)0
-rw-r--r--src/actions/make/make_project.c (renamed from src/action/make/make_project.c)17
-rw-r--r--src/actions/make/make_project.h (renamed from src/action/make/make_project.h)0
-rw-r--r--src/actions/make/make_solution.c (renamed from src/action/make/gmake_solution.c)105
-rw-r--r--src/actions/make/make_solution.h19
-rw-r--r--src/actions/make/tests/make_config_tests.cpp142
-rw-r--r--src/actions/make/tests/make_project_tests.cpp (renamed from src/action/make/tests/gmake_project_tests.cpp)91
-rw-r--r--src/actions/make/tests/make_solution_tests.cpp (renamed from src/action/make/tests/gmake_solution_tests.cpp)39
-rw-r--r--src/actions/make/tests/make_tests.cpp (renamed from src/action/make/tests/make_tests.cpp)2
-rw-r--r--src/actions/support/sourcetree.c (renamed from src/action/action.c)53
-rw-r--r--src/actions/support/sourcetree.h38
-rw-r--r--src/actions/tests/action_tests.h (renamed from src/action/tests/action_tests.h)22
-rw-r--r--src/actions/vs200x/tests/vs2002_solution_tests.cpp (renamed from src/action/vs200x/tests/vs2002_solution_tests.cpp)4
-rw-r--r--src/actions/vs200x/tests/vs2003_solution_tests.cpp (renamed from src/action/vs200x/tests/vs2003_solution_tests.cpp)4
-rw-r--r--src/actions/vs200x/tests/vs2005_solution_tests.cpp (renamed from src/action/vs200x/tests/vs2005_solution_tests.cpp)4
-rw-r--r--src/actions/vs200x/tests/vs2008_solution_tests.cpp (renamed from src/action/vs200x/tests/vs2008_solution_tests.cpp)4
-rw-r--r--src/actions/vs200x/tests/vs200x_compiler_tests.cpp102
-rw-r--r--src/actions/vs200x/tests/vs200x_config_tests.cpp67
-rw-r--r--src/actions/vs200x/tests/vs200x_linker_tests.cpp80
-rw-r--r--src/actions/vs200x/tests/vs200x_project_tests.cpp467
-rw-r--r--src/actions/vs200x/tests/vs200x_tests.cpp (renamed from src/action/vs200x/tests/vs200x_tests.cpp)11
-rw-r--r--src/actions/vs200x/tests/vs200x_xml_tests.cpp (renamed from src/action/vs200x/tests/vs200x_xml_tests.cpp)30
-rw-r--r--src/actions/vs200x/vs2002.c (renamed from src/action/vs200x/vs2002.c)2
-rw-r--r--src/actions/vs200x/vs2002_solution.c (renamed from src/action/vs200x/vs2002_solution.c)0
-rw-r--r--src/actions/vs200x/vs2003.c (renamed from src/action/vs200x/vs2003.c)2
-rw-r--r--src/actions/vs200x/vs2003_solution.c (renamed from src/action/vs200x/vs2003_solution.c)0
-rw-r--r--src/actions/vs200x/vs2005.c (renamed from src/action/vs200x/vs2005.c)2
-rw-r--r--src/actions/vs200x/vs2005_solution.c (renamed from src/action/vs200x/vs2005_solution.c)0
-rw-r--r--src/actions/vs200x/vs2008.c (renamed from src/action/vs200x/vs2008.c)2
-rw-r--r--src/actions/vs200x/vs2008_solution.c (renamed from src/action/vs200x/vs2008_solution.c)0
-rw-r--r--src/actions/vs200x/vs200x.c (renamed from src/action/vs200x/vs200x.c)33
-rw-r--r--src/actions/vs200x/vs200x.h (renamed from src/action/vs200x/vs200x.h)1
-rw-r--r--src/actions/vs200x/vs200x_config.c (renamed from src/action/vs200x/vs200x_config.c)16
-rw-r--r--src/actions/vs200x/vs200x_config.h (renamed from src/action/vs200x/vs200x_config.h)1
-rw-r--r--src/actions/vs200x/vs200x_project.c (renamed from src/action/vs200x/vs200x_project.c)18
-rw-r--r--src/actions/vs200x/vs200x_project.h (renamed from src/action/vs200x/vs200x_project.h)0
-rw-r--r--src/actions/vs200x/vs200x_solution.c (renamed from src/action/vs200x/vs200x_solution.c)0
-rw-r--r--src/actions/vs200x/vs200x_solution.h (renamed from src/action/vs200x/vs200x_solution.h)0
-rw-r--r--src/base/array.c29
-rw-r--r--src/base/buffers.c2
-rw-r--r--src/base/cstr.c21
-rw-r--r--src/base/cstr.h1
-rw-r--r--src/base/stream.c55
-rw-r--r--src/base/stream.h5
-rw-r--r--src/base/strings.c16
-rw-r--r--src/base/strings.h1
-rw-r--r--src/base/tests/cstr_tests.cpp21
-rw-r--r--src/base/tests/stream_tests.cpp16
-rw-r--r--src/host/host.c2
-rw-r--r--src/premake.c2
-rw-r--r--src/premake.lua57
-rw-r--r--src/project/block.c22
-rw-r--r--src/project/block.h3
-rw-r--r--src/project/blocks.c84
-rw-r--r--src/project/blocks.h25
-rw-r--r--src/project/fields.c2
-rw-r--r--src/project/filter.c112
-rw-r--r--src/project/filter.h36
-rw-r--r--src/project/project.c142
-rw-r--r--src/project/project.h12
-rw-r--r--src/project/solution.c57
-rw-r--r--src/project/solution.h6
-rw-r--r--src/project/tests/filter_tests.cpp67
-rw-r--r--src/project/tests/project_config_tests.cpp73
-rw-r--r--src/project/tests/project_tests.cpp59
-rw-r--r--src/project/tests/solution_tests.cpp27
-rw-r--r--src/script/script.c1
-rw-r--r--src/script/tests/unload_block_tests.cpp2
-rw-r--r--src/script/tests/unload_tests.cpp2
-rw-r--r--src/script/unload.c16
-rw-r--r--src/session/session.c9
-rw-r--r--src/session/session.h1
91 files changed, 1994 insertions, 1395 deletions
diff --git a/samples/vs2005/CppExe/CppExe.vcproj b/samples/vs2005/CppExe/CppExe.vcproj
index 415aeb0..6cc541f 100644
--- a/samples/vs2005/CppExe/CppExe.vcproj
+++ b/samples/vs2005/CppExe/CppExe.vcproj
@@ -40,11 +40,11 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;MSG=&quot;Hi there&quot;;BUILDING"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
- UsePrecompiledHeader="2"
+ UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
@@ -169,54 +169,8 @@
<References>
</References>
<Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\CppExe.cpp"
- >
- </File>
- <File
- RelativePath=".\stdafx.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\stdafx.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
<File
- RelativePath=".\ReadMe.txt"
+ RelativePath=".\CppExe.cpp"
>
</File>
</Files>
diff --git a/src/action/action.h b/src/action/action.h
deleted file mode 100644
index 0f0e190..0000000
--- a/src/action/action.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * \file action.h
- * \brief Built-in engine actions.
- * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
- *
- * \defgroup action Actions
- *
- * The actions component contains the implementation of all of the built-in
- * Premake actions, along with a few common support functions.
- *
- * @{
- */
-#if !defined(PREMAKE_ACTION_H)
-#define PREMAKE_ACTION_H
-
-#include "session/session.h"
-
-
-/**
- * State values for the source tree enumeration functions.
- */
-enum ActionSourceState
-{
- GroupStart,
- GroupEnd,
- SourceFile
-};
-
-
-/**
- * Per-file callback signature for action_source_tree.
- * \param sess The current execution state context.
- * \param prj The current project; contains the file being enumerated.
- * \param strm The active output stream; for writing the file markup.
- * \param filename The name of the file to process.
- * \param state One of the ActionSourceStates, enabling file grouping.
- * \returns OKAY if successful.
- */
-typedef int (*ActionSourceCallback)(Session sess, Project prj, Stream strm, const char* filename, int state);
-
-
-/* the list of built-in Premake actions */
-extern SessionAction Actions[];
-
-int gmake_action(Session sess);
-int vs2002_action(Session sess);
-int vs2003_action(Session sess);
-int vs2005_action(Session sess);
-int vs2008_action(Session sess);
-
-
-/* support functions */
-int action_source_tree(Session sess, Project prj, Stream strm, ActionSourceCallback handler);
-
-
-#endif
-/** @} */
diff --git a/src/action/make/make_solution.c b/src/action/make/make_solution.c
deleted file mode 100644
index 5f31087..0000000
--- a/src/action/make/make_solution.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * \file make_solution.c
- * \brief Makefile solution generation functions.
- * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
- */
-
-#include <assert.h>
-#include "premake.h"
-#include "action/make/make.h"
-#include "action/make/make_solution.h"
-#include "base/error.h"
-
-
-/**
- * Create a new output stream for a solution, and make it active for subsequent writes.
- * \param sess The execution session context.
- * \param sln The current solution.
- * \param strm The currently active stream; set with session_set_active_stream().
- * \returns OKAY if successful.
- */
-int make_solution_create(Session sess, Solution sln, Stream strm)
-{
- /* create the makefile */
- const char* filename = make_get_solution_makefile(sess, sln);
- 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/make/make_solution.h b/src/action/make/make_solution.h
deleted file mode 100644
index 01a5989..0000000
--- a/src/action/make/make_solution.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * \file make_solution.h
- * \brief Makefile solution generation functions.
- * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
- */
-#if !defined(PREMAKE_MAKE_SOLUTION_H)
-#define PREMAKE_MAKE_SOLUTION_H
-
-#include "session/session.h"
-
-int make_solution_create(Session sess, Solution sln, Stream strm);
-
-int gmake_solution_all_rule(Session sess, Solution sln, Stream strm);
-int gmake_solution_clean_rule(Session sess, Solution sln, Stream strm);
-int gmake_solution_default_config(Session sess, Solution sln, Stream strm);
-int gmake_solution_phony_rule(Session sess, Solution sln, Stream strm);
-int gmake_solution_projects(Session sess, Solution sln, Stream strm);
-int gmake_solution_signature(Session sess, Solution sln, Stream strm);
-
-#endif
diff --git a/src/action/vs200x/tests/vs2002_config_tests.cpp b/src/action/vs200x/tests/vs2002_config_tests.cpp
deleted file mode 100644
index e3fe0d1..0000000
--- a/src/action/vs200x/tests/vs2002_config_tests.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * \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, strm);
- 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
deleted file mode 100644
index e4704a0..0000000
--- a/src/action/vs200x/tests/vs2002_project_tests.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * \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
deleted file mode 100644
index 3c8e251..0000000
--- a/src/action/vs200x/tests/vs2003_config_tests.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * \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, strm);
- 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
deleted file mode 100644
index 0cbb999..0000000
--- a/src/action/vs200x/tests/vs2003_project_tests.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * \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
deleted file mode 100644
index 7711643..0000000
--- a/src/action/vs200x/tests/vs2005_config_tests.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * \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, strm);
- 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
deleted file mode 100644
index 2568c35..0000000
--- a/src/action/vs200x/tests/vs2005_project_tests.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * \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
deleted file mode 100644
index e2c45a3..0000000
--- a/src/action/vs200x/tests/vs2008_config_tests.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * \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, strm);
- 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
deleted file mode 100644
index ffcdad1..0000000
--- a/src/action/vs200x/tests/vs2008_project_tests.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * \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
deleted file mode 100644
index f919b81..0000000
--- a/src/action/vs200x/tests/vs200x_project_tests.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/**
- * \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");
- }
-};
-
-
-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_OnNoFiles)
- {
- vs200x_project_files(sess, prj, strm);
- CHECK_EQUAL(
- "\t<Files>\n"
- "\t</Files>\n",
- buffer);
- }
-
- TEST_FIXTURE(FxVsProject, Vs200x_Files_OnSingleCppFile)
- {
- char* values[] = { "Hello.cpp", 0 };
- SetField(prj, ProjectFiles, values);
- vs200x_project_files(sess, prj, strm);
- CHECK_EQUAL(
- "\t<Files>\n"
- "\t\t<File\n"
- "\t\t\tRelativePath=\".\\Hello.cpp\">\n"
- "\t\t</File>\n"
- "\t</Files>\n",
- buffer);
- }
-
- TEST_FIXTURE(FxVsProject, Vs200x_Files_OnUpperDirectory)
- {
- char* values[] = { "../../Hello.cpp", 0 };
- SetField(prj, ProjectFiles, values);
- vs200x_project_files(sess, prj, strm);
- CHECK_EQUAL(
- "\t<Files>\n"
- "\t\t<File\n"
- "\t\t\tRelativePath=\"..\\..\\Hello.cpp\">\n"
- "\t\t</File>\n"
- "\t</Files>\n",
- buffer);
- }
-
- TEST_FIXTURE(FxVsProject, Vs200x_Files_OnGroupedCppFile)
- {
- char* values[] = { "Src/Hello.cpp", 0 };
- SetField(prj, ProjectFiles, values);
- vs200x_project_files(sess, prj, strm);
- CHECK_EQUAL(
- "\t<Files>\n"
- "\t\t<Filter\n"
- "\t\t\tName=\"Src\"\n"
- "\t\t\tFilter=\"\">\n"
- "\t\t\t<File\n"
- "\t\t\t\tRelativePath=\".\\Src\\Hello.cpp\">\n"
- "\t\t\t</File>\n"
- "\t\t</Filter>\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/actions/actions.c b/src/actions/actions.c
new file mode 100644
index 0000000..78b0d67
--- /dev/null
+++ b/src/actions/actions.c
@@ -0,0 +1,20 @@
+/**
+ * \file actions.c
+ * \brief Built-in engine actions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <string.h>
+#include "premake.h"
+#include "actions/actions.h"
+
+
+SessionAction Actions[] =
+{
+ { "gmake", "GNU Makefiles for POSIX, MinGW, and Cygwin", gmake_action },
+ { "vs2002", "Microsoft Visual Studio 2002", vs2002_action },
+ { "vs2003", "Microsoft Visual Studio 2003", vs2003_action },
+ { "vs2005", "Microsoft Visual Studio 2005 (includes Express editions)", vs2005_action },
+ { "vs2008", "Microsoft Visual Studio 2008 (includes Express editions)", vs2008_action },
+ { 0, 0, 0 }
+};
diff --git a/src/actions/actions.h b/src/actions/actions.h
new file mode 100644
index 0000000..5bdc6a5
--- /dev/null
+++ b/src/actions/actions.h
@@ -0,0 +1,31 @@
+/**
+ * \file actions.h
+ * \brief Built-in engine actions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ *
+ * \defgroup action Actions
+ *
+ * The actions component contains the implementation of all of the built-in
+ * Premake actions, along with a few common support functions.
+ *
+ * @{
+ */
+#if !defined(PREMAKE_ACTIONS_H)
+#define PREMAKE_ACTIONS_H
+
+#include "session/session.h"
+
+
+int gmake_action (Session sess);
+int vs2002_action(Session sess);
+int vs2003_action(Session sess);
+int vs2005_action(Session sess);
+int vs2008_action(Session sess);
+
+
+/* the list of built-in Premake actions */
+extern SessionAction Actions[];
+
+
+#endif
+/** @} */
diff --git a/src/action/make/gmake.c b/src/actions/make/gmake.c
index e6c4721..073cb5e 100644
--- a/src/action/make/gmake.c
+++ b/src/actions/make/gmake.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "premake.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "make.h"
#include "make_solution.h"
#include "make_project.h"
@@ -23,12 +23,12 @@ static SessionFeatures Features =
static SessionSolutionCallback SolutionCallbacks[] =
{
make_solution_create,
- gmake_solution_signature,
- gmake_solution_default_config,
- gmake_solution_phony_rule,
- gmake_solution_all_rule,
- gmake_solution_projects,
- gmake_solution_clean_rule,
+ make_solution_signature,
+ make_solution_default_config,
+ make_solution_phony_rule,
+ make_solution_all_rule,
+ make_solution_projects,
+ make_solution_clean_rule,
NULL
};
diff --git a/src/action/make/gmake_project.c b/src/actions/make/gmake_project.c
index 3788e2d..3788e2d 100644
--- a/src/action/make/gmake_project.c
+++ b/src/actions/make/gmake_project.c
diff --git a/src/actions/make/gmake_solution.c b/src/actions/make/gmake_solution.c
new file mode 100644
index 0000000..5351441
--- /dev/null
+++ b/src/actions/make/gmake_solution.c
@@ -0,0 +1,19 @@
+/**
+ * \file gmake_solution.c
+ * \brief GNU makefile solution generation functions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "premake.h"
+#include "make.h"
+#include "make_solution.h"
+#include "base/buffers.h"
+#include "base/cstr.h"
+#include "base/path.h"
+#include "base/strings.h"
+
+
+
diff --git a/src/action/make/make.c b/src/actions/make/make.c
index e2a1d7f..e2a1d7f 100644
--- a/src/action/make/make.c
+++ b/src/actions/make/make.c
diff --git a/src/action/make/make.h b/src/actions/make/make.h
index 4ac8e43..4ac8e43 100644
--- a/src/action/make/make.h
+++ b/src/actions/make/make.h
diff --git a/src/action/make/make_project.c b/src/actions/make/make_project.c
index 8bdac0a..8e1298b 100644
--- a/src/action/make/make_project.c
+++ b/src/actions/make/make_project.c
@@ -5,9 +5,10 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "premake.h"
-#include "action/make/make.h"
-#include "action/make/make_project.h"
+#include "actions/make/make.h"
+#include "actions/make/make_project.h"
#include "base/error.h"
#include "base/path.h"
@@ -60,9 +61,17 @@ int make_project_config_cflags(Session sess, Project prj, Stream strm)
*/
int make_project_config_cppflags(Session sess, Project prj, Stream strm)
{
+ Strings values;
+ int z = OKAY;
UNUSED(sess);
- UNUSED(prj);
- return stream_writeline(strm, " CPPFLAGS += -MMD");
+
+ z |= stream_write(strm, " CPPFLAGS += -MMD");
+
+ values = project_get_config_values(prj, BlockDefines);
+ z |= stream_write_strings(strm, values, "", " -D \"", "\"", "", "", NULL);
+
+ z |= stream_writeline(strm, "");
+ return z;
}
diff --git a/src/action/make/make_project.h b/src/actions/make/make_project.h
index e8a3ef8..e8a3ef8 100644
--- a/src/action/make/make_project.h
+++ b/src/actions/make/make_project.h
diff --git a/src/action/make/gmake_solution.c b/src/actions/make/make_solution.c
index 6f2b1ee..2516453 100644
--- a/src/action/make/gmake_solution.c
+++ b/src/actions/make/make_solution.c
@@ -1,6 +1,6 @@
/**
- * \file gmake_solution.c
- * \brief GNU makefile solution generation functions.
+ * \file make_solution.c
+ * \brief Makefile solution generation functions.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
@@ -8,24 +8,53 @@
#include <stdlib.h>
#include <string.h>
#include "premake.h"
-#include "make.h"
-#include "make_solution.h"
+#include "actions/make/make.h"
+#include "actions/make/make_solution.h"
#include "base/buffers.h"
#include "base/cstr.h"
+#include "base/error.h"
#include "base/path.h"
-#include "base/strings.h"
-const char* gmake_solution_project_rule(Session sess, Solution sln, Project prj);
+
+static const char* make_solution_project_rule(Session sess, Solution sln, Project prj);
/**
- * Write the GNU makefile all rule.
+ * Write the GNU solution makefile clean rules.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_all_rule(Session sess, Solution sln, Stream strm)
+int make_solution_clean_rule(Session sess, Solution sln, Stream strm)
+{
+ int i, n, z;
+
+ assert(sess);
+ assert(sln);
+ assert(strm);
+
+ z = stream_writeline(strm, "clean:");
+ n = solution_num_projects(sln);
+ for (i = 0; i < n; ++i)
+ {
+ Project prj = solution_get_project(sln, i);
+ const char* rule = make_solution_project_rule(sess, sln, prj);
+ z |= stream_writeline(strm, "%s clean", rule);
+ }
+
+ return z;
+}
+
+
+/**
+ * Write the makefile "all" rule.
+ * \param sess The execution session context.
+ * \param sln The current solution.
+ * \param strm The currently active stream; set with session_set_active_stream().
+ * \returns OKAY if successful.
+ */
+int make_solution_all_rule(Session sess, Solution sln, Stream strm)
{
Strings prj_names;
int z;
@@ -43,30 +72,25 @@ int gmake_solution_all_rule(Session sess, Solution sln, Stream strm)
/**
- * Write the GNU solution makefile clean rules.
+ * Create a new output stream for a solution, and make it active for subsequent writes.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_clean_rule(Session sess, Solution sln, Stream strm)
+int make_solution_create(Session sess, Solution sln, Stream strm)
{
- int i, n, z;
-
- assert(sess);
- assert(sln);
- assert(strm);
-
- z = stream_writeline(strm, "clean:");
- n = solution_num_projects(sln);
- for (i = 0; i < n; ++i)
+ /* create the makefile */
+ const char* filename = make_get_solution_makefile(sess, sln);
+ strm = stream_create_file(filename);
+ if (!strm)
{
- Project prj = solution_get_project(sln, i);
- const char* rule = gmake_solution_project_rule(sess, sln, prj);
- z |= stream_writeline(strm, "%s clean", rule);
+ return !OKAY;
}
- return z;
+ /* make the stream active for the functions that come after */
+ session_set_active_stream(sess, strm);
+ return OKAY;
}
@@ -77,7 +101,7 @@ int gmake_solution_clean_rule(Session sess, Solution sln, Stream strm)
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_default_config(Session sess, Solution sln, Stream strm)
+int make_solution_default_config(Session sess, Solution sln, Stream strm)
{
const char* default_config_name;
int z;
@@ -97,13 +121,13 @@ int gmake_solution_default_config(Session sess, Solution sln, Stream strm)
/**
- * Write the GNU makefile .PHONY rule.
+ * Write the makefile .PHONY rule.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_phony_rule(Session sess, Solution sln, Stream strm)
+int make_solution_phony_rule(Session sess, Solution sln, Stream strm)
{
Strings prj_names;
int z;
@@ -120,6 +144,7 @@ int gmake_solution_phony_rule(Session sess, Solution sln, Stream strm)
}
+
/**
* Build the makefile rule to call an individual project.
* \param sess The current session context.
@@ -127,7 +152,7 @@ int gmake_solution_phony_rule(Session sess, Solution sln, Stream strm)
* \param prj The project to be built.
* \returns The makefile rule to trigger the project build.
*/
-const char* gmake_solution_project_rule(Session sess, Solution sln, Project prj)
+const char* make_solution_project_rule(Session sess, Solution sln, Project prj)
{
char* buffer = buffers_next();
@@ -155,15 +180,14 @@ const char* gmake_solution_project_rule(Session sess, Solution sln, Project prj)
}
-
/**
- * Write the GNU solution makefile project entry.
+ * Write the solution makefile project entries.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_projects(Session sess, Solution sln, Stream strm)
+int make_solution_projects(Session sess, Solution sln, Stream strm)
{
int i, n, z = OKAY;
@@ -176,7 +200,7 @@ int gmake_solution_projects(Session sess, Solution sln, Stream strm)
{
Project prj = solution_get_project(sln, i);
const char* prj_name = project_get_name(prj);
- const char* rule = gmake_solution_project_rule(sess, sln, prj);
+ const char* rule = make_solution_project_rule(sess, sln, prj);
z |= stream_writeline(strm, "%s:", prj_name);
z |= stream_writeline(strm, "\t@echo ==== Building %s ====", prj_name);
@@ -189,22 +213,33 @@ int gmake_solution_projects(Session sess, Solution sln, Stream strm)
/**
- * Write the GNU makefile solution file signature block.
+ * Write the makefile solution file signature block.
* \param sess The execution session context.
* \param sln The current solution.
* \param strm The currently active stream; set with session_set_active_stream().
* \returns OKAY if successful.
*/
-int gmake_solution_signature(Session sess, Solution sln, Stream strm)
+int make_solution_signature(Session sess, Solution sln, Stream strm)
{
+ const char* file_type;
Strings config_names;
int z;
- UNUSED(sess);
+ assert(sess);
assert(sln);
assert(strm);
- z = stream_writeline(strm, "# GNU Makefile autogenerated by Premake");
+ if (cstr_eq(session_get_action(sess), "gmake"))
+ {
+ file_type = "GNU Make";
+ }
+ else
+ {
+ file_type = "(unknown)";
+ assert(0);
+ }
+
+ z = stream_writeline(strm, "# %s makefile autogenerated by Premake", file_type);
z |= stream_writeline(strm, "# Usage: make [ CONFIG=config_name ]");
z |= stream_writeline(strm, "# Where {config_name} is one of:");
diff --git a/src/actions/make/make_solution.h b/src/actions/make/make_solution.h
new file mode 100644
index 0000000..0ff86cd
--- /dev/null
+++ b/src/actions/make/make_solution.h
@@ -0,0 +1,19 @@
+/**
+ * \file make_solution.h
+ * \brief Makefile solution generation functions.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+#if !defined(PREMAKE_MAKE_SOLUTION_H)
+#define PREMAKE_MAKE_SOLUTION_H
+
+#include "session/session.h"
+
+int make_solution_clean_rule(Session sess, Solution sln, Stream strm);
+int make_solution_all_rule(Session sess, Solution sln, Stream strm);
+int make_solution_create(Session sess, Solution sln, Stream strm);
+int make_solution_default_config(Session sess, Solution sln, Stream strm);
+int make_solution_phony_rule(Session sess, Solution sln, Stream strm);
+int make_solution_projects(Session sess, Solution sln, Stream strm);
+int make_solution_signature(Session sess, Solution sln, Stream strm);
+
+#endif
diff --git a/src/actions/make/tests/make_config_tests.cpp b/src/actions/make/tests/make_config_tests.cpp
new file mode 100644
index 0000000..5c8ae6b
--- /dev/null
+++ b/src/actions/make/tests/make_config_tests.cpp
@@ -0,0 +1,142 @@
+/**
+ * \file make_config_tests.cpp
+ * \brief Automated tests for makefile configuration block processing.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "actions/tests/action_tests.h"
+extern "C" {
+#include "actions/make/make_project.h"
+#include "platform/platform.h"
+}
+
+SUITE(action)
+{
+ /**********************************************************************
+ * CPPFLAGS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeCppFlags_Defaults)
+ {
+ make_project_config_cppflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " CPPFLAGS += -MMD\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, MakeCppFlags_WithDefines)
+ {
+ char* defines[] = { "DEFINE0", "DEFINE1", NULL};
+ SetConfigField(prj, BlockDefines, defines);
+ make_project_config_cppflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " CPPFLAGS += -MMD -D \"DEFINE0\" -D \"DEFINE1\"\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * CFLAGS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_CFlags)
+ {
+ make_project_config_cflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " CFLAGS += $(CPPFLAGS) $(ARCHFLAGS)\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * CXXFLAGS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_CxxFlags)
+ {
+ make_project_config_cxxflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " CXXFLAGS += $(CFLAGS)\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * LDDEPS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_LdDeps)
+ {
+ make_project_config_lddeps(sess, prj, strm);
+ CHECK_EQUAL(
+ " LDDEPS :=\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * LDFLAGS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_LdFlags)
+ {
+ make_project_config_ldflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " LDFLAGS +=\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * OBJDIR tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_ObjDir)
+ {
+ make_project_config_objdir(sess, prj, strm);
+ CHECK_EQUAL(
+ " OBJDIR := obj/Debug\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * OUTFILE tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_OutFile)
+ {
+ platform_set(MacOSX);
+ make_project_config_outfile(sess, prj, strm);
+ CHECK_EQUAL(
+ " OUTFILE := $(OUTDIR)/MyProject\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * OUTDIR tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_OutDir)
+ {
+ make_project_config_outdir(sess, prj, strm);
+ CHECK_EQUAL(
+ " OUTDIR := .\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * RESFLAGS tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_Config_ResFlags)
+ {
+ make_project_config_resflags(sess, prj, strm);
+ CHECK_EQUAL(
+ " RESFLAGS +=\n",
+ buffer);
+ }
+}
diff --git a/src/action/make/tests/gmake_project_tests.cpp b/src/actions/make/tests/make_project_tests.cpp
index ba0821a..2ca0319 100644
--- a/src/action/make/tests/gmake_project_tests.cpp
+++ b/src/actions/make/tests/make_project_tests.cpp
@@ -1,20 +1,25 @@
/**
- * \file gmake_project_tests.cpp
+ * \file make_project_tests.cpp
* \brief Automated tests for GNU makefile project processing.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/make/make_project.h"
+#include "actions/make/make_project.h"
#include "platform/platform.h"
}
SUITE(action)
{
- TEST_FIXTURE(FxAction, MakeProject_Signature)
+ /**********************************************************************
+ * Signature tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, MakeProject_SignatureIsCorrect_OnGmake)
{
+ session_set_action(sess, "gmake");
make_project_signature(sess, prj, strm);
CHECK_EQUAL(
"# GNU Makefile autogenerated by Premake\n"
@@ -22,6 +27,11 @@ SUITE(action)
buffer);
}
+
+ /**********************************************************************
+ * Config block conditional tests
+ **********************************************************************/
+
TEST_FIXTURE(FxAction, MakeProject_Config_Conditional)
{
make_project_config_conditional(sess, prj, strm);
@@ -39,79 +49,6 @@ SUITE(action)
buffer);
}
- TEST_FIXTURE(FxAction, MakeProject_Config_CFlags)
- {
- make_project_config_cflags(sess, prj, strm);
- CHECK_EQUAL(
- " CFLAGS += $(CPPFLAGS) $(ARCHFLAGS)\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_CppFlags)
- {
- make_project_config_cppflags(sess, prj, strm);
- CHECK_EQUAL(
- " CPPFLAGS += -MMD\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_CxxFlags)
- {
- make_project_config_cxxflags(sess, prj, strm);
- CHECK_EQUAL(
- " CXXFLAGS += $(CFLAGS)\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_LdDeps)
- {
- make_project_config_lddeps(sess, prj, strm);
- CHECK_EQUAL(
- " LDDEPS :=\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_LdFlags)
- {
- make_project_config_ldflags(sess, prj, strm);
- CHECK_EQUAL(
- " LDFLAGS +=\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_ObjDir)
- {
- make_project_config_objdir(sess, prj, strm);
- CHECK_EQUAL(
- " OBJDIR := obj/Debug\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_OutFile)
- {
- platform_set(MacOSX);
- make_project_config_outfile(sess, prj, strm);
- CHECK_EQUAL(
- " OUTFILE := $(OUTDIR)/MyProject\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_OutDir)
- {
- make_project_config_outdir(sess, prj, strm);
- CHECK_EQUAL(
- " OUTDIR := .\n",
- buffer);
- }
-
- TEST_FIXTURE(FxAction, MakeProject_Config_ResFlags)
- {
- make_project_config_resflags(sess, prj, strm);
- CHECK_EQUAL(
- " RESFLAGS +=\n",
- buffer);
- }
-
/**********************************************************************
* Object file list tests
diff --git a/src/action/make/tests/gmake_solution_tests.cpp b/src/actions/make/tests/make_solution_tests.cpp
index f9e918b..896a8e5 100644
--- a/src/action/make/tests/gmake_solution_tests.cpp
+++ b/src/actions/make/tests/make_solution_tests.cpp
@@ -1,13 +1,13 @@
/**
- * \file gmake_solution_tests.cpp
- * \brief Automated tests for GNU makefile solution processing.
- * \author Copyright (c) 2008 Jason Perkins and the Premake project
+ * \file make_solution_tests.cpp
+ * \brief Automated tests for makefile "solution" processing.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/make/make_solution.h"
+#include "actions/make/make_solution.h"
}
@@ -17,11 +17,12 @@ SUITE(action)
* Signature tests
**********************************************************************/
- TEST_FIXTURE(FxAction, Gmake_SolutionSignature_IsCorrect)
+ TEST_FIXTURE(FxAction, MakeSolution_SignatureIsCorrect_OnGmake)
{
- gmake_solution_signature(sess, sln, strm);
+ session_set_action(sess, "gmake");
+ make_solution_signature(sess, sln, strm);
CHECK_EQUAL(
- "# GNU Makefile autogenerated by Premake\n"
+ "# GNU Make makefile autogenerated by Premake\n"
"# Usage: make [ CONFIG=config_name ]\n"
"# Where {config_name} is one of:\n"
"# Debug, Release\n"
@@ -34,9 +35,9 @@ SUITE(action)
* Default configuration tests
**********************************************************************/
- TEST_FIXTURE(FxAction, Gmake_SolutionDefaultConfig_IsCorrect)
+ TEST_FIXTURE(FxAction, MakeSolution_DefaultConfigIsCorrect)
{
- gmake_solution_default_config(sess, sln, strm);
+ make_solution_default_config(sess, sln, strm);
CHECK_EQUAL(
"ifndef CONFIG\n"
" CONFIG=Debug\n"
@@ -51,9 +52,9 @@ SUITE(action)
* Phony rule tests
**********************************************************************/
- TEST_FIXTURE(FxAction, Gmake_SolutionPhonyRule_IsCorrect)
+ TEST_FIXTURE(FxAction, MakeSolution_PhonyRuleIsCorrect)
{
- gmake_solution_phony_rule(sess, sln, strm);
+ make_solution_phony_rule(sess, sln, strm);
CHECK_EQUAL(
".PHONY: all clean MyProject\n"
"\n",
@@ -65,9 +66,9 @@ SUITE(action)
* All rule tests
**********************************************************************/
- TEST_FIXTURE(FxAction, Gmake_SolutionAllRule_IsCorrect)
+ TEST_FIXTURE(FxAction, MakeSolution_AllRuleIsCorrect)
{
- gmake_solution_all_rule(sess, sln, strm);
+ make_solution_all_rule(sess, sln, strm);
CHECK_EQUAL(
"all: MyProject\n"
"\n",
@@ -79,10 +80,10 @@ SUITE(action)
* Project entry tests
**********************************************************************/
- TEST_FIXTURE(FxAction, Gmake_ProjectEntry_InSameDirectory)
+ TEST_FIXTURE(FxAction, Make_ProjectEntry_InSameDirectory)
{
project_set_location(prj, "");
- gmake_solution_projects(sess, sln, strm);
+ make_solution_projects(sess, sln, strm);
CHECK_EQUAL(
"MyProject:\n"
"\t@echo ==== Building MyProject ====\n"
@@ -91,10 +92,10 @@ SUITE(action)
buffer);
}
- TEST_FIXTURE(FxAction, Gmake_ProjectEntry_InDifferentDirectory)
+ TEST_FIXTURE(FxAction, Make_ProjectEntry_InDifferentDirectory)
{
project_set_location(prj, "MyProject");
- gmake_solution_projects(sess, sln, strm);
+ make_solution_projects(sess, sln, strm);
CHECK_EQUAL(
"MyProject:\n"
"\t@echo ==== Building MyProject ====\n"
@@ -111,7 +112,7 @@ SUITE(action)
TEST_FIXTURE(FxAction, Gmake_CleanRule_IsCorrect)
{
project_set_location(prj, "");
- gmake_solution_clean_rule(sess, sln, strm);
+ make_solution_clean_rule(sess, sln, strm);
CHECK_EQUAL(
"clean:\n"
"\t@$(MAKE) -f MyProject.make clean\n",
diff --git a/src/action/make/tests/make_tests.cpp b/src/actions/make/tests/make_tests.cpp
index 789fd53..db4fe87 100644
--- a/src/action/make/tests/make_tests.cpp
+++ b/src/actions/make/tests/make_tests.cpp
@@ -7,7 +7,7 @@
#include "premake.h"
#include "testing/testing.h"
extern "C" {
-#include "action/make/make.h"
+#include "actions/make/make.h"
#include "base/error.h"
}
diff --git a/src/action/action.c b/src/actions/support/sourcetree.c
index 9a10740..7659dcf 100644
--- a/src/action/action.c
+++ b/src/actions/support/sourcetree.c
@@ -1,26 +1,18 @@
/**
- * \file action.c
- * \brief Built-in engine actions.
+ * \file sourcetree.h
+ * \brief Source code tree enumerator.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <string.h>
#include "premake.h"
-#include "action/action.h"
+#include "sourcetree.h"
#include "base/buffers.h"
#include "base/cstr.h"
+#include "base/string.h"
-SessionAction Actions[] =
-{
- { "gmake", "GNU Makefiles for POSIX, MinGW, and Cygwin", gmake_action },
- { "vs2002", "Microsoft Visual Studio 2002", vs2002_action },
- { "vs2003", "Microsoft Visual Studio 2003", vs2003_action },
- { "vs2005", "Microsoft Visual Studio 2005 (includes Express editions)", vs2005_action },
- { "vs2008", "Microsoft Visual Studio 2008 (includes Express editions)", vs2008_action },
- { 0, 0, 0 }
-};
-static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionSourceCallback handler, const char* group);
+static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallback handler, const char* group);
/**
@@ -33,25 +25,25 @@ static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionS
* \param handler The per-file handler function.
* \returns OKAY on success.
*/
-int action_source_tree(Session sess, Project prj, Stream strm, ActionSourceCallback handler)
+int sourcetree_walk(Session sess, Project prj, Stream strm, SourceTreeCallback handler)
{
- return action_source_tree_do(sess, prj, strm, handler, "");
+ return sourcetree_do(sess, prj, strm, handler, "");
}
-static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionSourceCallback handler, const char* group)
+static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallback handler, const char* group)
{
- int i, n, group_len;
+ int i, n;
+ unsigned group_len;
Strings files;
- char* buffer = buffers_next();
+ char* buffer;
- /* open an enclosing group */
group_len = strlen(group);
+
+ /* open an enclosing group */
+ buffer = buffers_next();
strcpy(buffer, group);
- if (cstr_ends_with(buffer, "/")) /* Trim off trailing path separator */
- {
- buffer[strlen(buffer)-1] = '\0';
- }
+ cstr_trim(buffer, '/');
handler(sess, prj, strm, buffer, GroupStart);
/* scan all files in this group and process any subdirectories (subgroups) */
@@ -72,6 +64,7 @@ static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionS
/* pull out the name of this new group */
size_t len = ptr - filename + 1;
+ buffer = buffers_next();
strncpy(buffer, filename, len);
buffer[len] = '\0';
@@ -85,8 +78,10 @@ static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionS
if (i == j)
{
/* a new group, process it now */
- if (action_source_tree_do(sess, prj, strm, handler, buffer) != OKAY)
- return !OKAY;
+ String new_group = string_create(buffer);
+ int z = sourcetree_do(sess, prj, strm, handler, string_cstr(new_group));
+ string_destroy(new_group);
+ if (z != OKAY) return !OKAY;
}
}
}
@@ -96,7 +91,7 @@ static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionS
for (i = 0; i < n; ++i)
{
const char* filename = strings_item(files, i);
- if (!strchr(filename + group_len, '/'))
+ if (cstr_starts_with(filename, group) && strchr(filename + group_len, '/') == NULL)
{
if (handler(sess, prj, strm, filename, SourceFile) != OKAY)
return !OKAY;
@@ -104,11 +99,9 @@ static int action_source_tree_do(Session sess, Project prj, Stream strm, ActionS
}
/* close the group */
+ buffer = buffers_next();
strcpy(buffer, group);
- if (cstr_ends_with(buffer, "/")) /* Trim off trailing path separator */
- {
- buffer[strlen(buffer)-1] = '\0';
- }
+ cstr_trim(buffer, '/');
handler(sess, prj, strm, buffer, GroupEnd);
return OKAY;
}
diff --git a/src/actions/support/sourcetree.h b/src/actions/support/sourcetree.h
new file mode 100644
index 0000000..f39224f
--- /dev/null
+++ b/src/actions/support/sourcetree.h
@@ -0,0 +1,38 @@
+/**
+ * \file sourcetree.h
+ * \brief Source code tree enumerator.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+#if !defined(PREMAKE_SOURCETREE_H)
+#define PREMAKE_SOURCETREE_H
+
+#include "session/session.h"
+
+
+/**
+ * State values for the source tree enumeration functions.
+ */
+enum SourceTreeState
+{
+ GroupStart,
+ GroupEnd,
+ SourceFile
+};
+
+
+/**
+ * Per-file callback signature for action_source_tree.
+ * \param sess The current execution state context.
+ * \param prj The current project; contains the file being enumerated.
+ * \param strm The active output stream; for writing the file markup.
+ * \param filename The name of the file to process.
+ * \param state One of the ActionSourceStates, enabling file grouping.
+ * \returns OKAY if successful.
+ */
+typedef int (*SourceTreeCallback)(Session sess, Project prj, Stream strm, const char* filename, int state);
+
+
+int sourcetree_walk(Session sess, Project prj, Stream strm, SourceTreeCallback handler);
+
+
+#endif
diff --git a/src/action/tests/action_tests.h b/src/actions/tests/action_tests.h
index 0d38652..71c53b8 100644
--- a/src/action/tests/action_tests.h
+++ b/src/actions/tests/action_tests.h
@@ -15,6 +15,7 @@ struct FxAction
Session sess;
Stream strm;
Solution sln;
+ Filter flt;
Project prj;
char buffer[8192];
@@ -40,13 +41,17 @@ struct FxAction
project_set_location(prj, "ProjectFolder");
project_set_guid(prj, "AE2461B7-236F-4278-81D3-F0D476F9A4C0");
project_set_language(prj, "c++");
- project_set_configuration_filter(prj, "Debug");
+
+ flt = filter_create();
+ filter_set_value(flt, FilterConfig, "Debug");
+ project_set_filter(prj, flt);
}
~FxAction()
{
stream_destroy(strm);
session_destroy(sess);
+ filter_destroy(flt);
}
@@ -60,4 +65,19 @@ struct FxAction
project_set_values(prj, index, strs);
}
+
+ void SetConfigField(Project prj, enum BlockField index, char** values)
+ {
+ Strings strs = strings_create();
+ for (char** value = values; (*value) != NULL; ++value)
+ {
+ strings_add(strs, *value);
+ }
+
+ Block blk = block_create();
+ block_set_values(blk, index, strs);
+
+ Blocks blks = project_get_blocks(prj);
+ blocks_add(blks, blk);
+ }
};
diff --git a/src/action/vs200x/tests/vs2002_solution_tests.cpp b/src/actions/vs200x/tests/vs2002_solution_tests.cpp
index fb51c39..1605ef9 100644
--- a/src/action/vs200x/tests/vs2002_solution_tests.cpp
+++ b/src/actions/vs200x/tests/vs2002_solution_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x_solution.h"
+#include "actions/vs200x/vs200x_solution.h"
}
diff --git a/src/action/vs200x/tests/vs2003_solution_tests.cpp b/src/actions/vs200x/tests/vs2003_solution_tests.cpp
index f545e95..8ee8614 100644
--- a/src/action/vs200x/tests/vs2003_solution_tests.cpp
+++ b/src/actions/vs200x/tests/vs2003_solution_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x_solution.h"
+#include "actions/vs200x/vs200x_solution.h"
}
diff --git a/src/action/vs200x/tests/vs2005_solution_tests.cpp b/src/actions/vs200x/tests/vs2005_solution_tests.cpp
index 5cfcbee..e50edcb 100644
--- a/src/action/vs200x/tests/vs2005_solution_tests.cpp
+++ b/src/actions/vs200x/tests/vs2005_solution_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x_solution.h"
+#include "actions/vs200x/vs200x_solution.h"
}
diff --git a/src/action/vs200x/tests/vs2008_solution_tests.cpp b/src/actions/vs200x/tests/vs2008_solution_tests.cpp
index dd324c2..7495b97 100644
--- a/src/action/vs200x/tests/vs2008_solution_tests.cpp
+++ b/src/actions/vs200x/tests/vs2008_solution_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x_solution.h"
+#include "actions/vs200x/vs200x_solution.h"
}
diff --git a/src/actions/vs200x/tests/vs200x_compiler_tests.cpp b/src/actions/vs200x/tests/vs200x_compiler_tests.cpp
new file mode 100644
index 0000000..167ad30
--- /dev/null
+++ b/src/actions/vs200x/tests/vs200x_compiler_tests.cpp
@@ -0,0 +1,102 @@
+/**
+ * \file vs200x_compiler_tests.cpp
+ * \brief Automated tests for VS200x compiler block processing.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "actions/tests/action_tests.h"
+extern "C" {
+#include "actions/vs200x/vs200x_project.h"
+}
+
+SUITE(action)
+{
+ /**********************************************************************
+ * Default settings
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VCCLCompilerTool_Defaults_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, VCCLCompilerTool_Defaults_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ 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(FxAction, VCCLCompilerTool_Defaults_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ 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);
+ }
+
+
+
+ /**********************************************************************
+ * Defines tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VCCLCompilerTool_WithDefines)
+ {
+ session_set_action(sess, "vs2002");
+ char* defines[] = { "DEFINE0", "DEFINE1", NULL };
+ SetConfigField(prj, BlockDefines, defines);
+ 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\tPreprocessorDefinitions=\"DEFINE0;DEFINE1\"\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);
+ }
+}
diff --git a/src/actions/vs200x/tests/vs200x_config_tests.cpp b/src/actions/vs200x/tests/vs200x_config_tests.cpp
new file mode 100644
index 0000000..7a8fbe9
--- /dev/null
+++ b/src/actions/vs200x/tests/vs200x_config_tests.cpp
@@ -0,0 +1,67 @@
+/**
+ * \file vs200x_config_tests.cpp
+ * \brief Automated tests for VS200x configuration settings processing.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "actions/tests/action_tests.h"
+extern "C" {
+#include "actions/vs200x/vs200x_config.h"
+}
+
+SUITE(action)
+{
+ /*************************************************************************
+ * Character set tests
+ *************************************************************************/
+
+ TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_config_character_set(sess, strm);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_config_character_set(sess, strm);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_config_character_set(sess, strm);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_config_character_set(sess, strm);
+ CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer);
+ }
+
+
+ /*************************************************************************
+ * Defines tests
+ *************************************************************************/
+
+ TEST_FIXTURE(FxAction, VsDefines_Empty_OnNoSymbols)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_config_defines(sess, strm, prj);
+ CHECK_EQUAL("", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsDefines_SemiSplitList)
+ {
+ session_set_action(sess, "vs2002");
+ char* values[] = { "DEFINE0", "DEFINE1", "DEFINE2", NULL };
+ SetConfigField(prj, BlockDefines, values);
+ vs200x_config_defines(sess, strm, prj);
+ CHECK_EQUAL("\n\t\t\t\tPreprocessorDefinitions=\"DEFINE0;DEFINE1;DEFINE2\"", buffer);
+ }
+}
diff --git a/src/actions/vs200x/tests/vs200x_linker_tests.cpp b/src/actions/vs200x/tests/vs200x_linker_tests.cpp
new file mode 100644
index 0000000..10b8e01
--- /dev/null
+++ b/src/actions/vs200x/tests/vs200x_linker_tests.cpp
@@ -0,0 +1,80 @@
+/**
+ * \file vs200x_linker_tests.cpp
+ * \brief Automated tests for VS200x linker block processing.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "actions/tests/action_tests.h"
+extern "C" {
+#include "actions/vs200x/vs200x_project.h"
+}
+
+SUITE(action)
+{
+ /**********************************************************************
+ * Default settings
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VCLinkerTool_Defaults_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, VCLinkerTool_Defaults_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ 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(FxAction, VCLinkerTool_Defaults_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ 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(FxAction, VCLinkerTool_Defaults_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ 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);
+ }
+}
diff --git a/src/actions/vs200x/tests/vs200x_project_tests.cpp b/src/actions/vs200x/tests/vs200x_project_tests.cpp
new file mode 100644
index 0000000..ff14eb9
--- /dev/null
+++ b/src/actions/vs200x/tests/vs200x_project_tests.cpp
@@ -0,0 +1,467 @@
+/**
+ * \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 "actions/tests/action_tests.h"
+extern "C" {
+#include "actions/vs200x/vs200x_project.h"
+}
+
+
+SUITE(action)
+{
+ /**********************************************************************
+ * 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);
+ }
+
+
+ /**********************************************************************
+ * Project element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VsProject_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, VsProject_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ 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(FxAction, VsProject_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ 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(FxAction, VsProject_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ 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);
+ }
+
+
+ /**********************************************************************
+ * Platforms tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_Platforms)
+ {
+ session_set_action(sess, "vs2002");
+ 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 files tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<ToolFiles>\n"
+ "\t</ToolFiles>\n"
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_project_tool_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<ToolFiles>\n"
+ "\t</ToolFiles>\n"
+ "\t<Configurations>\n",
+ buffer);
+ }
+
+
+
+ /**********************************************************************
+ * Configuration element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_Configuration)
+ {
+ session_set_action(sess, "vs2002");
+ 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);
+ }
+
+
+ /**********************************************************************
+ * Tool element tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_VCALinkTool)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_vc_alink_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCALinkTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_VCAppVerifierTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCBscMakeTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCCustomBuildTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCFxCopTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCManagedResourceCompilerTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCManifestTool)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_vc_manifest_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCManifestTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_VCMIDLTool)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_vc_midl_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCMIDLTool\"/>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_VCPreBuildEventTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCPreLinkEventTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCPostBuildEventTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCResourceCompilerTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCWebDeploymentTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCWebServiceProxyGeneratorTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCXDCMakeTool)
+ {
+ session_set_action(sess, "vs2002");
+ 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(FxAction, Vs200x_VCXMLDataGeneratorTool)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_vc_xml_data_generator_tool(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t\t\t<Tool\n"
+ "\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * References section tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2002)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2003)
+ {
+ session_set_action(sess, "vs2003");
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2005)
+ {
+ session_set_action(sess, "vs2005");
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2008)
+ {
+ session_set_action(sess, "vs2008");
+ vs200x_project_references(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t</Configurations>\n"
+ "\t<References>\n"
+ "\t</References>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Files section tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_Files_OnNoFiles)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_project_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Files>\n"
+ "\t</Files>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_Files_OnSingleCppFile)
+ {
+ session_set_action(sess, "vs2002");
+ char* values[] = { "Hello.cpp", 0 };
+ SetField(prj, ProjectFiles, values);
+ vs200x_project_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Files>\n"
+ "\t\t<File\n"
+ "\t\t\tRelativePath=\".\\Hello.cpp\">\n"
+ "\t\t</File>\n"
+ "\t</Files>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_Files_OnUpperDirectory)
+ {
+ session_set_action(sess, "vs2002");
+ char* values[] = { "../../Hello.cpp", 0 };
+ SetField(prj, ProjectFiles, values);
+ vs200x_project_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Files>\n"
+ "\t\t<File\n"
+ "\t\t\tRelativePath=\"..\\..\\Hello.cpp\">\n"
+ "\t\t</File>\n"
+ "\t</Files>\n",
+ buffer);
+ }
+
+ TEST_FIXTURE(FxAction, Vs200x_Files_OnGroupedCppFile)
+ {
+ session_set_action(sess, "vs2002");
+ char* values[] = { "Src/Hello.cpp", 0 };
+ SetField(prj, ProjectFiles, values);
+ vs200x_project_files(sess, prj, strm);
+ CHECK_EQUAL(
+ "\t<Files>\n"
+ "\t\t<Filter\n"
+ "\t\t\tName=\"Src\"\n"
+ "\t\t\tFilter=\"\">\n"
+ "\t\t\t<File\n"
+ "\t\t\t\tRelativePath=\".\\Src\\Hello.cpp\">\n"
+ "\t\t\t</File>\n"
+ "\t\t</Filter>\n"
+ "\t</Files>\n",
+ buffer);
+ }
+
+
+ /**********************************************************************
+ * Globals section tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxAction, Vs200x_Globals)
+ {
+ session_set_action(sess, "vs2002");
+ 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/actions/vs200x/tests/vs200x_tests.cpp
index 2f3d62f..a41a071 100644
--- a/src/action/vs200x/tests/vs200x_tests.cpp
+++ b/src/actions/vs200x/tests/vs200x_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x.h"
+#include "actions/vs200x/vs200x.h"
}
@@ -46,4 +46,11 @@ SUITE(action)
const char* result = vs200x_project_file_extension(prj);
CHECK_EQUAL(".vcproj", result);
}
+
+ TEST_FIXTURE(FxAction, ProjectExtension_IsVcproj_ForCpp)
+ {
+ project_set_language(prj, "c++");
+ const char* result = vs200x_project_file_extension(prj);
+ CHECK_EQUAL(".vcproj", result);
+ }
}
diff --git a/src/action/vs200x/tests/vs200x_xml_tests.cpp b/src/actions/vs200x/tests/vs200x_xml_tests.cpp
index dfde57a..9616b99 100644
--- a/src/action/vs200x/tests/vs200x_xml_tests.cpp
+++ b/src/actions/vs200x/tests/vs200x_xml_tests.cpp
@@ -5,9 +5,9 @@
*/
#include "premake.h"
-#include "action/tests/action_tests.h"
+#include "actions/tests/action_tests.h"
extern "C" {
-#include "action/vs200x/vs200x.h"
+#include "actions/vs200x/vs200x.h"
}
@@ -91,4 +91,30 @@ SUITE(action)
vs200x_attribute(strm, 3, "ProjectType", "Visual C++");
CHECK_EQUAL("\n\t\t\tProjectType=\"Visual C++\"", buffer);
}
+
+ TEST_FIXTURE(FxAction, Attribute_IsEscaped)
+ {
+ session_set_action(sess, "vs2002");
+ vs200x_attribute(strm, 1, "PreprocessorSymbols", "DEBUG;MSG=\"Hello\";TRACE");
+ CHECK_EQUAL("\n\tPreprocessorSymbols=\"DEBUG;MSG=&quot;Hello&quot;;TRACE\"", buffer);
+ }
+
+ TEST_FIXTURE(FxAction, AttributeList_OnLevel0)
+ {
+ const char* values[] = { "VALUE0", "VALUE1", "VALUE2", NULL };
+ Strings strs = strings_create_from_array(values);
+ vs200x_list_attribute(strm, 0, "Values", strs);
+ CHECK_EQUAL("\nValues=\"VALUE0;VALUE1;VALUE2\"", buffer);
+ strings_destroy(strs);
+ }
+
+ TEST_FIXTURE(FxAction, AttributeList_IsEscaped)
+ {
+ const char* values[] = { "VALUE0", "VALUE1=\"Hello\"", "VALUE2", NULL };
+ Strings strs = strings_create_from_array(values);
+ vs200x_list_attribute(strm, 0, "Values", strs);
+ CHECK_EQUAL("\nValues=\"VALUE0;VALUE1=&quot;Hello&quot;;VALUE2\"", buffer);
+ strings_destroy(strs);
+ }
+
}
diff --git a/src/action/vs200x/vs2002.c b/src/actions/vs200x/vs2002.c
index ad34a95..8abc23b 100644
--- a/src/action/vs200x/vs2002.c
+++ b/src/actions/vs200x/vs2002.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "premake.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
diff --git a/src/action/vs200x/vs2002_solution.c b/src/actions/vs200x/vs2002_solution.c
index 7274eb7..7274eb7 100644
--- a/src/action/vs200x/vs2002_solution.c
+++ b/src/actions/vs200x/vs2002_solution.c
diff --git a/src/action/vs200x/vs2003.c b/src/actions/vs200x/vs2003.c
index 6c9ec3c..db83666 100644
--- a/src/action/vs200x/vs2003.c
+++ b/src/actions/vs200x/vs2003.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "premake.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
diff --git a/src/action/vs200x/vs2003_solution.c b/src/actions/vs200x/vs2003_solution.c
index 1c1517c..1c1517c 100644
--- a/src/action/vs200x/vs2003_solution.c
+++ b/src/actions/vs200x/vs2003_solution.c
diff --git a/src/action/vs200x/vs2005.c b/src/actions/vs200x/vs2005.c
index 8b4175a..47e835c 100644
--- a/src/action/vs200x/vs2005.c
+++ b/src/actions/vs200x/vs2005.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "premake.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
diff --git a/src/action/vs200x/vs2005_solution.c b/src/actions/vs200x/vs2005_solution.c
index 6f589ea..6f589ea 100644
--- a/src/action/vs200x/vs2005_solution.c
+++ b/src/actions/vs200x/vs2005_solution.c
diff --git a/src/action/vs200x/vs2008.c b/src/actions/vs200x/vs2008.c
index 20f191f..9af42ad 100644
--- a/src/action/vs200x/vs2008.c
+++ b/src/actions/vs200x/vs2008.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "premake.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
diff --git a/src/action/vs200x/vs2008_solution.c b/src/actions/vs200x/vs2008_solution.c
index 856bd51..856bd51 100644
--- a/src/action/vs200x/vs2008_solution.c
+++ b/src/actions/vs200x/vs2008_solution.c
diff --git a/src/action/vs200x/vs200x.c b/src/actions/vs200x/vs200x.c
index 21b60ff..91b4cfb 100644
--- a/src/action/vs200x/vs200x.c
+++ b/src/actions/vs200x/vs200x.c
@@ -5,9 +5,11 @@
*/
#include <assert.h>
+#include <stdio.h>
#include <stdlib.h>
#include "premake.h"
#include "vs200x.h"
+#include "base/buffers.h"
#include "base/cstr.h"
#include "base/error.h"
@@ -23,15 +25,40 @@
int vs200x_attribute(Stream strm, int indent_size, const char* name, const char* value, ...)
{
va_list args;
+ char* buffer;
int z = OKAY;
- va_start(args, value);
z |= stream_writeline(strm, "");
z |= stream_write_n(strm, "\t", indent_size);
z |= stream_write(strm, "%s=\"", name);
- z |= stream_vprintf(strm, value, args);
- z |= stream_write(strm, "\"");
+
+ buffer = buffers_next();
+ va_start(args, value);
+ vsprintf(buffer, value, args);
+ z |= stream_write_escaped(strm, buffer);
va_end(args);
+
+ z |= stream_write(strm, "\"");
+ return z;
+}
+
+
+/**
+ * Write an XML attribute containing a list of values, adjusting for the differing Visual Studio formats.
+ * \param strm The output stream, the attribute will be written here.
+ * \param indent_size How far to indent (with tabs) the attribute.
+ * \param name The attribute name.
+ * \param values The attribute list value.
+ * \returns OKAY if successful.
+ */
+int vs200x_list_attribute(Stream strm, int indent_size, const char* name, Strings values)
+{
+ int z = OKAY;
+
+ z |= stream_writeline(strm, "");
+ z |= stream_write_n(strm, "\t", indent_size);
+ z |= stream_write(strm, "%s=", name);
+ z |= stream_write_strings(strm, values, "\"", "", "", ";", "\"", stream_write_escaped);
return z;
}
diff --git a/src/action/vs200x/vs200x.h b/src/actions/vs200x/vs200x.h
index 6035cd8..b99c2f5 100644
--- a/src/action/vs200x/vs200x.h
+++ b/src/actions/vs200x/vs200x.h
@@ -9,6 +9,7 @@
#include "session/session.h"
int vs200x_attribute(Stream strm, int indent_size, const char* name, const char* value, ...);
+int vs200x_list_attribute(Stream strm, int indent_size, const char* name, Strings values);
int vs200x_element_end(Session sess, Stream strm, int level, const char* markup);
const char* vs200x_false(Session sess);
int vs200x_get_target_version(Session sess);
diff --git a/src/action/vs200x/vs200x_config.c b/src/actions/vs200x/vs200x_config.c
index 24e4493..3e94305 100644
--- a/src/action/vs200x/vs200x_config.c
+++ b/src/actions/vs200x/vs200x_config.c
@@ -16,6 +16,22 @@ int vs200x_config_character_set(Session sess, Stream strm)
}
+/**
+ * Write out the list of preprocessor symbols as defined by the configuration.
+ * This entry is only written if there are values to write.
+ */
+int vs200x_config_defines(Session sess, Stream strm, Project prj)
+{
+ Strings values = project_get_config_values(prj, BlockDefines);
+ UNUSED(sess);
+ if (strings_size(values) > 0)
+ {
+ return vs200x_list_attribute(strm, 4, "PreprocessorDefinitions", values);
+ }
+ return OKAY;
+}
+
+
int vs200x_config_detect_64bit_portability(Session sess, Stream strm, Project prj)
{
int version = vs200x_get_target_version(sess);
diff --git a/src/action/vs200x/vs200x_config.h b/src/actions/vs200x/vs200x_config.h
index 54c1c03..53172e9 100644
--- a/src/action/vs200x/vs200x_config.h
+++ b/src/actions/vs200x/vs200x_config.h
@@ -9,6 +9,7 @@
#include "session/session.h"
int vs200x_config_character_set(Session sess, Stream strm);
+int vs200x_config_defines(Session sess, Stream strm, Project prj);
int vs200x_config_detect_64bit_portability(Session sess, Stream strm, Project prj);
int vs200x_config_runtime_type_info(Session sess, Stream strm, Project prj);
int vs200x_config_use_precompiled_header(Session sess, Stream strm, Project prj);
diff --git a/src/action/vs200x/vs200x_project.c b/src/actions/vs200x/vs200x_project.c
index 5c5f2a2..0c48255 100644
--- a/src/action/vs200x/vs200x_project.c
+++ b/src/actions/vs200x/vs200x_project.c
@@ -7,10 +7,10 @@
#include <stdlib.h>
#include <string.h>
#include "premake.h"
-#include "action/action.h"
#include "vs200x.h"
#include "vs200x_project.h"
#include "vs200x_config.h"
+#include "actions/support/sourcetree.h"
#include "base/cstr.h"
#include "base/path.h"
@@ -111,15 +111,18 @@ int vs200x_project_element(Session sess, Project prj, Stream strm)
*/
int vs200x_project_encoding(Session sess, Project prj, Stream strm)
{
+ int z;
UNUSED(sess);
UNUSED(prj);
+
stream_set_newline(strm, "\r\n");
- return stream_writeline(strm, "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>");
+ z = stream_writeline(strm, "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>");
+ return z;
}
/**
- * Write an individual file entry to the project file; callback for action_source_tree().
+ * Write an individual file entry to the project file; callback for sourcetree_walk().
* \param sess The current execution session context.
* \param prj The current project; contains the file being enumerated.
* \param strm The active output stream; for writing the file markup.
@@ -199,7 +202,7 @@ int vs200x_project_files(Session sess, Project prj, Stream strm)
{
int z = OKAY;
z |= stream_writeline(strm, "\t<Files>");
- z |= action_source_tree(sess, prj, strm, vs200x_project_file);
+ z |= sourcetree_walk(sess, prj, strm, vs200x_project_file);
z |= stream_writeline(strm, "\t</Files>");
return z;
}
@@ -318,12 +321,11 @@ 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 version, z;
- UNUSED(prj);
- version = vs200x_get_target_version(sess);
- z = stream_write(strm, "\t\t\t<Tool");
+ int z = OKAY;
+ z |= stream_write(strm, "\t\t\t<Tool");
z |= vs200x_attribute(strm, 4, "Name", "VCCLCompilerTool");
z |= vs200x_attribute(strm, 4, "Optimization", "0");
+ z |= vs200x_config_defines(sess, strm, prj);
z |= vs200x_attribute(strm, 4, "MinimalRebuild", vs200x_true(sess));
z |= vs200x_attribute(strm, 4, "BasicRuntimeChecks", "3");
z |= vs200x_attribute(strm, 4, "RuntimeLibrary", "3");
diff --git a/src/action/vs200x/vs200x_project.h b/src/actions/vs200x/vs200x_project.h
index a4950f9..a4950f9 100644
--- a/src/action/vs200x/vs200x_project.h
+++ b/src/actions/vs200x/vs200x_project.h
diff --git a/src/action/vs200x/vs200x_solution.c b/src/actions/vs200x/vs200x_solution.c
index 6578bd4..6578bd4 100644
--- a/src/action/vs200x/vs200x_solution.c
+++ b/src/actions/vs200x/vs200x_solution.c
diff --git a/src/action/vs200x/vs200x_solution.h b/src/actions/vs200x/vs200x_solution.h
index 18683c4..18683c4 100644
--- a/src/action/vs200x/vs200x_solution.h
+++ b/src/actions/vs200x/vs200x_solution.h
diff --git a/src/base/array.c b/src/base/array.c
index e6747b1..96ffbe2 100644
--- a/src/base/array.c
+++ b/src/base/array.c
@@ -4,11 +4,12 @@
* \author Copyright (c) 2007-2008 Jason Perkins and the Premake project
*/
+#include <assert.h>
#include <stdlib.h>
#include "premake.h"
#include "base/array.h"
-#define INITIAL_SIZE 16
+#define ALLOCATION_SIZE (16)
DEFINE_CLASS(Array)
{
@@ -25,9 +26,9 @@ DEFINE_CLASS(Array)
Array array_create()
{
Array arr = ALLOC_CLASS(Array);
- arr->contents = (void**)malloc(sizeof(void*) * INITIAL_SIZE);
+ arr->contents = NULL;
arr->size = 0;
- arr->capacity = INITIAL_SIZE;
+ arr->capacity = 0;
return arr;
}
@@ -38,7 +39,11 @@ Array array_create()
*/
void array_destroy(Array arr)
{
- free(arr->contents);
+ assert(arr);
+ if (arr->contents != NULL)
+ {
+ free(arr->contents);
+ }
free(arr);
}
@@ -50,6 +55,7 @@ void array_destroy(Array arr)
*/
int array_size(Array arr)
{
+ assert(arr);
return arr->size;
}
@@ -61,10 +67,12 @@ int array_size(Array arr)
*/
void array_add(Array arr, void* item)
{
+ assert(arr);
+ assert(item);
if (arr->size == arr->capacity)
{
- arr->capacity *= 2;
- arr->contents = (void**)realloc(arr->contents, arr->capacity);
+ arr->capacity += ALLOCATION_SIZE;
+ arr->contents = (void**)realloc(arr->contents, sizeof(void*) * arr->capacity);
}
arr->contents[arr->size] = item;
@@ -80,6 +88,8 @@ void array_add(Array arr, void* item)
*/
void* array_item(Array arr, int index)
{
+ assert(arr);
+ assert((index >= 0 && index < arr->size) || (index == 0 && arr->size == 0));
return arr->contents[index];
}
@@ -92,6 +102,9 @@ void* array_item(Array arr, int index)
*/
void array_set(Array arr, int index, void* item)
{
+ assert(arr);
+ assert(item);
+ assert(index >= 0 && index < arr->size);
arr->contents[index] = item;
}
@@ -104,6 +117,10 @@ void array_set(Array arr, int index, void* item)
void array_append(Array dest, Array src)
{
int i;
+
+ assert(dest);
+ assert(src);
+
for (i = 0; i < src->size; ++i)
{
array_add(dest, src->contents[i]);
diff --git a/src/base/buffers.c b/src/base/buffers.c
index 42edd58..2e3304b 100644
--- a/src/base/buffers.c
+++ b/src/base/buffers.c
@@ -23,7 +23,7 @@
const int BUFFER_SIZE = 0x4000;
/** The number of buffers stored in the pool */
-static const int NUM_BUFFERS = 64;
+static const int NUM_BUFFERS = 128;
/** The pool of buffers */
static char** buffers = NULL;
diff --git a/src/base/cstr.c b/src/base/cstr.c
index ea3bd30..feb326e 100644
--- a/src/base/cstr.c
+++ b/src/base/cstr.c
@@ -4,6 +4,7 @@
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
+#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
@@ -21,6 +22,8 @@
*/
int cstr_contains(const char* str, const char* expected)
{
+ assert(str);
+ assert(expected);
return (strstr(str, expected) != NULL);
}
@@ -122,3 +125,21 @@ int cstr_starts_with(const char* str, const char* expected)
}
return 0;
}
+
+
+/**
+ * Remove a character from the end of a string, if present.
+ * \param str The string to trim.
+ * \param ch The character to trim.
+ */
+void cstr_trim(char* str, char ch)
+{
+ int i;
+ assert(str);
+ i = strlen(str) - 1;
+ while (i >= 0 && str[i] == ch)
+ {
+ str[i] = '\0';
+ i--;
+ }
+}
diff --git a/src/base/cstr.h b/src/base/cstr.h
index 3904126..3d734b6 100644
--- a/src/base/cstr.h
+++ b/src/base/cstr.h
@@ -19,6 +19,7 @@ int cstr_eq(const char* str, const char* expected);
int cstr_eqi(const char* str, const char* expected);
char* cstr_format(const char* format, ...);
int cstr_starts_with(const char* str, const char* expected);
+void cstr_trim(char* str, char ch);
#endif
/** @} */
diff --git a/src/base/stream.c b/src/base/stream.c
index ebe7247..8aae05b 100644
--- a/src/base/stream.c
+++ b/src/base/stream.c
@@ -140,9 +140,10 @@ void stream_set_newline(Stream strm, const char* newline)
* \param infix An infix strings, to write between items, after the
* previous postfix string and before the next prefix.
* \param end The end string, always written last, even if there are no items in the list.
+ * \param writer A callback function to handle output of each list item.
* \returns OKAY if successful.
*/
-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_strings(Stream strm, Strings strs, const char* start, const char* prefix, const char* postfix, const char* infix, const char* end, StreamWriterFunc writer)
{
int i, n, z;
@@ -154,7 +155,14 @@ int stream_write_strings(Stream strm, Strings strs, const char* start, const cha
const char* value = strings_item(strs, i);
if (i > 0) z |= stream_write(strm, infix);
z |= stream_write(strm, prefix);
- z |= stream_write(strm, value);
+ if (writer != NULL)
+ {
+ z |= writer(strm, value);
+ }
+ else
+ {
+ z |= stream_write(strm, value);
+ }
z |= stream_write(strm, postfix);
}
@@ -242,6 +250,49 @@ int stream_write(Stream strm, const char* value, ...)
/**
+ * Write a string value to a stream, applying XML escape codes in the process.
+ * \param strm The stream to which to write.
+ * \param value The string to write.
+ * \returns OKAY if successful.
+ */
+int stream_write_escaped(Stream strm, const char* value)
+{
+ const char* ptr;
+ char buffer[2];
+ int z = OKAY;
+
+ buffer[1] = '\0';
+
+ for (ptr = value; *ptr != '\0'; ++ptr)
+ {
+ switch (*ptr)
+ {
+ case '\"':
+ z |= stream_write(strm, "&quot;");
+ break;
+ case '&':
+ z |= stream_write(strm, "&amp;");
+ break;
+ case '\'':
+ z |= stream_write(strm, "&apos;");
+ break;
+ case '<':
+ z |= stream_write(strm, "&lt;");
+ break;
+ case '>':
+ z |= stream_write(strm, "&gt;");
+ break;
+ default:
+ z |= stream_write(strm, "%c", *ptr);
+ break;
+ }
+ }
+
+ return z;
+}
+
+
+/**
* Write N copies of a string to a stream.
* \param strm The stream to which to write.
* \param value The string to write.
diff --git a/src/base/stream.h b/src/base/stream.h
index 89925ea..e319510 100644
--- a/src/base/stream.h
+++ b/src/base/stream.h
@@ -20,6 +20,8 @@ DECLARE_CLASS(Stream);
extern Stream Console;
+typedef int (*StreamWriterFunc)(Stream strm, const char *value);
+
Stream stream_create_file(const char* filename);
Stream stream_create_null(void);
void stream_destroy(Stream stream);
@@ -27,8 +29,9 @@ 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_escaped(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_strings(Stream strm, Strings strs, const char* start, const char* prefix, const char* postfix, const char* infix, const char* end, StreamWriterFunc writer);
int stream_write_unicode_marker(Stream strm);
int stream_writeline(Stream strm, const char* value, ...);
int stream_writeline_strings(Stream strm, Strings strs, const char* start, const char* prefix, const char* postfix, const char* infix);
diff --git a/src/base/strings.c b/src/base/strings.c
index 7862b68..70a7a95 100644
--- a/src/base/strings.c
+++ b/src/base/strings.c
@@ -29,6 +29,22 @@ Strings strings_create()
/**
+ * Create a dynamic array of C strings, initialized from an existing array.
+ * \param items The initial list of items for the strings collection.
+ * \returns A new string array.
+ */
+Strings strings_create_from_array(const char* items[])
+{
+ Strings strs = strings_create();
+ for ( ; *items != NULL; ++items)
+ {
+ strings_add(strs, *items);
+ }
+ return strs;
+}
+
+
+/**
* Destroy a strings array and free the associated memory.
* \param strs The string array to destroy.
*/
diff --git a/src/base/strings.h b/src/base/strings.h
index d75daa2..cd17f44 100644
--- a/src/base/strings.h
+++ b/src/base/strings.h
@@ -16,6 +16,7 @@
DECLARE_CLASS(Strings);
Strings strings_create(void);
+Strings strings_create_from_array(const char** items);
void strings_destroy(Strings strs);
void strings_add(Strings strs, const char* item);
diff --git a/src/base/tests/cstr_tests.cpp b/src/base/tests/cstr_tests.cpp
index bf7a996..470cce8 100644
--- a/src/base/tests/cstr_tests.cpp
+++ b/src/base/tests/cstr_tests.cpp
@@ -146,4 +146,25 @@ SUITE(cstr)
{
CHECK(!cstr_starts_with("Abc", NULL));
}
+
+
+ /**********************************************************************
+ * cstr_trim() tests
+ **********************************************************************/
+
+ TEST(CStrTrim_DoesNothing_OnNoMatch)
+ {
+ char buffer[32];
+ strcpy(buffer, "Msg");
+ cstr_trim(buffer, '/');
+ CHECK_EQUAL("Msg", buffer);
+ }
+
+ TEST(CStrTrim_DoesTrim_OnMatch)
+ {
+ char buffer[32];
+ strcpy(buffer, "Msg///");
+ cstr_trim(buffer, '/');
+ CHECK_EQUAL("Msg", buffer);
+ }
}
diff --git a/src/base/tests/stream_tests.cpp b/src/base/tests/stream_tests.cpp
index 1339f68..2fb74e4 100644
--- a/src/base/tests/stream_tests.cpp
+++ b/src/base/tests/stream_tests.cpp
@@ -84,14 +84,14 @@ SUITE(base)
TEST_FIXTURE(FxStreamStrings, WriteStrings_WritesStartEnd_OnEmptyList)
{
- stream_write_strings(strm, strs, "^", "<", ">", ",", "$");
+ stream_write_strings(strm, strs, "^", "<", ">", ",", "$", NULL);
CHECK_EQUAL("^$", buffer);
}
TEST_FIXTURE(FxStreamStrings, WriteStrings_WriteSingleItem_OnSingleItem)
{
strings_add(strs, "AAA");
- stream_write_strings(strm, strs, "^", "<", ">", ",", "$");
+ stream_write_strings(strm, strs, "^", "<", ">", ",", "$", NULL);
CHECK_EQUAL("^<AAA>$", buffer);
}
@@ -100,8 +100,18 @@ SUITE(base)
strings_add(strs, "AAA");
strings_add(strs, "BBB");
strings_add(strs, "CCC");
- stream_write_strings(strm, strs, "^", "<", ">", ",", "$");
+ stream_write_strings(strm, strs, "^", "<", ">", ",", "$", NULL);
CHECK_EQUAL("^<AAA>,<BBB>,<CCC>$", buffer);
}
+
+ /**********************************************************************
+ * stream_write_escaped() tests
+ **********************************************************************/
+
+ TEST_FIXTURE(FxStream, WriteEscaped_EscapesSpecialCharacters)
+ {
+ stream_write_escaped(strm, "Specials: \" & \' < >");
+ CHECK_EQUAL("Specials: &quot; &amp; &apos; &lt; &gt;", buffer);
+ }
}
diff --git a/src/host/host.c b/src/host/host.c
index 8226c7b..aa89b4c 100644
--- a/src/host/host.c
+++ b/src/host/host.c
@@ -8,7 +8,7 @@
#include <stdlib.h>
#include "premake.h"
#include "host/host.h"
-#include "action/action.h"
+#include "actions/actions.h"
#include "base/cstr.h"
#include "base/error.h"
#include "base/file.h"
diff --git a/src/premake.c b/src/premake.c
index 8c57761..6a4cf65 100644
--- a/src/premake.c
+++ b/src/premake.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "premake.h"
#include "host/host.h"
-#include "action/action.h"
+#include "actions/actions.h"
/**
diff --git a/src/premake.lua b/src/premake.lua
index 0754881..f4b5b8c 100644
--- a/src/premake.lua
+++ b/src/premake.lua
@@ -3,18 +3,8 @@ package.target = "premake4"
package.language = "c"
package.kind = "exe"
-local subsystems =
-{
- "platform",
- "base",
- "project",
- "action",
- "action/make",
- "action/vs200x",
- "script",
- "session",
- "host"
-}
+ local lua = "script/lua-5.1.2"
+ local unittest = "testing/UnitTest++/src"
-- Build settings
@@ -50,30 +40,26 @@ local subsystems =
package.includepaths =
{
- "."
+ ".",
+ lua .. "/src",
}
-
-
--- Files
-
- package.files = matchfiles("*.h", "*.c")
- for k,m in subsystems do
- table.insert(package.files, matchfiles(m.."/*.h", m.."/*.c"))
- end
-
-
--- Lua scripting engine
- local lua = "script/lua-5.1.2/src"
- table.insert(package.includepaths, lua)
- table.insert(package.files, matchfiles(lua.."/*.h", lua.."/*.c"))
- table.insert(package.excludes, {lua.."/lua.c", lua.."/luac.c"})
+ package.files =
+ {
+ matchrecursive("*.h", "*.c"),
+ }
+
+ package.excludes =
+ {
+ lua .. "/src/lua.c",
+ lua .. "/src/luac.c",
+ matchfiles(lua .. "/etc/*.c")
+ }
-- Automated tests
if (not options["no-tests"]) then
- local unittest = "testing/UnitTest++/src"
-- UnitTest++ is a C++ system
package.language = "c++"
@@ -81,18 +67,15 @@ local subsystems =
-- Define a symbol so I can compile in the testing calls
table.insert(package.defines, "TESTING_ENABLED")
- table.insert(package.files, matchfiles("testing/*.h", "testing/*.cpp", unittest.."/*"))
-
- for k,m in subsystems do
- table.insert(package.files, matchfiles(m.."/tests/*.h", m.."/tests/*.cpp"))
- end
+ table.insert(package.files, matchrecursive("*.cpp"))
+ table.insert(package.excludes, matchfiles(unittest .. "/tests/*"))
- if (windows) then
- table.insert(package.files, matchfiles(unittest.."/Win32/*"))
+ if (windows) then
+ table.insert(package.excludes, matchfiles(unittest .. "/Posix/*"))
package.config["Debug"].postbuildcommands = { "..\\bin\\debug\\premake4.exe" }
package.config["Release"].postbuildcommands = { "..\\bin\\release\\premake4.exe" }
else
- table.insert(package.files, matchfiles(unittest.."/Posix/*"))
+ table.insert(package.excludes, matchfiles(unittest .. "/Win32/*"))
package.config["Debug"].postbuildcommands = { "../bin/debug/premake4" }
package.config["Release"].postbuildcommands = { "../bin/release/premake4" }
end
diff --git a/src/project/block.c b/src/project/block.c
index 7843407..ffae09c 100644
--- a/src/project/block.c
+++ b/src/project/block.c
@@ -49,20 +49,30 @@ void block_destroy(Block blk)
/**
- * Retrieve the list of defines associated with a block.
+ * Retrieve the fields object for this block; used to unload values from the script.
*/
-Strings block_get_defines(Block blk)
+Fields block_get_fields(Block blk)
{
assert(blk);
- return fields_get_values(blk->fields, BlockDefines);
+ return blk->fields;
}
/**
- * Retrieve the fields object for this block; used to unload values from the script.
+ * Retrieve a list of values associated with a block.
*/
-Fields block_get_fields(Block blk)
+Strings block_get_values(Block blk, enum BlockField which)
{
assert(blk);
- return blk->fields;
+ return fields_get_values(blk->fields, which);
+}
+
+
+/**
+ * Set a value list field on the block.
+ */
+void block_set_values(Block blk, enum BlockField which, Strings strs)
+{
+ assert(blk);
+ fields_set_values(blk->fields, which, strs);
}
diff --git a/src/project/block.h b/src/project/block.h
index 0d4f4ff..89b5fe3 100644
--- a/src/project/block.h
+++ b/src/project/block.h
@@ -31,8 +31,9 @@ DECLARE_CLASS(Block)
Block block_create(void);
void block_destroy(Block blk);
-Strings block_get_defines(Block blk);
Fields block_get_fields(Block blk);
+Strings block_get_values(Block blk, enum BlockField which);
+void block_set_values(Block blk, enum BlockField which, Strings strs);
#endif
diff --git a/src/project/blocks.c b/src/project/blocks.c
new file mode 100644
index 0000000..7ff81bd
--- /dev/null
+++ b/src/project/blocks.c
@@ -0,0 +1,84 @@
+/**
+ * \file blocks.h
+ * \brief A list of configuration blocks.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include "premake.h"
+#include "project/blocks.h"
+#include "base/array.h"
+
+
+DEFINE_CLASS(Blocks)
+{
+ Array blocks;
+};
+
+
+/**
+ * Create and initialize a new list of configuration blocks.
+ * \returns A new configuration block list.
+ */
+Blocks blocks_create(void)
+{
+ Blocks blks = ALLOC_CLASS(Blocks);
+ blks->blocks = array_create();
+ return blks;
+}
+
+
+/**
+ * Destroy a configuration block list and release the associated memory.
+ * \param blks The configuration block list to destroy.
+ */
+void blocks_destroy(Blocks blks)
+{
+ int i, n;
+ assert(blks);
+ n = blocks_size(blks);
+ for (i = 0; i < n; ++i)
+ {
+ Block blk = blocks_item(blks, i);
+ block_destroy(blk);
+ }
+ array_destroy(blks->blocks);
+ free(blks);
+}
+
+
+/**
+ * Add a new block to a list.
+ * \param blks The configuration block list.
+ * \param blk The block to add to the list.
+ */
+void blocks_add(Blocks blks, Block blk)
+{
+ assert(blks);
+ assert(blk);
+ array_add(blks->blocks, blk);
+}
+
+
+/**
+ * Retrieve an item from the list of blocks.
+ * \param blks The configuration block list.
+ * \param index The index of the item to retrieve.
+ * \returns The block at the given index.
+ */
+Block blocks_item(Blocks blks, int index)
+{
+ assert(blks);
+ return (Block)array_item(blks->blocks, index);
+}
+
+
+/**
+ * Returns the number of blocks in the list.
+ * \param blks The configuration block list.
+ */
+int blocks_size(Blocks blks)
+{
+ return array_size(blks->blocks);
+}
diff --git a/src/project/blocks.h b/src/project/blocks.h
new file mode 100644
index 0000000..1bf7887
--- /dev/null
+++ b/src/project/blocks.h
@@ -0,0 +1,25 @@
+/**
+ * \file blocks.h
+ * \brief A list of configuration blocks.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ *
+ * \addtogroup project
+ * @{
+ */
+#if !defined(PREMAKE_BLOCKS_H)
+#define PREMAKE_BLOCKS_H
+
+#include "block.h"
+
+DECLARE_CLASS(Blocks)
+
+Blocks blocks_create(void);
+void blocks_destroy(Blocks blks);
+
+void blocks_add(Blocks blks, Block blk);
+Block blocks_item(Blocks blks, int index);
+int blocks_size(Blocks blks);
+
+
+#endif
+/** @} */
diff --git a/src/project/fields.c b/src/project/fields.c
index 7ee178d..49e131d 100644
--- a/src/project/fields.c
+++ b/src/project/fields.c
@@ -146,7 +146,7 @@ void fields_set_value(Fields fields, int index, const char* value)
/**
* Sets the list of values associated with a field. The field will subsequently
- * "own" the list, and take responsibility to destroying it with the field set.
+ * "own" the list, and take responsibility for destroying it with the field set.
* \param fields The collection of fields.
* \param index The index of the field to set.
* \param values The list of new values for the field.
diff --git a/src/project/filter.c b/src/project/filter.c
new file mode 100644
index 0000000..a6df87b
--- /dev/null
+++ b/src/project/filter.c
@@ -0,0 +1,112 @@
+/**
+ * \file filter.c
+ * \brief Configuration filter settings.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include "premake.h"
+#include "project/filter.h"
+#include "base/cstr.h"
+
+
+DEFINE_CLASS(Filter)
+{
+ const char* values[NumFilters];
+};
+
+
+/**
+ * Create and initialize a new configuration filter.
+ * \returns A new configuration filter.
+ */
+Filter filter_create(void)
+{
+ int i;
+
+ Filter flt = ALLOC_CLASS(Filter);
+ for (i = 0; i < NumFilters; ++i)
+ {
+ flt->values[i] = NULL;
+ }
+ return flt;
+}
+
+
+/**
+ * Destroy a configuration filter and release the associated memory.
+ * \param flt The configuration filter to destroy.
+ */
+void filter_destroy(Filter flt)
+{
+ assert(flt);
+ free(flt);
+}
+
+
+/**
+ * Retrieve a filter value.
+ * \param flt The configuration filter to query.
+ * \param key The value key to query.
+ * \returns The current value of the key.
+ */
+const char* filter_get_value(Filter flt, enum FilterKey key)
+{
+ assert(flt);
+ assert(key >= 0 && key < NumFilters);
+ return flt->values[key];
+}
+
+
+/**
+ * Determines if the filter includes the specified list of terms. All terms in the
+ * list must be included in the filter.
+ * \param flt The configuration filter to query.
+ * \param terms The list of terms to check.
+ * \returns True is the list of terms is included in the filter.
+ */
+int filter_is_match(Filter flt, Strings terms)
+{
+ int ti, tn;
+
+ assert(flt);
+ assert(terms);
+
+ tn = strings_size(terms);
+ for (ti = 0; ti < tn; ++ti)
+ {
+ int ki, is_match = 0;
+
+ const char* term = strings_item(terms, ti);
+ for (ki = 0; ki < NumFilters; ++ki)
+ {
+ if (cstr_eq(flt->values[ki], term))
+ {
+ is_match = 1;
+ break;
+ }
+ }
+
+ if (!is_match)
+ {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+
+/**
+ * Set a filter value.
+ * \param flt The configuration filter to set.
+ * \param key The value key to set.
+ * \param value The new value for the key.
+ */
+void filter_set_value(Filter flt, enum FilterKey key, const char* value)
+{
+ assert(flt);
+ assert(key >= 0 && key < NumFilters);
+ flt->values[key] = value;
+}
diff --git a/src/project/filter.h b/src/project/filter.h
new file mode 100644
index 0000000..b042815
--- /dev/null
+++ b/src/project/filter.h
@@ -0,0 +1,36 @@
+/**
+ * \file filter.h
+ * \brief Configuration filter settings.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ *
+ * \addtogroup project
+ * @{
+ */
+#if !defined(PREMAKE_FILTER_H)
+#define PREMAKE_FILTER_H
+
+#include "base/strings.h"
+
+
+/**
+ * Configuration filter keys.
+ */
+enum FilterKey
+{
+ FilterConfig,
+ NumFilters
+};
+
+
+DECLARE_CLASS(Filter)
+
+Filter filter_create(void);
+void filter_destroy(Filter flt);
+
+const char* filter_get_value(Filter flt, enum FilterKey key);
+int filter_is_match(Filter flt, Strings terms);
+void filter_set_value(Filter flt, enum FilterKey key, const char* value);
+
+
+#endif
+/** @} */
diff --git a/src/project/project.c b/src/project/project.c
index c9485f5..b9d1183 100644
--- a/src/project/project.c
+++ b/src/project/project.c
@@ -33,9 +33,10 @@ struct FieldInfo ProjectFieldInfo[] =
DEFINE_CLASS(Project)
{
Solution solution;
- Array blocks;
+ Blocks blocks;
Fields fields;
- const char* config_filter;
+ Filter filter;
+ Strings config_cache[NumBlockFields];
};
@@ -45,11 +46,19 @@ DEFINE_CLASS(Project)
*/
Project project_create()
{
+ int i;
+
Project prj = ALLOC_CLASS(Project);
prj->solution = NULL;
- prj->blocks = array_create();
+ prj->blocks = blocks_create();
prj->fields = fields_create(ProjectFieldInfo);
- prj->config_filter = NULL;
+ prj->filter = NULL;
+
+ for (i = 0; i < NumBlockFields; ++i)
+ {
+ prj->config_cache[i] = NULL;
+ }
+
return prj;
}
@@ -60,37 +69,21 @@ Project project_create()
*/
void project_destroy(Project prj)
{
- int i, n;
-
- assert(prj);
+ int i;
- n = project_num_blocks(prj);
- for (i = 0; i < n; ++i)
+ assert(prj);
+ blocks_destroy(prj->blocks);
+ fields_destroy(prj->fields);
+ for (i = 0; i < NumBlockFields; ++i)
{
- Block blk = project_get_block(prj, i);
- block_destroy(blk);
+ if (prj->config_cache[i] != NULL)
+ strings_destroy(prj->config_cache[i]);
}
- array_destroy(prj->blocks);
-
- fields_destroy(prj->fields);
free(prj);
}
/**
- * Add a configuration block to a project.
- * \param prj The project to contain the project.
- * \param blk The configuration block to add.
- */
-void project_add_block(Project prj, Block blk)
-{
- assert(prj);
- assert(blk);
- array_add(prj->blocks, blk);
-}
-
-
-/**
* Get the base directory for the project; any properties containing relative
* paths are relative to this location.
* \param prj The project object to query.
@@ -103,29 +96,64 @@ const char* project_get_base_dir(Project prj)
/**
- * Retrieve a configuration block from a project.
+ * Retrieve the list of configuration blocks associated with a project.
* \param prj The project to query.
- * \param index The index of the block to retreive.
- * \returns The block at the given index within the project.
+ * \returns A list of configuration blocks.
*/
-Block project_get_block(Project prj, int index)
+Blocks project_get_blocks(Project prj)
{
- Block blk;
assert(prj);
- blk = (Block)array_item(prj->blocks, index);
- return blk;
+ return prj->blocks;
}
+
/**
- * Retrieve the list of configuration blocks associated with a project.
+ * Scans a list of blocks and appends any values found to the provided list.
+ * \param values The resulting list of values.
+ * \param blks The list of blocks to scan.
+ * \param field The field to query.
+ */
+static void project_get_values_from_blocks(Strings values, Blocks blks, enum BlockField field)
+{
+ int i, n = blocks_size(blks);
+ for (i = 0; i < n; ++i)
+ {
+ Block blk = blocks_item(blks, i);
+ Strings block_values = block_get_values(blk, field);
+ strings_append(values, block_values);
+ }
+}
+
+
+/**
+ * Retrieve a list value from the project configuration, respecting the current filter set.
* \param prj The project to query.
- * \returns A list of configuration blocks.
+ * \param field Which field to retrieve.
+ * \returns The list of values stored in that field.
*/
-Array project_get_blocks(Project prj)
+Strings project_get_config_values(Project prj, enum BlockField field)
{
+ Strings values;
+
assert(prj);
- return prj->blocks;
+ assert(field >= 0 && field < NumBlockFields);
+
+ values = strings_create();
+
+ /* The "cache" just keeps track of all lists that I return to callers; I will
+ * take responsibility for destroying the lists, so the callers don't have to
+ * do it themselves. A bit of complexity here to simplify the action handers. */
+ if (prj->config_cache[field] != NULL)
+ {
+ strings_destroy(prj->config_cache[field]);
+ }
+ prj->config_cache[field] = values;
+
+ project_get_values_from_blocks(values, solution_get_blocks(prj->solution), field);
+ project_get_values_from_blocks(values, project_get_blocks(prj), field);
+
+ return values;
}
@@ -138,7 +166,24 @@ Array project_get_blocks(Project prj)
const char* project_get_configuration_filter(Project prj)
{
assert(prj);
- return prj->config_filter;
+ if (prj->filter)
+ {
+ return filter_get_value(prj->filter, FilterConfig);
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+/**
+ * Retrieve the list of preprocessor defines, using the current configuration filter.
+ */
+Strings project_get_defines(Project prj)
+{
+ Strings values = project_get_config_values(prj, BlockDefines);
+ return values;
}
@@ -303,18 +348,6 @@ int project_is_valid_language(const char* language)
/**
- * Return the number of configuration blocks contained by this project.
- * \param prj The project to query.
- * \returns The number of blocks contained by the project.
- */
-int project_num_blocks(Project prj)
-{
- assert(prj);
- return array_size(prj->blocks);
-}
-
-
-/**
* Set the base directory of the project.
* \param prj The project object to modify.
* \param base_dir The new base directory.
@@ -329,12 +362,13 @@ 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.
+ * \param filter The current filter.
*/
-void project_set_configuration_filter(Project prj, const char* cfg_name)
+void project_set_filter(Project prj, Filter flt)
{
assert(prj);
- prj->config_filter = cfg_name;
+ assert(flt);
+ prj->filter = flt;
}
diff --git a/src/project/project.h b/src/project/project.h
index 78b8596..dde57d4 100644
--- a/src/project/project.h
+++ b/src/project/project.h
@@ -13,8 +13,8 @@
#define PREMAKE_PROJECT_H
#include "fields.h"
-#include "block.h"
-#include "base/array.h"
+#include "blocks.h"
+#include "filter.h"
/**
@@ -40,10 +40,9 @@ DECLARE_CLASS(Project)
Project project_create(void);
void project_destroy(Project prj);
-void project_add_block(Project prj, Block blk);
const char* project_get_base_dir(Project prj);
-Block project_get_block(Project prj, int index);
-Array project_get_blocks(Project prj);
+Blocks project_get_blocks(Project prj);
+Strings project_get_config_values(Project prj, enum BlockField field);
const char* project_get_configuration_filter(Project prj);
Fields project_get_fields(Project prj);
const char* project_get_filename(Project prj, const char* basename, const char* ext);
@@ -55,9 +54,8 @@ const char* project_get_name(Project prj);
const char* project_get_outfile(Project prj);
const char* project_get_value(Project prj, enum ProjectField field);
int project_is_valid_language(const char* language);
-int project_num_blocks(Project prj);
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_filter(Project prj, Filter flt);
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/solution.c b/src/project/solution.c
index 0859696..e5cbab4 100644
--- a/src/project/solution.c
+++ b/src/project/solution.c
@@ -13,8 +13,6 @@
#include "base/path.h"
#include "base/strings.h"
-#include "base/string.h" /* <-- remove this? */
-
struct FieldInfo SolutionFieldInfo[] =
{
@@ -31,7 +29,7 @@ DEFINE_CLASS(Solution)
{
Fields fields;
Array projects;
- Array blocks;
+ Blocks blocks;
};
@@ -44,7 +42,7 @@ Solution solution_create()
Solution sln = ALLOC_CLASS(Solution);
sln->fields = fields_create(SolutionFieldInfo);
sln->projects = array_create();
- sln->blocks = array_create();
+ sln->blocks = blocks_create();
return sln;
}
@@ -59,14 +57,7 @@ void solution_destroy(Solution sln)
assert(sln);
fields_destroy(sln->fields);
-
- n = solution_num_blocks(sln);
- for (i = 0; i < n; ++i)
- {
- Block blk = solution_get_block(sln, i);
- block_destroy(blk);
- }
- array_destroy(sln->blocks);
+ blocks_destroy(sln->blocks);
n = solution_num_projects(sln);
for (i = 0; i < n; ++i)
@@ -81,19 +72,6 @@ void solution_destroy(Solution sln)
/**
- * Add a configuration block to a solution.
- * \param sln The solution to contain the project.
- * \param blk The configuration block to add.
- */
-void solution_add_block(Solution sln, Block blk)
-{
- assert(sln);
- assert(blk);
- array_add(sln->blocks, blk);
-}
-
-
-/**
* Add a configuration name to a solution.
* \param sln The solution to contain the project.
* \param config_name The name of the configuration add.
@@ -133,26 +111,11 @@ const char* solution_get_base_dir(Solution sln)
/**
- * Retrieve a configuration block from the solution.
- * \param sln The solution to query.
- * \param index The index of the block to retreive.
- * \returns The block at the given index within the solution.
- */
-Block solution_get_block(Solution sln, int index)
-{
- Block blk;
- assert(sln);
- blk = (Block)array_item(sln->blocks, index);
- return blk;
-}
-
-
-/**
* Retrieve the list of configuration blocks associated with a solution.
* \param sln The solution to query.
* \returns A list of configuration blocks.
*/
-Array solution_get_blocks(Solution sln)
+Blocks solution_get_blocks(Solution sln)
{
assert(sln);
return sln->blocks;
@@ -297,18 +260,6 @@ const char* solution_get_value(Solution sln, enum SolutionField field)
/**
- * Return the number of configuration blocks contained by this solution.
- * \param sln The solution to query.
- * \returns The number of blocks contained by the solution.
- */
-int solution_num_blocks(Solution sln)
-{
- assert(sln);
- return array_size(sln->blocks);
-}
-
-
-/**
* Return the number of configurations contained by this solution.
* \param sln The solution to query.
* \returns The number of configurations contained by the solution.
diff --git a/src/project/solution.h b/src/project/solution.h
index a34e3e3..2ebecc2 100644
--- a/src/project/solution.h
+++ b/src/project/solution.h
@@ -11,7 +11,6 @@
#include "fields.h"
#include "project.h"
-#include "block.h"
#include "base/strings.h"
@@ -37,12 +36,10 @@ DECLARE_CLASS(Solution)
Solution solution_create(void);
void solution_destroy(Solution sln);
-void solution_add_block(Solution sln, Block blk);
void solution_add_config(Solution sln, const char* config_name);
void solution_add_project(Solution sln, Project prj);
const char* solution_get_base_dir(Solution sln);
-Block solution_get_block(Solution sln, int index);
-Array solution_get_blocks(Solution sln);
+Blocks solution_get_blocks(Solution sln);
const char* solution_get_config(Solution sln, int index);
Strings solution_get_configs(Solution sln);
Fields solution_get_fields(Solution sln);
@@ -52,7 +49,6 @@ const char* solution_get_location(Solution sln);
const char* solution_get_name(Solution sln);
Project solution_get_project(Solution sln, int index);
const char* solution_get_value(Solution sln, enum SolutionField field);
-int solution_num_blocks(Solution sln);
int solution_num_configs(Solution sln);
int solution_num_projects(Solution sln);
void solution_set_base_dir(Solution sln, const char* base_dir);
diff --git a/src/project/tests/filter_tests.cpp b/src/project/tests/filter_tests.cpp
new file mode 100644
index 0000000..ae24e96
--- /dev/null
+++ b/src/project/tests/filter_tests.cpp
@@ -0,0 +1,67 @@
+/**
+ * \file filter_tests.cpp
+ * \brief Automated tests for the configuration filters API.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "testing/testing.h"
+extern "C" {
+#include "project/solution.h"
+#include "project/filter.h"
+}
+
+
+struct FxFilter
+{
+ Filter flt;
+ Strings terms;
+
+ FxFilter()
+ {
+ flt = filter_create();
+ terms = strings_create();
+ strings_add(terms, "Debug");
+ }
+
+ ~FxFilter()
+ {
+ filter_destroy(flt);
+ strings_destroy(terms);
+ }
+};
+
+
+SUITE(project)
+{
+ TEST_FIXTURE(FxFilter, Create_ReturnsObject_OnSuccess)
+ {
+ CHECK(flt != NULL);
+ }
+
+ TEST_FIXTURE(FxFilter, SetValue_CanRoundtrip)
+ {
+ filter_set_value(flt, FilterConfig, "Debug");
+ const char* result = filter_get_value(flt, FilterConfig);
+ CHECK_EQUAL("Debug", result);
+ }
+
+ TEST_FIXTURE(FxFilter, IsMatch_ReturnsTrue_OnValueMatch)
+ {
+ filter_set_value(flt, FilterConfig, "Debug");
+ CHECK(filter_is_match(flt, terms));
+ }
+
+ TEST_FIXTURE(FxFilter, IsMatch_ReturnsFalse_OnNullKey)
+ {
+ CHECK(!filter_is_match(flt, terms));
+ }
+
+ TEST_FIXTURE(FxFilter, IsMatch_ReturnsFalse_OnValueMismatch)
+ {
+ filter_set_value(flt, FilterConfig, "Release");
+ CHECK(!filter_is_match(flt, terms));
+ }
+}
+
+
diff --git a/src/project/tests/project_config_tests.cpp b/src/project/tests/project_config_tests.cpp
new file mode 100644
index 0000000..630de68
--- /dev/null
+++ b/src/project/tests/project_config_tests.cpp
@@ -0,0 +1,73 @@
+/**
+ * \file project_config_tests.cpp
+ * \brief Automated tests for the project configuration data API.
+ * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
+ */
+
+#include "premake.h"
+#include "testing/testing.h"
+extern "C" {
+#include "project/solution.h"
+#include "project/project.h"
+#include "project/project_internal.h"
+}
+
+
+struct FxPrjConfig
+{
+ Solution sln;
+ Fields sln_blk0_fields;
+
+ Project prj;
+ Fields prj_blk0_fields;
+
+ FxPrjConfig()
+ {
+ Blocks blks;
+ Block blk;
+ Strings strs;
+
+ sln = solution_create();
+ prj = project_create();
+ solution_add_project(sln, prj);
+
+ blks = solution_get_blocks(sln);
+ blk = block_create();
+ blocks_add(blks, blk);
+ sln_blk0_fields = block_get_fields(blk);
+
+ strs = strings_create();
+ strings_add(strs, "SLN");
+ fields_set_values(sln_blk0_fields, BlockDefines, strs);
+
+ blks = project_get_blocks(prj);
+ blk = block_create();
+ blocks_add(blks, blk);
+ prj_blk0_fields = block_get_fields(blk);
+
+ strs = strings_create();
+ strings_add(strs, "PRJ");
+ fields_set_values(prj_blk0_fields, BlockDefines, strs);
+ }
+
+ ~FxPrjConfig()
+ {
+ solution_destroy(sln);
+ }
+};
+
+
+SUITE(project_config)
+{
+ TEST_FIXTURE(FxPrjConfig, GetValues_GetsFromBoth)
+ {
+ Strings strs = project_get_config_values(prj, BlockDefines);
+ CHECK(strings_size(strs) == 2);
+ if (strings_size(strs) == 2)
+ {
+ CHECK_EQUAL("SLN", strings_item(strs, 0));
+ CHECK_EQUAL("PRJ", strings_item(strs, 1));
+ }
+ }
+}
+
diff --git a/src/project/tests/project_tests.cpp b/src/project/tests/project_tests.cpp
index 691bc5b..96d5acf 100644
--- a/src/project/tests/project_tests.cpp
+++ b/src/project/tests/project_tests.cpp
@@ -22,6 +22,7 @@ int project_tests()
{
int status = tests_run_suite("fields");
if (status == OKAY) status = tests_run_suite("project");
+ if (status == OKAY) status = tests_run_suite("project_config");
return status;
}
@@ -54,24 +55,6 @@ SUITE(project)
/**********************************************************************
- * Name tests
- **********************************************************************/
-
- TEST_FIXTURE(FxProject, GetName_ReturnsNull_OnStartup)
- {
- const char* name = project_get_name(prj);
- CHECK(name == NULL);
- }
-
- TEST_FIXTURE(FxProject, SetName_CanRoundtrip)
- {
- project_set_name(prj, "MyProject");
- const char* name = project_get_name(prj);
- CHECK_EQUAL("MyProject", name);
- }
-
-
- /**********************************************************************
* Base directory tests
**********************************************************************/
@@ -90,23 +73,28 @@ SUITE(project)
/**********************************************************************
- * Configuration filter tests
+ * Filename tests
**********************************************************************/
- TEST_FIXTURE(FxProject, ConfigurationFilter_ReturnsNull_OnStartup)
+ TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnNoLocation)
{
- const char* result = project_get_configuration_filter(prj);
- CHECK(result == NULL);
+ project_set_name(prj, "MyProject");
+ project_set_base_dir(prj, "/BaseDir");
+ const char* filename = project_get_filename(prj, NULL, ".xyz");
+ CHECK_EQUAL("/BaseDir/MyProject.xyz", filename);
}
- TEST_FIXTURE(FxProject, ConfigurationFilter_CanRoundtrip)
+ TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnLocation)
{
- project_set_configuration_filter(prj, "Debug");
- const char* result = project_get_configuration_filter(prj);
- CHECK_EQUAL("Debug", result);
+ project_set_name(prj, "MyProject");
+ project_set_base_dir(prj, "/BaseDir");
+ project_set_location(prj, "Location");
+ const char* filename = project_get_filename(prj, NULL, ".xyz");
+ CHECK_EQUAL("/BaseDir/Location/MyProject.xyz", filename);
}
+
/**********************************************************************
* GUID tests
**********************************************************************/
@@ -170,28 +158,23 @@ SUITE(project)
/**********************************************************************
- * Filename tests
+ * Name tests
**********************************************************************/
- TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnNoLocation)
+ TEST_FIXTURE(FxProject, GetName_ReturnsNull_OnStartup)
{
- project_set_name(prj, "MyProject");
- project_set_base_dir(prj, "/BaseDir");
- const char* filename = project_get_filename(prj, NULL, ".xyz");
- CHECK_EQUAL("/BaseDir/MyProject.xyz", filename);
+ const char* name = project_get_name(prj);
+ CHECK(name == NULL);
}
- TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnLocation)
+ TEST_FIXTURE(FxProject, SetName_CanRoundtrip)
{
project_set_name(prj, "MyProject");
- project_set_base_dir(prj, "/BaseDir");
- project_set_location(prj, "Location");
- const char* filename = project_get_filename(prj, NULL, ".xyz");
- CHECK_EQUAL("/BaseDir/Location/MyProject.xyz", filename);
+ const char* name = project_get_name(prj);
+ CHECK_EQUAL("MyProject", name);
}
-
/**********************************************************************
* Output file tests
**********************************************************************/
diff --git a/src/project/tests/solution_tests.cpp b/src/project/tests/solution_tests.cpp
index 80f8569..0078b00 100644
--- a/src/project/tests/solution_tests.cpp
+++ b/src/project/tests/solution_tests.cpp
@@ -114,33 +114,6 @@ SUITE(project)
/**********************************************************************
- * Block containment tests
- **********************************************************************/
-
- TEST_FIXTURE(FxSolution, NumBlocks_IsZero_OnStartup)
- {
- int result = solution_num_blocks(sln);
- CHECK(result == 0);
- }
-
- TEST_FIXTURE(FxSolution, AddBlock_IncrementsNumBlocks)
- {
- Block blk = block_create();
- solution_add_block(sln, blk);
- int result = solution_num_blocks(sln);
- CHECK(result == 1);
- }
-
- TEST_FIXTURE(FxSolution, AddBlock_CanRoundtrip)
- {
- Block blk = block_create();
- solution_add_block(sln, blk);
- Block result = solution_get_block(sln, 0);
- CHECK(result == blk);
- }
-
-
- /**********************************************************************
* Language tests
**********************************************************************/
diff --git a/src/script/script.c b/src/script/script.c
index 2d737a6..b595bbd 100644
--- a/src/script/script.c
+++ b/src/script/script.c
@@ -259,6 +259,7 @@ int script_unload(Script script, Array slns)
funcs.unload_solution = unload_solution;
funcs.unload_project = unload_project;
+ funcs.unload_block = unload_block;
result = unload_all(script->L, slns, &funcs);
return result;
}
diff --git a/src/script/tests/unload_block_tests.cpp b/src/script/tests/unload_block_tests.cpp
index 45b342f..a66d659 100644
--- a/src/script/tests/unload_block_tests.cpp
+++ b/src/script/tests/unload_block_tests.cpp
@@ -43,7 +43,7 @@ SUITE(unload)
TEST_FIXTURE(FxUnloadBlock, UnloadBlock_UnloadsDefines)
{
unload_block(L, blk);
- Strings defines = block_get_defines(blk);
+ Strings defines = block_get_values(blk, BlockDefines);
CHECK(strings_size(defines) == 2);
if (strings_size(defines) == 2) {
CHECK_EQUAL("DEBUG", strings_item(defines, 0));
diff --git a/src/script/tests/unload_tests.cpp b/src/script/tests/unload_tests.cpp
index 7699af4..572fd3a 100644
--- a/src/script/tests/unload_tests.cpp
+++ b/src/script/tests/unload_tests.cpp
@@ -199,7 +199,7 @@ SUITE(unload)
{
unload_all(L, slns, &funcs);
Solution sln = (Solution)array_item(slns, 0);
- int n = solution_num_blocks(sln);
+ int n = blocks_size(solution_get_blocks(sln));
CHECK(n == 1);
}
diff --git a/src/script/unload.c b/src/script/unload.c
index 2177656..269adb7 100644
--- a/src/script/unload.c
+++ b/src/script/unload.c
@@ -9,7 +9,7 @@
#include "script/script_internal.h"
-static int unload_blocks(lua_State* L, struct UnloadFuncs* funcs, Array blocks);
+static int unload_blocks(lua_State* L, struct UnloadFuncs* funcs, Blocks blocks);
static int unload_projects(lua_State* L, struct UnloadFuncs* funcs, Solution sln);
@@ -29,6 +29,8 @@ int unload_all(lua_State* L, Array slns, struct UnloadFuncs* funcs)
assert(slns);
assert(funcs);
assert(funcs->unload_solution);
+ assert(funcs->unload_project);
+ assert(funcs->unload_block);
/* iterate over the list of solutions */
lua_getglobal(L, SOLUTIONS_KEY);
@@ -42,15 +44,11 @@ int unload_all(lua_State* L, Array slns, struct UnloadFuncs* funcs)
/* get the scripted solution object from the solutions list */
lua_rawgeti(L, -1, si);
- /* hardcoded a standard set of configurations for now */
- solution_add_config(sln, "Debug");
- solution_add_config(sln, "Release");
-
/* unload the solution fields, then configuration blocks, then projects */
z = funcs->unload_solution(L, sln);
if (z == OKAY)
{
- Array blocks = solution_get_blocks(sln);
+ Blocks blocks = solution_get_blocks(sln);
z = unload_blocks(L, funcs, blocks);
}
if (z == OKAY)
@@ -88,7 +86,7 @@ static int unload_projects(lua_State* L, struct UnloadFuncs* funcs, Solution sln
z = funcs->unload_project(L, prj);
if (z == OKAY)
{
- Array blocks = project_get_blocks(prj);
+ Blocks blocks = project_get_blocks(prj);
z = unload_blocks(L, funcs, blocks);
}
@@ -102,7 +100,7 @@ static int unload_projects(lua_State* L, struct UnloadFuncs* funcs, Solution sln
}
-static int unload_blocks(lua_State* L, struct UnloadFuncs* funcs, Array blocks)
+static int unload_blocks(lua_State* L, struct UnloadFuncs* funcs, Blocks blocks)
{
int ci, cn, z = OKAY;
@@ -112,7 +110,7 @@ static int unload_blocks(lua_State* L, struct UnloadFuncs* funcs, Array blocks)
for (ci = 1; z == OKAY && ci <= cn; ++ci)
{
Block blk = block_create();
- array_add(blocks, blk);
+ blocks_add(blocks, blk);
/* unload the configuration block fields */
lua_rawgeti(L, -1, ci);
diff --git a/src/session/session.c b/src/session/session.c
index 57efa0a..8ee71e8 100644
--- a/src/session/session.c
+++ b/src/session/session.c
@@ -21,6 +21,7 @@ DEFINE_CLASS(Session)
{
Script script;
Array solutions;
+ Filter filter;
Stream active_stream;
};
@@ -44,6 +45,7 @@ Session session_create(void)
sess = ALLOC_CLASS(Session);
sess->script = script;
sess->solutions = array_create();
+ sess->filter = filter_create();
sess->active_stream = NULL;
return sess;
}
@@ -68,6 +70,7 @@ void session_destroy(Session sess)
script_destroy(sess->script);
array_destroy(sess->solutions);
+ filter_destroy(sess->filter);
free(sess);
}
@@ -138,6 +141,8 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs,
for (pi = 0; pi < pn; ++pi)
{
Project prj = solution_get_project(sln, pi);
+ project_set_filter(prj, sess->filter);
+
for (fi = 0; result == OKAY && prj_funcs[fi]; ++fi)
{
/* A bit of black magic here - I use the "session_enumerate_configurations"
@@ -150,8 +155,10 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs,
for (ci = 0; result == OKAY && ci < cn; ++ci)
{
int cfi;
+
+ /* Make this the active configuration in the value filter */
const char* cfg_name = solution_get_config(sln, ci);
- project_set_configuration_filter(prj, cfg_name);
+ filter_set_value(sess->filter, FilterConfig, cfg_name);
/* enumerate configurations */
for (cfi = 0; result == OKAY && cfg_funcs[cfi]; ++cfi)
diff --git a/src/session/session.h b/src/session/session.h
index da96563..1189bc1 100644
--- a/src/session/session.h
+++ b/src/session/session.h
@@ -18,6 +18,7 @@
#include "project/solution.h"
#include "project/project.h"
#include "project/block.h"
+#include "project/filter.h"
DECLARE_CLASS(Session)