Implements VS2002 and VS2003 solutions with hardcoded configurations; much refactoring

This commit is contained in:
starkos 2008-04-17 15:53:46 +00:00
parent 0cd1e2dd85
commit cbeb7c9eb9
29 changed files with 1113 additions and 298 deletions

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="CppExe"
ProjectGUID="{AE61726D-187C-E440-BD07-2556188A6565}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".."
IntermediateDirectory="obj/Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/CppExe.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=".."
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/CppExe.pdb"
SubSystem="1"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".."
IntermediateDirectory="obj/Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/CppExe.exe"
LinkIncremental="1"
AdditionalLibraryDirectories=".."
GenerateDebugInformation="FALSE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<File
RelativePath=".\Hello.cpp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppExe", "CppExe/CppExe.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="CppExe"
ProjectGUID="{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".."
IntermediateDirectory="obj/Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/CppExe.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=".."
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/CppExe.pdb"
SubSystem="1"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".."
IntermediateDirectory="obj/Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/CppExe.exe"
LinkIncremental="1"
AdditionalLibraryDirectories=".."
GenerateDebugInformation="FALSE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\Hello.cpp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppExe", "CppExe/CppExe.vcproj", "{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}.Debug.ActiveCfg = Debug|Win32
{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}.Debug.Build.0 = Debug|Win32
{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}.Release.ActiveCfg = Release|Win32
{2606321E-67AA-8244-A5C1-67F2E3F8CA0C}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -43,15 +43,14 @@ int make_solution_create(Session sess, Solution sln, Stream strm)
*/ */
int make_solution_signature(Session sess, Solution sln, Stream strm) int make_solution_signature(Session sess, Solution sln, Stream strm)
{ {
int z = OKAY; int z;
assert(strm); assert(strm);
sess = 0; /* unused */ UNUSED(sess);
sln = 0; /* unused */ UNUSED(sln);
z |= stream_writeline(strm, "# GNU Makefile autogenerated by Premake"); z = stream_writeline(strm, "# GNU Makefile autogenerated by Premake");
z |= stream_writeline(strm, "# Usage: make [ CONFIG=config_name ]"); z |= stream_writeline(strm, "# Usage: make [ CONFIG=config_name ]");
z |= stream_writeline(strm, "# Where {config_name} is one of:"); z |= stream_writeline(strm, "# Where {config_name} is one of:");
return z; return z;
} }

View File

@ -0,0 +1,111 @@
/**
* \file vs2002_solution_tests.cpp
* \brief Automated tests for VS2002 solution processing.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "action/vs200x/vs200x_solution.h"
}
#include "vs200x_tests.h"
SUITE(action)
{
/**********************************************************************
* Signature tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_Signature_IsCorrect)
{
session_set_action(sess, "vs2002");
vs2002_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"Microsoft Visual Studio Solution File, Format Version 7.00\r\n",
buffer);
}
/**********************************************************************
* Project entry tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_ProjectEntry_UsesRelativePath)
{
vs2002_solution_projects(sess, sln, strm);
CHECK_EQUAL(
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MyProject\", \"ProjectFolder\\MyProject.vcproj\", \"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
"EndProject\n",
buffer);
}
/**********************************************************************
* Solution configuration tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_SolutionConfiguration_IsCorrect)
{
vs2002_solution_configuration(sess, sln, strm);
CHECK_EQUAL(
"Global\n"
"\tGlobalSection(SolutionConfiguration) = preSolution\n"
"\t\tConfigName.0 = Debug\n"
"\t\tConfigName.1 = Release\n"
"\tEndGlobalSection\n",
buffer);
}
/**********************************************************************
* Project dependencies tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_ProjectDependencies_IsCorrect)
{
vs2002_solution_dependencies(sess, sln, strm);
CHECK_EQUAL(
"\tGlobalSection(ProjectDependencies) = postSolution\n"
"\tEndGlobalSection\n",
buffer);
}
/**********************************************************************
* Project configuration tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_ProjectConfiguration_IsCorrect)
{
vs2002_solution_project_configuration(sess, sln, strm);
CHECK_EQUAL(
"\tGlobalSection(ProjectConfiguration) = postSolution\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug.ActiveCfg = Debug|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug.Build.0 = Debug|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Release.ActiveCfg = Release|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Release.Build.0 = Release|Win32\n"
"\tEndGlobalSection\n",
buffer);
}
/**********************************************************************
* Solution extensibility tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2002_Extensibility_IsCorrect)
{
vs2002_solution_extensibility(sess, sln, strm);
CHECK_EQUAL(
"\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
"\tEndGlobalSection\n"
"\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
"\tEndGlobalSection\n"
"EndGlobal\n",
buffer);
}
}

View File

@ -0,0 +1,48 @@
/**
* \file vs2003_solution_tests.cpp
* \brief Automated tests for VS2003 solution processing.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "action/vs200x/vs200x_solution.h"
}
#include "vs200x_tests.h"
SUITE(action)
{
/**********************************************************************
* Signature tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2003_Signature_IsCorrect)
{
session_set_action(sess, "vs2003");
vs2003_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"Microsoft Visual Studio Solution File, Format Version 8.00\r\n",
buffer);
}
/**********************************************************************
* Solution configuration tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2003_SolutionConfiguration_IsCorrect)
{
vs2003_solution_configuration(sess, sln, strm);
CHECK_EQUAL(
"Global\n"
"\tGlobalSection(SolutionConfiguration) = preSolution\n"
"\t\tDebug = Debug\n"
"\t\tRelease = Release\n"
"\tEndGlobalSection\n",
buffer);
}
}

View File

@ -0,0 +1,83 @@
/**
* \file vs2005_solution_tests.cpp
* \brief Automated tests for VS2005 solution processing.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "action/vs200x/vs200x_solution.h"
}
#include "vs200x_tests.h"
SUITE(action)
{
/**********************************************************************
* Signature tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Vs2005_Signature_IsCorrect)
{
session_set_action(sess, "vs2005");
vs2005_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"\357\273\277\r\n"
"Microsoft Visual Studio Solution File, Format Version 9.00\r\n"
"# Visual Studio 2005\r\n",
buffer);
}
/**********************************************************************
* Solution Configuration Platforms tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Platforms_IsCorrect)
{
vs2005_solution_platforms(sess, sln, strm);
CHECK_EQUAL(
"Global\n"
"\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"
"\t\tDebug|Win32 = Debug|Win32\n"
"\t\tRelease|Win32 = Release|Win32\n"
"\tEndGlobalSection\n",
buffer);
}
/**********************************************************************
* Project Configuration Platforms tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, ProjectPlatforms_IsCorrect)
{
vs2005_solution_project_platforms(sess, sln, strm);
CHECK_EQUAL(
"\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug|Win32.ActiveCfg = Debug|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug|Win32.Build.0 = Debug|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Release|Win32.ActiveCfg = Release|Win32\n"
"\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Release|Win32.Build.0 = Release|Win32\n"
"\tEndGlobalSection\n",
buffer);
}
/**********************************************************************
* Solution Project tests
**********************************************************************/
TEST_FIXTURE(FxVs200x, Properties_IsCorrect)
{
vs2005_solution_properties(sess, sln, strm);
CHECK_EQUAL(
"\tGlobalSection(SolutionProperties) = preSolution\n"
"\t\tHideSolutionNode = FALSE\n"
"\tEndGlobalSection\n"
"EndGlobal\n",
buffer);
}
}

View File

@ -1,112 +0,0 @@
/**
* \file vs200x_solution_tests.cpp
* \brief Automated tests for VS200x solution processing.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "action/vs200x/vs200x_solution.h"
}
struct FxVs200xSln
{
Session sess;
Stream strm;
Solution sln;
char buffer[8192];
FxVs200xSln()
{
sess = session_create();
strm = stream_create_null();
stream_set_buffer(strm, buffer);
sln = solution_create();
solution_set_name(sln, "MySolution");
solution_set_base_dir(sln, "/Root");
}
~FxVs200xSln()
{
solution_destroy(sln);
stream_destroy(strm);
session_destroy(sess);
}
Project AddProject()
{
Project prj = project_create();
project_set_name(prj, "MyProject");
project_set_base_dir(prj, "/Root");
project_set_guid(prj, "AE2461B7-236F-4278-81D3-F0D476F9A4C0");
solution_add_project(sln, prj);
return prj;
}
};
SUITE(action)
{
/**********************************************************************
* Signature tests
**********************************************************************/
TEST_FIXTURE(FxVs200xSln, Signature_IsCorrect_OnVs2002)
{
session_set_action(sess, "vs2002");
vs200x_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"\357\273\277Microsoft Visual Studio Solution File, Format Version 7.00\r\n",
buffer);
}
TEST_FIXTURE(FxVs200xSln, Signature_IsCorrect_OnVs2003)
{
session_set_action(sess, "vs2003");
vs200x_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"\357\273\277Microsoft Visual Studio Solution File, Format Version 8.00\r\n",
buffer);
}
TEST_FIXTURE(FxVs200xSln, Signature_IsCorrect_OnVs2005)
{
session_set_action(sess, "vs2005");
vs200x_solution_signature(sess, sln, strm);
CHECK_EQUAL(
"\357\273\277\r\n"
"Microsoft Visual Studio Solution File, Format Version 9.00\r\n"
"# Visual Studio 2005\r\n",
buffer);
}
/**********************************************************************
* Project entry tests
**********************************************************************/
TEST_FIXTURE(FxVs200xSln, ProjectEntry_IsCorrect_OnCppProject)
{
AddProject();
vs200x_solution_projects(sess, sln, strm);
CHECK_EQUAL(
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MyProject\", \"MyProject.vcproj\", \"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
"EndProject\n",
buffer);
}
TEST_FIXTURE(FxVs200xSln, ProjectEntry_UsesRelativePath)
{
Project prj = AddProject();
project_set_location(prj, "ProjectFolder");
vs200x_solution_projects(sess, sln, strm);
CHECK_EQUAL(
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"MyProject\", \"ProjectFolder\\MyProject.vcproj\", \"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n"
"EndProject\n",
buffer);
}
}

View File

@ -10,20 +10,8 @@ extern "C" {
#include "action/vs200x/vs200x.h" #include "action/vs200x/vs200x.h"
} }
struct FxVs200x #include "vs200x_tests.h"
{
Session sess;
FxVs200x()
{
sess = session_create();
}
~FxVs200x()
{
session_destroy(sess);
}
};
SUITE(action) SUITE(action)
{ {

View File

@ -0,0 +1,42 @@
/**
* \file vs200x_tests.h
* \brief Standard test fixtures for Visual Studio.
* \author Copyright (c) 2008 Jason Perkins and the Premake project
*/
struct FxVs200x
{
Session sess;
Stream strm;
Solution sln;
Project prj;
char buffer[8192];
FxVs200x()
{
sess = session_create();
strm = stream_create_null();
stream_set_buffer(strm, buffer);
sln = solution_create();
solution_set_name(sln, "MySolution");
solution_set_base_dir(sln, "/Root");
solution_add_config_name(sln, "Debug");
solution_add_config_name(sln, "Release");
prj = project_create();
project_set_name(prj, "MyProject");
project_set_base_dir(prj, "/Root");
project_set_location(prj, "ProjectFolder");
project_set_guid(prj, "AE2461B7-236F-4278-81D3-F0D476F9A4C0");
solution_add_project(sln, prj);
}
~FxVs200x()
{
solution_destroy(sln);
stream_destroy(strm);
session_destroy(sess);
}
};

View File

@ -13,7 +13,13 @@
/** The VS2002 solution writing process, for session_enumerate_objects() */ /** The VS2002 solution writing process, for session_enumerate_objects() */
static SessionSolutionCallback Vs2002SolutionCallbacks[] = static SessionSolutionCallback Vs2002SolutionCallbacks[] =
{ {
vs200x_solution_create, vs2002_solution_create,
vs2002_solution_signature,
vs2002_solution_projects,
vs2002_solution_configuration,
vs2002_solution_dependencies,
vs2002_solution_project_configuration,
vs2002_solution_extensibility,
NULL NULL
}; };

View File

@ -0,0 +1,192 @@
/**
* \file vs2002_solution.c
* \brief Visual Studio 2002 solution generation functions.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <assert.h>
#include <stdlib.h>
#include "premake.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
#include "base/path.h"
/**
* Create the Visual Studio 2002 solution configuration 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 vs2002_solution_configuration(Session sess, Solution sln, Stream strm)
{
int i, n, z;
UNUSED(sess);
z = stream_writeline(strm, "Global");
z |= stream_writeline(strm, "\tGlobalSection(SolutionConfiguration) = preSolution");
n = solution_num_configs(sln);
for (i = 0; i < n; ++i)
{
const char* config_name = solution_get_config_name(sln, i);
z |= stream_writeline(strm, "\t\tConfigName.%d = %s", i, config_name);
}
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Create the Visual Studio 2002 project dependencies 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 vs2002_solution_dependencies(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
z = stream_writeline(strm, "\tGlobalSection(ProjectDependencies) = postSolution");
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Write out the Visual Studio 2002 solution extensibility 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 vs2002_solution_extensibility(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
z = stream_writeline(strm, "\tGlobalSection(ExtensibilityGlobals) = postSolution");
z |= stream_writeline(strm, "\tEndGlobalSection");
z |= stream_writeline(strm, "\tGlobalSection(ExtensibilityAddIns) = postSolution");
z |= stream_writeline(strm, "\tEndGlobalSection");
z |= stream_writeline(strm, "EndGlobal");
return z;
}
/**
* 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 vs2002_solution_create(Session sess, Solution sln, Stream strm)
{
/* create the solution file */
const char* filename = solution_get_filename(sln, NULL, ".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;
}
/**
* Write out the Visual Studio 2002 project configurations 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 vs2002_solution_project_configuration(Session sess, Solution sln, Stream strm)
{
int pi, pn, z;
UNUSED(sess);
z = stream_writeline(strm, "\tGlobalSection(ProjectConfiguration) = postSolution");
pn = solution_num_projects(sln);
for (pi = 0; pi < pn; ++pi)
{
int ci, cn;
Project prj = solution_get_project(sln, pi);
const char* prj_id = project_get_guid(prj);
cn = solution_num_configs(sln);
for (ci = 0; ci < cn; ++ci)
{
const char* config_name = solution_get_config_name(sln, ci);
z |= stream_writeline(strm, "\t\t{%s}.%s.ActiveCfg = %s|Win32", prj_id, config_name, config_name);
z |= stream_writeline(strm, "\t\t{%s}.%s.Build.0 = %s|Win32", prj_id, config_name, config_name);
}
}
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Write out the list of projects contained by the solution.
* \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 vs2002_solution_projects(Session sess, Solution sln, Stream strm)
{
const char* sln_path;
int i, n;
UNUSED(sess);
/* project file paths are specified relative to the solution */
sln_path = path_directory(solution_get_filename(sln, NULL, NULL));
n = solution_num_projects(sln);
for (i = 0; i < n; ++i)
{
Project prj = solution_get_project(sln, i);
const char* prj_name = project_get_name(prj);
const char* prj_id = project_get_guid(prj);
const char* prj_lang = project_get_language(prj);
const char* prj_ext = vs200x_project_extension(prj);
const char* prj_file = project_get_filename(prj, prj_name, prj_ext);
const char* tool_id = vs200x_tool_guid(prj_lang);
/* convert absolute project file name to be relative to solution */
prj_file = path_relative(sln_path, prj_file);
prj_file = path_translate(prj_file, "\\");
stream_writeline(strm, "Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"", tool_id, prj_name, prj_file, prj_id);
stream_writeline(strm, "EndProject");
}
return OKAY;
}
/**
* Write the Visual Studio 2002 solution file signature.
* \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 vs2002_solution_signature(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
stream_set_newline(strm, "\r\n");
z = stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 7.00");
return z;
}

View File

@ -13,7 +13,12 @@
/** The VS2003 solution writing process, for session_enumerate_objects() */ /** The VS2003 solution writing process, for session_enumerate_objects() */
static SessionSolutionCallback Vs2003SolutionCallbacks[] = static SessionSolutionCallback Vs2003SolutionCallbacks[] =
{ {
vs200x_solution_create, vs2002_solution_create,
vs2003_solution_signature,
vs2002_solution_projects,
vs2003_solution_configuration,
vs2002_solution_project_configuration,
vs2002_solution_extensibility,
NULL NULL
}; };
@ -34,4 +39,3 @@ int vs2003_action(Session sess)
stream_writeline(Console, "Generating project files for Visual Studio 2003..."); stream_writeline(Console, "Generating project files for Visual Studio 2003...");
return session_enumerate_objects(sess, Vs2003SolutionCallbacks, Vs2003ProjectCallbacks); return session_enumerate_objects(sess, Vs2003SolutionCallbacks, Vs2003ProjectCallbacks);
} }

View File

@ -0,0 +1,55 @@
/**
* \file vs2003_solution.c
* \brief Visual Studio 2003 solution generation functions.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <assert.h>
#include <stdlib.h>
#include "premake.h"
#include "vs200x_solution.h"
/**
* Create the Visual Studio 2003 solution configuration 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 vs2003_solution_configuration(Session sess, Solution sln, Stream strm)
{
int i, n, z;
UNUSED(sess);
z = stream_writeline(strm, "Global");
z |= stream_writeline(strm, "\tGlobalSection(SolutionConfiguration) = preSolution");
n = solution_num_configs(sln);
for (i = 0; i < n; ++i)
{
const char* config_name = solution_get_config_name(sln, i);
z |= stream_writeline(strm, "\t\t%s = %s", config_name, config_name);
}
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Write the Visual Studio 2003 solution file signature.
* \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 vs2003_solution_signature(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
stream_set_newline(strm, "\r\n");
z = stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 8.00");
return z;
}

View File

@ -13,9 +13,12 @@
/** The VS2005 solution writing process, for session_enumerate_objects() */ /** The VS2005 solution writing process, for session_enumerate_objects() */
static SessionSolutionCallback Vs2005SolutionCallbacks[] = static SessionSolutionCallback Vs2005SolutionCallbacks[] =
{ {
vs200x_solution_create, vs2002_solution_create,
vs200x_solution_signature, vs2005_solution_signature,
vs200x_solution_projects, vs2002_solution_projects,
vs2005_solution_platforms,
vs2005_solution_project_platforms,
vs2005_solution_properties,
NULL NULL
}; };

View File

@ -0,0 +1,110 @@
/**
* \file vs2005_solution.c
* \brief Visual Studio 2005 solution generation functions.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <assert.h>
#include <stdlib.h>
#include "premake.h"
#include "vs200x_solution.h"
/**
* Write out the Visual Studio solution-level platform configuration 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 vs2005_solution_platforms(Session sess, Solution sln, Stream strm)
{
int i, n, z;
UNUSED(sess);
z = stream_writeline(strm, "Global");
z |= stream_writeline(strm, "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
n = solution_num_configs(sln);
for (i = 0; i < n; ++i)
{
const char* config_name = solution_get_config_name(sln, i);
z |= stream_writeline(strm, "\t\t%s|Win32 = %s|Win32", config_name, config_name);
}
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Write out the Visual Studio 2005 project-level platform configurations 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 vs2005_solution_project_platforms(Session sess, Solution sln, Stream strm)
{
int pi, pn, z;
UNUSED(sess);
z = stream_writeline(strm, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
pn = solution_num_projects(sln);
for (pi = 0; pi < pn; ++pi)
{
int ci, cn;
Project prj = solution_get_project(sln, pi);
const char* prj_id = project_get_guid(prj);
cn = solution_num_configs(sln);
for (ci = 0; ci < cn; ++ci)
{
const char* config_name = solution_get_config_name(sln, ci);
z |= stream_writeline(strm, "\t\t{%s}.%s|Win32.ActiveCfg = %s|Win32", prj_id, config_name, config_name);
z |= stream_writeline(strm, "\t\t{%s}.%s|Win32.Build.0 = %s|Win32", prj_id, config_name, config_name);
}
}
z |= stream_writeline(strm, "\tEndGlobalSection");
return z;
}
/**
* Write out the Visual Studio 2005 solution properties 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 vs2005_solution_properties(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
z = stream_writeline(strm, "\tGlobalSection(SolutionProperties) = preSolution");
z |= stream_writeline(strm, "\t\tHideSolutionNode = FALSE");
z |= stream_writeline(strm, "\tEndGlobalSection");
z |= stream_writeline(strm, "EndGlobal");
return z;
}
/**
* Write the Visual Studio 2005 solution file signature.
* \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 vs2005_solution_signature(Session sess, Solution sln, Stream strm)
{
int z;
UNUSED(sess);
UNUSED(sln);
stream_set_newline(strm, "\r\n");
z = stream_write_unicode_marker(strm);
z |= stream_writeline(strm, "");
z |= stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 9.00");
z |= stream_writeline(strm, "# Visual Studio 2005");
return z;
}

View File

@ -5,9 +5,11 @@
*/ */
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include "premake.h" #include "premake.h"
#include "vs200x.h" #include "vs200x.h"
#include "base/cstr.h" #include "base/cstr.h"
#include "base/error.h"
/** /**
@ -36,3 +38,26 @@ int vs200x_get_target_version(Session sess)
return 0; return 0;
} }
} }
/**
* Returns the Visual Studio GUID for a particular project type.
* \param language The programming language used in the project.
* \returns The GUID corresponding the programming language.
*/
const char* vs200x_tool_guid(const char* language)
{
if (cstr_eq(language, "c") || cstr_eq(language, "c++"))
{
return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
}
else if (cstr_eq(language, "c#"))
{
return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
}
else
{
error_set("unsupported language '%s'", language);
return NULL;
}
}

View File

@ -9,6 +9,8 @@
#include "engine/session.h" #include "engine/session.h"
int vs200x_get_target_version(Session sess); int vs200x_get_target_version(Session sess);
const char* vs200x_tool_guid(const char* language);
#endif #endif

View File

@ -1,137 +0,0 @@
/**
* \file vs200x_solution.c
* \brief Visual Studio 200x solution generation functions.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include <assert.h>
#include <stdlib.h>
#include "premake.h"
#include "vs200x.h"
#include "vs200x_solution.h"
#include "vs200x_project.h"
#include "base/cstr.h"
#include "base/error.h"
#include "base/path.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 vs200x_solution_create(Session sess, Solution sln, Stream strm)
{
/* create the solution file */
const char* filename = solution_get_filename(sln, NULL, ".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;
}
/**
* Write out the list of projects contained by the solution.
* \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 vs200x_solution_projects(Session sess, Solution sln, Stream strm)
{
const char* sln_path;
int i, n;
sess = 0; /* unused */
/* project file paths are specified relative to the solution */
sln_path = path_directory(solution_get_filename(sln, NULL, NULL));
n = solution_num_projects(sln);
for (i = 0; i < n; ++i)
{
Project prj = solution_get_project(sln, i);
const char* prj_name = project_get_name(prj);
const char* prj_id = project_get_guid(prj);
const char* prj_ext = vs200x_project_extension(prj);
const char* prj_file = project_get_filename(prj, prj_name, prj_ext);
const char* tool_id = vs200x_solution_tool_guid("c++");
/* convert absolute project file name to be relative to solution */
prj_file = path_relative(sln_path, prj_file);
prj_file = path_translate(prj_file, "\\");
stream_writeline(strm, "Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"", tool_id, prj_name, prj_file, prj_id);
stream_writeline(strm, "EndProject");
}
return OKAY;
}
/**
* Write the 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 vs200x_solution_signature(Session sess, Solution sln, Stream strm)
{
int version, z;
assert(sess);
assert(strm);
sln = 0; /* unused */
stream_set_newline(strm, "\r\n");
z = stream_write_unicode_marker(strm);
version = vs200x_get_target_version(sess);
switch (version)
{
case 2002:
z |= stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 7.00");
break;
case 2003:
z |= stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 8.00");
break;
case 2005:
z |= stream_writeline(strm, "");
z |= stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 9.00");
z |= stream_writeline(strm, "# Visual Studio 2005");
break;
}
return z;
}
/**
* Returns the Visual Studio GUID for a particular project type.
* \param language The programming language used in the project.
* \returns The GUID corresponding the programming language.
*/
const char* vs200x_solution_tool_guid(const char* language)
{
if (cstr_eq(language, "c") || cstr_eq(language, "c++"))
{
return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
}
else if (cstr_eq(language, "c#"))
{
return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
}
else
{
error_set("unsupported language '%s'", language);
return NULL;
}
}

View File

@ -8,9 +8,20 @@
#include "engine/session.h" #include "engine/session.h"
int vs200x_solution_create(Session sess, Solution sln, Stream strm); int vs2002_solution_configuration(Session sess, Solution sln, Stream strm);
int vs200x_solution_projects(Session sess, Solution sln, Stream strm); int vs2002_solution_create(Session sess, Solution sln, Stream strm);
int vs200x_solution_signature(Session sess, Solution sln, Stream strm); int vs2002_solution_dependencies(Session sess, Solution sln, Stream strm);
const char* vs200x_solution_tool_guid(const char* language); int vs2002_solution_extensibility(Session sess, Solution sln, Stream strm);
int vs2002_solution_project_configuration(Session sess, Solution sln, Stream strm);
int vs2002_solution_projects(Session sess, Solution sln, Stream strm);
int vs2002_solution_signature(Session sess, Solution sln, Stream strm);
int vs2003_solution_configuration(Session sess, Solution sln, Stream strm);
int vs2003_solution_signature(Session sess, Solution sln, Stream strm);
int vs2005_solution_platforms(Session sess, Solution sln, Stream strm);
int vs2005_solution_project_platforms(Session sess, Solution sln, Stream strm);
int vs2005_solution_properties(Session sess, Solution sln, Stream strm);
int vs2005_solution_signature(Session sess, Solution sln, Stream strm);
#endif #endif

View File

@ -8,6 +8,8 @@
#include "premake.h" #include "premake.h"
#include "internals.h" #include "internals.h"
static int unload_solution_projects(Session sess, lua_State* L, struct UnloadFuncs* funcs, Solution sln);
/** /**
* Copy project information out of the scripting environment and into C objects that * Copy project information out of the scripting environment and into C objects that
@ -34,13 +36,35 @@ int unload_all(Session sess, lua_State* L, struct UnloadFuncs* funcs)
{ {
Solution sln = solution_create(); Solution sln = solution_create();
session_add_solution(sess, sln); session_add_solution(sess, sln);
lua_rawgeti(L, -1, si); lua_rawgeti(L, -1, si);
/* hardcoded a standard set of configurations for now */
solution_add_config_name(sln, "Debug");
solution_add_config_name(sln, "Release");
/* extract the project fields */
status = funcs->unload_solution(sess, L, sln); status = funcs->unload_solution(sess, L, sln);
if (status == OKAY) if (status == OKAY)
{ {
/* iterate over list of projects */ status = unload_solution_projects(sess, L, funcs, sln);
}
/* remove solution object from stack */
lua_pop(L, 1);
}
/* remove list of solutions from stack */
lua_pop(L, 1);
return status;
}
static int unload_solution_projects(Session sess, lua_State* L, struct UnloadFuncs* funcs, Solution sln)
{
int pi, pn; int pi, pn;
int status = OKAY;
/* iterate over list of projects from the solution */
lua_getfield(L, -1, PROJECTS_KEY); lua_getfield(L, -1, PROJECTS_KEY);
pn = luaL_getn(L, -1); pn = luaL_getn(L, -1);
for (pi = 1; status == OKAY && pi <= pn; ++pi) for (pi = 1; status == OKAY && pi <= pn; ++pi)
@ -48,6 +72,7 @@ int unload_all(Session sess, lua_State* L, struct UnloadFuncs* funcs)
Project prj = project_create(); Project prj = project_create();
solution_add_project(sln, prj); solution_add_project(sln, prj);
/* unload the project fields */
lua_rawgeti(L, -1, pi); lua_rawgeti(L, -1, pi);
status = funcs->unload_project(sess, L, prj); status = funcs->unload_project(sess, L, prj);
@ -57,14 +82,6 @@ int unload_all(Session sess, lua_State* L, struct UnloadFuncs* funcs)
/* remove list of projects from stack */ /* remove list of projects from stack */
lua_pop(L, 1); lua_pop(L, 1);
}
/* remove solution object from stack */
lua_pop(L, 1);
}
/* remove list of solutions from stack */
lua_pop(L, 1);
return status; return status;
} }

View File

@ -35,3 +35,9 @@
*/ */
#define ALLOC_CLASS(n) (n)malloc(sizeof(struct n##_impl)) #define ALLOC_CLASS(n) (n)malloc(sizeof(struct n##_impl))
/**
* Mark a variable as unused, so the compiler won't complain about it. I suspect
* there is a better way to do this.
*/
#define UNUSED(var) var = 0

View File

@ -83,7 +83,7 @@ local subsystems =
table.insert(package.files, matchfiles("testing/*.h", "testing/*.cpp", unittest.."/*")) table.insert(package.files, matchfiles("testing/*.h", "testing/*.cpp", unittest.."/*"))
for k,m in subsystems do for k,m in subsystems do
table.insert(package.files, matchfiles(m.."/tests/*.cpp")) table.insert(package.files, matchfiles(m.."/tests/*.h", m.."/tests/*.cpp"))
end end
if (windows) then if (windows) then

View File

@ -111,6 +111,18 @@ const char* project_get_guid(Project prj)
} }
/**
* Retrieve the programming language specified for a project.
* \param prj The project to query.
* \returns The programming language specified for the project.
*/
const char* project_get_language(Project prj)
{
prj = 0;
return "c++";
}
/** /**
* Retrieve the output location (the relative path from the base directory to the * Retrieve the output location (the relative path from the base directory to the
* target output directory) for this project. * target output directory) for this project.

View File

@ -33,6 +33,7 @@ void project_destroy(Project prj);
const char* project_get_base_dir(Project prj); const char* project_get_base_dir(Project prj);
const char* project_get_filename(Project prj, const char* basename, const char* ext); const char* project_get_filename(Project prj, const char* basename, const char* ext);
const char* project_get_guid(Project prj); const char* project_get_guid(Project prj);
const char* project_get_language(Project prj);
const char* project_get_location(Project prj); const char* project_get_location(Project prj);
const char* project_get_name(Project prj); const char* project_get_name(Project prj);
const char* project_get_value(Project prj, enum ProjectField field); const char* project_get_value(Project prj, enum ProjectField field);

View File

@ -27,6 +27,7 @@ struct FieldInfo SolutionFieldInfo[] =
DEFINE_CLASS(Solution) DEFINE_CLASS(Solution)
{ {
Fields fields; Fields fields;
Array configs;
Array projects; Array projects;
}; };
@ -39,6 +40,7 @@ Solution solution_create()
{ {
Solution sln = ALLOC_CLASS(Solution); Solution sln = ALLOC_CLASS(Solution);
sln->fields = fields_create(SolutionFieldInfo); sln->fields = fields_create(SolutionFieldInfo);
sln->configs = array_create();
sln->projects = array_create(); sln->projects = array_create();
return sln; return sln;
} }
@ -54,6 +56,7 @@ void solution_destroy(Solution sln)
assert(sln); assert(sln);
fields_destroy(sln->fields); fields_destroy(sln->fields);
array_destroy(sln->configs);
n = solution_num_projects(sln); n = solution_num_projects(sln);
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
@ -67,6 +70,19 @@ void solution_destroy(Solution sln)
} }
/**
* Add a configuration name to a solution.
* \param sln The solution to contain the project.
* \param config_name The name of the configuration add.
*/
void solution_add_config_name(Solution sln, const char* config_name)
{
assert(sln);
assert(config_name);
array_add(sln->configs, (void*)config_name);
}
/** /**
* Add a project to a solution. * Add a project to a solution.
* \param sln The solution to contain the project. * \param sln The solution to contain the project.
@ -92,6 +108,21 @@ const char* solution_get_base_dir(Solution sln)
} }
/**
* Get the configuration name at a given index.
* \param sln The solution to query.
* \param index The configuration index to query.
* \returns The configuration name at the given index.
*/
const char* solution_get_config_name(Solution sln, int index)
{
const char* name;
assert(sln);
name = (const char*)array_item(sln->configs, index);
return name;
}
/** /**
* Get the path to the solution output file, using the provided file extension. * Get the path to the solution output file, using the provided file extension.
* \param sln The solution object to query. * \param sln The solution object to query.
@ -179,6 +210,18 @@ const char* solution_get_value(Solution sln, enum SolutionField field)
} }
/**
* Return the number of configurations contained by this solution.
* \param sln The solution to query.
* \returns The number of configurations contained by the solution.
*/
int solution_num_configs(Solution sln)
{
assert(sln);
return array_size(sln->configs);
}
/** /**
* Return the number of projects contained by this solution. * Return the number of projects contained by this solution.
* \param sln The solution to query. * \param sln The solution to query.

View File

@ -30,13 +30,16 @@ DECLARE_CLASS(Solution)
Solution solution_create(void); Solution solution_create(void);
void solution_destroy(Solution sln); void solution_destroy(Solution sln);
void solution_add_config_name(Solution sln, const char* config_name);
void solution_add_project(Solution sln, Project prj); void solution_add_project(Solution sln, Project prj);
const char* solution_get_base_dir(Solution sln); const char* solution_get_base_dir(Solution sln);
const char* solution_get_config_name(Solution sln, int index);
const char* solution_get_filename(Solution sln, const char* basename, const char* ext); const char* solution_get_filename(Solution sln, const char* basename, const char* ext);
const char* solution_get_location(Solution sln); const char* solution_get_location(Solution sln);
const char* solution_get_name(Solution sln); const char* solution_get_name(Solution sln);
Project solution_get_project(Solution sln, int index); Project solution_get_project(Solution sln, int index);
const char* solution_get_value(Solution sln, enum SolutionField field); const char* solution_get_value(Solution sln, enum SolutionField field);
int solution_num_configs(Solution sln);
int solution_num_projects(Solution sln); int solution_num_projects(Solution sln);
void solution_set_base_dir(Solution sln, const char* base_dir); void solution_set_base_dir(Solution sln, const char* base_dir);
void solution_set_location(Solution sln, const char* location); void solution_set_location(Solution sln, const char* location);

View File

@ -72,6 +72,31 @@ SUITE(project)
} }
/**********************************************************************
* Configuration containment tests
**********************************************************************/
TEST_FIXTURE(FxSolution, NumConfigs_IsZero_OnStartup)
{
int result = solution_num_configs(sln);
CHECK(result == 0);
}
TEST_FIXTURE(FxSolution, AddConfig_IncrementsNumConfigs)
{
solution_add_config_name(sln, "Debug");
int result = solution_num_configs(sln);
CHECK(result == 1);
}
TEST_FIXTURE(FxSolution, AddConfig_CanRoundtrip)
{
solution_add_config_name(sln, "Debug");
const char* result = solution_get_config_name(sln, 0);
CHECK_EQUAL("Debug", result);
}
/********************************************************************** /**********************************************************************
* Location tests * Location tests
**********************************************************************/ **********************************************************************/