Author: hpoussin
Date: Tue Aug 7 19:08:09 2007
New Revision: 28218
URL:
http://svn.reactos.org/svn/reactos?rev=28218&view=rev
Log:
Support absolute paths for intermediate/output directories
Never put real intermediate/output directory names in generated makefile, use
$(INTERMEDIATE) and $(OUTPUT) instead
Modified:
trunk/reactos/tools/rbuild/automaticdependency.cpp
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
trunk/reactos/tools/rbuild/compilationunit.cpp
trunk/reactos/tools/rbuild/directory.cpp
trunk/reactos/tools/rbuild/installfile.cpp
trunk/reactos/tools/rbuild/module.cpp
trunk/reactos/tools/rbuild/project.cpp
trunk/reactos/tools/rbuild/rbuild.h
trunk/reactos/tools/rbuild/wineresource.cpp
Modified: trunk/reactos/tools/rbuild/automaticdependency.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/automaticdepe…
==============================================================================
--- trunk/reactos/tools/rbuild/automaticdependency.cpp (original)
+++ trunk/reactos/tools/rbuild/automaticdependency.cpp Tue Aug 7 19:08:09 2007
@@ -336,10 +336,31 @@
AutomaticDependency::ParseFile ( const Module& module,
const File& file )
{
- string normalizedFilename = NormalizeFilename ( file.name );
+ string normalizedFilename = NormalizeFilename ( file.GetFullPath () );
RetrieveFromCacheOrParse ( module,
normalizedFilename,
NULL );
+}
+
+string
+AutomaticDependency::ReplaceVariable ( const string& name,
+ const string& value,
+ string path )
+{
+ size_t i = path.find ( name );
+ if ( i != string::npos )
+ return path.replace ( i, name.length (), value );
+ else
+ return path;
+}
+
+string
+AutomaticDependency::ResolveVariablesInPath ( const string& path )
+{
+ string s = ReplaceVariable ( "$(INTERMEDIATE)",
Environment::GetIntermediatePath (), path );
+ s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
+ s = ReplaceVariable ( "$(INSTALL)", Environment::GetInstallPath (), s );
+ return s;
}
bool
@@ -423,7 +444,7 @@
{
sourceFile = new SourceFile ( this,
module,
- filename,
+ ResolveVariablesInPath ( filename ),
parentSourceFile,
false );
sourcefile_map[filename] = sourceFile;
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Tue Aug 7 19:08:09 2007
@@ -766,7 +766,7 @@
char separators[] = " ";
char *token;
char *prevtoken = NULL;
-
+
string version;
token = strtok ( buffer, separators );
@@ -865,11 +865,11 @@
}
buffer[i] = '\0';
pclose ( fp );
-
+
char separators[] = " ";
char *token;
char *prevtoken = NULL;
-
+
token = strtok ( buffer, separators );
while ( token != NULL )
{
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Tue Aug 7 19:08:09 2007
@@ -466,7 +466,7 @@
FileLocation* sourceFileLocation = GetActualSourceFilename (
compilationUnits[i]->GetFilename ( backend->intermediateDirectory ) );
list.push_back ( PassThruCacheDirectory ( sourceFileLocation->filename,
- sourceFileLocation->directory )
);
+ sourceFileLocation->directory ) );
}
}
// intentionally make a copy so that we can append more work in
@@ -693,9 +693,9 @@
if ( parameters.length () > 0 )
parameters += " ";
if ( include.root == "intermediate" )
- path_prefix = backend->intermediateDirectory->name + cSep;
+ path_prefix = "$(INTERMEDIATE)" + sSep;
else if (include.root == "output" )
- path_prefix = backend->outputDirectory->name + cSep;
+ path_prefix = "$(OUTPUT)" + sSep;
else
path_prefix = "";
@@ -811,14 +811,14 @@
include.baseModule->type == RpcClient ||
include.baseModule->type == IdlHeader) )
includeDirectory = PassThruCacheDirectory ( NormalizeFilename ( include.directory ),
-
backend->intermediateDirectory );
+ backend->intermediateDirectory );
else
includeDirectory = include.directory;
if ( include.root == "intermediate" )
- path_prefix = backend->intermediateDirectory->name + cSep;
+ path_prefix = "$(INTERMEDIATE)" + sSep;
else if (include.root == "output" )
- path_prefix = backend->outputDirectory->name + cSep;
+ path_prefix = "$(OUTPUT)" + sSep;
else
path_prefix = "";
@@ -1281,13 +1281,12 @@
GetDirectory ( EmbeddedTypeLibFilename ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
fprintf ( fMakefile,
- //"\t%s %s %s -t -T $@ %s\n",
- "\t%s %s %s -t -T %s %s\n",
+ "\t%s %s %s -t -T %s %s\n",
"$(Q)$(WIDL_TARGET)",
GetWidlFlags ( compilationUnit ).c_str (),
widlflagsMacro.c_str (),
- EmbeddedTypeLibFilename.c_str(),
- filename.c_str () );
+ EmbeddedTypeLibFilename.c_str(),
+ filename.c_str () );
}
void
@@ -2003,8 +2002,9 @@
fprintf (
fMakefile,
- "%s += $(PROJECT_WIDLFLAGS)\n",
- widlflagsMacro.c_str () );
+ "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
+ widlflagsMacro.c_str (),
+ module.GetBasePath ().c_str () );
fprintf (
fMakefile,
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h Tue Aug 7 19:08:09 2007
@@ -98,7 +98,7 @@
void GetModuleDependencies ( string_list& dependencies );
std::string GetAllDependencies () const;
void GetSourceFilenames ( string_list& list,
- bool includeGeneratedFiles ) const;
+ bool includeGeneratedFiles ) const;
void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list ) const;
std::string GetObjectFilename ( const FileLocation* sourceFileLocation,
string_list* pclean_files ) const;
@@ -213,7 +213,7 @@
void GetRpcHeaderDependencies ( std::vector<std::string>& dependencies )
const;
std::string GetRpcServerHeaderFilename ( std::string basename ) const;
std::string GetRpcClientHeaderFilename ( std::string basename ) const;
- std::string GetIdlHeaderFilename ( std::string basename ) const;
+ std::string GetIdlHeaderFilename ( std::string basename ) const;
std::string GetModuleCleanTarget ( const Module& module ) const;
void GetReferencedObjectLibraryModuleCleanTargets ( std::vector<std::string>&
moduleNames ) const;
public:
@@ -334,8 +334,8 @@
MingwWin32DLLModuleHandler ( const Module& module );
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
- std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
- void AddImplicitLibraries ( Module& module );
+ std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
+ void AddImplicitLibraries ( Module& module );
private:
void GenerateWin32DLLModuleTarget ();
};
@@ -347,8 +347,8 @@
MingwWin32OCXModuleHandler ( const Module& module );
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
- std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
- void AddImplicitLibraries ( Module& module );
+ std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
+ void AddImplicitLibraries ( Module& module );
private:
void GenerateWin32OCXModuleTarget ();
};
@@ -361,7 +361,7 @@
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
- void AddImplicitLibraries ( Module& module );
+ void AddImplicitLibraries ( Module& module );
private:
void GenerateWin32CUIModuleTarget ();
};
@@ -374,7 +374,7 @@
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
std::string TypeSpecificLinkerFlags() { return module.useHostStdlib ?
"-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
- void AddImplicitLibraries ( Module& module );
+ void AddImplicitLibraries ( Module& module );
private:
void GenerateWin32GUIModuleTarget ();
};
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationun…
==============================================================================
--- trunk/reactos/tools/rbuild/compilationunit.cpp (original)
+++ trunk/reactos/tools/rbuild/compilationunit.cpp Tue Aug 7 19:08:09 2007
@@ -98,7 +98,10 @@
if ( files.size () == 0 || files.size () > 1 )
return new FileLocation ( intermediateDirectory, name );
File* file = files[0];
- return new FileLocation ( NULL, file->name );
+ if (file->path_prefix.length() > 0)
+ return new FileLocation ( intermediateDirectory, file->name );
+ else
+ return new FileLocation ( NULL, file->name );
}
std::string
Modified: trunk/reactos/tools/rbuild/directory.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/directory.cpp…
==============================================================================
--- trunk/reactos/tools/rbuild/directory.cpp (original)
+++ trunk/reactos/tools/rbuild/directory.cpp Tue Aug 7 19:08:09 2007
@@ -53,6 +53,14 @@
}
const char* p = strpbrk ( subdir, "/\\" );
+ if ( subdir == p || ( *subdir && subdir[1] == ':' ) )
+ {
+ throw InvalidOperationException ( __FILE__,
+ __LINE__,
+ "Invalid relative path '%s'",
+ subdir );
+ }
+
if ( !p )
p = subdir + strlen(subdir);
string s ( subdir, p-subdir );
@@ -109,8 +117,8 @@
}
string
-Directory::ReplaceVariable ( string name,
- string value,
+Directory::ReplaceVariable ( const string& name,
+ const string& value,
string path )
{
size_t i = path.find ( name );
@@ -122,7 +130,7 @@
void
Directory::ResolveVariablesInPath ( char* buf,
- string path )
+ const string& path )
{
string s = ReplaceVariable ( "$(INTERMEDIATE)",
Environment::GetIntermediatePath (), path );
s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
@@ -140,7 +148,10 @@
{
char buf[256];
- path = parent + sSep + name;
+ if ( name.size () > 0 )
+ path = parent + sSep + name;
+ else
+ path = parent;
ResolveVariablesInPath ( buf, path );
if ( CreateDirectory ( buf ) && verbose )
printf ( "Created %s\n", buf );
Modified: trunk/reactos/tools/rbuild/installfile.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/installfile.c…
==============================================================================
--- trunk/reactos/tools/rbuild/installfile.cpp (original)
+++ trunk/reactos/tools/rbuild/installfile.cpp Tue Aug 7 19:08:09 2007
@@ -45,9 +45,9 @@
if ( att != NULL)
{
if ( att->value == "intermediate" )
- this->path = Environment::GetIntermediatePath () + sSep + path;
+ this->path = "$(INTERMEDIATE)" + sSep + path;
else if ( att->value == "output" )
- this->path = Environment::GetOutputPath () + sSep + path;
+ this->path = "$(OUTPUT)" + sSep + path;
else
{
throw InvalidAttributeValueException (
Modified: trunk/reactos/tools/rbuild/module.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?re…
==============================================================================
--- trunk/reactos/tools/rbuild/module.cpp (original)
+++ trunk/reactos/tools/rbuild/module.cpp Tue Aug 7 19:08:09 2007
@@ -121,7 +121,6 @@
const Project& project,
const string& location,
const string& path,
- const XMLAttribute* root,
const string& att_value )
{
if ( !att_value.size() )
@@ -135,25 +134,7 @@
if ( !path.size() )
return att_value;
- string path_prefix;
- if ( root )
- {
- if ( root->value == "intermediate" )
- path_prefix = Environment::GetIntermediatePath() + cSep;
- else if ( root->value == "output" )
- path_prefix = Environment::GetOutputPath() + cSep;
- else
- {
- throw InvalidAttributeValueException (
- location,
- "root",
- root->value );
- }
- }
- else
- path_prefix = "";
-
- return FixSeparator(path_prefix + path + cSep + att_value);
+ return FixSeparator(path + cSep + att_value);
}
string
@@ -540,7 +521,7 @@
for ( i = 0; i < node.subElements.size(); i++ )
{
ParseContext parseContext;
- ProcessXMLSubElement ( *node.subElements[i], path, parseContext );
+ ProcessXMLSubElement ( *node.subElements[i], path, "", parseContext );
}
for ( i = 0; i < invocations.size(); i++ )
invocations[i]->ProcessXML ();
@@ -564,12 +545,14 @@
void
Module::ProcessXMLSubElement ( const XMLElement& e,
const string& path,
+ const string& path_prefix,
ParseContext& parseContext )
{
If* pOldIf = parseContext.ifData;
CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
bool subs_invalid = false;
string subpath ( path );
+ string subpath_prefix ( "" );
if ( e.name == "file" && e.value.size () > 0 )
{
bool first = false;
@@ -601,6 +584,7 @@
cplusplus = true;
}
File* pFile = new File ( FixSeparator ( path + cSep + e.value ),
+ path_prefix,
first,
switches,
false );
@@ -638,9 +622,23 @@
else if ( e.name == "directory" )
{
const XMLAttribute* att = e.GetAttribute ( "name", true );
- const XMLAttribute* base = e.GetAttribute ( "root", false );
+ const XMLAttribute* root = e.GetAttribute ( "root", false );
assert(att);
- subpath = GetSubPath ( this->project, e.location, path, base, att->value );
+ if ( root )
+ {
+ if ( root->value == "intermediate" )
+ subpath_prefix = "$(INTERMEDIATE)";
+ else if ( root->value == "output" )
+ subpath_prefix = "$(OUTPUT)";
+ else
+ {
+ throw InvalidAttributeValueException (
+ e.location,
+ "root",
+ root->value );
+ }
+ }
+ subpath = GetSubPath ( this->project, e.location, path, att->value );
}
else if ( e.name == "include" )
{
@@ -809,7 +807,7 @@
e.name.c_str() );
}
for ( size_t i = 0; i < e.subElements.size (); i++ )
- ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
+ ProcessXMLSubElement ( *e.subElements[i], subpath, subpath_prefix, parseContext );
parseContext.ifData = pOldIf;
parseContext.compilationUnit = pOldCompilationUnit;
}
@@ -1206,19 +1204,44 @@
}
-File::File ( const string& _name, bool _first,
+File::File ( const string& _name,
+ bool _first,
std::string _switches,
bool _isPreCompiledHeader )
: name(_name),
+ path_prefix(""),
first(_first),
switches(_switches),
isPreCompiledHeader(_isPreCompiledHeader)
{
}
+
+File::File ( const string& _name,
+ const string& _path_prefix,
+ bool _first,
+ std::string _switches,
+ bool _isPreCompiledHeader )
+ : name(_name),
+ path_prefix(_path_prefix),
+ first(_first),
+ switches(_switches),
+ isPreCompiledHeader(_isPreCompiledHeader)
+{
+}
+
void
File::ProcessXML()
{
+}
+
+
+std::string File::GetFullPath () const
+{
+ if ( path_prefix.length () > 0 )
+ return path_prefix + sSep + name;
+ else
+ return name;
}
Modified: trunk/reactos/tools/rbuild/project.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/project.cpp?r…
==============================================================================
--- trunk/reactos/tools/rbuild/project.cpp (original)
+++ trunk/reactos/tools/rbuild/project.cpp Tue Aug 7 19:08:09 2007
@@ -391,9 +391,8 @@
else if ( e.name == "directory" )
{
const XMLAttribute* att = e.GetAttribute ( "name", true );
- const XMLAttribute* base = e.GetAttribute ( "root", false );
assert(att);
- subpath = GetSubPath ( *this, e.location, path, base, att->value );
+ subpath = GetSubPath ( *this, e.location, path, att->value );
}
else if ( e.name == "include" )
{
Modified: trunk/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=…
==============================================================================
--- trunk/reactos/tools/rbuild/rbuild.h (original)
+++ trunk/reactos/tools/rbuild/rbuild.h Tue Aug 7 19:08:09 2007
@@ -119,12 +119,12 @@
const std::string& parent );
private:
bool mkdir_p ( const char* path );
- std::string ReplaceVariable ( std::string name,
- std::string value,
+ std::string ReplaceVariable ( const std::string& name,
+ const std::string& value,
std::string path );
std::string GetEnvironmentVariable ( const std::string& name );
void ResolveVariablesInPath ( char* buf,
- std::string path );
+ const std::string& path );
bool CreateDirectory ( std::string path );
};
@@ -354,6 +354,7 @@
std::string entrypoint;
void ProcessXMLSubElement ( const XMLElement& e,
const std::string& path,
+ const std::string& path_prefix,
ParseContext& parseContext );
};
@@ -388,10 +389,10 @@
public:
const Project& project;
const Module* module;
- const XMLElement* node;
+ const XMLElement* node;
std::string name;
std::string value;
- std::string backend;
+ std::string backend;
Define ( const Project& project,
const XMLElement& defineNode );
@@ -413,6 +414,7 @@
{
public:
std::string name;
+ std::string path_prefix;
bool first;
std::string switches;
bool isPreCompiledHeader;
@@ -422,7 +424,14 @@
std::string _switches,
bool _isPreCompiledHeader );
- void ProcessXML();
+ File ( const std::string& _name,
+ const std::string& _path_prefix,
+ bool _first,
+ std::string _switches,
+ bool _isPreCompiledHeader );
+
+ void ProcessXML();
+ std::string GetFullPath () const;
};
@@ -629,11 +638,11 @@
void WriteHooksFile ( Module& module );
std::string GetStubsFilename ( Module& module );
char* WriteStubbedSymbolToStubsFile ( char* buffer,
- const StubbedComponent& component,
+ const StubbedComponent& component,
const StubbedSymbol& symbol,
int stubIndex );
char* WriteStubbedComponentToStubsFile ( char* buffer,
- const StubbedComponent& component,
+ const StubbedComponent& component,
int* stubIndex );
void WriteStubsFile ( Module& module );
std::string GetStartupFilename ( Module& module );
@@ -641,9 +650,9 @@
std::string GetTestDispatcherName ( std::string filename );
bool IsTestFile ( std::string& filename ) const;
void GetSourceFilenames ( string_list& list,
- Module& module ) const;
+ Module& module ) const;
char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
- Module& module );
+ Module& module );
char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
Module& module );
void WriteStartupFile ( Module& module );
@@ -740,18 +749,22 @@
private:
void GetModulesToCheck ( Module& module, std::vector<const Module*>&
modules );
void CheckAutomaticDependencies ( const Module& module,
- bool verbose );
+ bool verbose );
void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
void GetIncludeDirectories ( std::vector<Include*>& includes,
const Module& module,
- Include& currentDirectory,
- bool searchCurrentDirectory );
+ Include& currentDirectory,
+ bool searchCurrentDirectory );
void GetModuleFiles ( const Module& module,
- std::vector<File*>& files ) const;
+ std::vector<File*>& files ) const;
void ParseFiles ();
void ParseFiles ( const Module& module );
void ParseFile ( const Module& module,
const File& file );
+ std::string ReplaceVariable ( const std::string& name,
+ const std::string& value,
+ std::string path );
+ std::string ResolveVariablesInPath ( const std::string& path );
std::map<std::string, SourceFile*> sourcefile_map;
};
@@ -994,7 +1007,6 @@
const Project& project,
const std::string& location,
const std::string& path,
- const XMLAttribute* root,
const std::string& att_value );
extern std::string
Modified: trunk/reactos/tools/rbuild/wineresource.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/wineresource.…
==============================================================================
--- trunk/reactos/tools/rbuild/wineresource.cpp (original)
+++ trunk/reactos/tools/rbuild/wineresource.cpp Tue Aug 7 19:08:09 2007
@@ -111,7 +111,7 @@
NormalizeFilename ( resourceFilename ).c_str () );
string command = FixSeparatorForSystemCommand(bin2res) + " " + parameters;
- Directory( outputDirectory ).GenerateTree( ".", false );
+ Directory( relativeDirectory ).GenerateTree( Environment::GetIntermediatePath(), false
);
int exitcode = system ( command.c_str () );
if ( exitcode != 0 )