Added support for ROS_AUTOMAKE variable.

Added support for <if> <module ...> </if>
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
This commit is contained in:
Art Yerkes 2005-12-04 12:02:45 +00:00
parent 05a351a06f
commit b1fa799b0b
11 changed files with 245 additions and 14 deletions

91
reactos/ReactOS-ppc.xml Normal file
View file

@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
<project name="ReactOS" makefile="makefile.ppc" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config-ppc.xml">
<xi:fallback>
<xi:include href="config.template.xml" />
</xi:fallback>
</xi:include>
<xi:include href="baseaddress.xml" />
<property name="BOOTPROG_PREPARE" value="ppc-le2be" />
<property name="BOOTPROG_FLATFORMAT" value="-O elf32-powerpc -B powerpc:common" />
<property name="BOOTPROG_LINKFORMAT" value="-melf32ppc --no-omagic -Ttext 0xe00000 -Tdata 0xe10000" />
<property name="BOOTPROG_COPYFORMAT" value="--only-section=.text --only-section=.data --only-section=.bss -O aixcoff-rs6000" />
<define name="_M_PPC" />
<define name="_PPC_" />
<define name="__PowerPC__" />
<define name="_REACTOS_" />
<define name="__MINGW_IMPORT" empty="true" />
<define name="__restrict__" empty="true" />
<compilerflag>-v</compilerflag>
<if property="MP" value="1">
<define name="CONFIG_SMP" value="1" />
</if>
<if property="DBG" value="1">
<define name="DBG" value="1" />
<property name="DBG_OR_KDBG" value="true" />
</if>
<if property="DBG" value="0">
<compilerflag>-Os</compilerflag>
<compilerflag>-Wno-strict-aliasing</compilerflag>
</if>
<if property="KDBG" value="1">
<define name="KDBG" value="1" />
<property name="DBG_OR_KDBG" value="true" />
</if>
<compilerflag>-Wpointer-arith</compilerflag>
<include>.</include>
<include>include</include>
<include>include/reactos</include>
<include>include/libs</include>
<include>include/drivers</include>
<include>include/subsys</include>
<include>include/ndk</include>
<include>w32api/include</include>
<include>w32api/include/crt</include>
<include>w32api/include/ddk</include>
<directory name="apps">
<xi:include href="apps/directory.xml" />
</directory>
<directory name="boot">
<xi:include href="boot/boot.xml" />
</directory>
<directory name="bootdata">
<xi:include href="bootdata/bootdata.xml" />
</directory>
<directory name="drivers">
<xi:include href="drivers/directory.xml" />
</directory>
<directory name="hal">
<xi:include href="hal/directory.xml" />
</directory>
<directory name="include">
<xi:include href="include/directory.xml" />
</directory>
<directory name="lib">
<xi:include href="lib/directory.xml" />
</directory>
<directory name="media">
<xi:include href="media/directory.xml" />
</directory>
<directory name="modules">
<xi:include href="modules/directory.xml" />
</directory>
<directory name="ntoskrnl">
<xi:include href="ntoskrnl/ntoskrnl.xml" />
</directory>
<directory name="regtests">
<xi:include href="regtests/directory.xml" />
</directory>
<directory name="services">
<xi:include href="services/directory.xml" />
</directory>
<directory name="subsys">
<xi:include href="subsys/directory.xml" />
</directory>
</project>

View file

@ -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<MingwModuleHandler*> 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

View file

@ -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;

View file

@ -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_ )

View file

@ -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:

View file

@ -51,6 +51,7 @@ Bootstrap::IsSupportedModuleType ( ModuleType type )
case KernelModeDriver:
case BootSector:
case BootLoader:
case BootProgram:
return true;
case BuildTool:
case StaticLibrary:

View file

@ -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

View file

@ -195,6 +195,13 @@ ToLower ( string filename )
return filename;
}
void IfableData::ExtractModules( std::vector<Module*> &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:

View file

@ -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,
"<module> is not a valid sub-element of <if>" );
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*

View file

@ -183,11 +183,13 @@ public:
std::vector<Define*> defines;
std::vector<Library*> libraries;
std::vector<Property*> properties;
std::vector<Module*> modules;
std::vector<CompilerFlag*> compilerFlags;
std::vector<If*> ifs;
~IfableData();
void ProcessXML();
void ExtractModules( std::vector<Module*> &modules );
};
class Project
@ -200,10 +202,10 @@ public:
std::string name;
std::string makefile;
XMLIncludes xmlbuildfiles;
std::vector<Module*> modules;
std::vector<LinkerFlag*> linkerFlags;
std::vector<CDFile*> cdfiles;
std::vector<InstallFile*> installfiles;
std::vector<Module*> 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;

View file

@ -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)