<xi:include href="lib/directory.xml" />\r
</directory>\r
<directory name="ntoskrnl">\r
- <xi:include href="ntoskrnl/module.xml" />\r
+ <xi:include href="ntoskrnl/ntoskrnl.xml" />\r
</directory>\r
</project>\r
<module name="ntoskrnl" type="kernelmodedll" extension=".exe">\r
<dependency>buildno</dependency>\r
+ <dependency>wmc</dependency>\r
<define name="_SEH_NO_NATIVE_NLG" />\r
<define name="_DISABLE_TIDENTS" />\r
<define name="__NTOSKRNL__" />\r
<include base="kjs">./include</include>\r
<include base="ntoskrnl">include</include>\r
<library>kjs</library>\r
+ <invoke module="wmc">\r
+ <input>\r
+ <inputfile>ntoskrnl.mc</inputfile>\r
+ </input>\r
+ <output>\r
+ <outputfile switches="-H">../include/reactos/bugcodes.h</outputfile>\r
+ <outputfile switches="-o">bugcodes.rc</outputfile>\r
+ </output>\r
+ </invoke>\r
<directory name="cc">\r
<file>cacheman.c</file>\r
<file>copy.c</file>\r
#define FALSE 0
#define TRUE 1
-/* File to (over)write */
-#define BUILDNO_INCLUDE_FILE "../include/reactos/buildno.h"
-
static char * argv0 = "";
+static char * filename = "";
#ifdef DBG
void
s = s + sprintf (s, "-%S\"\n", KERNEL_VERSION_BUILD_TYPE);
s = s + sprintf (s, "#endif\n/* EOF */\n");
- h = fopen (BUILDNO_INCLUDE_FILE, "rb");
+ h = fopen (filename, "rb");
if (h != NULL)
{
fseek(h, 0, SEEK_END);
fclose(h);
}
- h = fopen (BUILDNO_INCLUDE_FILE, "wb");
+ h = fopen (filename, "wb");
if (!h)
{
fprintf (stderr,
"%s: can not create file \"%s\"!\n",
argv0,
- BUILDNO_INCLUDE_FILE);
+ filename);
return;
}
fwrite(s1, 1, strlen(s1), h);
{
fprintf (
stderr,
- "Usage: %s [-{p|q}]\n\n -p print version number and exit\n -q run in quiet mode\n",
+ "Usage: %s [-{p|q}] path-to-header\n\n -p print version number and exit\n -q run in quiet mode\n",
argv0
);
exit (EXIT_SUCCESS);
case 1:
break;
case 2:
+ case 3:
if (argv[1][0] == '-')
{
if (argv[1][1] == 'q')
{
usage ();
}
+ filename = argv[2];
+ }
+ else if (argc == 2)
+ {
+ filename = argv[1];
}
else
{
MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const\r
{\r
return FixupTargetFilename ( ReplaceExtension ( sourceFilename,\r
- ".o" ) );\r
+ ".o" ) );\r
}\r
\r
string\r
{\r
string sourceFilename = module.files[i]->name;\r
string objectFilename = GetObjectFilename ( sourceFilename );\r
- string dependencies = GetModuleDependencies ( module );\r
fprintf ( fMakefile,\r
- "%s: %s %s\n",\r
+ "%s: %s\n",\r
objectFilename.c_str (),\r
- sourceFilename.c_str (),\r
- dependencies.c_str ());\r
+ sourceFilename.c_str () );\r
fprintf ( fMakefile,\r
"\t%s -c %s -o %s %s\n",\r
cc.c_str (),\r
for ( size_t i = 0; i < module.invocations.size (); i++ )\r
{\r
Invoke& invoke = *module.invocations[i];\r
+ if (invoke.invokeModule == &module)\r
+ /* Protect against circular dependencies */\r
+ continue;\r
if ( dependencies.length () > 0 )\r
dependencies += " ";\r
- string invokeTarget = module.GetInvocationTarget ( i );\r
- dependencies += invokeTarget;\r
+ dependencies += invoke.GetTargets ();\r
}\r
return dependencies;\r
}\r
- \r
+\r
+string\r
+MingwModuleHandler::GetInvocationParameters ( const Invoke& invoke ) const\r
+{\r
+ string parameters ( "" );\r
+ size_t i;\r
+ for (i = 0; i < invoke.output.size (); i++)\r
+ {\r
+ if (parameters.length () > 0)\r
+ parameters += " ";\r
+ InvokeFile& invokeFile = *invoke.output[i];\r
+ if (invokeFile.switches.length () > 0)\r
+ {\r
+ parameters += invokeFile.switches;\r
+ parameters += " ";\r
+ }\r
+ parameters += invokeFile.name;\r
+ }\r
+\r
+ for (i = 0; i < invoke.input.size (); i++)\r
+ {\r
+ if (parameters.length () > 0)\r
+ parameters += " ";\r
+ InvokeFile& invokeFile = *invoke.input[i];\r
+ if (invokeFile.switches.length () > 0)\r
+ {\r
+ parameters += invokeFile.switches;\r
+ parameters += " ";\r
+ }\r
+ parameters += invokeFile.name;\r
+ }\r
+\r
+ return parameters;\r
+}\r
+\r
void\r
MingwModuleHandler::GenerateInvocations ( const Module& module ) const\r
{\r
if ( module.invocations.size () == 0 )\r
return;\r
\r
- if ( module.type != BuildTool )\r
- throw InvalidBuildFileException ( module.node.location,\r
- "Only modules of type buildtool can be invoked." );\r
-\r
for ( size_t i = 0; i < module.invocations.size (); i++ )\r
{\r
- Invoke& invoke = *module.invocations[i];\r
+ const Invoke& invoke = *module.invocations[i];\r
+\r
+ if ( invoke.invokeModule->type != BuildTool )\r
+ throw InvalidBuildFileException ( module.node.location,\r
+ "Only modules of type buildtool can be invoked." );\r
+\r
string invokeTarget = module.GetInvocationTarget ( i );\r
fprintf ( fMakefile,\r
"%s: %s\n\n",\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
invokeTarget.c_str (),\r
- FixupTargetFilename ( module.GetPath () ).c_str () );\r
+ FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () );\r
fprintf ( fMakefile,\r
- "\t%s\n\n",\r
- FixupTargetFilename ( module.GetPath () ).c_str () );\r
+ "\t%s %s\n\n",\r
+ FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),\r
+ GetInvocationParameters ( invoke ).c_str () );\r
fprintf ( fMakefile,\r
".PNONY: %s\n\n",\r
invokeTarget.c_str () );\r
}\r
}\r
\r
+string\r
+MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const\r
+{\r
+ return ssprintf ( "%s_precondition",\r
+ module.name.c_str () );\r
+}\r
+\r
+void\r
+MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const\r
+{\r
+ string preconditionDependenciesName = GetPreconditionDependenciesName ( module );\r
+ string sourceFilenames = GetSourceFilenames ( module );\r
+ string dependencies = GetModuleDependencies ( module );\r
+ string s = GetInvocationDependencies ( module );\r
+ if ( s.length () > 0 )\r
+ {\r
+ if ( dependencies.length () > 0 )\r
+ dependencies += " ";\r
+ dependencies += s;\r
+ }\r
+ \r
+ fprintf ( fMakefile,\r
+ "%s: %s\n\n",\r
+ preconditionDependenciesName.c_str (),\r
+ dependencies.c_str () );\r
+ fprintf ( fMakefile,\r
+ "%s: %s\n\n",\r
+ sourceFilenames.c_str (),\r
+ preconditionDependenciesName.c_str ());\r
+ fprintf ( fMakefile,\r
+ ".PNONY: %s\n\n",\r
+ preconditionDependenciesName.c_str () );\r
+}\r
+\r
\r
MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( FILE* fMakefile )\r
: MingwModuleHandler ( fMakefile )\r
void\r
MingwBuildToolModuleHandler::Process ( const Module& module )\r
{\r
+ GeneratePreconditionDependencies ( module );\r
GenerateBuildToolModuleTarget ( module );\r
GenerateInvocations ( module );\r
}\r
void\r
MingwKernelModuleHandler::Process ( const Module& module )\r
{\r
+ GeneratePreconditionDependencies ( module );\r
GenerateKernelModuleTarget ( module );\r
GenerateInvocations ( module );\r
}\r
void\r
MingwStaticLibraryModuleHandler::Process ( const Module& module )\r
{\r
+ GeneratePreconditionDependencies ( module );\r
GenerateStaticLibraryModuleTarget ( module );\r
GenerateInvocations ( module );\r
}\r
void GenerateArchiveTargetHost ( const Module& module ) const;\r
void GenerateArchiveTargetTarget ( const Module& module ) const;\r
std::string GetInvocationDependencies ( const Module& module ) const;\r
+ std::string GetInvocationParameters ( const Invoke& invoke ) const;\r
void GenerateInvocations ( const Module& module ) const;\r
+ void GeneratePreconditionDependencies ( const Module& module ) const;\r
FILE* fMakefile;\r
private:\r
std::string ConcatenatePaths ( const std::string& path1,\r
const std::string& cc ) const;\r
void GenerateArchiveTarget ( const Module& module,\r
const std::string& ar ) const;\r
+ std::string GetPreconditionDependenciesName ( const Module& module ) const;\r
};\r
\r
\r
if ( !module.project.LocateModule ( name ) )\r
throw InvalidBuildFileException (\r
node.location,\r
- "module '%s' trying to link against non-existant module '%s'",\r
+ "module '%s' is trying to link against non-existant module '%s'",\r
module.name.c_str(),\r
name.c_str() );\r
}\r
\r
Invoke::Invoke ( const XMLElement& _node,\r
const Module& _module )\r
- : node(_node),\r
- module(_module)\r
+ : node (_node),\r
+ module (_module)\r
{\r
}\r
\r
void\r
Invoke::ProcessXML()\r
{\r
+ const XMLAttribute* att = node.GetAttribute ( "module", false );\r
+ if (att == NULL)\r
+ invokeModule = &module;\r
+ else\r
+ {\r
+ invokeModule = module.project.LocateModule ( att->value );\r
+ if ( invokeModule == NULL )\r
+ throw InvalidBuildFileException (\r
+ node.location,\r
+ "module '%s' is trying to invoke non-existant module '%s'",\r
+ module.name.c_str(),\r
+ att->value.c_str() );\r
+ }\r
+ \r
for ( size_t i = 0; i < node.subElements.size (); i++ )\r
ProcessXMLSubElement ( *node.subElements[i] );\r
}\r
Invoke::ProcessXMLSubElement ( const XMLElement& e )\r
{\r
bool subs_invalid = false;\r
- if ( e.name == "output" )\r
+ if ( e.name == "input" )\r
+ {\r
+ for ( size_t i = 0; i < e.subElements.size (); i++ )\r
+ ProcessXMLSubElementInput ( *e.subElements[i] );\r
+ }\r
+ else if ( e.name == "output" )\r
{\r
for ( size_t i = 0; i < e.subElements.size (); i++ )\r
ProcessXMLSubElementOutput ( *e.subElements[i] );\r
e.name.c_str() );\r
}\r
\r
+void\r
+Invoke::ProcessXMLSubElementInput ( const XMLElement& e )\r
+{\r
+ bool subs_invalid = false;\r
+ if ( e.name == "inputfile" && e.value.size () > 0 )\r
+ {\r
+ input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) );\r
+ subs_invalid = true;\r
+ }\r
+ if ( subs_invalid && e.subElements.size() > 0 )\r
+ throw InvalidBuildFileException ( e.location,\r
+ "<%s> cannot have sub-elements",\r
+ e.name.c_str() );\r
+}\r
+\r
void\r
Invoke::ProcessXMLSubElementOutput ( const XMLElement& e )\r
{\r
bool subs_invalid = false;\r
if ( e.name == "outputfile" && e.value.size () > 0 )\r
{\r
- output.push_back ( new File ( FixSeparator ( module.path + CSEP + e.value ) ) );\r
+ output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) );\r
subs_invalid = true;\r
}\r
if ( subs_invalid && e.subElements.size() > 0 )\r
string targets ( "" );\r
for ( size_t i = 0; i < output.size (); i++ )\r
{\r
- File& file = *output[i];\r
+ InvokeFile& file = *output[i];\r
if ( targets.length () > 0 )\r
targets += " ";\r
targets += file.name;\r
}\r
\r
\r
+InvokeFile::InvokeFile ( const XMLElement& _node,\r
+ const string& _name )\r
+ : node (_node),\r
+ name (_name)\r
+{\r
+ const XMLAttribute* att = _node.GetAttribute ( "switches", false );\r
+ if (att != NULL)\r
+ switches = att->value;\r
+ else\r
+ switches = "";\r
+}\r
+\r
+void\r
+InvokeFile::ProcessXML()\r
+{\r
+}\r
+\r
+\r
Dependency::Dependency ( const XMLElement& _node,\r
const Module& _module )\r
: node (_node),\r
class File;\r
class Library;\r
class Invoke;\r
+class InvokeFile;\r
class Dependency;\r
\r
class Project\r
public:\r
const XMLElement& node;\r
const Module& module;\r
- std::vector<File*> output;\r
+ const Module* invokeModule;\r
+ std::vector<InvokeFile*> input;\r
+ std::vector<InvokeFile*> output;\r
\r
Invoke ( const XMLElement& _node,\r
const Module& _module );\r
std::string GetTargets () const;\r
private:\r
void ProcessXMLSubElement ( const XMLElement& e );\r
+ void ProcessXMLSubElementInput ( const XMLElement& e );\r
void ProcessXMLSubElementOutput ( const XMLElement& e );\r
};\r
\r
\r
+class InvokeFile\r
+{\r
+public:\r
+ const XMLElement& node;\r
+ std::string name;\r
+ std::string switches;\r
+\r
+ InvokeFile ( const XMLElement& _node,\r
+ const std::string& _name );\r
+\r
+ void ProcessXML ();\r
+};\r
+\r
+\r
class Dependency\r
{\r
public:\r
</output>\r
</invoke>\r
</module>\r
+<directory name="wmc">\r
+ <xi:include href="wmc/wmc.xml" />\r
+</directory>\r
--- /dev/null
+<module name="wmc" type="buildtool">\r
+ <include base="wmc">.</include>\r
+ <file>getopt.c</file>\r
+ <file>lang.c</file>\r
+ <file>mcl.c</file>\r
+ <file>misc.c</file>\r
+ <file>utils.c</file>\r
+ <file>wmc.c</file>\r
+ <file>write.c</file>\r
+ <file>y_tab.c</file>\r
+</module>\r