# Integrated our new unit testing framework with premake to get automated testing after every re-compile.

Trac #117

This was SVN commit r3975.
This commit is contained in:
Simon Brenner 2006-06-07 22:19:42 +00:00
parent 76cbda8713
commit c59de80915
10 changed files with 368 additions and 334 deletions

View File

@ -48,6 +48,8 @@ extern_lib_defs = {
},
cxxtest = {
},
misc = {
},
dbghelp = {
win_names = { "dbghelp" },
dbg_suffix = "",

Binary file not shown.

View File

@ -17,6 +17,9 @@ project.configs = { "Debug", "Release", "Testing" }
if OS == "windows" then
project.nasmpath = "../../build/bin/nasm.exe"
project.cxxtestpath = "../../build/bin/cxxtestgen.pl"
else
project.cxxtestpath = "../../build/bin/cxxtestgen"
end
source_root = "../../../source/" -- default for most projects - overridden by local in others
@ -571,17 +574,29 @@ end
function setup_tests()
-- package_create("test_3_gen" , "cxxtestgen")
package_create("test_3_gen" , "cxxtestgen")
--package.files = files_in_test_subdirs(source_root, ".h")
package.files = { source_root .. "lib/tests/test_byte_order.h" }
package.rootfile = source_root .. "test_root.cpp"
if OS == "windows" then
package.rootoptions = "--gui=Win32Gui --have-eh --runner=ParenPrinter"
else
package.rootoptions = "--error-printer"
end
package_create("test_2_build", "winexe")
package.files = files_in_test_subdirs(source_root, ".cpp")
--package.files = files_in_test_subdirs(source_root, ".cpp")
package.files = { source_root .. "lib/tests/test_byte_order.cpp" }
table.insert(package.files, source_root .. "test_root.cpp")
package.includepaths = {source_root}
package.links = { "test_3_gen" }
listconcat(package.links, static_lib_names)
package_add_extern_libs(used_extern_libs)
-- package_create("test_1_run" , "run")
-- use package's output target as the file to run
-- (avoids having to mess around with project.bindir and
-- OS-specific application extension, e.g. EXE)
package_create("test_1_run" , "run")
package.links = { "test_2_build" } -- This determines which project's executable to run
end

View File

@ -1,19 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Premake", "Src\Premake.vcproj", "{B33708C1-1744-52D6-8DCE-385E5CF8C348}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Debug|Win32.ActiveCfg = Debug|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Debug|Win32.Build.0 = Debug|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Release|Win32.ActiveCfg = Release|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Release|Win32.Build.0 = Release|Win32
GlobalSection(ProjectConfiguration) = postSolution
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Debug.ActiveCfg = Debug|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Debug.Build.0 = Debug|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Release.ActiveCfg = Release|Win32
{B33708C1-1744-52D6-8DCE-385E5CF8C348}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -1,552 +1,395 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Version="7.10"
Name="Premake"
ProjectGUID="{B33708C1-1744-52D6-8DCE-385E5CF8C348}"
Keyword="Win32Proj"
>
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"
/>
Name="Win32"/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../bin"
OutputDirectory="../.."
IntermediateDirectory="obj/Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="true"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/premake.exe"
LinkIncremental="2"
AdditionalLibraryDirectories=".."
GenerateManifest="false"
GenerateDebugInformation="true"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/premake.pdb"
SubSystem="1"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"
/>
TargetMachine="1"/>
<Tool
Name="VCALinkTool"
/>
Name="VCMIDLTool"/>
<Tool
Name="VCManifestTool"
/>
Name="VCPostBuildEventTool"/>
<Tool
Name="VCXDCMakeTool"
/>
Name="VCPreBuildEventTool"/>
<Tool
Name="VCBscMakeTool"
/>
Name="VCPreLinkEventTool"/>
<Tool
Name="VCFxCopTool"
/>
Name="VCResourceCompilerTool"/>
<Tool
Name="VCAppVerifierTool"
/>
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"
/>
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCPostBuildEventTool"
/>
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../bin"
IntermediateDirectory="obj/Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="true"
EnableFunctionLevelLinking="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
/>
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="0"/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/premake.exe"
LinkIncremental="1"
AdditionalLibraryDirectories=".."
GenerateManifest="false"
GenerateDebugInformation="false"
GenerateDebugInformation="FALSE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
EntryPointSymbol="mainCRTStartup"
TargetMachine="1"
/>
TargetMachine="1"/>
<Tool
Name="VCALinkTool"
/>
Name="VCMIDLTool"/>
<Tool
Name="VCManifestTool"
/>
Name="VCPostBuildEventTool"/>
<Tool
Name="VCXDCMakeTool"
/>
Name="VCPreBuildEventTool"/>
<Tool
Name="VCBscMakeTool"
/>
Name="VCPreLinkEventTool"/>
<Tool
Name="VCFxCopTool"
/>
Name="VCResourceCompilerTool"/>
<Tool
Name="VCAppVerifierTool"
/>
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"
/>
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCPostBuildEventTool"
/>
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Lua"
>
Name="Lua">
<File
RelativePath=".\Lua\lapi.c"
>
RelativePath=".\Lua\lapi.c">
</File>
<File
RelativePath=".\Lua\lapi.h"
>
RelativePath=".\Lua\lapi.h">
</File>
<File
RelativePath=".\Lua\lauxlib.c"
>
RelativePath=".\Lua\lauxlib.c">
</File>
<File
RelativePath=".\Lua\lauxlib.h"
>
RelativePath=".\Lua\lauxlib.h">
</File>
<File
RelativePath=".\Lua\lbaselib.c"
>
RelativePath=".\Lua\lbaselib.c">
</File>
<File
RelativePath=".\Lua\lcode.c"
>
RelativePath=".\Lua\lcode.c">
</File>
<File
RelativePath=".\Lua\lcode.h"
>
RelativePath=".\Lua\lcode.h">
</File>
<File
RelativePath=".\Lua\ldblib.c"
>
RelativePath=".\Lua\ldblib.c">
</File>
<File
RelativePath=".\Lua\ldebug.c"
>
RelativePath=".\Lua\ldebug.c">
</File>
<File
RelativePath=".\Lua\ldebug.h"
>
RelativePath=".\Lua\ldebug.h">
</File>
<File
RelativePath=".\Lua\ldo.c"
>
RelativePath=".\Lua\ldo.c">
</File>
<File
RelativePath=".\Lua\ldo.h"
>
RelativePath=".\Lua\ldo.h">
</File>
<File
RelativePath=".\Lua\ldump.c"
>
RelativePath=".\Lua\ldump.c">
</File>
<File
RelativePath=".\Lua\lfunc.c"
>
RelativePath=".\Lua\lfunc.c">
</File>
<File
RelativePath=".\Lua\lfunc.h"
>
RelativePath=".\Lua\lfunc.h">
</File>
<File
RelativePath=".\Lua\lgc.c"
>
RelativePath=".\Lua\lgc.c">
</File>
<File
RelativePath=".\Lua\lgc.h"
>
RelativePath=".\Lua\lgc.h">
</File>
<File
RelativePath=".\Lua\liolib.c"
>
RelativePath=".\Lua\liolib.c">
</File>
<File
RelativePath=".\Lua\llex.c"
>
RelativePath=".\Lua\llex.c">
</File>
<File
RelativePath=".\Lua\llex.h"
>
RelativePath=".\Lua\llex.h">
</File>
<File
RelativePath=".\Lua\llimits.h"
>
RelativePath=".\Lua\llimits.h">
</File>
<File
RelativePath=".\Lua\lmathlib.c"
>
RelativePath=".\Lua\lmathlib.c">
</File>
<File
RelativePath=".\Lua\lmem.c"
>
RelativePath=".\Lua\lmem.c">
</File>
<File
RelativePath=".\Lua\lmem.h"
>
RelativePath=".\Lua\lmem.h">
</File>
<File
RelativePath=".\Lua\loadlib.c"
>
RelativePath=".\Lua\loadlib.c">
</File>
<File
RelativePath=".\Lua\lobject.c"
>
RelativePath=".\Lua\lobject.c">
</File>
<File
RelativePath=".\Lua\lobject.h"
>
RelativePath=".\Lua\lobject.h">
</File>
<File
RelativePath=".\Lua\lopcodes.c"
>
RelativePath=".\Lua\lopcodes.c">
</File>
<File
RelativePath=".\Lua\lopcodes.h"
>
RelativePath=".\Lua\lopcodes.h">
</File>
<File
RelativePath=".\Lua\lparser.c"
>
RelativePath=".\Lua\lparser.c">
</File>
<File
RelativePath=".\Lua\lparser.h"
>
RelativePath=".\Lua\lparser.h">
</File>
<File
RelativePath=".\Lua\lstate.c"
>
RelativePath=".\Lua\lstate.c">
</File>
<File
RelativePath=".\Lua\lstate.h"
>
RelativePath=".\Lua\lstate.h">
</File>
<File
RelativePath=".\Lua\lstring.c"
>
RelativePath=".\Lua\lstring.c">
</File>
<File
RelativePath=".\Lua\lstring.h"
>
RelativePath=".\Lua\lstring.h">
</File>
<File
RelativePath=".\Lua\lstrlib.c"
>
RelativePath=".\Lua\lstrlib.c">
</File>
<File
RelativePath=".\Lua\ltable.c"
>
RelativePath=".\Lua\ltable.c">
</File>
<File
RelativePath=".\Lua\ltable.h"
>
RelativePath=".\Lua\ltable.h">
</File>
<File
RelativePath=".\Lua\ltablib.c"
>
RelativePath=".\Lua\ltablib.c">
</File>
<File
RelativePath=".\Lua\ltests.c"
>
RelativePath=".\Lua\ltests.c">
</File>
<File
RelativePath=".\Lua\ltm.c"
>
RelativePath=".\Lua\ltm.c">
</File>
<File
RelativePath=".\Lua\ltm.h"
>
RelativePath=".\Lua\ltm.h">
</File>
<File
RelativePath=".\Lua\lua.h"
>
RelativePath=".\Lua\lua.h">
</File>
<File
RelativePath=".\Lua\luadebug.h"
>
RelativePath=".\Lua\luadebug.h">
</File>
<File
RelativePath=".\Lua\lualib.h"
>
RelativePath=".\Lua\lualib.h">
</File>
<File
RelativePath=".\Lua\lundump.c"
>
RelativePath=".\Lua\lundump.c">
</File>
<File
RelativePath=".\Lua\lundump.h"
>
RelativePath=".\Lua\lundump.h">
</File>
<File
RelativePath=".\Lua\lvm.c"
>
RelativePath=".\Lua\lvm.c">
</File>
<File
RelativePath=".\Lua\lvm.h"
>
RelativePath=".\Lua\lvm.h">
</File>
<File
RelativePath=".\Lua\lzio.c"
>
RelativePath=".\Lua\lzio.c">
</File>
<File
RelativePath=".\Lua\lzio.h"
>
RelativePath=".\Lua\lzio.h">
</File>
</Filter>
<File
RelativePath=".\arg.c"
>
RelativePath=".\arg.c">
</File>
<File
RelativePath=".\arg.h"
>
RelativePath=".\arg.h">
</File>
<File
RelativePath=".\clean.c"
>
RelativePath=".\clean.c">
</File>
<File
RelativePath=".\gnu.c"
>
RelativePath=".\gnu.c">
</File>
<File
RelativePath=".\gnu.h"
>
RelativePath=".\gnu.h">
</File>
<File
RelativePath=".\gnu_cpp.c"
>
RelativePath=".\gnu_cpp.c">
</File>
<File
RelativePath=".\gnu_cs.c"
>
RelativePath=".\gnu_cs.c">
</File>
<File
RelativePath=".\gnu_helpers.c"
>
RelativePath=".\gnu_helpers.c">
</File>
<File
RelativePath=".\io.c"
>
RelativePath=".\io.c">
</File>
<File
RelativePath=".\io.h"
>
RelativePath=".\io.h">
</File>
<File
RelativePath=".\os.c"
>
RelativePath=".\os.c">
</File>
<File
RelativePath=".\os.h"
>
RelativePath=".\os.h">
</File>
<File
RelativePath=".\path.c"
>
RelativePath=".\path.c">
</File>
<File
RelativePath=".\path.h"
>
RelativePath=".\path.h">
</File>
<File
RelativePath=".\platform.h"
>
RelativePath=".\platform.h">
</File>
<File
RelativePath=".\platform_posix.c"
>
RelativePath=".\platform_posix.c">
</File>
<File
RelativePath=".\platform_windows.c"
>
RelativePath=".\platform_windows.c">
</File>
<File
RelativePath=".\premake.c"
>
RelativePath=".\premake.c">
</File>
<File
RelativePath=".\premake.h"
>
RelativePath=".\premake.h">
</File>
<File
RelativePath=".\project.c"
>
RelativePath=".\project.c">
</File>
<File
RelativePath=".\project.h"
>
RelativePath=".\project.h">
</File>
<File
RelativePath=".\script.c"
>
RelativePath=".\script.c">
</File>
<File
RelativePath=".\script.h"
>
RelativePath=".\script.h">
</File>
<File
RelativePath=".\sharpdev.c"
>
RelativePath=".\sharpdev.c">
</File>
<File
RelativePath=".\sharpdev.h"
>
RelativePath=".\sharpdev.h">
</File>
<File
RelativePath=".\sharpdev_cs.c"
>
RelativePath=".\sharpdev_cs.c">
</File>
<File
RelativePath=".\util.c"
>
RelativePath=".\util.c">
</File>
<File
RelativePath=".\util.h"
>
RelativePath=".\util.h">
</File>
<File
RelativePath=".\vs.c"
>
RelativePath=".\vs.c">
</File>
<File
RelativePath=".\vs.h"
>
RelativePath=".\vs.h">
</File>
<File
RelativePath=".\vs2002.c"
>
RelativePath=".\vs2002.c">
</File>
<File
RelativePath=".\vs2002.h"
>
RelativePath=".\vs2002.h">
</File>
<File
RelativePath=".\vs2002_cs.c"
>
RelativePath=".\vs2002_cs.c">
</File>
<File
RelativePath=".\vs2005.c"
>
RelativePath=".\vs2005.c">
</File>
<File
RelativePath=".\vs2005.h"
>
RelativePath=".\vs2005.h">
</File>
<File
RelativePath=".\vs2005_cs.c"
>
RelativePath=".\vs2005_cs.c">
</File>
<File
RelativePath=".\vs6.c"
>
RelativePath=".\vs6.c">
</File>
<File
RelativePath=".\vs6.h"
>
RelativePath=".\vs6.h">
</File>
<File
RelativePath=".\vs6_cpp.c"
>
RelativePath=".\vs6_cpp.c">
</File>
</Files>
<Globals>

View File

@ -22,6 +22,7 @@
#include "os.h"
static const char* filterLinks(const char* name);
static const char* listCxxTestSources(const char* name);
static const char* listCppSources(const char* name);
static const char* listRcSources(const char* name);
static const char* listCppTargets(const char* name);
@ -50,6 +51,8 @@ int gnu_cpp()
io_print("Windowed Executable");
else if (prj_is_kind("dll"))
io_print("Shared Library");
else if (prj_is_kind("cxxtestgen"))
io_print("CxxTest Generator");
else if (prj_is_kind("lib"))
io_print("Static Library");
@ -133,6 +136,9 @@ int gnu_cpp()
io_print("\n");
/* Build the target name */
if (prj_is_kind("cxxtestgen"))
io_print(" TARGET := $(OBJECTS)\n");
else
io_print(" TARGET := %s\n", path_getname(prj_get_target()));
if (os_is("macosx") && prj_is_kind("winexe"))
io_print(" MACAPP := %s.app/Contents\n", path_getname(prj_get_target()));
@ -141,6 +147,8 @@ int gnu_cpp()
io_print(" BLDCMD = ");
if (prj_is_kind("lib"))
io_print("ar -cr $(OUTDIR)/$(TARGET) $(OBJECTS); ranlib $(OUTDIR)/$(TARGET)");
else if (prj_is_kind("cxxtestgen"))
io_print("true");
else
io_print("$(%s) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES)", prj_is_lang("c") ? "CC" : "CXX");
io_print("\n");
@ -150,6 +158,9 @@ int gnu_cpp()
/* Write out the list of object file targets for all C/C++ sources */
io_print("OBJECTS := \\\n");
if (prj_is_kind("cxxtestgen"))
print_list(prj_get_files(), "\t", " \\\n", "", listCxxTestSources);
else
print_list(prj_get_files(), "\t$(OBJDIR)/", " \\\n", "", listCppSources);
io_print("\n");
@ -184,12 +195,16 @@ int gnu_cpp()
io_print("all: $(OUTDIR)/$(MACAPP)/PkgInfo $(OUTDIR)/$(MACAPP)/Info.plist $(OUTDIR)/$(MACAPP)/MacOS/$(TARGET)\n\n");
io_print("$(OUTDIR)/$(MACAPP)/MacOS/$(TARGET)");
}
else if (prj_is_kind("cxxtestgen"))
io_print("all");
else
{
io_print("$(OUTDIR)/$(TARGET)");
}
io_print(": $(OBJECTS) $(LDDEPS) $(RESOURCES)\n");
if (!prj_is_kind("cxxtestgen"))
{
if (!g_verbose)
io_print("\t@echo Linking %s\n", prj_get_pkgname());
io_print("\t-%s$(CMD_MKBINDIR)\n", prefix);
@ -198,6 +213,11 @@ int gnu_cpp()
if (os_is("macosx") && prj_is_kind("winexe"))
io_print("\t-%sif [ ! -d $(OUTDIR)/$(MACAPP)/MacOS ]; then mkdir -p $(OUTDIR)/$(MACAPP)/MacOS; fi\n", prefix);
io_print("\t%s$(BLDCMD)\n\n", prefix);
}
else
{
io_print("\t@true\n\n", prefix);
}
/*
if (prj_is_kind("lib"))
@ -241,6 +261,7 @@ int gnu_cpp()
if (os_is("windows"))
print_list(prj_get_files(), "", "", "", listRcTargets);
if (!prj_is_kind("cxxtestgen"))
/* Include the automatically generated dependency lists */
io_print("-include $(OBJECTS:%%.o=%%.d)\n\n");
@ -261,7 +282,10 @@ static const char* filterLinks(const char* name)
if (i >= 0)
{
const char* lang = prj_get_language_for(i);
if (matches(lang, "c++") || matches(lang, "c"))
const char *kind = prj_get_config_for(i)->kind;
if (matches(kind, "cxxtestgen"))
return NULL;
else if (matches(lang, "c++") || matches(lang, "c"))
{
return prj_get_target_for(i);
}
@ -297,6 +321,16 @@ static const char* listCppSources(const char* name)
}
static const char* listCxxTestSources(const char* name)
{
if (endsWith(name, ".h"))
{
return path_swapextension(name, ".h", ".cpp");
}
return NULL;
}
/************************************************************************
* Checks each source code file and filters out everything that is
* not a windows resource file
@ -321,11 +355,11 @@ static const char* listRcSources(const char* name)
***********************************************************************/
static const char* listCppTargets(const char* name)
{
if (is_cpp(name))
{
const char* ext = path_getextension(name);
const char* basename = path_getbasename(name);
if (is_cpp(name))
{
sprintf(g_buffer, "$(OBJDIR)/%s.o: %s\n", basename, name);
strcat(g_buffer, "\t-");
@ -376,6 +410,19 @@ static const char* listCppTargets(const char* name)
return g_buffer;
}
else if (prj_is_kind("cxxtestgen"))
{
const char *target_name=path_swapextension(name, ".h", ".cpp");
sprintf(g_buffer,
"%s: %s\n"
"%s"
"\t%s%s --part -o %s %s\n", target_name, name,
g_verbose?"":"\t@echo $(notdir $<)\n",
g_verbose?"":"@",
"cxxtestgen", target_name, name);
return g_buffer;
}
else
{
return NULL;
@ -419,6 +466,10 @@ static const char* listLinkerDeps(const char* name)
int i = prj_find_package(name);
if (i >= 0)
{
const char *kind = prj_get_config_for(i)->kind;
if (!strcmp(kind, "cxxtestgen"))
return NULL;
else
return prj_get_target_for(i);
}

View File

@ -248,6 +248,22 @@ const char* prj_get_nasmpath()
return buffer;
}
const char* prj_get_cxxtestpath()
{
strcpy(buffer, path_build(my_pkg->path, my_cfg->prjConfig->cxxtest_path));
return buffer;
}
const char* prj_get_cxxtest_rootoptions()
{
return my_cfg->cxxtest_rootoptions;
}
const char* prj_get_cxxtest_rootfile()
{
return my_cfg->cxxtest_rootfile;
}
const char* prj_get_trimprefix()
{
return my_cfg->trimprefix;

View File

@ -28,6 +28,7 @@ typedef struct tagPrjConfig
const char* bindir;
const char* libdir;
const char* nasmpath;
const char* cxxtest_path;
} PrjConfig;
typedef struct tagFileConfig
@ -55,6 +56,8 @@ typedef struct tagPkgConfig
const char* pchSource;
const char* trimprefix;
FileConfig** fileconfigs;
const char* cxxtest_rootoptions;
const char* cxxtest_rootfile;
} PkgConfig;
typedef struct tagPackage
@ -112,6 +115,7 @@ const char* prj_get_objdir();
const char* prj_get_prefix();
const char* prj_get_name();
const char* prj_get_nasmpath();
const char* prj_get_cxxtestpath();
int prj_get_numbuildoptions();
int prj_get_numconfigs();
int prj_get_numdefines();
@ -129,6 +133,8 @@ Package* prj_get_package_for();
const char* prj_get_path();
const char* prj_get_pch_header();
const char* prj_get_pch_source();
const char* prj_get_cxxtest_rootoptions();
const char* prj_get_cxxtest_rootfile();
const char* prj_get_pkgfilename(const char* extension);
const char* prj_get_pkgname();
const char* prj_get_pkgname_for();

View File

@ -352,6 +352,8 @@ static int export_pkgconfig(Package* package, int tbl)
config->pchHeader = export_value(tbl, obj, "pchheader");
config->pchSource = export_value(tbl, obj, "pchsource");
config->trimprefix = export_value(tbl, obj, "trimprefix");
config->cxxtest_rootoptions = export_value(tbl, obj, "rootoptions");
config->cxxtest_rootfile = export_value(tbl, obj, "rootfile");
/* Assign a default target, if none specified */
if (config->target == NULL)
@ -418,6 +420,7 @@ int script_export()
config->bindir = export_value(tbl, obj, "bindir");
config->libdir = export_value(tbl, obj, "libdir");
config->nasmpath = export_value(tbl, obj, "nasmpath");
config->cxxtest_path = export_value(tbl, obj, "cxxtestpath");
}
/* Copy out the packages */

View File

@ -326,7 +326,7 @@ int vs_write_cpp()
prj_select_config(i);
if (prj_is_kind("winexe") || prj_is_kind("exe"))
if (prj_is_kind("winexe") || prj_is_kind("exe") || prj_is_kind("cxxtestgen") || prj_is_kind("run"))
{
configTypeId = 1;
}
@ -390,6 +390,35 @@ int vs_write_cpp()
break;
case VCCustomBuildTool:
tag_attr("Name=\"VCCustomBuildTool\"");
if (prj_is_kind("run"))
{
tag_attr("Description=\"Running CxxTest Test Suite\"");
tag_attr_open("CommandLine");
print_list(prj_get_links(), "", "", " ", vs_filter_links);
print_list(prj_get_buildoptions(), " ", "", "", NULL);
tag_attr_close();
// This so that we're always run (and never "up-to-date")
tag_attr("Outputs=\".\\dummy.file.thats.never.created\"");
}
else if (prj_is_kind("cxxtestgen"))
{
char *rootfile = strdup(prj_get_cxxtest_rootfile());
char *ctpath = strdup(path_translate(prj_get_cxxtestpath(), "windows"));
char *options = strdup(prj_get_cxxtest_rootoptions());
tag_attr("Description=\"Generating test_root.cpp\"");
tag_attr("CommandLine=\"%s%s --root %s -o &quot;%s&quot;\"",
endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"",
ctpath,
options,
rootfile);
tag_attr("Outputs=\"%s\"", rootfile);
free(options);
free(ctpath);
free(rootfile);
}
break;
case VCXMLDataGeneratorTool:
tag_attr("Name=\"VCXMLDataGeneratorTool\"");
@ -603,6 +632,48 @@ int vs_write_cpp()
tag_open("Files");
print_source_tree("", vs_list_files);
/*if (prj_is_kind("cxxtestgen"))
{
char *rootfile = strdup(prj_get_cxxtest_rootfile());
char *ctpath = strdup(path_translate(prj_get_cxxtestpath(), "windows"));
int i;
tag_open("File");
tag_attr_open("RelativePath");
if (rootfile[0] != '.')
io_print(".\\");
io_print(rootfile);
tag_attr_close();
for (i = 0; i < prj_get_numconfigs(); ++i)
{
char *options;
prj_select_config(i);
options = strdup(prj_get_cxxtest_rootoptions());
tag_open("FileConfiguration");
tag_attr("Name=\"%s|Win32\"", prj_get_cfgname());
tag_open("Tool");
tag_attr("Name=\"VCCustomBuildTool\"");
tag_attr("Description=\"Generating test_root.cpp\"");
tag_attr("CommandLine=\"%s%s --root %s -o &quot;%s&quot;\"",
endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"",
ctpath,
options,
rootfile);
tag_attr("Outputs=\"%s\"", rootfile);
tag_close("Tool", 0);
tag_close("FileConfiguration", 1);
free(options);
}
tag_close("File", 1);
free(ctpath);
free(rootfile);
}*/
tag_close("Files", 1);
tag_open("Globals");
@ -625,7 +696,16 @@ const char* vs_filter_links(const char* name)
if (i >= 0)
{
const char* lang = prj_get_language_for(i);
if (matches(lang, "c") || matches(lang, "c++"))
const char* kind = prj_get_config_for(i)->kind;
if (matches(kind, "cxxtestgen"))
return NULL;
// note that "run" matches against the /current/ project, not the link
// dependency we've been run for
else if (prj_is_kind("run"))
{
return path_translate(prj_get_target_for(i), "windows");
}
else if (matches(lang, "c") || matches(lang, "c++"))
{
strcpy(g_buffer, prj_get_libdir_for(i));
return path_combine(g_buffer, prj_get_targetname_for(i));
@ -687,7 +767,8 @@ void vs_list_files(const char* path, int stage)
/* Add FileConfiguration section if this is a special PCH file, or
if it's a custom-built .asm */
if (matches(path_getname(path), pchSource) || endsWith(path, ".asm"))
if (matches(path_getname(path), pchSource) || endsWith(path, ".asm")
|| (prj_is_kind("cxxtestgen") && endsWith(path, ".h")))
{
for (i = 0; i < prj_get_numconfigs(); ++i)
{
@ -706,6 +787,21 @@ void vs_list_files(const char* path, int stage)
tag_attr("Outputs=\"$(IntDir)\\$(InputName).obj\"");
tag_close("Tool", 0);
}
else if (prj_is_kind("cxxtestgen") && endsWith(path, ".h"))
{
char *targetname=strdup(path_swapextension(path, ".h", ".cpp"));
tag_open("Tool");
tag_attr("Name=\"VCCustomBuildTool\"");
tag_attr("Description=\"Generating %s\"", targetname);
tag_attr("CommandLine=\"%s%s --part -o &quot;%s&quot; &quot;$(InputPath)&quot;\"",
endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"",
path_translate(prj_get_cxxtestpath(), "windows"), targetname);
tag_attr("Outputs=\"%s\"", targetname);
tag_close("Tool", 0);
free(targetname);
}
else /* (.asm doesn't need PCH) */
{
tag_open("Tool");