Have the object files of a module depend on the build file that contain the module

svn path=/branches/xmlbuildsystem/; revision=14591
This commit is contained in:
Casper Hornstrup 2005-04-11 18:45:48 +00:00
parent fb03ace091
commit 1c89a135da
5 changed files with 51 additions and 26 deletions

View file

@ -339,9 +339,11 @@ XMLAttribute& XMLAttribute::operator = ( const XMLAttribute& src )
return *this; return *this;
} }
XMLElement::XMLElement ( const string& location_ ) XMLElement::XMLElement ( XMLFile* xmlFile,
: location(location_), const string& location )
parentElement(NULL) : xmlFile ( xmlFile ),
location ( location ),
parentElement ( NULL )
{ {
} }
@ -517,7 +519,8 @@ XMLParse ( XMLFile& f,
return NULL; return NULL;
} }
XMLElement* e = new XMLElement ( f.Location () ); XMLElement* e = new XMLElement ( &f,
f.Location () );
bool bNeedEnd = e->Parse ( token, end_tag ); bool bNeedEnd = e->Parse ( token, end_tag );
if ( e->name == "xi:include" && includes ) if ( e->name == "xi:include" && includes )
@ -634,8 +637,8 @@ XMLLoadInclude ( XMLInclude& include,
string file ( include.path.Fixup(att->value, true) ); string file ( include.path.Fixup(att->value, true) );
string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); string top_file ( Path::RelativeFromWorkingDirectory ( file ) );
include.e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); include.e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) );
XMLFile fInc; XMLFile* fInc = new XMLFile();
if ( !fInc.open ( file ) ) if ( !fInc->open ( file ) )
{ {
include.fileExists = false; include.fileExists = false;
// look for xi:fallback element // look for xi:fallback element
@ -669,10 +672,11 @@ XMLLoadInclude ( XMLInclude& include,
else else
{ {
include.fileExists = true; include.fileExists = true;
XMLElement* new_e = new XMLElement ( include.e->location ); XMLElement* new_e = new XMLElement ( fInc,
include.e->location );
new_e->name = "xi:included"; new_e->name = "xi:included";
Path path2 ( include.path, att->value ); Path path2 ( include.path, att->value );
XMLReadFile ( fInc, *new_e, includes, path2 ); XMLReadFile ( *fInc, *new_e, includes, path2 );
return new_e; return new_e;
} }
} }
@ -682,14 +686,15 @@ XMLLoadFile ( const string& filename,
const Path& path, const Path& path,
XMLIncludes& includes ) XMLIncludes& includes )
{ {
XMLFile f; XMLFile* f = new XMLFile();
if ( !f.open ( filename ) ) if ( !f->open ( filename ) )
throw FileNotFoundException ( filename ); throw FileNotFoundException ( filename );
XMLElement* head = new XMLElement ( "(virtual)" ); XMLElement* head = new XMLElement ( f,
"(virtual)" );
XMLReadFile ( f, *head, includes, path ); XMLReadFile ( *f, *head, includes, path );
for ( size_t i = 0; i < includes.size (); i++ ) for ( size_t i = 0; i < includes.size (); i++ )
{ {
@ -700,7 +705,7 @@ XMLLoadFile ( const string& filename,
throw FileNotFoundException ( throw FileNotFoundException (
ssprintf ( "%s (referenced from %s)", ssprintf ( "%s (referenced from %s)",
e->GetAttribute ( "top_href", true )->value.c_str (), e->GetAttribute ( "top_href", true )->value.c_str (),
f.Location ().c_str () ) ); f->Location ().c_str () ) );
} }
XMLElement* parent = e->parentElement; XMLElement* parent = e->parentElement;
XMLElement** parent_container = NULL; XMLElement** parent_container = NULL;

View file

@ -88,6 +88,7 @@ public:
class XMLElement class XMLElement
{ {
public: public:
XMLFile* xmlFile;
std::string location; std::string location;
std::string name; std::string name;
std::vector<XMLAttribute*> attributes; std::vector<XMLAttribute*> attributes;
@ -95,7 +96,8 @@ public:
std::vector<XMLElement*> subElements; std::vector<XMLElement*> subElements;
std::string value; std::string value;
XMLElement ( const std::string& location_ ); XMLElement ( XMLFile* xmlFile,
const std::string& location );
~XMLElement(); ~XMLElement();
bool Parse(const std::string& token, bool Parse(const std::string& token,
bool& end_tag); bool& end_tag);

View file

@ -786,19 +786,20 @@ MingwModuleHandler::GenerateGccCommand (
const string& cc, const string& cc,
const string& cflagsMacro ) const string& cflagsMacro )
{ {
string deps = sourceFilename; string dependencies = sourceFilename;
if ( module.pch && use_pch ) if ( module.pch && use_pch )
deps += " " + module.pch->header + ".gch"; dependencies += " " + module.pch->header + ".gch";
/* WIDL generated headers may be used */ /* WIDL generated headers may be used */
deps += " " + GetLinkingDependenciesMacro (); dependencies += " " + GetLinkingDependenciesMacro ();
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename ( string objectFilename = GetObjectFilename (
sourceFilename, &clean_files ); sourceFilename, &clean_files );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s | %s\n", "%s: %s | %s\n",
objectFilename.c_str (), objectFilename.c_str (),
deps.c_str (), dependencies.c_str (),
GetDirectory ( objectFilename ).c_str () ); GetDirectory ( objectFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_CC)\n" ); fprintf ( fMakefile, "\t$(ECHO_CC)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -813,12 +814,14 @@ MingwModuleHandler::GenerateGccAssemblerCommand (
const string& cc, const string& cc,
const string& cflagsMacro ) const string& cflagsMacro )
{ {
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename ( string objectFilename = GetObjectFilename (
sourceFilename, &clean_files ); sourceFilename, &clean_files );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s | %s\n", "%s: %s | %s\n",
objectFilename.c_str (), objectFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( objectFilename ).c_str () ); GetDirectory ( objectFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_GAS)\n" ); fprintf ( fMakefile, "\t$(ECHO_GAS)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -832,12 +835,14 @@ MingwModuleHandler::GenerateNasmCommand (
const string& sourceFilename, const string& sourceFilename,
const string& nasmflagsMacro ) const string& nasmflagsMacro )
{ {
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = GetObjectFilename ( string objectFilename = GetObjectFilename (
sourceFilename, &clean_files ); sourceFilename, &clean_files );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s | %s\n", "%s: %s | %s\n",
objectFilename.c_str (), objectFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( objectFilename ).c_str () ); GetDirectory ( objectFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_NASM)\n" ); fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -851,6 +856,8 @@ MingwModuleHandler::GenerateWindresCommand (
const string& sourceFilename, const string& sourceFilename,
const string& windresflagsMacro ) const string& windresflagsMacro )
{ {
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string objectFilename = string objectFilename =
GetObjectFilename ( sourceFilename, &clean_files ); GetObjectFilename ( sourceFilename, &clean_files );
string rciFilename = ros_temp + string rciFilename = ros_temp +
@ -862,7 +869,7 @@ MingwModuleHandler::GenerateWindresCommand (
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s $(WRC_TARGET) | %s\n", "%s: %s $(WRC_TARGET) | %s\n",
objectFilename.c_str (), objectFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( objectFilename ).c_str () ); GetDirectory ( objectFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -890,7 +897,7 @@ MingwModuleHandler::GenerateWindresCommand (
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s $(WRC_TARGET) | %s\n", "%s: %s $(WRC_TARGET) | %s\n",
objectFilename.c_str (), objectFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( objectFilename ).c_str () ); GetDirectory ( objectFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -904,8 +911,10 @@ void
MingwModuleHandler::GenerateWinebuildCommands ( MingwModuleHandler::GenerateWinebuildCommands (
const string& sourceFilename ) const string& sourceFilename )
{ {
string basename = GetBasename ( sourceFilename ); string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string basename = GetBasename ( sourceFilename );
string def_file = PassThruCacheDirectory ( string def_file = PassThruCacheDirectory (
basename + ".spec.def", basename + ".spec.def",
backend->intermediateDirectory ); backend->intermediateDirectory );
@ -919,7 +928,7 @@ MingwModuleHandler::GenerateWinebuildCommands (
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s $(WINEBUILD_TARGET)\n", "%s: %s $(WINEBUILD_TARGET)\n",
def_file.c_str (), def_file.c_str (),
sourceFilename.c_str () ); dependencies.c_str () );
fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" ); fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t%s --def=%s -o %s\n", "\t%s --def=%s -o %s\n",
@ -944,6 +953,9 @@ MingwModuleHandler::GenerateWidlCommandsServer (
const string& sourceFilename, const string& sourceFilename,
const string& widlflagsMacro ) const string& widlflagsMacro )
{ {
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string basename = GetBasename ( sourceFilename ); string basename = GetBasename ( sourceFilename );
/*string generatedHeaderFilename = PassThruCacheDirectory ( /*string generatedHeaderFilename = PassThruCacheDirectory (
@ -963,7 +975,7 @@ MingwModuleHandler::GenerateWidlCommandsServer (
"%s %s: %s $(WIDL_TARGET) | %s\n", "%s %s: %s $(WIDL_TARGET) | %s\n",
generatedServerFilename.c_str (), generatedServerFilename.c_str (),
generatedHeaderFilename.c_str (), generatedHeaderFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( generatedServerFilename ).c_str () ); GetDirectory ( generatedServerFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
@ -980,6 +992,9 @@ MingwModuleHandler::GenerateWidlCommandsClient (
const string& sourceFilename, const string& sourceFilename,
const string& widlflagsMacro ) const string& widlflagsMacro )
{ {
string dependencies = sourceFilename;
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
string basename = GetBasename ( sourceFilename ); string basename = GetBasename ( sourceFilename );
/*string generatedHeaderFilename = PassThruCacheDirectory ( /*string generatedHeaderFilename = PassThruCacheDirectory (
@ -999,7 +1014,7 @@ MingwModuleHandler::GenerateWidlCommandsClient (
"%s %s: %s $(WIDL_TARGET) | %s\n", "%s %s: %s $(WIDL_TARGET) | %s\n",
generatedClientFilename.c_str (), generatedClientFilename.c_str (),
generatedHeaderFilename.c_str (), generatedHeaderFilename.c_str (),
sourceFilename.c_str (), dependencies.c_str (),
GetDirectory ( generatedClientFilename ).c_str () ); GetDirectory ( generatedClientFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,

View file

@ -137,6 +137,8 @@ Module::Module ( const Project& project,
__LINE__, __LINE__,
"Module created with non-<module> node" ); "Module created with non-<module> node" );
xmlbuildFile = Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename() );
path = FixSeparator ( modulePath ); path = FixSeparator ( modulePath );
const XMLAttribute* att = moduleNode.GetAttribute ( "name", true ); const XMLAttribute* att = moduleNode.GetAttribute ( "name", true );

View file

@ -154,6 +154,7 @@ class Module
public: public:
const Project& project; const Project& project;
const XMLElement& node; const XMLElement& node;
std::string xmlbuildFile;
std::string name; std::string name;
std::string extension; std::string extension;
std::string entrypoint; std::string entrypoint;