support for <if> tag

.PHONY must be output before the target gets defined


svn path=/branches/xmlbuildsystem/; revision=12944
This commit is contained in:
Royce Mitchell III 2005-01-12 06:02:58 +00:00
parent 4846c7b4a2
commit 9264ed7582
6 changed files with 380 additions and 134 deletions

View file

@ -6,9 +6,18 @@
<xi:include href="config.template.xml" /> <xi:include href="config.template.xml" />
</xi:fallback> </xi:fallback>
</xi:include> </xi:include>
<define name="_M_IX86" /> <define name="_M_IX86" />
<if property="dbg" value="true">
<define name="dbg_or_kdbg" value="true" />
</if>
<if property="kdbg" value="true">
<define name="dbg_or_kdbg" value="true" />
</if>
<include>include</include> <include>include</include>
<include>w32api/include</include> <include>w32api/include</include>
<directory name="tools"> <directory name="tools">
<xi:include href="tools/tools.xml" /> <xi:include href="tools/tools.xml" />
</directory> </directory>

View file

@ -41,10 +41,9 @@
<file>rtlfunc.c</file> <file>rtlfunc.c</file>
</directory> </directory>
<directory name="dbg"> <directory name="dbg">
<!--
<if property="arch" value="i386"> <if property="arch" value="i386">
<directory name="i386"> <directory name="i386">
<if property="kdbg" value="true"> <if property="kdbg" value="1">
<group> <group>
<file>i386-dis.c</file> <file>i386-dis.c</file>
<file>kdb_help.S</file> <file>kdb_help.S</file>
@ -52,36 +51,17 @@
</if> </if>
</directory> </directory>
</if> </if>
--> <if property="kdbg" value="1">
<!-- <file>kdb.c</file>
<if property="kdbg" value="true"> <file>kdb_keyboard.c</file>
<group> <file>kdb_serial.c</file>
<file>kdb.c</file> <file>rdebug.c</file>
<file>kdb_keyboard.c</file> <file>profile.c</file>
<file>kdb_serial.c</file> </if>
<file>rdebug.c</file> <if property="dbg_or_kdbg" value="true">
<file>profile.c</file> <file>kdb_stabs.c</file>
</group> <file>kdb_symbols.c</file>
</if> </if>
-->
<or>
<!--
<if property="kdbg" value="true">
<group>
<file>kdb_stabs.c</file>
<file>kdb_symbols.c</file>
</group>
</if>
-->
<!--
<if property="dbg" value="true">
<group>
<file>kdb_stabs.c</file>
<file>kdb_symbols.c</file>
</group>
</if>
-->
</or>
<file>dbgctrl.c</file> <file>dbgctrl.c</file>
<file>errinfo.c</file> <file>errinfo.c</file>
<file>print.c</file> <file>print.c</file>

View file

@ -237,12 +237,14 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Includ
void void
MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const
{ {
#if 0
string name ( module.name + "_CFLAGS" ); string name ( module.name + "_CFLAGS" );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s := %s %s\n", "%s := %s %s\n",
name.c_str(), name.c_str(),
GenerateGccDefineParameters(module).c_str(), GenerateGccDefineParameters(module).c_str(),
GenerateGccIncludeParameters(module).c_str() ); GenerateGccIncludeParameters(module).c_str() );
#endif
} }
string string
@ -258,73 +260,174 @@ MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
return parameters; return parameters;
} }
string void
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const MingwModuleHandler::GenerateMacros (
const Module& module,
const char* op,
const vector<File*>& files,
const vector<Include*>* includes,
const vector<Define*>& defines,
const string& cflags_macro,
const string& nasmflags_macro,
const string& objs_macro) const
{ {
return ssprintf(" $(%s_CFLAGS)", module.name.c_str()); size_t i;
if ( (includes && includes->size()) || defines.size() )
{
fprintf (
fMakefile,
"%s %s",
cflags_macro.c_str(),
op );
if ( includes )
for ( i = 0; i < includes->size(); i++ )
fprintf (
fMakefile,
" -I%s",
(*includes)[i]->directory.c_str() );
for ( i = 0; i < module.defines.size(); i++ )
{
Define& d = *module.defines[i];
fprintf (
fMakefile,
" -D%s",
d.name.c_str() );
if ( d.value.size() )
fprintf (
fMakefile,
"=%s",
d.value.c_str() );
}
fprintf ( fMakefile, "\n" );
}
if ( files.size() )
{
fprintf (
fMakefile,
"%s %s",
objs_macro.c_str(),
op );
for ( i = 0; i < files.size(); i++ )
{
fprintf (
fMakefile,
"%s%s",
( i%10 == 9 ? "\\\n\t" : " " ),
GetObjectFilename(files[i]->name).c_str() );
}
fprintf ( fMakefile, "\n" );
}
} }
string void
MingwModuleHandler::GenerateNasmParameters ( const Module& module ) const MingwModuleHandler::GenerateMacros (
const Module& module,
const string& cflags_macro,
const string& nasmflags_macro,
const string& objs_macro) const
{ {
return ""; GenerateMacros (
module,
"=",
module.files,
&module.includes,
module.defines,
cflags_macro,
nasmflags_macro,
objs_macro );
fprintf ( fMakefile, "\n" );
for ( size_t i = 0; i < module.ifs.size(); i++ )
{
If& rIf = *module.ifs[i];
if ( rIf.defines.size() || rIf.files.size() )
{
fprintf (
fMakefile,
"ifeq ($(%s),\"%s\")\n",
rIf.property.c_str(),
rIf.value.c_str() );
GenerateMacros (
module,
"+=",
rIf.files,
NULL,
rIf.defines,
cflags_macro,
nasmflags_macro,
objs_macro );
fprintf (
fMakefile,
"endif\n\n" );
}
}
} }
string string
MingwModuleHandler::GenerateGccCommand ( const Module& module, MingwModuleHandler::GenerateGccCommand ( const Module& module,
const string& sourceFilename, const string& sourceFilename,
const string& cc ) const const string& cc,
const string& cflagsMacro ) const
{ {
string objectFilename = GetObjectFilename ( sourceFilename ); string objectFilename = GetObjectFilename ( sourceFilename );
return ssprintf ( "%s -c %s -o %s %s\n", return ssprintf ( "%s -c %s -o %s %s\n",
cc.c_str (), cc.c_str (),
sourceFilename.c_str (), sourceFilename.c_str (),
objectFilename.c_str (), objectFilename.c_str (),
GenerateGccParameters ( module ).c_str () ); cflagsMacro.c_str () );
} }
string string
MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module, MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
const string& sourceFilename, const string& sourceFilename,
const string& cc ) const const string& cc,
const string& cflagsMacro ) const
{ {
string objectFilename = GetObjectFilename ( sourceFilename ); string objectFilename = GetObjectFilename ( sourceFilename );
return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n", return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
cc.c_str (), cc.c_str (),
sourceFilename.c_str (), sourceFilename.c_str (),
objectFilename.c_str (), objectFilename.c_str (),
GenerateGccParameters ( module ).c_str () ); cflagsMacro.c_str () );
} }
string string
MingwModuleHandler::GenerateNasmCommand ( const Module& module, MingwModuleHandler::GenerateNasmCommand ( const Module& module,
const string& sourceFilename ) const const string& sourceFilename,
const string& nasmflagsMacro ) const
{ {
string objectFilename = GetObjectFilename ( sourceFilename ); string objectFilename = GetObjectFilename ( sourceFilename );
return ssprintf ( "%s -f win32 %s -o %s %s\n", return ssprintf ( "%s -f win32 %s -o %s %s\n",
"nasm", "nasm",
sourceFilename.c_str (), sourceFilename.c_str (),
objectFilename.c_str (), objectFilename.c_str (),
GenerateNasmParameters ( module ).c_str () ); nasmflagsMacro.c_str () );
} }
string string
MingwModuleHandler::GenerateCommand ( const Module& module, MingwModuleHandler::GenerateCommand ( const Module& module,
const string& sourceFilename, const string& sourceFilename,
const string& cc ) const const string& cc,
const string& cflagsMacro,
const string& nasmflagsMacro ) const
{ {
string extension = GetExtension ( sourceFilename ); string extension = GetExtension ( sourceFilename );
if ( extension == ".c" || extension == ".C" ) if ( extension == ".c" || extension == ".C" )
return GenerateGccCommand ( module, return GenerateGccCommand ( module,
sourceFilename, sourceFilename,
cc ); cc,
cflagsMacro );
else if ( extension == ".s" || extension == ".S" ) else if ( extension == ".s" || extension == ".S" )
return GenerateGccAssemblerCommand ( module, return GenerateGccAssemblerCommand ( module,
sourceFilename, sourceFilename,
cc ); cc,
cflagsMacro );
else if ( extension == ".asm" || extension == ".ASM" ) else if ( extension == ".asm" || extension == ".ASM" )
return GenerateNasmCommand ( module, return GenerateNasmCommand ( module,
sourceFilename ); sourceFilename,
nasmflagsMacro );
throw InvalidOperationException ( __FILE__, throw InvalidOperationException ( __FILE__,
__LINE__, __LINE__,
@ -335,16 +438,17 @@ MingwModuleHandler::GenerateCommand ( const Module& module,
void void
MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const string& cc) const const vector<File*>& files,
const string& cc,
const string& cflagsMacro,
const string& nasmflagsMacro ) const
{ {
if ( module.files.size () == 0 ) if ( files.size () == 0 )
return; return;
GenerateGccModuleIncludeVariable ( module );
for ( size_t i = 0; i < module.files.size (); i++ ) for ( size_t i = 0; i < files.size (); i++ )
{ {
string sourceFilename = module.files[i]->name; string sourceFilename = files[i]->name;
string objectFilename = GetObjectFilename ( sourceFilename ); string objectFilename = GetObjectFilename ( sourceFilename );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s\n", "%s: %s\n",
@ -354,58 +458,76 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
"\t%s\n", "\t%s\n",
GenerateCommand ( module, GenerateCommand ( module,
sourceFilename, sourceFilename,
cc ).c_str () ); cc,
cflagsMacro,
nasmflagsMacro ).c_str () );
} }
fprintf ( fMakefile, "\n" ); fprintf ( fMakefile, "\n" );
} }
void void
MingwModuleHandler::GenerateObjectFileTargetsHost ( const Module& module ) const MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const string& cc,
const string& cflagsMacro,
const string& nasmflagsMacro ) const
{ {
GenerateObjectFileTargets ( module, GenerateObjectFileTargets ( module, module.files, cc, cflagsMacro, nasmflagsMacro );
"${host_gcc}" ); for ( size_t i = 0; i < module.ifs.size(); i++ )
} GenerateObjectFileTargets ( module, module.ifs[i]->files, cc, cflagsMacro, nasmflagsMacro );
void
MingwModuleHandler::GenerateObjectFileTargetsTarget ( const Module& module ) const
{
GenerateObjectFileTargets ( module,
"${gcc}" );
} }
void void
MingwModuleHandler::GenerateArchiveTarget ( const Module& module, MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
const string& ar ) const const string& ar,
const string& objs_macro ) const
{ {
string archiveFilename = GetModuleArchiveFilename ( module ); string archiveFilename = GetModuleArchiveFilename ( module );
string sourceFilenames = GetSourceFilenames ( module ); string sourceFilenames = GetSourceFilenames ( module );
string objectsMacro = GenerateObjectList ( module );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s\n", "%s: %s\n",
archiveFilename.c_str (), archiveFilename.c_str (),
objectsMacro.c_str ()); objs_macro.c_str ());
fprintf ( fMakefile, fprintf ( fMakefile,
"\t%s -rc %s %s\n\n", "\t%s -rc %s %s\n\n",
ar.c_str (), ar.c_str (),
archiveFilename.c_str (), archiveFilename.c_str (),
objectsMacro.c_str ()); objs_macro.c_str ());
} }
void void
MingwModuleHandler::GenerateArchiveTargetHost ( const Module& module ) const MingwModuleHandler::GenerateMacrosAndTargets (
const Module& module,
const string& cc,
const string& ar ) const
{ {
GenerateArchiveTarget ( module, string cflagsMacro = ssprintf("%s_CFLAGS",module.name.c_str());
"${host_ar}" ); string nasmflagsMacro = ssprintf("%s_NASMFLAGS",module.name.c_str());
string objectsMacro = ssprintf("%s_OBJS",module.name.c_str());
GenerateMacros ( module, cflagsMacro, nasmflagsMacro, objectsMacro );
// future references to the macros will be to get their values
cflagsMacro = ssprintf("$(%s)",cflagsMacro.c_str());
nasmflagsMacro = ssprintf("$(%s)",nasmflagsMacro.c_str());
objectsMacro = ssprintf("$(%s)",objectsMacro.c_str());
GenerateArchiveTarget ( module, ar, objectsMacro );
GenerateObjectFileTargets ( module, cc, cflagsMacro, nasmflagsMacro );
} }
void void
MingwModuleHandler::GenerateArchiveTargetTarget ( const Module& module ) const MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
{ {
GenerateArchiveTarget ( module, GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}" );
"${ar}" ); }
void
MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const
{
GenerateMacrosAndTargets ( module, "${gcc}", "${ar}" );
} }
string string
@ -513,28 +635,37 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
dependencies += s; dependencies += s;
} }
fprintf ( fMakefile,
".PHONY: %s\n\n",
preconditionDependenciesName.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s\n\n", "%s: %s\n\n",
preconditionDependenciesName.c_str (), preconditionDependenciesName.c_str (),
dependencies.c_str () ); dependencies.c_str () );
fprintf ( fMakefile, const char* p = sourceFilenames.c_str();
"%s: %s\n\n", const char* end = p + strlen(p);
sourceFilenames.c_str (), while ( p < end )
preconditionDependenciesName.c_str ()); {
fprintf ( fMakefile, const char* p2 = &p[512];
".PHONY: %s\n\n", if ( p2 > end )
preconditionDependenciesName.c_str () ); p2 = end;
} while ( p2 > p && !isspace(*p2) )
--p2;
string MingwModuleHandler::GenerateObjectList ( const Module& module ) const if ( p == p2 )
{ {
string macro ( ssprintf("%s_OBJS",module.name.c_str()) ); p2 = strpbrk ( p, " \t" );
fprintf ( if ( !p2 )
fMakefile, p2 = end;
"%s = %s\n", }
macro.c_str(), fprintf ( fMakefile,
GetObjectFilenames(module).c_str() ); "%.*s: %s\n",
return ssprintf("$(%s)",macro.c_str()); p2-p,
p,
preconditionDependenciesName.c_str ());
p = p2;
p += strspn ( p, " \t" );
}
fprintf ( fMakefile, "\n" );
} }
@ -562,11 +693,10 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
target.c_str (), target.c_str (),
archiveFilename.c_str () ); archiveFilename.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${host_gcc} -o %s %s\n", "\t${host_gcc} -o %s %s\n\n",
target.c_str (), target.c_str (),
archiveFilename.c_str () ); archiveFilename.c_str () );
GenerateArchiveTargetHost ( module ); GenerateMacrosAndTargetsHost ( module );
GenerateObjectFileTargetsHost ( module );
} }
static MingwKernelModuleHandler kernelmodule_handler; static MingwKernelModuleHandler kernelmodule_handler;
@ -628,11 +758,10 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
archiveFilename.c_str (), archiveFilename.c_str (),
importLibraryDependencies.c_str () ); importLibraryDependencies.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${rm} %s\n", "\t${rm} %s\n\n",
temp_exp.c_str () ); temp_exp.c_str () );
GenerateArchiveTargetTarget ( module ); GenerateMacrosAndTargetsTarget ( module );
GenerateObjectFileTargetsTarget ( module );
} }
@ -654,8 +783,7 @@ MingwStaticLibraryModuleHandler::Process ( const Module& module )
void void
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module ) MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )
{ {
GenerateArchiveTargetTarget ( module ); GenerateMacrosAndTargetsTarget ( module );
GenerateObjectFileTargetsTarget ( module );
} }
@ -703,17 +831,16 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
importLibraryDependencies.c_str () ); importLibraryDependencies.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n", "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n\n",
target.c_str (), target.c_str (),
archiveFilename.c_str (), archiveFilename.c_str (),
importLibraryDependencies.c_str () ); importLibraryDependencies.c_str () );
GenerateArchiveTargetTarget ( module ); GenerateMacrosAndTargetsTarget ( module );
GenerateObjectFileTargetsTarget ( module );
} }
else else
{ {
fprintf ( fMakefile, "%s:\n\n", fprintf ( fMakefile, "%s:\n",
target.c_str ()); target.c_str ());
fprintf ( fMakefile, ".PHONY: %s\n\n", fprintf ( fMakefile, ".PHONY: %s\n\n",
target.c_str ()); target.c_str ());
@ -765,13 +892,12 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
importLibraryDependencies.c_str () ); importLibraryDependencies.c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n", "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n\n",
target.c_str (), target.c_str (),
archiveFilename.c_str (), archiveFilename.c_str (),
importLibraryDependencies.c_str () ); importLibraryDependencies.c_str () );
GenerateArchiveTargetTarget ( module ); GenerateMacrosAndTargetsTarget ( module );
GenerateObjectFileTargetsTarget ( module );
} }
else else
{ {

View file

@ -30,15 +30,15 @@ protected:
std::string GetObjectFilename ( const std::string& sourceFilename ) const; std::string GetObjectFilename ( const std::string& sourceFilename ) const;
std::string GetObjectFilenames ( const Module& module ) const; std::string GetObjectFilenames ( const Module& module ) const;
void GenerateObjectFileTargetsHost ( const Module& module ) const; void GenerateMacrosAndTargetsHost ( const Module& module ) const;
void GenerateObjectFileTargetsTarget ( const Module& module ) const; void GenerateMacrosAndTargetsTarget ( const Module& module ) const;
void GenerateArchiveTargetHost ( const Module& module ) const;
void GenerateArchiveTargetTarget ( const Module& module ) const;
std::string GetInvocationDependencies ( const Module& module ) const; std::string GetInvocationDependencies ( const Module& module ) const;
std::string GetInvocationParameters ( const Invoke& invoke ) const; std::string GetInvocationParameters ( const Invoke& invoke ) const;
void GenerateInvocations ( const Module& module ) const; void GenerateInvocations ( const Module& module ) const;
void GeneratePreconditionDependencies ( const Module& module ) const; void GeneratePreconditionDependencies ( const Module& module ) const;
std::string GenerateObjectList ( const Module& module ) const; std::string GenerateMacros ( const Module& module,
const std::string& cflags_macro,
const std::string& objs_macro ) const;
static FILE* fMakefile; static FILE* fMakefile;
private: private:
std::string ConcatenatePaths ( const std::string& path1, std::string ConcatenatePaths ( const std::string& path1,
@ -46,25 +46,53 @@ private:
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const; std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
std::string GenerateGccDefineParameters ( const Module& module ) const; std::string GenerateGccDefineParameters ( const Module& module ) const;
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const; std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
void GenerateMacros ( const Module& module,
const char* op,
const std::vector<File*>& files,
const std::vector<Include*>* includes,
const std::vector<Define*>& defines,
const std::string& cflags_macro,
const std::string& nasmflags_macro,
const std::string& objs_macro) const;
void GenerateMacros ( const Module& module,
const std::string& cflags_macro,
const std::string& nasmflags_macro,
const std::string& objs_macro) const;
void GenerateGccModuleIncludeVariable ( const Module& module ) const; void GenerateGccModuleIncludeVariable ( const Module& module ) const;
std::string GenerateGccIncludeParameters ( const Module& module ) const; std::string GenerateGccIncludeParameters ( const Module& module ) const;
std::string GenerateGccParameters ( const Module& module ) const; std::string GenerateGccParameters ( const Module& module ) const;
std::string GenerateNasmParameters ( const Module& module ) const; std::string GenerateNasmParameters ( const Module& module ) const;
std::string GenerateGccCommand ( const Module& module, std::string GenerateGccCommand ( const Module& module,
const std::string& sourceFilename, const std::string& sourceFilename,
const std::string& cc ) const; const std::string& cc,
const std::string& cflagsMacro ) const;
std::string GenerateGccAssemblerCommand ( const Module& module, std::string GenerateGccAssemblerCommand ( const Module& module,
const std::string& sourceFilename, const std::string& sourceFilename,
const std::string& cc ) const; const std::string& cc,
const std::string& cflagsMacro ) const;
std::string GenerateNasmCommand ( const Module& module, std::string GenerateNasmCommand ( const Module& module,
const std::string& sourceFilename ) const; const std::string& sourceFilename,
const std::string& nasmflagsMacro ) const;
std::string GenerateCommand ( const Module& module, std::string GenerateCommand ( const Module& module,
const std::string& sourceFilename, const std::string& sourceFilename,
const std::string& cc ) const; const std::string& cc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro ) const;
void GenerateObjectFileTargets ( const Module& module, void GenerateObjectFileTargets ( const Module& module,
const std::string& cc ) const; const std::vector<File*>& files,
const std::string& cc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro ) const;
void GenerateObjectFileTargets ( const Module& module,
const std::string& cc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro ) const;
void GenerateArchiveTarget ( const Module& module, void GenerateArchiveTarget ( const Module& module,
const std::string& ar ) const; const std::string& ar,
const std::string& objs_macro ) const;
void GenerateMacrosAndTargets ( const Module& module,
const std::string& cc,
const std::string& ar ) const;
std::string GetPreconditionDependenciesName ( const Module& module ) const; std::string GetPreconditionDependenciesName ( const Module& module ) const;
}; };

View file

@ -63,6 +63,8 @@ Module::~Module ()
delete invocations[i]; delete invocations[i];
for ( i = 0; i < dependencies.size(); i++ ) for ( i = 0; i < dependencies.size(); i++ )
delete dependencies[i]; delete dependencies[i];
for ( i = 0; i < ifs.size(); i++ )
delete ifs[i];
} }
void void
@ -83,21 +85,32 @@ Module::ProcessXML()
invocations[i]->ProcessXML (); invocations[i]->ProcessXML ();
for ( i = 0; i < dependencies.size(); i++ ) for ( i = 0; i < dependencies.size(); i++ )
dependencies[i]->ProcessXML (); dependencies[i]->ProcessXML ();
for ( i = 0; i < ifs.size(); i++ )
ifs[i]->ProcessXML();
} }
void void
Module::ProcessXMLSubElement ( const XMLElement& e, Module::ProcessXMLSubElement ( const XMLElement& e,
const string& path ) const string& path,
If* pIf /*= NULL*/ )
{ {
bool subs_invalid = false; bool subs_invalid = false;
string subpath ( path ); string subpath ( path );
if ( e.name == "file" && e.value.size () > 0 ) if ( e.name == "file" && e.value.size () > 0 )
{ {
files.push_back ( new File ( FixSeparator ( path + CSEP + e.value ) ) ); File* pFile = new File ( FixSeparator ( path + CSEP + e.value ) );
if ( pIf )
pIf->files.push_back ( pFile );
else
files.push_back ( pFile );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "library" && e.value.size () ) else if ( e.name == "library" && e.value.size () )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<library> is not a valid sub-element of <if>" );
libraries.push_back ( new Library ( e, *this, e.value ) ); libraries.push_back ( new Library ( e, *this, e.value ) );
subs_invalid = true; subs_invalid = true;
} }
@ -109,36 +122,66 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
} }
else if ( e.name == "include" ) else if ( e.name == "include" )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<include> is not a valid sub-element of <if>" );
includes.push_back ( new Include ( project, this, e ) ); includes.push_back ( new Include ( project, this, e ) );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "define" ) else if ( e.name == "define" )
{ {
defines.push_back ( new Define ( project, this, e ) ); Define* pDefine = new Define ( project, this, e );
if ( pIf )
pIf->defines.push_back ( pDefine );
else
defines.push_back ( pDefine );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "invoke" ) else if ( e.name == "invoke" )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<invoke> is not a valid sub-element of <if>" );
invocations.push_back ( new Invoke ( e, *this ) ); invocations.push_back ( new Invoke ( e, *this ) );
subs_invalid = false; subs_invalid = false;
} }
else if ( e.name == "dependency" ) else if ( e.name == "dependency" )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<dependency> is not a valid sub-element of <if>" );
dependencies.push_back ( new Dependency ( e, *this ) ); dependencies.push_back ( new Dependency ( e, *this ) );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "importlibrary" ) else if ( e.name == "importlibrary" )
{ {
if ( pIf )
throw InvalidBuildFileException (
e.location,
"<importlibrary> is not a valid sub-element of <if>" );
if ( importLibrary )
throw InvalidBuildFileException (
e.location,
"Only one <importlibrary> is valid per module" );
importLibrary = new ImportLibrary ( e, *this ); importLibrary = new ImportLibrary ( e, *this );
subs_invalid = true; subs_invalid = true;
} }
else if ( e.name == "if" )
{
pIf = new If ( e, *this );
ifs.push_back ( pIf );
subs_invalid = false;
}
if ( subs_invalid && e.subElements.size() > 0 ) if ( subs_invalid && e.subElements.size() > 0 )
throw InvalidBuildFileException ( throw InvalidBuildFileException (
e.location, e.location,
"<%s> cannot have sub-elements", "<%s> cannot have sub-elements",
e.name.c_str() ); e.name.c_str() );
for ( size_t i = 0; i < e.subElements.size (); i++ ) for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXMLSubElement ( *e.subElements[i], subpath ); ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );
} }
ModuleType ModuleType
@ -188,14 +231,23 @@ Module::GetTargetName () const
string string
Module::GetDependencyPath () const Module::GetDependencyPath () const
{ {
if ( type == KernelModeDLL ) switch ( type )
{
case KernelModeDLL:
return ssprintf ( "dk%snkm%slib%slib%s.a", return ssprintf ( "dk%snkm%slib%slib%s.a",
SSEP, SSEP,
SSEP, SSEP,
SSEP, SSEP,
name.c_str () ); name.c_str () );
else case NativeDLL:
return GetPath (); return ssprintf ( "dk%sw32%slib%slib%s.a",
SSEP,
SSEP,
SSEP,
name.c_str () );
default:
return GetPath();
}
} }
string string
@ -425,5 +477,36 @@ ImportLibrary::ImportLibrary ( const XMLElement& _node,
att = _node.GetAttribute ( "definition", true ); att = _node.GetAttribute ( "definition", true );
assert (att); assert (att);
definition = att->value; definition = FixSeparator(att->value);
}
If::If ( const XMLElement& node_, const Module& module_ )
: node(node_), module(module_)
{
const XMLAttribute* att;
att = node.GetAttribute ( "property", true );
assert(att);
property = att->value;
att = node.GetAttribute ( "value", true );
assert(att);
value = att->value;
}
If::~If ()
{
size_t i;
for ( i = 0; i < files.size(); i++ )
delete files[i];
for ( i = 0; i < defines.size(); i++ )
delete defines[i];
for ( i = 0; i < ifs.size(); i++ )
delete ifs[i];
}
void
If::ProcessXML()
{
} }

View file

@ -31,6 +31,7 @@ class Invoke;
class InvokeFile; class InvokeFile;
class Dependency; class Dependency;
class ImportLibrary; class ImportLibrary;
class If;
class Project class Project
{ {
@ -86,6 +87,7 @@ public:
std::vector<Define*> defines; std::vector<Define*> defines;
std::vector<Invoke*> invocations; std::vector<Invoke*> invocations;
std::vector<Dependency*> dependencies; std::vector<Dependency*> dependencies;
std::vector<If*> ifs;
Module ( const Project& project, Module ( const Project& project,
const XMLElement& moduleNode, const XMLElement& moduleNode,
@ -104,7 +106,8 @@ public:
private: private:
std::string GetDefaultModuleExtension () const; std::string GetDefaultModuleExtension () const;
void ProcessXMLSubElement ( const XMLElement& e, void ProcessXMLSubElement ( const XMLElement& e,
const std::string& path ); const std::string& path,
If* pIf = NULL );
}; };
@ -239,6 +242,23 @@ public:
void ProcessXML (); void ProcessXML ();
}; };
class If
{
public:
const XMLElement& node;
const Module& module;
std::string property, value;
std::vector<File*> files;
std::vector<Define*> defines;
std::vector<If*> ifs;
If ( const XMLElement& node_,
const Module& module_ );
~If();
void ProcessXML();
};
extern std::string extern std::string
FixSeparator ( const std::string& s ); FixSeparator ( const std::string& s );