mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:23:01 +00:00
* Run build tools after parsing build files
* Generate roscfg.h svn path=/branches/xmlbuildsystem/; revision=13496
This commit is contained in:
parent
63b4ab39e4
commit
760ebcb3e3
13 changed files with 354 additions and 63 deletions
|
@ -862,8 +862,6 @@ DriverEntry(
|
||||||
DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
|
DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
|
||||||
KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc);
|
KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc);
|
||||||
|
|
||||||
PREPARE_TESTS
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,8 +176,6 @@ DllMain(HANDLE hDll,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PREPARE_TESTS
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,8 +330,6 @@ DriverEntry (
|
||||||
CreateStockObjects();
|
CreateStockObjects();
|
||||||
CreateSysColorObjects();
|
CreateSysColorObjects();
|
||||||
|
|
||||||
PREPARE_TESTS
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ MingwBackend::Process ()
|
||||||
GenerateHeader ();
|
GenerateHeader ();
|
||||||
GenerateGlobalVariables ();
|
GenerateGlobalVariables ();
|
||||||
GenerateAllTarget ();
|
GenerateAllTarget ();
|
||||||
|
GenerateInitTarget ();
|
||||||
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
|
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
|
||||||
{
|
{
|
||||||
Module& module = *ProjectNode.modules[i];
|
Module& module = *ProjectNode.modules[i];
|
||||||
|
@ -167,6 +168,7 @@ MingwBackend::GenerateGlobalVariables () const
|
||||||
fprintf ( fMakefile, "host_ar = ar\n" );
|
fprintf ( fMakefile, "host_ar = ar\n" );
|
||||||
fprintf ( fMakefile, "host_objcopy = objcopy\n" );
|
fprintf ( fMakefile, "host_objcopy = objcopy\n" );
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
fprintf ( fMakefile, "nmkdir = mkdir\n" );
|
||||||
fprintf ( fMakefile, "rm = del /f /q\n" );
|
fprintf ( fMakefile, "rm = del /f /q\n" );
|
||||||
fprintf ( fMakefile, "gcc = gcc\n" );
|
fprintf ( fMakefile, "gcc = gcc\n" );
|
||||||
fprintf ( fMakefile, "gpp = g++\n" );
|
fprintf ( fMakefile, "gpp = g++\n" );
|
||||||
|
@ -176,6 +178,7 @@ MingwBackend::GenerateGlobalVariables () const
|
||||||
fprintf ( fMakefile, "dlltool = dlltool\n" );
|
fprintf ( fMakefile, "dlltool = dlltool\n" );
|
||||||
fprintf ( fMakefile, "windres = windres\n" );
|
fprintf ( fMakefile, "windres = windres\n" );
|
||||||
#else
|
#else
|
||||||
|
fprintf ( fMakefile, "nmkdir = mkdir -p\n" );
|
||||||
fprintf ( fMakefile, "rm = rm -f\n" );
|
fprintf ( fMakefile, "rm = rm -f\n" );
|
||||||
fprintf ( fMakefile, "gcc = mingw32-gcc\n" );
|
fprintf ( fMakefile, "gcc = mingw32-gcc\n" );
|
||||||
fprintf ( fMakefile, "gpp = mingw32-g++\n" );
|
fprintf ( fMakefile, "gpp = mingw32-g++\n" );
|
||||||
|
@ -235,6 +238,53 @@ MingwBackend::GenerateAllTarget () const
|
||||||
fprintf ( fMakefile, "\n\t\n\n" );
|
fprintf ( fMakefile, "\n\t\n\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
MingwBackend::GetBuildToolDependencies () const
|
||||||
|
{
|
||||||
|
string dependencies;
|
||||||
|
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
|
||||||
|
{
|
||||||
|
Module& module = *ProjectNode.modules[i];
|
||||||
|
if ( module.type == BuildTool )
|
||||||
|
{
|
||||||
|
if ( dependencies.length () > 0 )
|
||||||
|
dependencies += " ";
|
||||||
|
dependencies += module.GetDependencyPath ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MingwBackend::GenerateInitTarget () const
|
||||||
|
{
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"init:");
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
" $(ROS_INTERMEDIATE)." SSEP "tools" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
" %s",
|
||||||
|
GetBuildToolDependencies ().c_str () );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
" %s",
|
||||||
|
"include" SSEP "reactos" SSEP "buildno.h" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"\n\t\n\n" );
|
||||||
|
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"$(ROS_INTERMEDIATE)." SSEP "tools:\n" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"ifneq ($(ROS_INTERMEDIATE),)\n" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"\t${nmkdir} $(ROS_INTERMEDIATE)\n" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"endif\n" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"\t${nmkdir} $(ROS_INTERMEDIATE)." SSEP "tools\n" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"\n" );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwBackend::CheckAutomaticDependencies ()
|
MingwBackend::CheckAutomaticDependencies ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ private:
|
||||||
void GenerateGlobalVariables () const;
|
void GenerateGlobalVariables () const;
|
||||||
bool IncludeInAllTarget ( const Module& module ) const;
|
bool IncludeInAllTarget ( const Module& module ) const;
|
||||||
void GenerateAllTarget () const;
|
void GenerateAllTarget () const;
|
||||||
|
std::string GetBuildToolDependencies () const;
|
||||||
|
void GenerateInitTarget () const;
|
||||||
void CheckAutomaticDependencies ();
|
void CheckAutomaticDependencies ();
|
||||||
FILE* fMakefile;
|
FILE* fMakefile;
|
||||||
};
|
};
|
||||||
|
|
|
@ -257,6 +257,15 @@ MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
|
||||||
return objectFilenames;
|
return objectFilenames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
MingwModuleHandler::IncludeDirectoryTarget ( const string& directory ) const
|
||||||
|
{
|
||||||
|
if ( directory == "$(ROS_INTERMEDIATE)." SSEP "tools")
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GenerateDirectoryTargets () const
|
MingwModuleHandler::GenerateDirectoryTargets () const
|
||||||
{
|
{
|
||||||
|
@ -270,7 +279,12 @@ MingwModuleHandler::GenerateDirectoryTargets () const
|
||||||
i != directory_set.end ();
|
i != directory_set.end ();
|
||||||
i++ )
|
i++ )
|
||||||
{
|
{
|
||||||
fprintf ( fMakefile, " %s", i->c_str () );
|
if ( IncludeDirectoryTarget ( *i ) )
|
||||||
|
{
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
" %s",
|
||||||
|
i->c_str () );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf ( fMakefile, "\n\n" );
|
fprintf ( fMakefile, "\n\n" );
|
||||||
|
@ -279,7 +293,12 @@ MingwModuleHandler::GenerateDirectoryTargets () const
|
||||||
i != directory_set.end ();
|
i != directory_set.end ();
|
||||||
i++ )
|
i++ )
|
||||||
{
|
{
|
||||||
fprintf ( fMakefile, "%s ", i->c_str () );
|
if ( IncludeDirectoryTarget ( *i ) )
|
||||||
|
{
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"%s ",
|
||||||
|
i->c_str () );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
|
@ -1069,40 +1088,6 @@ MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
|
||||||
MingwModuleHandler::GetInvocationParameters ( const Invoke& invoke ) const
|
|
||||||
{
|
|
||||||
string parameters ( "" );
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < invoke.output.size (); i++)
|
|
||||||
{
|
|
||||||
if (parameters.length () > 0)
|
|
||||||
parameters += " ";
|
|
||||||
InvokeFile& invokeFile = *invoke.output[i];
|
|
||||||
if (invokeFile.switches.length () > 0)
|
|
||||||
{
|
|
||||||
parameters += invokeFile.switches;
|
|
||||||
parameters += " ";
|
|
||||||
}
|
|
||||||
parameters += invokeFile.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < invoke.input.size (); i++)
|
|
||||||
{
|
|
||||||
if (parameters.length () > 0)
|
|
||||||
parameters += " ";
|
|
||||||
InvokeFile& invokeFile = *invoke.input[i];
|
|
||||||
if (invokeFile.switches.length () > 0)
|
|
||||||
{
|
|
||||||
parameters += invokeFile.switches;
|
|
||||||
parameters += " ";
|
|
||||||
}
|
|
||||||
parameters += invokeFile.name ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GenerateInvocations ( const Module& module ) const
|
MingwModuleHandler::GenerateInvocations ( const Module& module ) const
|
||||||
{
|
{
|
||||||
|
@ -1134,7 +1119,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t%s %s\n\n",
|
"\t%s %s\n\n",
|
||||||
FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),
|
FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),
|
||||||
GetInvocationParameters ( invoke ).c_str () );
|
invoke.GetParameters ().c_str () );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,13 +1130,31 @@ MingwModuleHandler::GetPreconditionDependenciesName ( const Module& module ) con
|
||||||
module.name.c_str () );
|
module.name.c_str () );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
MingwModuleHandler::GetDefaultDependencies ( const Module& module ) const
|
||||||
|
{
|
||||||
|
/* Avoid circular dependency */
|
||||||
|
if ( module.type == BuildTool || module.name == "zlib" )
|
||||||
|
return "$(ROS_INTERMEDIATE)." SSEP "tools $(ROS_INTERMEDIATE)." SSEP "lib" SSEP "zlib";
|
||||||
|
else
|
||||||
|
return "init";
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const
|
MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string preconditionDependenciesName = GetPreconditionDependenciesName ( module );
|
string preconditionDependenciesName = GetPreconditionDependenciesName ( module );
|
||||||
string sourceFilenames = GetSourceFilenamesWithoutGeneratedFiles ( module );
|
string sourceFilenames = GetSourceFilenamesWithoutGeneratedFiles ( module );
|
||||||
string dependencies = GetModuleDependencies ( module );
|
string dependencies = GetDefaultDependencies ( module );
|
||||||
string s = GetInvocationDependencies ( module );
|
string s = GetModuleDependencies ( module );
|
||||||
|
if ( s.length () > 0 )
|
||||||
|
{
|
||||||
|
if ( dependencies.length () > 0 )
|
||||||
|
dependencies += " ";
|
||||||
|
dependencies += s;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = GetInvocationDependencies ( module );
|
||||||
if ( s.length () > 0 )
|
if ( s.length () > 0 )
|
||||||
{
|
{
|
||||||
if ( dependencies.length () > 0 )
|
if ( dependencies.length () > 0 )
|
||||||
|
@ -1223,6 +1226,9 @@ string
|
||||||
MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
|
MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string dependencies;
|
string dependencies;
|
||||||
|
string dkNkmLibNoFixup = "dk/nkm/lib";
|
||||||
|
dependencies += FixupTargetFilename ( dkNkmLibNoFixup );
|
||||||
|
PassThruCacheDirectory ( dkNkmLibNoFixup + SSEP );
|
||||||
for ( size_t i = 0; i < module.files.size (); i++ )
|
for ( size_t i = 0; i < module.files.size (); i++ )
|
||||||
{
|
{
|
||||||
File& file = *module.files[i];
|
File& file = *module.files[i];
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
static MingwModuleHandler* LookupHandler ( const std::string& location,
|
static MingwModuleHandler* LookupHandler ( const std::string& location,
|
||||||
ModuleType moduletype_ );
|
ModuleType moduletype_ );
|
||||||
virtual void Process ( const Module& module ) = 0;
|
virtual void Process ( const Module& module ) = 0;
|
||||||
|
bool IncludeDirectoryTarget ( const std::string& directory ) const;
|
||||||
void GenerateDirectoryTargets () const;
|
void GenerateDirectoryTargets () const;
|
||||||
static std::string GetObjectFilename ( const std::string& sourceFilename );
|
static std::string GetObjectFilename ( const std::string& sourceFilename );
|
||||||
protected:
|
protected:
|
||||||
|
@ -46,7 +47,6 @@ protected:
|
||||||
const std::string* cflags,
|
const std::string* cflags,
|
||||||
const std::string* nasmflags ) const;
|
const std::string* nasmflags ) const;
|
||||||
std::string GetInvocationDependencies ( const Module& module ) const;
|
std::string GetInvocationDependencies ( const Module& module ) const;
|
||||||
std::string GetInvocationParameters ( const Invoke& invoke ) const;
|
|
||||||
void GenerateInvocations ( const Module& module ) const;
|
void GenerateInvocations ( const Module& module ) const;
|
||||||
|
|
||||||
std::string GetPreconditionDependenciesName ( const Module& module ) const;
|
std::string GetPreconditionDependenciesName ( const Module& module ) const;
|
||||||
|
@ -149,6 +149,7 @@ private:
|
||||||
const std::string* clags,
|
const std::string* clags,
|
||||||
const std::string* nasmflags ) const;
|
const std::string* nasmflags ) const;
|
||||||
std::string GetSpecObjectDependencies ( const std::string& filename ) const;
|
std::string GetSpecObjectDependencies ( const std::string& filename ) const;
|
||||||
|
std::string GetDefaultDependencies ( const Module& module ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,12 @@ void Exception::SetMessage ( const char* message,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OutOfMemoryException::OutOfMemoryException ()
|
||||||
|
: Exception ( "Out of memory" )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InvalidOperationException::InvalidOperationException ( const char* filename,
|
InvalidOperationException::InvalidOperationException ( const char* filename,
|
||||||
const int linenumber )
|
const int linenumber )
|
||||||
{
|
{
|
||||||
|
@ -147,6 +153,7 @@ UnknownBackendException::UnknownBackendException ( const string& name )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
|
UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
|
||||||
int moduletype )
|
int moduletype )
|
||||||
: InvalidBuildFileException ( location,
|
: InvalidBuildFileException ( location,
|
||||||
|
@ -154,3 +161,14 @@ UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
|
||||||
moduletype )
|
moduletype )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InvocationFailedException::InvocationFailedException ( const std::string& command,
|
||||||
|
int exitcode )
|
||||||
|
: Exception ( "Failed to execute '%s' (exit code %d)",
|
||||||
|
command.c_str (),
|
||||||
|
exitcode )
|
||||||
|
{
|
||||||
|
Command = command;
|
||||||
|
ExitCode = exitcode;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OutOfMemoryException : public Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OutOfMemoryException ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class FileNotFoundException : public Exception
|
class FileNotFoundException : public Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -105,4 +112,14 @@ public:
|
||||||
int moduletype );
|
int moduletype );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class InvocationFailedException : public Exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvocationFailedException ( const std::string& command,
|
||||||
|
int exitcode );
|
||||||
|
std::string Command;
|
||||||
|
int ExitCode;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __EXCEPTION_H */
|
#endif /* __EXCEPTION_H */
|
||||||
|
|
|
@ -451,6 +451,21 @@ Module::HasFileWithExtensions ( const std::string& extension1,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Module::InvokeModule () const
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < invocations.size (); i++ )
|
||||||
|
{
|
||||||
|
Invoke& invoke = *invocations[i];
|
||||||
|
string command = invoke.invokeModule->GetPath () + " " + invoke.GetParameters ();
|
||||||
|
printf ( "Executing '%s'\n\n", command.c_str () );
|
||||||
|
int exitcode = system ( command.c_str () );
|
||||||
|
if ( exitcode != 0 )
|
||||||
|
throw InvocationFailedException ( command,
|
||||||
|
exitcode );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
File::File ( const string& _name, bool _first )
|
File::File ( const string& _name, bool _first )
|
||||||
: name(_name), first(_first)
|
: name(_name), first(_first)
|
||||||
|
@ -581,6 +596,40 @@ Invoke::GetTargets () const
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Invoke::GetParameters () const
|
||||||
|
{
|
||||||
|
string parameters ( "" );
|
||||||
|
size_t i;
|
||||||
|
for ( i = 0; i < output.size (); i++ )
|
||||||
|
{
|
||||||
|
if ( parameters.length () > 0)
|
||||||
|
parameters += " ";
|
||||||
|
InvokeFile& invokeFile = *output[i];
|
||||||
|
if ( invokeFile.switches.length () > 0 )
|
||||||
|
{
|
||||||
|
parameters += invokeFile.switches;
|
||||||
|
parameters += " ";
|
||||||
|
}
|
||||||
|
parameters += invokeFile.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < input.size (); i++ )
|
||||||
|
{
|
||||||
|
if ( parameters.length () > 0 )
|
||||||
|
parameters += " ";
|
||||||
|
InvokeFile& invokeFile = *input[i];
|
||||||
|
if ( invokeFile.switches.length () > 0 )
|
||||||
|
{
|
||||||
|
parameters += invokeFile.switches;
|
||||||
|
parameters += " ";
|
||||||
|
}
|
||||||
|
parameters += invokeFile.name ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InvokeFile::InvokeFile ( const XMLElement& _node,
|
InvokeFile::InvokeFile ( const XMLElement& _node,
|
||||||
const string& _name )
|
const string& _name )
|
||||||
|
|
|
@ -7,15 +7,10 @@
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
/*Project::Project()
|
|
||||||
: node(NULL), head(NULL)
|
|
||||||
{
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Project::Project ( const string& filename )
|
Project::Project ( const string& filename )
|
||||||
: xmlfile(filename),
|
: xmlfile (filename),
|
||||||
node(NULL),
|
node (NULL),
|
||||||
head(NULL)
|
head (NULL)
|
||||||
{
|
{
|
||||||
ReadXml();
|
ReadXml();
|
||||||
}
|
}
|
||||||
|
@ -25,26 +20,170 @@ Project::~Project ()
|
||||||
size_t i;
|
size_t i;
|
||||||
for ( i = 0; i < modules.size (); i++ )
|
for ( i = 0; i < modules.size (); i++ )
|
||||||
delete modules[i];
|
delete modules[i];
|
||||||
for ( i = 0; i < includes.size(); i++ )
|
for ( i = 0; i < includes.size (); i++ )
|
||||||
delete includes[i];
|
delete includes[i];
|
||||||
for ( i = 0; i < defines.size(); i++ )
|
for ( i = 0; i < defines.size (); i++ )
|
||||||
delete defines[i];
|
delete defines[i];
|
||||||
for ( i = 0; i < linkerFlags.size(); i++ )
|
for ( i = 0; i < linkerFlags.size (); i++ )
|
||||||
delete linkerFlags[i];
|
delete linkerFlags[i];
|
||||||
for ( i = 0; i < properties.size(); i++ )
|
for ( i = 0; i < properties.size (); i++ )
|
||||||
delete properties[i];
|
delete properties[i];
|
||||||
for ( i = 0; i < ifs.size(); i++ )
|
for ( i = 0; i < ifs.size (); i++ )
|
||||||
delete ifs[i];
|
delete ifs[i];
|
||||||
delete head;
|
delete head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Property*
|
||||||
|
Project::LookupProperty ( const string& name ) const
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < properties.size (); i++ )
|
||||||
|
{
|
||||||
|
const Property* property = properties[i];
|
||||||
|
if ( property->name == name )
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Project::ReadXml()
|
Project::WriteIfChanged ( char* outbuf,
|
||||||
|
string filename )
|
||||||
|
{
|
||||||
|
FILE* out;
|
||||||
|
unsigned int end;
|
||||||
|
char* cmpbuf;
|
||||||
|
unsigned int stat;
|
||||||
|
|
||||||
|
out = fopen ( filename.c_str (), "rb" );
|
||||||
|
if ( out == NULL )
|
||||||
|
{
|
||||||
|
out = fopen ( filename.c_str (), "wb" );
|
||||||
|
if ( out == NULL )
|
||||||
|
throw AccessDeniedException ( filename );
|
||||||
|
fputs ( outbuf, out );
|
||||||
|
fclose ( out );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek ( out, 0, SEEK_END );
|
||||||
|
end = ftell ( out );
|
||||||
|
cmpbuf = (char*) malloc ( end );
|
||||||
|
if ( cmpbuf == NULL )
|
||||||
|
{
|
||||||
|
fclose ( out );
|
||||||
|
throw OutOfMemoryException ();
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek ( out, 0, SEEK_SET );
|
||||||
|
stat = fread ( cmpbuf, 1, end, out );
|
||||||
|
if ( stat != end )
|
||||||
|
{
|
||||||
|
free ( cmpbuf );
|
||||||
|
fclose ( out );
|
||||||
|
throw AccessDeniedException ( filename );
|
||||||
|
}
|
||||||
|
if ( end == strlen ( outbuf ) && memcmp ( cmpbuf, outbuf, end ) == 0 )
|
||||||
|
{
|
||||||
|
free ( cmpbuf );
|
||||||
|
fclose ( out );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free ( cmpbuf );
|
||||||
|
fclose ( out );
|
||||||
|
out = fopen ( filename.c_str (), "wb" );
|
||||||
|
if ( out == NULL )
|
||||||
|
{
|
||||||
|
throw AccessDeniedException ( filename );
|
||||||
|
}
|
||||||
|
|
||||||
|
stat = fwrite ( outbuf, 1, strlen ( outbuf ), out);
|
||||||
|
if ( strlen ( outbuf ) != stat )
|
||||||
|
{
|
||||||
|
fclose ( out );
|
||||||
|
throw AccessDeniedException ( filename );
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose ( out );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Project::SetConfigurationOption ( char* s,
|
||||||
|
string name,
|
||||||
|
string* alternativeName )
|
||||||
|
{
|
||||||
|
const Property* property = LookupProperty ( name );
|
||||||
|
if ( property != NULL && property->value.length () > 0 )
|
||||||
|
{
|
||||||
|
s = s + sprintf ( s,
|
||||||
|
"#define %s=%s\n",
|
||||||
|
property->name.c_str (),
|
||||||
|
property->value.c_str () );
|
||||||
|
}
|
||||||
|
else if ( property != NULL )
|
||||||
|
{
|
||||||
|
s = s + sprintf ( s,
|
||||||
|
"#define %s\n",
|
||||||
|
property->name.c_str () );
|
||||||
|
}
|
||||||
|
else if ( alternativeName != NULL )
|
||||||
|
{
|
||||||
|
s = s + sprintf ( s,
|
||||||
|
"#define %s\n",
|
||||||
|
alternativeName->c_str () );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Project::SetConfigurationOption ( char* s,
|
||||||
|
string name )
|
||||||
|
{
|
||||||
|
SetConfigurationOption ( s, name, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Project::WriteConfigurationFile ()
|
||||||
|
{
|
||||||
|
char* buf;
|
||||||
|
char* s;
|
||||||
|
|
||||||
|
buf = (char*) malloc ( 10*1024 );
|
||||||
|
if ( buf == NULL )
|
||||||
|
throw OutOfMemoryException ();
|
||||||
|
|
||||||
|
s = buf;
|
||||||
|
s = s + sprintf ( s, "/* Automatically generated. " );
|
||||||
|
s = s + sprintf ( s, "Edit config.xml to change configuration */\n" );
|
||||||
|
s = s + sprintf ( s, "#ifndef __INCLUDE_CONFIG_H\n" );
|
||||||
|
s = s + sprintf ( s, "#define __INCLUDE_CONFIG_H\n" );
|
||||||
|
|
||||||
|
SetConfigurationOption ( s, "ARCH" );
|
||||||
|
SetConfigurationOption ( s, "OPTIMIZED" );
|
||||||
|
SetConfigurationOption ( s, "MP", new string ( "UP" ) );
|
||||||
|
SetConfigurationOption ( s, "ACPI" );
|
||||||
|
SetConfigurationOption ( s, "_3GB" );
|
||||||
|
|
||||||
|
s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" );
|
||||||
|
|
||||||
|
WriteIfChanged ( buf, "include" SSEP "roscfg.h" );
|
||||||
|
|
||||||
|
free ( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Project::ExecuteInvocations ()
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < modules.size (); i++ )
|
||||||
|
modules[i]->InvokeModule ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Project::ReadXml ()
|
||||||
{
|
{
|
||||||
Path path;
|
Path path;
|
||||||
head = XMLLoadFile ( xmlfile, path );
|
head = XMLLoadFile ( xmlfile, path );
|
||||||
node = NULL;
|
node = NULL;
|
||||||
for ( size_t i = 0; i < head->subElements.size(); i++ )
|
for ( size_t i = 0; i < head->subElements.size (); i++ )
|
||||||
{
|
{
|
||||||
if ( head->subElements[i]->name == "project" )
|
if ( head->subElements[i]->name == "project" )
|
||||||
{
|
{
|
||||||
|
@ -189,7 +328,7 @@ Project::LocateModule ( const string& name ) const
|
||||||
{
|
{
|
||||||
for ( size_t i = 0; i < modules.size (); i++ )
|
for ( size_t i = 0; i < modules.size (); i++ )
|
||||||
{
|
{
|
||||||
if (modules[i]->name == name)
|
if ( modules[i]->name == name )
|
||||||
return modules[i];
|
return modules[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ main ( int argc, char** argv )
|
||||||
{
|
{
|
||||||
string projectFilename ( "ReactOS.xml" );
|
string projectFilename ( "ReactOS.xml" );
|
||||||
Project project ( projectFilename );
|
Project project ( projectFilename );
|
||||||
|
project.WriteConfigurationFile ();
|
||||||
|
project.ExecuteInvocations ();
|
||||||
Backend* backend = Backend::Factory::Create ( buildtarget,
|
Backend* backend = Backend::Factory::Create ( buildtarget,
|
||||||
project );
|
project );
|
||||||
backend->Process ();
|
backend->Process ();
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
#else
|
#else
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
#include <process.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ssprintf.h"
|
#include "ssprintf.h"
|
||||||
|
@ -67,10 +68,20 @@ public:
|
||||||
|
|
||||||
Project ( const std::string& filename );
|
Project ( const std::string& filename );
|
||||||
~Project ();
|
~Project ();
|
||||||
|
void WriteConfigurationFile ();
|
||||||
|
void ExecuteInvocations ();
|
||||||
void ProcessXML ( const std::string& path );
|
void ProcessXML ( const std::string& path );
|
||||||
Module* LocateModule ( const std::string& name );
|
Module* LocateModule ( const std::string& name );
|
||||||
const Module* LocateModule ( const std::string& name ) const;
|
const Module* LocateModule ( const std::string& name ) const;
|
||||||
private:
|
private:
|
||||||
|
const Property* LookupProperty ( const std::string& name ) const;
|
||||||
|
void SetConfigurationOption ( char* s,
|
||||||
|
std::string name,
|
||||||
|
std::string* alternativeName );
|
||||||
|
void SetConfigurationOption ( char* s,
|
||||||
|
std::string name );
|
||||||
|
void WriteIfChanged ( char* outbuf,
|
||||||
|
std::string filename );
|
||||||
void ReadXml ();
|
void ReadXml ();
|
||||||
void ProcessXMLSubElement ( const XMLElement& e,
|
void ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
|
@ -139,7 +150,8 @@ public:
|
||||||
std::string GetInvocationTarget ( const int index ) const;
|
std::string GetInvocationTarget ( const int index ) const;
|
||||||
bool HasFileWithExtensions ( const std::string& extension1,
|
bool HasFileWithExtensions ( const std::string& extension1,
|
||||||
const std::string& extension2 ) const;
|
const std::string& extension2 ) const;
|
||||||
void ProcessXML();
|
void InvokeModule () const;
|
||||||
|
void ProcessXML ();
|
||||||
private:
|
private:
|
||||||
std::string GetDefaultModuleExtension () const;
|
std::string GetDefaultModuleExtension () const;
|
||||||
std::string GetDefaultModuleEntrypoint () const;
|
std::string GetDefaultModuleEntrypoint () const;
|
||||||
|
@ -232,6 +244,7 @@ public:
|
||||||
|
|
||||||
void ProcessXML();
|
void ProcessXML();
|
||||||
std::string GetTargets () const;
|
std::string GetTargets () const;
|
||||||
|
std::string GetParameters () const;
|
||||||
private:
|
private:
|
||||||
void ProcessXMLSubElement ( const XMLElement& e );
|
void ProcessXMLSubElement ( const XMLElement& e );
|
||||||
void ProcessXMLSubElementInput ( const XMLElement& e );
|
void ProcessXMLSubElementInput ( const XMLElement& e );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue