From f7257ee1be06ec0037ef9f7bd448de963c81a34b Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Thu, 6 Jan 2005 22:22:13 +0000 Subject: [PATCH] * Generate kernel * Add static library module type * Add build script for kjs svn path=/branches/xmlbuildsystem/; revision=12856 --- reactos/ReactOS.xml | 3 ++ reactos/lib/directory.xml | 3 ++ reactos/lib/kjs/module.xml | 42 +++++++++++++++ reactos/tools/rbuild/backend/mingw/mingw.cpp | 2 + .../rbuild/backend/mingw/modulehandler.cpp | 52 ++++++++++++++++--- .../rbuild/backend/mingw/modulehandler.h | 3 +- reactos/tools/rbuild/module.cpp | 8 ++- reactos/tools/rbuild/project.cpp | 14 ++++- reactos/tools/rbuild/rbuild.h | 6 ++- 9 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 reactos/lib/directory.xml create mode 100644 reactos/lib/kjs/module.xml diff --git a/reactos/ReactOS.xml b/reactos/ReactOS.xml index cfa5837ebb7..c5bde83b19a 100644 --- a/reactos/ReactOS.xml +++ b/reactos/ReactOS.xml @@ -4,6 +4,9 @@ depends.c + + + diff --git a/reactos/lib/directory.xml b/reactos/lib/directory.xml new file mode 100644 index 00000000000..8b1c86e60b1 --- /dev/null +++ b/reactos/lib/directory.xml @@ -0,0 +1,3 @@ + + + diff --git a/reactos/lib/kjs/module.xml b/reactos/lib/kjs/module.xml new file mode 100644 index 00000000000..d60ef2384b9 --- /dev/null +++ b/reactos/lib/kjs/module.xml @@ -0,0 +1,42 @@ + + . + ./src + ./include + + setjmp.S + longjmp.S + alloc.c + bc.c + b_core.c + b_file.c + b_func.c + b_regexp.c + b_system.c + compat.c + debug.c + iostream.c + js.c + kjs.c + mrgsort.c + object.c + regex.c + vm.c + vmjumps.c + vmswitch.c + vmswt0.c + longjmp.c + + + b_array.c + b_bool.c + b_object.c + b_number.c + b_string.c + b_vm.c + compiler.c + crc32.c + dl_dummy.c + heap.c + utils.c + + diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 3d2ea8ac005..5f529afc03f 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -61,9 +61,11 @@ MingwBackend::GenerateHeader () void MingwBackend::GenerateGlobalVariables () { + fprintf ( fMakefile, "rm = del /y\n" ); fprintf ( fMakefile, "gcc = gcc\n" ); fprintf ( fMakefile, "ld = ld\n" ); fprintf ( fMakefile, "ar = ar\n" ); + fprintf ( fMakefile, "dlltool = dlltool\n" ); fprintf ( fMakefile, "\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 60cc98caac6..e1f6214e7c0 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -12,6 +12,12 @@ MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile ) { } +string +MingwModuleHandler::GetWorkingDirectory () +{ + return "."; +} + string MingwModuleHandler::ReplaceExtension ( string filename, string newExtension ) @@ -30,7 +36,7 @@ MingwModuleHandler::GetModuleArchiveFilename ( Module& module ) } string -MingwModuleHandler::GetModuleLibraryDependencies ( Module& module ) +MingwModuleHandler::GetImportLibraryDependencies ( Module& module ) { if ( module.libraries.size () == 0 ) return ""; @@ -40,7 +46,9 @@ MingwModuleHandler::GetModuleLibraryDependencies ( Module& module ) { if ( dependencies.size () > 0 ) dependencies += " "; - dependencies += module.libraries[i]->name; + Module* importedModule = module.project->LocateModule ( module.libraries[i]->name ); + assert ( importedModule != NULL ); + dependencies += importedModule->GetPath ().c_str (); } return dependencies; } @@ -96,8 +104,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( Module& module ) string objectFilename = GetObjectFilename ( sourceFilename ); fprintf ( fMakefile, "%s: %s\n", - sourceFilename.c_str (), - objectFilename.c_str() ); + objectFilename.c_str (), + sourceFilename.c_str() ); fprintf ( fMakefile, "\t${gcc} -c %s -o %s\n", sourceFilename.c_str (), @@ -146,10 +154,40 @@ MingwKernelModuleHandler::Process ( Module& module ) void MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module ) { - fprintf ( fMakefile, "%s: %s\n", + string workingDirectory = GetWorkingDirectory ( ); + string archiveFilename = GetModuleArchiveFilename ( module ); + string importLibraryDependencies = GetImportLibraryDependencies ( module ); + fprintf ( fMakefile, "%s: %s %s\n", module.GetPath ().c_str (), - GetModuleLibraryDependencies ( module ).c_str () ); - fprintf ( fMakefile, "\t\n\n" ); + archiveFilename.c_str (), + importLibraryDependencies.c_str () ); + fprintf ( fMakefile, + "\t${gcc} -Wl,--base-file,%s/base.tmp -o %s/junk.tmp %s %s\n", + workingDirectory.c_str (), + workingDirectory.c_str (), + archiveFilename.c_str (), + importLibraryDependencies.c_str () ); + fprintf ( fMakefile, + "\t${rm} %s/junk.tmp\n", + workingDirectory.c_str () ); + fprintf ( fMakefile, + "\t${dlltool} --dllname %s --base-file %s/base.tmp --output-exp %s/temp.exp --kill-at\n", + module.GetPath ().c_str (), + workingDirectory.c_str (), + workingDirectory.c_str ()); + fprintf ( fMakefile, + "\t${rm} %s/base.tmp\n", + workingDirectory.c_str () ); + fprintf ( fMakefile, + "\t${ld} -Wl,%s/temp.exp -o %s %s %s\n", + workingDirectory.c_str (), + module.GetPath ().c_str (), + archiveFilename.c_str (), + importLibraryDependencies.c_str () ); + fprintf ( fMakefile, + "\t${rm} %s/temp.exp\n", + workingDirectory.c_str () ); + GenerateArchiveTarget ( module ); GenerateObjectFileTargets ( module ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index add4864fc3b..7763d7d11dd 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -10,10 +10,11 @@ public: virtual bool CanHandleModule ( Module& module ) = 0; virtual void Process ( Module& module ) = 0; protected: + std::string MingwModuleHandler::GetWorkingDirectory (); std::string ReplaceExtension ( std::string filename, std::string newExtension ); std::string GetModuleArchiveFilename ( Module& module ); - std::string GetModuleLibraryDependencies ( Module& module ); + std::string GetImportLibraryDependencies ( Module& module ); std::string GetSourceFilenames ( Module& module ); std::string GetObjectFilename ( std::string sourceFilename ); std::string GetObjectFilenames ( Module& module ); diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 1a3271a1ee9..cb20525d561 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -40,10 +40,12 @@ FixSeparator ( const string& s ) } #endif -Module::Module ( const XMLElement& moduleNode, +Module::Module ( Project* project, + const XMLElement& moduleNode, const string& moduleName, const string& modulePath ) - : node(moduleNode), + : project(project), + node(moduleNode), name(moduleName), path(modulePath) { @@ -87,6 +89,8 @@ Module::GetModuleType ( const XMLAttribute& attribute ) { if ( attribute.value == "buildtool" ) return BuildTool; + if ( attribute.value == "staticlibrary" ) + return StaticLibrary; if ( attribute.value == "kernelmodedll" ) return KernelModeDLL; throw InvalidAttributeValueException ( attribute.name, diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index c561ef30967..9381cf02e1f 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -64,7 +64,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path ) { att = e.GetAttribute ( "name", true ); assert(att); - Module* module = new Module ( e, att->value, path ); + Module* module = new Module ( this, e, att->value, path ); modules.push_back ( module ); module->ProcessXML ( e, path ); return; @@ -78,3 +78,15 @@ Project::ProcessXML ( const XMLElement& e, const string& path ) for ( size_t i = 0; i < e.subElements.size (); i++ ) ProcessXML ( *e.subElements[i], subpath ); } + +Module* +Project::LocateModule ( string name ) +{ + for ( size_t i = 0; i < modules.size (); i++ ) + { + if (modules[i]->name == name) + return modules[i]; + } + + return NULL; +} diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 913ec5d0232..88572eeeaed 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -24,6 +24,7 @@ public: ~Project (); void ProcessXML ( const XMLElement& e, const std::string& path ); + Module* LocateModule ( std::string name ); private: void ReadXml (); XMLFile xmlfile; @@ -34,12 +35,14 @@ private: enum ModuleType { BuildTool, + StaticLibrary, KernelModeDLL }; class Module { public: + Project* project; const XMLElement& node; std::string name; std::string path; @@ -47,7 +50,8 @@ public: std::vector files; std::vector libraries; - Module ( const XMLElement& moduleNode, + Module ( Project* project, + const XMLElement& moduleNode, const std::string& moduleName, const std::string& modulePath ); ~Module();