diff --git a/reactos/ReactOS.xml b/reactos/ReactOS.xml index 78b80dc06e7..63f491c335c 100644 --- a/reactos/ReactOS.xml +++ b/reactos/ReactOS.xml @@ -16,6 +16,6 @@ - + diff --git a/reactos/ntoskrnl/module.xml b/reactos/ntoskrnl/ntoskrnl.xml similarity index 92% rename from reactos/ntoskrnl/module.xml rename to reactos/ntoskrnl/ntoskrnl.xml index 68242082592..8a8fa4a895c 100644 --- a/reactos/ntoskrnl/module.xml +++ b/reactos/ntoskrnl/ntoskrnl.xml @@ -1,5 +1,6 @@ buildno + wmc @@ -7,6 +8,15 @@ ./include include kjs + + + ntoskrnl.mc + + + ../include/reactos/bugcodes.h + bugcodes.rc + + cacheman.c copy.c diff --git a/reactos/tools/buildno.c b/reactos/tools/buildno.c index ae2d1d0f7f8..72cad44a96a 100644 --- a/reactos/tools/buildno.c +++ b/reactos/tools/buildno.c @@ -32,10 +32,8 @@ #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 @@ -157,7 +155,7 @@ write_h (int build) 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); @@ -178,13 +176,13 @@ write_h (int build) 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); @@ -196,7 +194,7 @@ usage (void) { 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); @@ -221,6 +219,7 @@ main (int argc, char * argv []) case 1: break; case 2: + case 3: if (argv[1][0] == '-') { if (argv[1][1] == 'q') @@ -235,6 +234,11 @@ main (int argc, char * argv []) { usage (); } + filename = argv[2]; + } + else if (argc == 2) + { + filename = argv[1]; } else { diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 21becd2e016..4a91a8160a0 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -106,7 +106,7 @@ string MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const { return FixupTargetFilename ( ReplaceExtension ( sourceFilename, - ".o" ) ); + ".o" ) ); } string @@ -221,12 +221,10 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, { string sourceFilename = module.files[i]->name; string objectFilename = GetObjectFilename ( sourceFilename ); - string dependencies = GetModuleDependencies ( module ); fprintf ( fMakefile, - "%s: %s %s\n", + "%s: %s\n", objectFilename.c_str (), - sourceFilename.c_str (), - dependencies.c_str ()); + sourceFilename.c_str () ); fprintf ( fMakefile, "\t%s -c %s -o %s %s\n", cc.c_str (), @@ -293,27 +291,64 @@ MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const for ( size_t i = 0; i < module.invocations.size (); i++ ) { Invoke& invoke = *module.invocations[i]; + if (invoke.invokeModule == &module) + /* Protect against circular dependencies */ + continue; if ( dependencies.length () > 0 ) dependencies += " "; - string invokeTarget = module.GetInvocationTarget ( i ); - dependencies += invokeTarget; + dependencies += invoke.GetTargets (); } return dependencies; } - + +string +MingwModuleHandler::GetInvocationParameters ( const Invoke& invoke ) const +{ + string parameters ( "" ); + size_t i; + for (i = 0; i < invoke.output.size (); i++) + { + if (parameters.length () > 0) + parameters += " "; + InvokeFile& invokeFile = *invoke.output[i]; + if (invokeFile.switches.length () > 0) + { + parameters += invokeFile.switches; + parameters += " "; + } + parameters += invokeFile.name; + } + + for (i = 0; i < invoke.input.size (); i++) + { + if (parameters.length () > 0) + parameters += " "; + InvokeFile& invokeFile = *invoke.input[i]; + if (invokeFile.switches.length () > 0) + { + parameters += invokeFile.switches; + parameters += " "; + } + parameters += invokeFile.name; + } + + return parameters; +} + void MingwModuleHandler::GenerateInvocations ( const Module& module ) const { if ( module.invocations.size () == 0 ) return; - if ( module.type != BuildTool ) - throw InvalidBuildFileException ( module.node.location, - "Only modules of type buildtool can be invoked." ); - for ( size_t i = 0; i < module.invocations.size (); i++ ) { - Invoke& invoke = *module.invocations[i]; + const Invoke& invoke = *module.invocations[i]; + + if ( invoke.invokeModule->type != BuildTool ) + throw InvalidBuildFileException ( module.node.location, + "Only modules of type buildtool can be invoked." ); + string invokeTarget = module.GetInvocationTarget ( i ); fprintf ( fMakefile, "%s: %s\n\n", @@ -322,16 +357,51 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const fprintf ( fMakefile, "%s: %s\n", invokeTarget.c_str (), - FixupTargetFilename ( module.GetPath () ).c_str () ); + FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () ); fprintf ( fMakefile, - "\t%s\n\n", - FixupTargetFilename ( module.GetPath () ).c_str () ); + "\t%s %s\n\n", + FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (), + GetInvocationParameters ( invoke ).c_str () ); fprintf ( fMakefile, ".PNONY: %s\n\n", invokeTarget.c_str () ); } } +string +MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) const +{ + return ssprintf ( "%s_precondition", + module.name.c_str () ); +} + +void +MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const +{ + string preconditionDependenciesName = GetPreconditionDependenciesName ( module ); + string sourceFilenames = GetSourceFilenames ( module ); + string dependencies = GetModuleDependencies ( module ); + string s = GetInvocationDependencies ( module ); + if ( s.length () > 0 ) + { + if ( dependencies.length () > 0 ) + dependencies += " "; + dependencies += s; + } + + fprintf ( fMakefile, + "%s: %s\n\n", + preconditionDependenciesName.c_str (), + dependencies.c_str () ); + fprintf ( fMakefile, + "%s: %s\n\n", + sourceFilenames.c_str (), + preconditionDependenciesName.c_str ()); + fprintf ( fMakefile, + ".PNONY: %s\n\n", + preconditionDependenciesName.c_str () ); +} + MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( FILE* fMakefile ) : MingwModuleHandler ( fMakefile ) @@ -347,6 +417,7 @@ MingwBuildToolModuleHandler::CanHandleModule ( const Module& module ) const void MingwBuildToolModuleHandler::Process ( const Module& module ) { + GeneratePreconditionDependencies ( module ); GenerateBuildToolModuleTarget ( module ); GenerateInvocations ( module ); } @@ -382,6 +453,7 @@ MingwKernelModuleHandler::CanHandleModule ( const Module& module ) const void MingwKernelModuleHandler::Process ( const Module& module ) { + GeneratePreconditionDependencies ( module ); GenerateKernelModuleTarget ( module ); GenerateInvocations ( module ); } @@ -448,6 +520,7 @@ MingwStaticLibraryModuleHandler::CanHandleModule ( const Module& module ) const void MingwStaticLibraryModuleHandler::Process ( const Module& module ) { + GeneratePreconditionDependencies ( module ); GenerateStaticLibraryModuleTarget ( module ); GenerateInvocations ( module ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 5776b9e5a17..2f3266c5b1e 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -26,7 +26,9 @@ protected: void GenerateArchiveTargetHost ( const Module& module ) const; void GenerateArchiveTargetTarget ( const Module& module ) const; std::string GetInvocationDependencies ( const Module& module ) const; + std::string GetInvocationParameters ( const Invoke& invoke ) const; void GenerateInvocations ( const Module& module ) const; + void GeneratePreconditionDependencies ( const Module& module ) const; FILE* fMakefile; private: std::string ConcatenatePaths ( const std::string& path1, @@ -40,6 +42,7 @@ private: const std::string& cc ) const; void GenerateArchiveTarget ( const Module& module, const std::string& ar ) const; + std::string GetPreconditionDependenciesName ( const Module& module ) const; }; diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 68b7c9d8f05..85a5dc27c98 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -235,7 +235,7 @@ Library::ProcessXML() if ( !module.project.LocateModule ( name ) ) throw InvalidBuildFileException ( node.location, - "module '%s' trying to link against non-existant module '%s'", + "module '%s' is trying to link against non-existant module '%s'", module.name.c_str(), name.c_str() ); } @@ -243,14 +243,28 @@ Library::ProcessXML() Invoke::Invoke ( const XMLElement& _node, const Module& _module ) - : node(_node), - module(_module) + : node (_node), + module (_module) { } void Invoke::ProcessXML() { + const XMLAttribute* att = node.GetAttribute ( "module", false ); + if (att == NULL) + invokeModule = &module; + else + { + invokeModule = module.project.LocateModule ( att->value ); + if ( invokeModule == NULL ) + throw InvalidBuildFileException ( + node.location, + "module '%s' is trying to invoke non-existant module '%s'", + module.name.c_str(), + att->value.c_str() ); + } + for ( size_t i = 0; i < node.subElements.size (); i++ ) ProcessXMLSubElement ( *node.subElements[i] ); } @@ -259,7 +273,12 @@ void Invoke::ProcessXMLSubElement ( const XMLElement& e ) { bool subs_invalid = false; - if ( e.name == "output" ) + if ( e.name == "input" ) + { + for ( size_t i = 0; i < e.subElements.size (); i++ ) + ProcessXMLSubElementInput ( *e.subElements[i] ); + } + else if ( e.name == "output" ) { for ( size_t i = 0; i < e.subElements.size (); i++ ) ProcessXMLSubElementOutput ( *e.subElements[i] ); @@ -270,13 +289,28 @@ Invoke::ProcessXMLSubElement ( const XMLElement& e ) e.name.c_str() ); } +void +Invoke::ProcessXMLSubElementInput ( const XMLElement& e ) +{ + bool subs_invalid = false; + if ( e.name == "inputfile" && e.value.size () > 0 ) + { + input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) ); + subs_invalid = true; + } + if ( subs_invalid && e.subElements.size() > 0 ) + throw InvalidBuildFileException ( e.location, + "<%s> cannot have sub-elements", + e.name.c_str() ); +} + void Invoke::ProcessXMLSubElementOutput ( const XMLElement& e ) { bool subs_invalid = false; if ( e.name == "outputfile" && e.value.size () > 0 ) { - output.push_back ( new File ( FixSeparator ( module.path + CSEP + e.value ) ) ); + output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) ); subs_invalid = true; } if ( subs_invalid && e.subElements.size() > 0 ) @@ -291,7 +325,7 @@ Invoke::GetTargets () const string targets ( "" ); for ( size_t i = 0; i < output.size (); i++ ) { - File& file = *output[i]; + InvokeFile& file = *output[i]; if ( targets.length () > 0 ) targets += " "; targets += file.name; @@ -300,6 +334,24 @@ Invoke::GetTargets () const } +InvokeFile::InvokeFile ( const XMLElement& _node, + const string& _name ) + : node (_node), + name (_name) +{ + const XMLAttribute* att = _node.GetAttribute ( "switches", false ); + if (att != NULL) + switches = att->value; + else + switches = ""; +} + +void +InvokeFile::ProcessXML() +{ +} + + Dependency::Dependency ( const XMLElement& _node, const Module& _module ) : node (_node), diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 087c30f28b0..dd78dfe8a34 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -28,6 +28,7 @@ class Define; class File; class Library; class Invoke; +class InvokeFile; class Dependency; class Project @@ -168,7 +169,9 @@ class Invoke public: const XMLElement& node; const Module& module; - std::vector output; + const Module* invokeModule; + std::vector input; + std::vector output; Invoke ( const XMLElement& _node, const Module& _module ); @@ -177,10 +180,25 @@ public: std::string GetTargets () const; private: void ProcessXMLSubElement ( const XMLElement& e ); + void ProcessXMLSubElementInput ( const XMLElement& e ); void ProcessXMLSubElementOutput ( const XMLElement& e ); }; +class InvokeFile +{ +public: + const XMLElement& node; + std::string name; + std::string switches; + + InvokeFile ( const XMLElement& _node, + const std::string& _name ); + + void ProcessXML (); +}; + + class Dependency { public: diff --git a/reactos/tools/tools.xml b/reactos/tools/tools.xml index 9195b30c199..dc4f09c58ca 100644 --- a/reactos/tools/tools.xml +++ b/reactos/tools/tools.xml @@ -7,3 +7,6 @@ + + + diff --git a/reactos/tools/wmc/wmc.xml b/reactos/tools/wmc/wmc.xml new file mode 100644 index 00000000000..9a5f92ee164 --- /dev/null +++ b/reactos/tools/wmc/wmc.xml @@ -0,0 +1,11 @@ + + . + getopt.c + lang.c + mcl.c + misc.c + utils.c + wmc.c + write.c + y_tab.c +