* Build freeldr

* Add BootLoader and ObjectLibrary module types
* Add <compilerflag> tag


svn path=/branches/xmlbuildsystem/; revision=13211
This commit is contained in:
Casper Hornstrup
2005-01-22 14:07:45 +00:00
parent 7b13462f5a
commit 87f69aaf32
15 changed files with 451 additions and 17 deletions
+3
View File
@@ -21,6 +21,9 @@
<include>w32api/include</include>
<include>w32api/include/ddk</include>
<directory name="boot">
<xi:include href="boot/boot.xml" />
</directory>
<directory name="drivers">
<xi:include href="drivers/directory.xml" />
</directory>
+3
View File
@@ -0,0 +1,3 @@
<directory name="freeldr">
<xi:include href="freeldr/freeldr.xml" />
</directory>
+25
View File
@@ -0,0 +1,25 @@
<!--<module name="bootsector" type="bootsector">
<include base="bootsector">freeldr/include</include>
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-nostdinc</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-no-builtin</compilerflag>
<compilerflag>-no-inline</compilerflag>
<compilerflag>-no-zero-initialized-in-bss</compilerflag>
<directory name="bootsect">
<file>dosmbr.asm</file>
<file>ext2.asm</file>
<file>fat32.asm</file>
<file>fat.asm</file>
<file>isoboot.asm</file>
<file>win2k.asm</file>
<file>wxpfat16.asm</file>
</directory>
</module>-->
<directory name="freeldr">
<xi:include href="freeldr/freeldr_startup.xml" />
<xi:include href="freeldr/freeldr_base64k.xml" />
<xi:include href="freeldr/freeldr_base.xml" />
<xi:include href="freeldr/freeldr_main.xml" />
<xi:include href="freeldr/freeldr.xml" />
</directory>
+6
View File
@@ -0,0 +1,6 @@
<module name="freeldr" type="bootloader">
<library>freeldr_startup</library>
<library>freeldr_base64k</library>
<library>freeldr_base</library>
<library>freeldr_main</library>
</module>
@@ -0,0 +1,107 @@
<module name="freeldr_base" type="objectlibrary">
<include base="freeldr_base">include</include>
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-nostdinc</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
<compilerflag>-fno-zero-initialized-in-bss</compilerflag>
<compilerflag>-Os</compilerflag>
<directory name="arch">
<if property="ARCH" value="i386">
<directory name="i386">
<file>_alloca.S</file>
<file>archmach.c</file>
<file>hardware.c</file>
<file>hwacpi.c</file>
<file>hwapm.c</file>
<file>hwcpu.c</file>
<file>hwpci.c</file>
<file>i386disk.c</file>
<file>i386rtl.c</file>
<file>i386vid.c</file>
<file>machpc.c</file>
<file>machxbox.c</file>
<file>pccons.c</file>
<file>pcdisk.c</file>
<file>pcmem.c</file>
<file>pcrtc.c</file>
<file>pcvideo.c</file>
<file>portio.c</file>
<file>xboxcons.c</file>
<file>xboxdisk.c</file>
<file>xboxfont.c</file>
<file>xboxhw.c</file>
<file>xboxmem.c</file>
<file>xboxrtc.c</file>
<file>xboxvideo.c</file>
</directory>
</if>
</directory>
<directory name="cache">
<file>blocklist.c</file>
<file>cache.c</file>
</directory>
<directory name="comm">
<file>rs232.c</file>
</directory>
<directory name="disk">
<file>disk.c</file>
<file>partition.c</file>
</directory>
<directory name="fs">
<file>ext2.c</file>
<file>fat.c</file>
<file>fs.c</file>
<file>fsrec.c</file>
<file>iso.c</file>
<file>ntfs.c</file>
</directory>
<directory name="inifile">
<file>ini_init.c</file>
<file>inifile.c</file>
<file>parse.c</file>
</directory>
<directory name="math">
<file>libgcc2.c</file>
</directory>
<directory name="mm">
<file>meminit.c</file>
<file>mm.c</file>
</directory>
<directory name="reactos">
<file>arcname.c</file>
<file>binhive.c</file>
<file>reactos.c</file>
<file>registry.c</file>
</directory>
<directory name="rtl">
<file>list.c</file>
<file>memcmp.c</file>
<file>memcpy.c</file>
<file>memmove.c</file>
<file>memset.c</file>
<file>print.c</file>
<file>stdlib.c</file>
<file>string.c</file>
</directory>
<directory name="ui">
<file>gui.c</file>
<file>tui.c</file>
<file>tuimenu.c</file>
<file>ui.c</file>
</directory>
<directory name="video">
<file>bank.c</file>
<file>fade.c</file>
<file>palette.c</file>
<file>pixel.c</file>
<file>video.c</file>
</directory>
<file>freeldr.c</file>
<file>debug.c</file>
<file>multiboot.c</file>
<file>version.c</file>
<file>cmdline.c</file>
<file>machine.c</file>
</module>
@@ -0,0 +1,25 @@
<module name="freeldr_base64k" type="objectlibrary">
<include base="freeldr_base64k">include</include>
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-nostdinc</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
<compilerflag>-fno-zero-initialized-in-bss</compilerflag>
<compilerflag>-Os</compilerflag>
<directory name="arch">
<if property="ARCH" value="i386">
<directory name="i386">
<file>boot.S</file>
<file>drvmap.S</file>
<file>i386cpu.S</file>
<file>i386idt.S</file>
<file>i386pnp.S</file>
<file>i386trap.S</file>
<file>int386.S</file>
<file>linux.S</file>
<file>mb.S</file>
</directory>
</if>
</directory>
</module>
@@ -0,0 +1,20 @@
<module name="freeldr_main" type="objectlibrary">
<include base="freeldr_main">include</include>
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-nostdinc</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
<compilerflag>-fno-zero-initialized-in-bss</compilerflag>
<compilerflag>-Os</compilerflag>
<directory name="inffile">
<file>inffile.c</file>
</directory>
<file>bootmgr.c</file>
<file>drivemap.c</file>
<file>miscboot.c</file>
<file>options.c</file>
<file>linuxboot.c</file>
<file>oslist.c</file>
<file>custom.c</file>
</module>
@@ -0,0 +1,17 @@
<module name="freeldr_startup" type="objectlibrary">
<include base="freeldr_startup">include</include>
<compilerflag>-nostdlib</compilerflag>
<compilerflag>-nostdinc</compilerflag>
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
<compilerflag>-fno-zero-initialized-in-bss</compilerflag>
<directory name="arch">
<if property="ARCH" value="i386">
<directory name="i386">
<file first="true">fathelp.asm</file>
<file>arch.S</file>
</directory>
</if>
</directory>
</module>
+12 -5
View File
@@ -162,22 +162,26 @@ MingwBackend::GenerateGlobalVariables ()
{
#ifdef WIN32
fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_ld = ld\n" );
fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_objcopy = objcopy\n" );
fprintf ( fMakefile, "rm = del /f /q\n" );
fprintf ( fMakefile, "gcc = gcc\n" );
fprintf ( fMakefile, "ld = ld\n" );
fprintf ( fMakefile, "ar = ar\n" );
fprintf ( fMakefile, "objcopy = objcopy\n" );
fprintf ( fMakefile, "dlltool = dlltool\n" );
fprintf ( fMakefile, "windres = windres\n" );
#else
fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_ld = ld\n" );
fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_objcopy = objcopy\n" );
fprintf ( fMakefile, "rm = rm -f\n" );
fprintf ( fMakefile, "gcc = mingw32-gcc\n" );
fprintf ( fMakefile, "ld = mingw32-ld\n" );
fprintf ( fMakefile, "ar = mingw32-ar\n" );
fprintf ( fMakefile, "objcopy = mingw32-objcopy\n" );
fprintf ( fMakefile, "dlltool = mingw32-dlltool\n" );
fprintf ( fMakefile, "windres = mingw32-windres\n" );
#endif
@@ -207,9 +211,12 @@ MingwBackend::GenerateAllTarget ()
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
{
Module& module = *ProjectNode.modules[i];
fprintf ( fMakefile,
" %s",
FixupTargetFilename ( module.GetPath () ).c_str () );
if ( module.type != ObjectLibrary )
{
fprintf ( fMakefile,
" %s",
FixupTargetFilename ( module.GetPath () ).c_str () );
}
}
fprintf ( fMakefile, "\n\t\n\n" );
}
@@ -145,13 +145,19 @@ MingwModuleHandler::IsGeneratedFile ( const File& file ) const
else
return false;
}
string
MingwModuleHandler::GetImportLibraryDependency ( const Module& importedModule ) const
{
if ( importedModule.type == ObjectLibrary )
return GetObjectsMacro ( importedModule );
else
return PassThruCacheDirectory ( FixupTargetFilename ( importedModule.GetDependencyPath () ) );
}
string
MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
{
if ( module.libraries.size () == 0 )
return "";
string dependencies ( "" );
for ( size_t i = 0; i < module.libraries.size (); i++ )
{
@@ -159,7 +165,7 @@ MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
dependencies += " ";
const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );
assert ( importedModule != NULL );
dependencies += PassThruCacheDirectory ( FixupTargetFilename ( importedModule->GetDependencyPath () ) ).c_str ();
dependencies += GetImportLibraryDependency ( *importedModule );
}
return dependencies;
}
@@ -378,6 +384,20 @@ MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
}
string
MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
{
string parameters;
for ( size_t i = 0; i < compilerFlags.size (); i++ )
{
CompilerFlag& compilerFlag = *compilerFlags[i];
if ( parameters.length () > 0 )
parameters += " ";
parameters += compilerFlag.flag;
}
return parameters;
}
string
MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector<LinkerFlag*>& linkerFlags ) const
{
@@ -402,7 +422,8 @@ void
MingwModuleHandler::GenerateMacro ( const char* assignmentOperation,
const string& macro,
const vector<Include*>& includes,
const vector<Define*>& defines ) const
const vector<Define*>& defines,
const vector<CompilerFlag*>* compilerFlags ) const
{
size_t i;
@@ -411,6 +432,19 @@ MingwModuleHandler::GenerateMacro ( const char* assignmentOperation,
"%s %s",
macro.c_str(),
assignmentOperation );
if ( compilerFlags != NULL )
{
string compilerParameters = GenerateCompilerParametersFromVector ( *compilerFlags );
if ( compilerParameters.size () > 0 )
{
fprintf (
fMakefile,
" %s",
compilerParameters.c_str () );
}
}
for ( i = 0; i < includes.size(); i++ )
{
fprintf (
@@ -440,6 +474,7 @@ MingwModuleHandler::GenerateMacros (
const vector<File*>& files,
const vector<Include*>& includes,
const vector<Define*>& defines,
const vector<CompilerFlag*>* compilerFlags,
const vector<LinkerFlag*>* linkerFlags,
const vector<If*>& ifs,
const string& cflags_macro,
@@ -455,11 +490,13 @@ MingwModuleHandler::GenerateMacros (
GenerateMacro ( assignmentOperation,
cflags_macro,
includes,
defines );
defines,
compilerFlags );
GenerateMacro ( assignmentOperation,
windresflags_macro,
includes,
defines );
defines,
compilerFlags );
}
if ( linkerFlags != NULL )
@@ -527,6 +564,7 @@ MingwModuleHandler::GenerateMacros (
rIf.includes,
rIf.defines,
NULL,
NULL,
rIf.ifs,
cflags_macro,
nasmflags_macro,
@@ -554,6 +592,7 @@ MingwModuleHandler::GenerateMacros (
module.files,
module.includes,
module.defines,
&module.compilerFlags,
&module.linkerFlags,
module.ifs,
cflags_macro,
@@ -1225,6 +1264,7 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
archiveFilename.c_str () );
}
static MingwKernelModuleHandler kernelmodule_handler;
MingwKernelModuleHandler::MingwKernelModuleHandler ()
@@ -1318,6 +1358,28 @@ MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Modul
}
static MingwObjectLibraryModuleHandler objectlibrary_handler;
MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
: MingwModuleHandler ( ObjectLibrary )
{
}
void
MingwObjectLibraryModuleHandler::Process ( const Module& module )
{
GeneratePreconditionDependencies ( module );
GenerateObjectLibraryModuleTarget ( module );
GenerateInvocations ( module );
}
void
MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module )
{
GenerateMacrosAndTargetsTarget ( module );
}
static MingwKernelModeDLLModuleHandler kernelmodedll_handler;
MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
@@ -1607,3 +1669,52 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module
target.c_str ());
}
}
static MingwBootLoaderModuleHandler bootloadermodule_handler;
MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
: MingwModuleHandler ( BootLoader )
{
}
void
MingwBootLoaderModuleHandler::Process ( const Module& module )
{
GeneratePreconditionDependencies ( module );
GenerateBootLoaderModuleTarget ( module );
GenerateInvocations ( module );
}
void
MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& module )
{
static string ros_junk ( "$(ROS_TEMPORARY)" );
string targetName ( module.GetTargetName () );
string target ( FixupTargetFilename (module.GetPath ()) );
string workingDirectory = GetWorkingDirectory ();
string junk_tmp = ros_junk + module.name + ".junk.tmp";
string objectsMacro = GetObjectsMacro ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
GenerateMacrosAndTargetsTarget ( module );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
objectsMacro.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
"\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",
GetLinkerMacro ( module ).c_str (),
junk_tmp.c_str (),
objectsMacro.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
"\t${objcopy} -O binary %s %s\n",
junk_tmp.c_str (),
target.c_str () );
fprintf ( fMakefile,
"\t${rm} %s\n",
junk_tmp.c_str () );
}
@@ -29,6 +29,7 @@ protected:
std::string GetActualSourceFilename ( const std::string& filename ) const;
std::string GetModuleArchiveFilename ( const Module& module ) const;
bool IsGeneratedFile ( const File& file ) const;
std::string GetImportLibraryDependency ( const Module& importedModule ) const;
std::string GetImportLibraryDependencies ( const Module& module ) const;
std::string GetModuleDependencies ( const Module& module ) const;
std::string GetAllDependencies ( const Module& module ) const;
@@ -65,16 +66,19 @@ private:
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
std::string GenerateGccDefineParameters ( const Module& module ) const;
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;
std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
std::string GenerateLinkerParameters ( const Module& module ) const;
void GenerateMacro ( const char* assignmentOperation,
const std::string& macro,
const std::vector<Include*>& includes,
const std::vector<Define*>& defines ) const;
const std::vector<Define*>& defines,
const std::vector<CompilerFlag*>* compilerFlags ) const;
void GenerateMacros ( const char* op,
const std::vector<File*>& files,
const std::vector<Include*>& includes,
const std::vector<Define*>& defines,
const std::vector<CompilerFlag*>* compilerFlags,
const std::vector<LinkerFlag*>* linkerFlags,
const std::vector<If*>& ifs,
const std::string& cflags_macro,
@@ -170,6 +174,16 @@ private:
};
class MingwObjectLibraryModuleHandler : public MingwModuleHandler
{
public:
MingwObjectLibraryModuleHandler ();
virtual void Process ( const Module& module );
private:
void GenerateObjectLibraryModuleTarget ( const Module& module );
};
class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
{
public:
@@ -220,4 +234,14 @@ private:
void GenerateWin32GUIModuleTarget ( const Module& module );
};
class MingwBootLoaderModuleHandler : public MingwModuleHandler
{
public:
MingwBootLoaderModuleHandler ();
virtual void Process ( const Module& module );
private:
void GenerateBootLoaderModuleTarget ( const Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */
+47
View File
@@ -0,0 +1,47 @@
#include "pch.h"
#include <assert.h>
#include "rbuild.h"
using std::string;
using std::vector;
CompilerFlag::CompilerFlag ( const Project& project_,
const XMLElement& compilerFlagNode )
: project(project_),
module(NULL),
node(compilerFlagNode)
{
Initialize();
}
CompilerFlag::CompilerFlag ( const Project& project_,
const Module* module_,
const XMLElement& compilerFlagNode )
: project(project_),
module(module_),
node(compilerFlagNode)
{
Initialize();
}
CompilerFlag::~CompilerFlag ()
{
}
void
CompilerFlag::Initialize ()
{
}
void
CompilerFlag::ProcessXML ()
{
if (node.value.size () == 0)
{
throw InvalidBuildFileException (
node.location,
"<compilerflag> is empty." );
}
flag = node.value;
}
+1
View File
@@ -17,6 +17,7 @@ BACKEND_BASE_OBJECTS = \
BASE_OBJECTS = \
$(BACKEND_BASE_OBJECTS) \
compilerflag.o \
define.o \
exception.o \
include.o \
+16 -2
View File
@@ -1,5 +1,3 @@
// module.cpp
#include "pch.h"
#include <assert.h>
@@ -74,6 +72,8 @@ Module::~Module ()
delete dependencies[i];
for ( i = 0; i < ifs.size(); i++ )
delete ifs[i];
for ( i = 0; i < compilerFlags.size(); i++ )
delete compilerFlags[i];
for ( i = 0; i < linkerFlags.size(); i++ )
delete linkerFlags[i];
}
@@ -98,6 +98,8 @@ Module::ProcessXML()
dependencies[i]->ProcessXML ();
for ( i = 0; i < ifs.size(); i++ )
ifs[i]->ProcessXML();
for ( i = 0; i < compilerFlags.size(); i++ )
compilerFlags[i]->ProcessXML();
for ( i = 0; i < linkerFlags.size(); i++ )
linkerFlags[i]->ProcessXML();
}
@@ -203,6 +205,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
ifs.push_back ( pIf );
subs_invalid = false;
}
else if ( e.name == "compilerflag" )
{
compilerFlags.push_back ( new CompilerFlag ( project, this, e ) );
subs_invalid = true;
}
else if ( e.name == "linkerflag" )
{
linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );
@@ -230,6 +237,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return BuildTool;
if ( attribute.value == "staticlibrary" )
return StaticLibrary;
if ( attribute.value == "objectlibrary" )
return ObjectLibrary;
if ( attribute.value == "kernel" )
return Kernel;
if ( attribute.value == "kernelmodedll" )
@@ -242,6 +251,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return Win32DLL;
if ( attribute.value == "win32gui" )
return Win32GUI;
if ( attribute.value == "bootloader" )
return BootLoader;
throw InvalidAttributeValueException ( location,
attribute.name,
attribute.value );
@@ -256,6 +267,8 @@ Module::GetDefaultModuleExtension () const
return EXEPOSTFIX;
case StaticLibrary:
return ".a";
case ObjectLibrary:
return ".o";
case Kernel:
case Win32GUI:
return ".exe";
@@ -264,6 +277,7 @@ Module::GetDefaultModuleExtension () const
case Win32DLL:
return ".dll";
case KernelModeDriver:
case BootLoader:
return ".sys";
}
throw InvalidOperationException ( __FILE__,
+25 -1
View File
@@ -32,6 +32,7 @@ class InvokeFile;
class Dependency;
class ImportLibrary;
class If;
class CompilerFlag;
class LinkerFlag;
class Property;
@@ -71,12 +72,14 @@ enum ModuleType
{
BuildTool,
StaticLibrary,
ObjectLibrary,
Kernel,
KernelModeDLL,
KernelModeDriver,
NativeDLL,
Win32DLL,
Win32GUI
Win32GUI,
BootLoader
};
@@ -97,6 +100,7 @@ public:
std::vector<Invoke*> invocations;
std::vector<Dependency*> dependencies;
std::vector<If*> ifs;
std::vector<CompilerFlag*> compilerFlags;
std::vector<LinkerFlag*> linkerFlags;
Module ( const Project& project,
@@ -277,6 +281,26 @@ public:
};
class CompilerFlag
{
public:
const Project& project;
const Module* module;
const XMLElement& node;
std::string flag;
CompilerFlag ( const Project& project,
const XMLElement& compilerFlagNode );
CompilerFlag ( const Project& project,
const Module* module,
const XMLElement& compilerFlagNode );
~CompilerFlag ();
void ProcessXML();
private:
void Initialize();
};
class LinkerFlag
{
public: