* Build cabman and zlib

* Add iso module type


svn path=/branches/xmlbuildsystem/; revision=13214
This commit is contained in:
Casper Hornstrup 2005-01-22 15:27:06 +00:00
parent cd93112435
commit ac58a35d34
11 changed files with 177 additions and 36 deletions

View file

@ -50,4 +50,7 @@
<directory name="subsys">
<xi:include href="subsys/directory.xml" />
</directory>
<module name="bootcd" type="iso">
</module>
</project>

View file

@ -100,3 +100,6 @@
<directory name="ws2_32">
<xi:include href="ws2_32/ws2_32.xml" />
</directory>
<directory name="zlib">
<xi:include href="zlib/zlib.xml" />
</directory>

17
reactos/lib/zlib/zlib.xml Normal file
View file

@ -0,0 +1,17 @@
<module name="zlib" type="staticlibrary">
<include base="zlib">.</include>
<file>adler32.c</file>
<file>compress.c</file>
<file>crc32.c</file>
<file>gzio.c</file>
<file>uncompr.c</file>
<file>deflate.c</file>
<file>trees.c</file>
<file>zutil.c</file>
<file>inflate.c</file>
<file>infblock.c</file>
<file>inftrees.c</file>
<file>infcodes.c</file>
<file>infutil.c</file>
<file>inffast.c</file>
</module>

View file

@ -0,0 +1,10 @@
<module name="cabman" type="buildtool">
<include base="cabman">.</include>
<include base="zlib">.</include>
<library>zlib</library>
<file>cabinet.cxx</file>
<file>dfp.cxx</file>
<file>main.cxx</file>
<file>mszip.cxx</file>
<file>raw.cxx</file>
</module>

View file

@ -48,14 +48,14 @@ MingwBackend::CreateMakefile ()
}
void
MingwBackend::CloseMakefile ()
MingwBackend::CloseMakefile () const
{
if (fMakefile)
fclose ( fMakefile );
}
void
MingwBackend::GenerateHeader ()
MingwBackend::GenerateHeader () const
{
fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
}
@ -101,7 +101,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
const vector<Property*>& properties,
const vector<Include*>& includes,
const vector<Define*>& defines,
const vector<If*>& ifs )
const vector<If*>& ifs ) const
{
size_t i;
@ -144,7 +144,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
}
string
MingwBackend::GenerateProjectLFLAGS ()
MingwBackend::GenerateProjectLFLAGS () const
{
string lflags;
for ( size_t i = 0; i < ProjectNode.linkerFlags.size (); i++ )
@ -158,15 +158,17 @@ MingwBackend::GenerateProjectLFLAGS ()
}
void
MingwBackend::GenerateGlobalVariables ()
MingwBackend::GenerateGlobalVariables () const
{
#ifdef WIN32
fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_gpp = g++\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, "gpp = g++\n" );
fprintf ( fMakefile, "ld = ld\n" );
fprintf ( fMakefile, "ar = ar\n" );
fprintf ( fMakefile, "objcopy = objcopy\n" );
@ -174,11 +176,13 @@ MingwBackend::GenerateGlobalVariables ()
fprintf ( fMakefile, "windres = windres\n" );
#else
fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_gpp = g++\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, "gpp = mingw32-g++\n" );
fprintf ( fMakefile, "ld = mingw32-ld\n" );
fprintf ( fMakefile, "ar = mingw32-ar\n" );
fprintf ( fMakefile, "objcopy = mingw32-objcopy\n" );
@ -204,14 +208,24 @@ MingwBackend::GenerateGlobalVariables ()
fprintf ( fMakefile, ".PHONY: clean\n\n" );
}
bool
MingwBackend::IncludeInAllTarget ( const Module& module ) const
{
if ( module.type == ObjectLibrary )
return false;
if ( module.type == Iso )
return false;
return true;
}
void
MingwBackend::GenerateAllTarget ()
MingwBackend::GenerateAllTarget () const
{
fprintf ( fMakefile, "all:" );
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
{
Module& module = *ProjectNode.modules[i];
if ( module.type != ObjectLibrary )
if ( IncludeInAllTarget ( module ) )
{
fprintf ( fMakefile,
" %s",
@ -222,7 +236,7 @@ MingwBackend::GenerateAllTarget ()
}
void
MingwBackend::ProcessModule ( Module& module )
MingwBackend::ProcessModule ( Module& module ) const
{
MingwModuleHandler* h = MingwModuleHandler::LookupHandler (
module.node.location,

View file

@ -10,10 +10,10 @@ public:
MingwBackend ( Project& project );
virtual void Process ();
private:
void ProcessModule ( Module& module );
void ProcessModule ( Module& module ) const;
void CreateMakefile ();
void CloseMakefile ();
void GenerateHeader ();
void CloseMakefile () const;
void GenerateHeader () const;
void GenerateProjectCFlagsMacro ( const char* assignmentOperation,
const std::vector<Include*>& includes,
const std::vector<Define*>& defines ) const;
@ -21,11 +21,12 @@ private:
const std::vector<Property*>& properties,
const std::vector<Include*>& includes,
const std::vector<Define*>& defines,
const std::vector<If*>& ifs );
std::string GenerateProjectLFLAGS ();
void GenerateDirectoryTargets ();
void GenerateGlobalVariables ();
void GenerateAllTarget ();
const std::vector<If*>& ifs ) const;
std::string GenerateProjectLFLAGS () const;
void GenerateDirectoryTargets () const;
void GenerateGlobalVariables () const;
bool IncludeInAllTarget ( const Module& module ) const;
void GenerateAllTarget () const;
FILE* fMakefile;
};

View file

@ -82,18 +82,6 @@ MingwModuleHandler::GetDirectory ( const string& filename ) const
return filename.substr ( 0, index );
}
string
MingwModuleHandler::GetExtension ( const string& filename ) const
{
size_t index = filename.find_last_of ( '/' );
if (index == string::npos) index = 0;
string tmp = filename.substr( index, filename.size() - index );
size_t ext_index = tmp.find_last_of( '.' );
if (ext_index != string::npos)
return filename.substr ( index + ext_index, filename.size() );
return "";
}
string
MingwModuleHandler::GetBasename ( const string& filename ) const
{
@ -722,6 +710,7 @@ void
MingwModuleHandler::GenerateCommands ( const Module& module,
const string& sourceFilename,
const string& cc,
const string& cppc,
const string& cflagsMacro,
const string& nasmflagsMacro,
const string& windresflagsMacro ) const
@ -735,6 +724,14 @@ MingwModuleHandler::GenerateCommands ( const Module& module,
cflagsMacro );
return;
}
else if ( extension == ".cxx" || extension == ".CXX" )
{
GenerateGccCommand ( module,
sourceFilename,
cppc,
cflagsMacro );
return;
}
else if ( extension == ".s" || extension == ".S" )
{
GenerateGccAssemblerCommand ( module,
@ -848,6 +845,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const vector<File*>& files,
const vector<If*>& ifs,
const string& cc,
const string& cppc,
const string& cflagsMacro,
const string& nasmflagsMacro,
const string& windresflagsMacro ) const
@ -860,6 +858,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
GenerateCommands ( module,
sourceFilename,
cc,
cppc,
cflagsMacro,
nasmflagsMacro,
windresflagsMacro );
@ -873,6 +872,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
ifs[i]->files,
ifs[i]->ifs,
cc,
cppc,
cflagsMacro,
nasmflagsMacro,
windresflagsMacro );
@ -882,6 +882,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
void
MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const string& cc,
const string& cppc,
const string& cflagsMacro,
const string& nasmflagsMacro,
const string& windresflagsMacro ) const
@ -890,6 +891,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
module.files,
module.ifs,
cc,
cppc,
cflagsMacro,
nasmflagsMacro,
windresflagsMacro );
@ -956,6 +958,7 @@ void
MingwModuleHandler::GenerateMacrosAndTargets (
const Module& module,
const string& cc,
const string& cppc,
const string& ar,
const string* cflags ) const
{
@ -995,6 +998,7 @@ MingwModuleHandler::GenerateMacrosAndTargets (
string ar_target = GenerateArchiveTarget ( module, ar, objectsMacro );
GenerateObjectFileTargets ( module,
cc,
cppc,
cflagsMacro,
nasmflagsMacro,
windresflagsMacro );
@ -1017,7 +1021,7 @@ MingwModuleHandler::GenerateMacrosAndTargets (
void
MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
{
GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}", NULL );
GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_gpp}", "${host_ar}", NULL );
}
void
@ -1031,7 +1035,7 @@ void
MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,
const string* clags ) const
{
GenerateMacrosAndTargets ( module, "${gcc}", "${ar}", clags );
GenerateMacrosAndTargets ( module, "${gcc}", "${gpp}", "${ar}", clags );
}
string
@ -1251,17 +1255,27 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
{
string target ( FixupTargetFilename ( module.GetPath () ) );
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
GenerateMacrosAndTargetsHost ( module );
fprintf ( fMakefile, "%s: %s\n",
string linker;
if ( module.HasFileWithExtensions ( ".cxx", ".CXX" ) )
linker = "${host_gpp}";
else
linker = "${host_gcc}";
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
archiveFilename.c_str () );
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
"\t${host_gcc} %s -o %s %s\n\n",
"\t%s %s -o %s %s %s\n\n",
linker.c_str (),
GetLinkerMacro ( module ).c_str (),
target.c_str (),
archiveFilename.c_str () );
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
}
@ -1718,3 +1732,30 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& mod
"\t${rm} %s\n",
junk_tmp.c_str () );
}
static MingwIsoModuleHandler isomodule_handler;
MingwIsoModuleHandler::MingwIsoModuleHandler ()
: MingwModuleHandler ( Iso )
{
}
void
MingwIsoModuleHandler::Process ( const Module& module )
{
GeneratePreconditionDependencies ( module );
GenerateIsoModuleTarget ( module );
GenerateInvocations ( module );
}
void
MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
{
string target ( FixupTargetFilename ( module.GetPath ()) );
fprintf ( fMakefile, "%s: all\n",
target.c_str () );
fprintf ( fMakefile,
"\t\n" );
}

View file

@ -22,7 +22,6 @@ protected:
const std::string &PassThruCacheDirectory ( const std::string &f ) const;
std::string GetWorkingDirectory () const;
std::string GetDirectory (const std::string& filename ) const;
std::string GetExtension ( const std::string& filename ) const;
std::string GetBasename ( const std::string& filename ) const;
std::string ReplaceExtension ( const std::string& filename,
const std::string& newExtension ) const;
@ -114,6 +113,7 @@ private:
void GenerateCommands ( const Module& module,
const std::string& sourceFilename,
const std::string& cc,
const std::string& cppc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro,
const std::string& windresflagsMacro ) const;
@ -121,11 +121,13 @@ private:
const std::vector<File*>& files,
const std::vector<If*>& ifs,
const std::string& cc,
const std::string& cppc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro,
const std::string& windresflagsMacro ) const;
void GenerateObjectFileTargets ( const Module& module,
const std::string& cc,
const std::string& cppc,
const std::string& cflagsMacro,
const std::string& nasmflagsMacro,
const std::string& windresflagsMacro ) const;
@ -137,6 +139,7 @@ private:
const std::string& objs_macro ) const;
void GenerateMacrosAndTargets ( const Module& module,
const std::string& cc,
const std::string& cppc,
const std::string& ar,
const std::string* clags ) const;
std::string GetPreconditionDependenciesName ( const Module& module ) const;
@ -244,4 +247,14 @@ private:
void GenerateBootLoaderModuleTarget ( const Module& module );
};
class MingwIsoModuleHandler : public MingwModuleHandler
{
public:
MingwIsoModuleHandler ();
virtual void Process ( const Module& module );
private:
void GenerateIsoModuleTarget ( const Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */

View file

@ -19,6 +19,18 @@ FixSeparator ( const string& s )
return s2;
}
string
GetExtension ( const string& filename )
{
size_t index = filename.find_last_of ( '/' );
if (index == string::npos) index = 0;
string tmp = filename.substr( index, filename.size() - index );
size_t ext_index = tmp.find_last_of( '.' );
if (ext_index != string::npos)
return filename.substr ( index + ext_index, filename.size() );
return "";
}
string
NormalizeFilename ( const string& filename )
{
@ -253,6 +265,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return Win32GUI;
if ( attribute.value == "bootloader" )
return BootLoader;
if ( attribute.value == "iso" )
return Iso;
throw InvalidAttributeValueException ( location,
attribute.name,
attribute.value );
@ -279,6 +293,8 @@ Module::GetDefaultModuleExtension () const
case KernelModeDriver:
case BootLoader:
return ".sys";
case Iso:
return ".iso";
}
throw InvalidOperationException ( __FILE__,
__LINE__ );
@ -356,6 +372,20 @@ Module::GetInvocationTarget ( const int index ) const
index );
}
bool
Module::HasFileWithExtensions ( const std::string& extension1,
const std::string& extension2 ) const
{
for ( size_t i = 0; i < files.size (); i++ )
{
File& file = *files[i];
string extension = GetExtension ( file.name );
if ( extension == extension1 || extension == extension2 )
return true;
}
return false;
}
File::File ( const string& _name, bool _first )
: name(_name), first(_first)

View file

@ -79,7 +79,8 @@ enum ModuleType
NativeDLL,
Win32DLL,
Win32GUI,
BootLoader
BootLoader,
Iso
};
@ -117,6 +118,8 @@ public:
std::string GetPathWithPrefix ( const std::string& prefix ) const;
std::string GetTargets () const;
std::string GetInvocationTarget ( const int index ) const;
bool HasFileWithExtensions ( const std::string& extension1,
const std::string& extension2 ) const;
void ProcessXML();
private:
std::string GetDefaultModuleExtension () const;
@ -339,6 +342,9 @@ public:
extern std::string
FixSeparator ( const std::string& s );
extern std::string
GetExtension ( const std::string& filename );
extern std::string
NormalizeFilename ( const std::string& filename );

View file

@ -1,6 +1,9 @@
<directory name="bin2res">
<xi:include href="bin2res/bin2res.xml" />
</directory>
<directory name="cabman">
<xi:include href="cabman/cabman.xml" />
</directory>
<module name="buildno" type="buildtool">
<include base="buildno">.</include>
<file>buildno.c</file>