From b1fa799b0b5e2d77005372e9a03dc908a6a38521 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Sun, 4 Dec 2005 12:02:45 +0000 Subject: [PATCH] Added support for ROS_AUTOMAKE variable. Added support for Added BootProgram target type Added simple initial ReactOS-ppc.xml, using my egcs compiler More work required, but getting there svn path=/trunk/; revision=19854 --- reactos/ReactOS-ppc.xml | 91 +++++++++++++++++++ reactos/tools/rbuild/backend/mingw/mingw.cpp | 8 +- reactos/tools/rbuild/backend/mingw/mingw.h | 2 +- .../rbuild/backend/mingw/modulehandler.cpp | 66 ++++++++++++++ .../rbuild/backend/mingw/modulehandler.h | 13 +++ reactos/tools/rbuild/bootstrap.cpp | 1 + reactos/tools/rbuild/define.cpp | 2 + reactos/tools/rbuild/module.cpp | 25 +++++ reactos/tools/rbuild/project.cpp | 42 +++++++-- reactos/tools/rbuild/rbuild.h | 8 +- reactos/tools/rbuild/rbuild.mak | 1 + 11 files changed, 245 insertions(+), 14 deletions(-) create mode 100644 reactos/ReactOS-ppc.xml diff --git a/reactos/ReactOS-ppc.xml b/reactos/ReactOS-ppc.xml new file mode 100644 index 00000000000..a0fc78c299a --- /dev/null +++ b/reactos/ReactOS-ppc.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + -v + + + + + + + + + -Os + -Wno-strict-aliasing + + + + + + -Wpointer-arith + + . + include + include/reactos + include/libs + include/drivers + include/subsys + include/ndk + w32api/include + w32api/include/crt + w32api/include/ddk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 7b4ceb3f75c..9269ecde656 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -71,6 +71,7 @@ public: MingwBackend::MingwBackend ( Project& project, Configuration& configuration ) : Backend ( project, configuration ), + manualBinutilsSetting( false ), intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ), outputDirectory ( new Directory ( "$(OUTPUT)" ) ), installDirectory ( new Directory ( "$(INSTALL)" ) ) @@ -137,6 +138,7 @@ MingwBackend::ProcessModules () vector v; size_t i; + for ( i = 0; i < ProjectNode.modules.size (); i++ ) { Module& module = *ProjectNode.modules[i]; @@ -752,6 +754,7 @@ MingwBackend::GetBinutilsVersion ( const string& binutilsCommand ) bool MingwBackend::IsSupportedBinutilsVersion ( const string& binutilsVersion ) { + if ( manualBinutilsSetting ) return true; if ( ( ( strcmp ( binutilsVersion.c_str (), "20040902") >= 0 ) && ( strcmp ( binutilsVersion.c_str (), "20041008") <= 0 ) ) || ( strcmp ( binutilsVersion.c_str (), "20031001") < 0 ) ) @@ -767,11 +770,13 @@ MingwBackend::DetectBinutils () bool detectedBinutils = false; const string& ROS_PREFIXValue = Environment::GetVariable ( "ROS_PREFIX" ); + if ( ROS_PREFIXValue.length () > 0 ) { binutilsPrefix = ROS_PREFIXValue; binutilsCommand = binutilsPrefix + "-ld"; - detectedBinutils = TryToDetectThisBinutils ( binutilsCommand ); + manualBinutilsSetting = true; + detectedBinutils = true; } #if defined(WIN32) if ( !detectedBinutils ) @@ -802,6 +807,7 @@ MingwBackend::DetectBinutils () } else printf ( "not detected\n" ); + } void diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 4c392d289e0..1677d1c1818 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -48,7 +48,7 @@ public: std::string nasmCommand; std::string binutilsPrefix; std::string binutilsCommand; - bool usePipe; + bool usePipe, manualBinutilsSetting; Directory* intermediateDirectory; Directory* outputDirectory; Directory* installDirectory; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 569db3a6f0e..c4fe4aeeb32 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -230,6 +230,9 @@ MingwModuleHandler::InstanciateHandler ( case BootSector: handler = new MingwBootSectorModuleHandler ( module ); break; + case BootProgram: + handler = new MingwBootProgramModuleHandler ( module ); + break; case Iso: handler = new MingwIsoModuleHandler ( module ); break; @@ -2704,6 +2707,69 @@ MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget () } +MingwBootProgramModuleHandler::MingwBootProgramModuleHandler ( + const Module& module_ ) + : MingwModuleHandler ( module_ ) +{ +} + +void +MingwBootProgramModuleHandler::Process () +{ + GenerateBootProgramModuleTarget (); +} + +void +MingwBootProgramModuleHandler::GenerateBootProgramModuleTarget () +{ + string targetName ( module.GetTargetName () ); + string targetMacro ( GetTargetMacro (module) ); + string workingDirectory = GetWorkingDirectory (); + string junk_tmp = ros_temp + module.name + ".junk.tmp"; + string junk_elf = ros_temp + module.name + ".junk.elf"; + string junk_cpy = ros_temp + module.name + ".junk.cpy"; + CLEAN_FILE ( junk_tmp ); + CLEAN_FILE ( junk_elf ); + CLEAN_FILE ( junk_cpy ); + string objectsMacro = GetObjectsMacro ( module ); + string linkDepsMacro = GetLinkingDependenciesMacro (); + string libsMacro = GetLibsMacro (); + const Module *payload = module.project.LocateModule ( module.payload ); + + GenerateRules (); + + fprintf ( fMakefile, "%s: %s %s %s | %s\n", + targetMacro.c_str (), + objectsMacro.c_str (), + linkDepsMacro.c_str (), + payload->name.c_str (), + GetDirectory(GetTargetFilename(module,NULL)).c_str () ); + + fprintf ( fMakefile, "\t$(ECHO_BOOTPROG)\n" ); + + fprintf ( fMakefile, "\t$(BOOTPROG_PREPARE) $(OUTPUT)$(SEP)%s %s\n", + NormalizeFilename( payload->GetPath() ).c_str (), + junk_cpy.c_str () ); + + fprintf ( fMakefile, "\t${objcopy} $(BOOTPROG_FLATFORMAT) %s %s\n", + junk_cpy.c_str (), + junk_tmp.c_str () ); + + fprintf ( fMakefile, "\t${ld} $(BOOTPROG_LINKFORMAT) %s %s -g -o %s\n", + linkDepsMacro.c_str (), + junk_tmp.c_str (), + junk_elf.c_str () ); + + fprintf ( fMakefile, "\t${objcopy} $(BOOTPROG_COPYFORMAT) %s %s\n", + junk_elf.c_str (), + module.GetPath().c_str () ); + + fprintf ( fMakefile, + "\t-@${rm} %s %s %s 2>$(NUL)\n", + junk_tmp.c_str (), junk_elf.c_str (), junk_cpy.c_str () ); +} + + MingwIsoModuleHandler::MingwIsoModuleHandler ( const Module& module_ ) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index e911799f906..238ab1626cf 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -375,6 +375,19 @@ private: }; +class MingwBootProgramModuleHandler : public MingwModuleHandler +{ +public: + MingwBootProgramModuleHandler ( const Module& module ); + virtual HostType DefaultHost() { return HostFalse; } + virtual void Process (); + std::string GetProgTextAddrMacro (); + std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } +private: + void GenerateBootProgramModuleTarget (); +}; + + class MingwIsoModuleHandler : public MingwModuleHandler { public: diff --git a/reactos/tools/rbuild/bootstrap.cpp b/reactos/tools/rbuild/bootstrap.cpp index a953c458ff1..c9fa439a73a 100644 --- a/reactos/tools/rbuild/bootstrap.cpp +++ b/reactos/tools/rbuild/bootstrap.cpp @@ -51,6 +51,7 @@ Bootstrap::IsSupportedModuleType ( ModuleType type ) case KernelModeDriver: case BootSector: case BootLoader: + case BootProgram: return true; case BuildTool: case StaticLibrary: diff --git a/reactos/tools/rbuild/define.cpp b/reactos/tools/rbuild/define.cpp index fcd7f51512f..b2fc6b93c78 100644 --- a/reactos/tools/rbuild/define.cpp +++ b/reactos/tools/rbuild/define.cpp @@ -50,9 +50,11 @@ void Define::Initialize() { const XMLAttribute* att = node.GetAttribute ( "name", true ); + const XMLAttribute* empty = node.GetAttribute ( "empty", false ); assert(att); name = att->value; value = node.value; + if( empty ) value = " "; } void diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 716c880cdc9..a44be3b9887 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -195,6 +195,13 @@ ToLower ( string filename ) return filename; } +void IfableData::ExtractModules( std::vector &modules ) +{ + size_t i; + for ( i = 0; i < this->modules.size (); i++ ) + modules.push_back(this->modules[i]); +} + IfableData::~IfableData() { size_t i; @@ -208,6 +215,8 @@ IfableData::~IfableData() delete properties[i]; for ( i = 0; i < compilerFlags.size (); i++ ) delete compilerFlags[i]; + for ( i = 0; i < modules.size(); i++ ) + delete modules[i]; for ( i = 0; i < ifs.size (); i++ ) delete ifs[i]; for ( i = 0; i < compilationUnits.size (); i++ ) @@ -388,6 +397,12 @@ Module::Module ( const Project& project, aliasedModuleName = att->value; else aliasedModuleName = ""; + + if ( type == BootProgram ) + { + att = moduleNode.GetAttribute ( "payload", true ); + payload = att->value; + } } Module::~Module () @@ -732,6 +747,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) return BootLoader; if ( attribute.value == "bootsector" ) return BootSector; + if ( attribute.value == "bootprogram" ) + return BootProgram; if ( attribute.value == "iso" ) return Iso; if ( attribute.value == "liveiso" ) @@ -785,6 +802,8 @@ Module::GetDefaultModuleExtension () const return ".o"; case Alias: return ""; + case BootProgram: + return ""; } throw InvalidOperationException ( __FILE__, __LINE__ ); @@ -828,6 +847,7 @@ Module::GetDefaultModuleEntrypoint () const case RpcServer: case RpcClient: case Alias: + case BootProgram: return ""; } throw InvalidOperationException ( __FILE__, @@ -863,6 +883,7 @@ Module::GetDefaultModuleBaseaddress () const case RpcServer: case RpcClient: case Alias: + case BootProgram: return ""; } throw InvalidOperationException ( __FILE__, @@ -895,6 +916,7 @@ Module::IsDLL () const case ObjectLibrary: case BootLoader: case BootSector: + case BootProgram: case Iso: case LiveIso: case RpcServer: @@ -923,6 +945,7 @@ Module::GenerateInOutputTree () const case BuildTool: case BootLoader: case BootSector: + case BootProgram: case Iso: case LiveIso: return true; @@ -1289,6 +1312,7 @@ If::~If () void If::ProcessXML() { + } @@ -1358,6 +1382,7 @@ AutoRegister::IsSupportedModuleType ( ModuleType type ) case KernelModeDriver: case BootSector: case BootLoader: + case BootProgram: case BuildTool: case StaticLibrary: case ObjectLibrary: diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index be314f8431c..9617d3670d4 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -97,8 +97,10 @@ Project::~Project () size_t i; if ( _backend ) delete _backend; +#ifdef NOT_NEEDED_SINCE_THESE_ARE_CLEANED_BY_IFABLE_DATA for ( i = 0; i < modules.size (); i++ ) delete modules[i]; +#endif for ( i = 0; i < linkerFlags.size (); i++ ) delete linkerFlags[i]; for ( i = 0; i < cdfiles.size (); i++ ) @@ -225,6 +227,7 @@ Project::WriteConfigurationFile () void Project::ExecuteInvocations () { + fprintf( stderr, "ExecuteInvocations\n" ); for ( size_t i = 0; i < modules.size (); i++ ) modules[i]->InvokeModule (); } @@ -277,11 +280,29 @@ Project::ProcessXML ( const string& path ) ParseContext parseContext; ProcessXMLSubElement ( *node->subElements[i], path, parseContext ); } - for ( i = 0; i < modules.size (); i++ ) - modules[i]->ProcessXML (); + + non_if_data.ProcessXML (); + + non_if_data.ExtractModules( modules ); + + for ( i = 0; i < non_if_data.ifs.size (); i++ ) + { + const Property *property = + LookupProperty( non_if_data.ifs[i]->property ); + + if( !property ) continue; + + bool conditionTrue = + (non_if_data.ifs[i]->negated && + (property->value != non_if_data.ifs[i]->value)) || + (property->value == non_if_data.ifs[i]->value); + if ( conditionTrue ) + non_if_data.ifs[i]->data.ExtractModules( modules ); + } for ( i = 0; i < linkerFlags.size (); i++ ) linkerFlags[i]->ProcessXML (); - non_if_data.ProcessXML (); + for ( i = 0; i < modules.size (); i++ ) + modules[i]->ProcessXML (); for ( i = 0; i < cdfiles.size (); i++ ) cdfiles[i]->ProcessXML (); for ( i = 0; i < installfiles.size (); i++ ) @@ -294,13 +315,11 @@ Project::ProcessXMLSubElement ( const XMLElement& e, ParseContext& parseContext ) { bool subs_invalid = false; + If* pOldIf = parseContext.ifData; + string subpath(path); if ( e.name == "module" ) { - if ( parseContext.ifData ) - throw XMLInvalidBuildFileException ( - e.location, - " is not a valid sub-element of " ); Module* module = new Module ( *this, e, path ); if ( LocateModule ( module->name ) ) throw XMLInvalidBuildFileException ( @@ -308,7 +327,10 @@ Project::ProcessXMLSubElement ( const XMLElement& e, "module name conflict: '%s' (originally defined at %s)", module->name.c_str(), module->node.location.c_str() ); - modules.push_back ( module ); + if ( parseContext.ifData ) + parseContext.ifData->data.modules.push_back( module ); + else + non_if_data.modules.push_back ( module ); return; // defer processing until later } else if ( e.name == "cdfile" ) @@ -363,7 +385,6 @@ Project::ProcessXMLSubElement ( const XMLElement& e, } else if ( e.name == "if" ) { - If* pOldIf = parseContext.ifData; parseContext.ifData = new If ( e, *this, NULL ); if ( pOldIf ) pOldIf->data.ifs.push_back ( parseContext.ifData ); @@ -373,7 +394,6 @@ Project::ProcessXMLSubElement ( const XMLElement& e, } else if ( e.name == "ifnot" ) { - If* pOldIf = parseContext.ifData; parseContext.ifData = new If ( e, *this, NULL, true ); if ( pOldIf ) pOldIf->data.ifs.push_back ( parseContext.ifData ); @@ -398,6 +418,8 @@ Project::ProcessXMLSubElement ( const XMLElement& e, } for ( size_t i = 0; i < e.subElements.size (); i++ ) ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext ); + + parseContext.ifData = pOldIf; } Module* diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 4cdb08d6d5c..0fe88ad104c 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -183,11 +183,13 @@ public: std::vector defines; std::vector libraries; std::vector properties; + std::vector modules; std::vector compilerFlags; std::vector ifs; ~IfableData(); void ProcessXML(); + void ExtractModules( std::vector &modules ); }; class Project @@ -200,10 +202,10 @@ public: std::string name; std::string makefile; XMLIncludes xmlbuildfiles; - std::vector modules; std::vector linkerFlags; std::vector cdfiles; std::vector installfiles; + std::vector modules; IfableData non_if_data; Project ( const Configuration& configuration, @@ -258,7 +260,8 @@ enum ModuleType Test = 15, RpcServer = 16, RpcClient = 17, - Alias = 18 + Alias = 18, + BootProgram = 19 }; enum HostType @@ -279,6 +282,7 @@ public: std::string extension; std::string entrypoint; std::string baseaddress; + std::string payload; std::string path; ModuleType type; ImportLibrary* importLibrary; diff --git a/reactos/tools/rbuild/rbuild.mak b/reactos/tools/rbuild/rbuild.mak index 458fa620521..5e8d3ab64b8 100644 --- a/reactos/tools/rbuild/rbuild.mak +++ b/reactos/tools/rbuild/rbuild.mak @@ -254,6 +254,7 @@ RBUILD_HOST_LFLAGS = $(TOOLS_LFLAGS) .PHONY: rbuild rbuild: $(RBUILD_TARGET) +host_gpp += -g $(RBUILD_TARGET): $(RBUILD_OBJECTS) $(XML_SSPRINTF_OBJECTS) $(INFLIB_HOST_OBJECTS) | $(RBUILD_OUT) $(ECHO_LD) -- 2.17.1