mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 13:45:58 +00:00
Support absolute paths for intermediate/output directories
Never put real intermediate/output directory names in generated makefile, use $(INTERMEDIATE) and $(OUTPUT) instead svn path=/trunk/; revision=28218
This commit is contained in:
parent
ebb26326a5
commit
434e1ef9df
|
@ -336,12 +336,33 @@ void
|
||||||
AutomaticDependency::ParseFile ( const Module& module,
|
AutomaticDependency::ParseFile ( const Module& module,
|
||||||
const File& file )
|
const File& file )
|
||||||
{
|
{
|
||||||
string normalizedFilename = NormalizeFilename ( file.name );
|
string normalizedFilename = NormalizeFilename ( file.GetFullPath () );
|
||||||
RetrieveFromCacheOrParse ( module,
|
RetrieveFromCacheOrParse ( module,
|
||||||
normalizedFilename,
|
normalizedFilename,
|
||||||
NULL );
|
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
|
bool
|
||||||
AutomaticDependency::LocateIncludedFile ( const string& directory,
|
AutomaticDependency::LocateIncludedFile ( const string& directory,
|
||||||
const string& includedFilename,
|
const string& includedFilename,
|
||||||
|
@ -423,7 +444,7 @@ AutomaticDependency::RetrieveFromCacheOrParse ( const Module& module,
|
||||||
{
|
{
|
||||||
sourceFile = new SourceFile ( this,
|
sourceFile = new SourceFile ( this,
|
||||||
module,
|
module,
|
||||||
filename,
|
ResolveVariablesInPath ( filename ),
|
||||||
parentSourceFile,
|
parentSourceFile,
|
||||||
false );
|
false );
|
||||||
sourcefile_map[filename] = sourceFile;
|
sourcefile_map[filename] = sourceFile;
|
||||||
|
|
|
@ -693,9 +693,9 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Includ
|
||||||
if ( parameters.length () > 0 )
|
if ( parameters.length () > 0 )
|
||||||
parameters += " ";
|
parameters += " ";
|
||||||
if ( include.root == "intermediate" )
|
if ( include.root == "intermediate" )
|
||||||
path_prefix = backend->intermediateDirectory->name + cSep;
|
path_prefix = "$(INTERMEDIATE)" + sSep;
|
||||||
else if (include.root == "output" )
|
else if (include.root == "output" )
|
||||||
path_prefix = backend->outputDirectory->name + cSep;
|
path_prefix = "$(OUTPUT)" + sSep;
|
||||||
else
|
else
|
||||||
path_prefix = "";
|
path_prefix = "";
|
||||||
|
|
||||||
|
@ -816,9 +816,9 @@ MingwModuleHandler::GenerateMacro (
|
||||||
includeDirectory = include.directory;
|
includeDirectory = include.directory;
|
||||||
|
|
||||||
if ( include.root == "intermediate" )
|
if ( include.root == "intermediate" )
|
||||||
path_prefix = backend->intermediateDirectory->name + cSep;
|
path_prefix = "$(INTERMEDIATE)" + sSep;
|
||||||
else if (include.root == "output" )
|
else if (include.root == "output" )
|
||||||
path_prefix = backend->outputDirectory->name + cSep;
|
path_prefix = "$(OUTPUT)" + sSep;
|
||||||
else
|
else
|
||||||
path_prefix = "";
|
path_prefix = "";
|
||||||
|
|
||||||
|
@ -1281,7 +1281,6 @@ MingwModuleHandler::GenerateWidlCommandsEmbeddedTypeLib (
|
||||||
GetDirectory ( EmbeddedTypeLibFilename ).c_str () );
|
GetDirectory ( EmbeddedTypeLibFilename ).c_str () );
|
||||||
fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
|
fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
|
||||||
fprintf ( fMakefile,
|
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)",
|
"$(Q)$(WIDL_TARGET)",
|
||||||
GetWidlFlags ( compilationUnit ).c_str (),
|
GetWidlFlags ( compilationUnit ).c_str (),
|
||||||
|
@ -2003,8 +2002,9 @@ MingwModuleHandler::GenerateOtherMacros ()
|
||||||
|
|
||||||
fprintf (
|
fprintf (
|
||||||
fMakefile,
|
fMakefile,
|
||||||
"%s += $(PROJECT_WIDLFLAGS)\n",
|
"%s += $(PROJECT_WIDLFLAGS) -I%s\n",
|
||||||
widlflagsMacro.c_str () );
|
widlflagsMacro.c_str (),
|
||||||
|
module.GetBasePath ().c_str () );
|
||||||
|
|
||||||
fprintf (
|
fprintf (
|
||||||
fMakefile,
|
fMakefile,
|
||||||
|
|
|
@ -98,6 +98,9 @@ CompilationUnit::GetFilename ( Directory* intermediateDirectory ) const
|
||||||
if ( files.size () == 0 || files.size () > 1 )
|
if ( files.size () == 0 || files.size () > 1 )
|
||||||
return new FileLocation ( intermediateDirectory, name );
|
return new FileLocation ( intermediateDirectory, name );
|
||||||
File* file = files[0];
|
File* file = files[0];
|
||||||
|
if (file->path_prefix.length() > 0)
|
||||||
|
return new FileLocation ( intermediateDirectory, file->name );
|
||||||
|
else
|
||||||
return new FileLocation ( NULL, file->name );
|
return new FileLocation ( NULL, file->name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,14 @@ Directory::Add ( const char* subdir )
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* p = strpbrk ( subdir, "/\\" );
|
const char* p = strpbrk ( subdir, "/\\" );
|
||||||
|
if ( subdir == p || ( *subdir && subdir[1] == ':' ) )
|
||||||
|
{
|
||||||
|
throw InvalidOperationException ( __FILE__,
|
||||||
|
__LINE__,
|
||||||
|
"Invalid relative path '%s'",
|
||||||
|
subdir );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !p )
|
if ( !p )
|
||||||
p = subdir + strlen(subdir);
|
p = subdir + strlen(subdir);
|
||||||
string s ( subdir, p-subdir );
|
string s ( subdir, p-subdir );
|
||||||
|
@ -109,8 +117,8 @@ Directory::CreateDirectory ( string path )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
Directory::ReplaceVariable ( string name,
|
Directory::ReplaceVariable ( const string& name,
|
||||||
string value,
|
const string& value,
|
||||||
string path )
|
string path )
|
||||||
{
|
{
|
||||||
size_t i = path.find ( name );
|
size_t i = path.find ( name );
|
||||||
|
@ -122,7 +130,7 @@ Directory::ReplaceVariable ( string name,
|
||||||
|
|
||||||
void
|
void
|
||||||
Directory::ResolveVariablesInPath ( char* buf,
|
Directory::ResolveVariablesInPath ( char* buf,
|
||||||
string path )
|
const string& path )
|
||||||
{
|
{
|
||||||
string s = ReplaceVariable ( "$(INTERMEDIATE)", Environment::GetIntermediatePath (), path );
|
string s = ReplaceVariable ( "$(INTERMEDIATE)", Environment::GetIntermediatePath (), path );
|
||||||
s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
|
s = ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s );
|
||||||
|
@ -140,7 +148,10 @@ Directory::GenerateTree ( const string& parent,
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
|
if ( name.size () > 0 )
|
||||||
path = parent + sSep + name;
|
path = parent + sSep + name;
|
||||||
|
else
|
||||||
|
path = parent;
|
||||||
ResolveVariablesInPath ( buf, path );
|
ResolveVariablesInPath ( buf, path );
|
||||||
if ( CreateDirectory ( buf ) && verbose )
|
if ( CreateDirectory ( buf ) && verbose )
|
||||||
printf ( "Created %s\n", buf );
|
printf ( "Created %s\n", buf );
|
||||||
|
|
|
@ -45,9 +45,9 @@ InstallFile::InstallFile ( const Project& project_,
|
||||||
if ( att != NULL)
|
if ( att != NULL)
|
||||||
{
|
{
|
||||||
if ( att->value == "intermediate" )
|
if ( att->value == "intermediate" )
|
||||||
this->path = Environment::GetIntermediatePath () + sSep + path;
|
this->path = "$(INTERMEDIATE)" + sSep + path;
|
||||||
else if ( att->value == "output" )
|
else if ( att->value == "output" )
|
||||||
this->path = Environment::GetOutputPath () + sSep + path;
|
this->path = "$(OUTPUT)" + sSep + path;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw InvalidAttributeValueException (
|
throw InvalidAttributeValueException (
|
||||||
|
|
|
@ -121,7 +121,6 @@ GetSubPath (
|
||||||
const Project& project,
|
const Project& project,
|
||||||
const string& location,
|
const string& location,
|
||||||
const string& path,
|
const string& path,
|
||||||
const XMLAttribute* root,
|
|
||||||
const string& att_value )
|
const string& att_value )
|
||||||
{
|
{
|
||||||
if ( !att_value.size() )
|
if ( !att_value.size() )
|
||||||
|
@ -135,25 +134,7 @@ GetSubPath (
|
||||||
if ( !path.size() )
|
if ( !path.size() )
|
||||||
return att_value;
|
return att_value;
|
||||||
|
|
||||||
string path_prefix;
|
return FixSeparator(path + cSep + att_value);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
@ -540,7 +521,7 @@ Module::ProcessXML()
|
||||||
for ( i = 0; i < node.subElements.size(); i++ )
|
for ( i = 0; i < node.subElements.size(); i++ )
|
||||||
{
|
{
|
||||||
ParseContext parseContext;
|
ParseContext parseContext;
|
||||||
ProcessXMLSubElement ( *node.subElements[i], path, parseContext );
|
ProcessXMLSubElement ( *node.subElements[i], path, "", parseContext );
|
||||||
}
|
}
|
||||||
for ( i = 0; i < invocations.size(); i++ )
|
for ( i = 0; i < invocations.size(); i++ )
|
||||||
invocations[i]->ProcessXML ();
|
invocations[i]->ProcessXML ();
|
||||||
|
@ -564,12 +545,14 @@ Module::ProcessXML()
|
||||||
void
|
void
|
||||||
Module::ProcessXMLSubElement ( const XMLElement& e,
|
Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const string& path,
|
const string& path,
|
||||||
|
const string& path_prefix,
|
||||||
ParseContext& parseContext )
|
ParseContext& parseContext )
|
||||||
{
|
{
|
||||||
If* pOldIf = parseContext.ifData;
|
If* pOldIf = parseContext.ifData;
|
||||||
CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
|
CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
|
||||||
bool subs_invalid = false;
|
bool subs_invalid = false;
|
||||||
string subpath ( path );
|
string subpath ( path );
|
||||||
|
string subpath_prefix ( "" );
|
||||||
if ( e.name == "file" && e.value.size () > 0 )
|
if ( e.name == "file" && e.value.size () > 0 )
|
||||||
{
|
{
|
||||||
bool first = false;
|
bool first = false;
|
||||||
|
@ -601,6 +584,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
cplusplus = true;
|
cplusplus = true;
|
||||||
}
|
}
|
||||||
File* pFile = new File ( FixSeparator ( path + cSep + e.value ),
|
File* pFile = new File ( FixSeparator ( path + cSep + e.value ),
|
||||||
|
path_prefix,
|
||||||
first,
|
first,
|
||||||
switches,
|
switches,
|
||||||
false );
|
false );
|
||||||
|
@ -638,9 +622,23 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "directory" )
|
else if ( e.name == "directory" )
|
||||||
{
|
{
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
const XMLAttribute* base = e.GetAttribute ( "root", false );
|
const XMLAttribute* root = e.GetAttribute ( "root", false );
|
||||||
assert(att);
|
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" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
|
@ -809,7 +807,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
e.name.c_str() );
|
e.name.c_str() );
|
||||||
}
|
}
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
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.ifData = pOldIf;
|
||||||
parseContext.compilationUnit = pOldCompilationUnit;
|
parseContext.compilationUnit = pOldCompilationUnit;
|
||||||
}
|
}
|
||||||
|
@ -1206,10 +1204,26 @@ Module::InvokeModule () const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File::File ( const string& _name, bool _first,
|
File::File ( const string& _name,
|
||||||
|
bool _first,
|
||||||
std::string _switches,
|
std::string _switches,
|
||||||
bool _isPreCompiledHeader )
|
bool _isPreCompiledHeader )
|
||||||
: name(_name),
|
: 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),
|
first(_first),
|
||||||
switches(_switches),
|
switches(_switches),
|
||||||
isPreCompiledHeader(_isPreCompiledHeader)
|
isPreCompiledHeader(_isPreCompiledHeader)
|
||||||
|
@ -1222,6 +1236,15 @@ File::ProcessXML()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string File::GetFullPath () const
|
||||||
|
{
|
||||||
|
if ( path_prefix.length () > 0 )
|
||||||
|
return path_prefix + sSep + name;
|
||||||
|
else
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Library::Library ( const XMLElement& _node,
|
Library::Library ( const XMLElement& _node,
|
||||||
const Module& _module,
|
const Module& _module,
|
||||||
const string& _name )
|
const string& _name )
|
||||||
|
|
|
@ -391,9 +391,8 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
else if ( e.name == "directory" )
|
else if ( e.name == "directory" )
|
||||||
{
|
{
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
const XMLAttribute* base = e.GetAttribute ( "root", false );
|
|
||||||
assert(att);
|
assert(att);
|
||||||
subpath = GetSubPath ( *this, e.location, path, base, att->value );
|
subpath = GetSubPath ( *this, e.location, path, att->value );
|
||||||
}
|
}
|
||||||
else if ( e.name == "include" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,12 +119,12 @@ public:
|
||||||
const std::string& parent );
|
const std::string& parent );
|
||||||
private:
|
private:
|
||||||
bool mkdir_p ( const char* path );
|
bool mkdir_p ( const char* path );
|
||||||
std::string ReplaceVariable ( std::string name,
|
std::string ReplaceVariable ( const std::string& name,
|
||||||
std::string value,
|
const std::string& value,
|
||||||
std::string path );
|
std::string path );
|
||||||
std::string GetEnvironmentVariable ( const std::string& name );
|
std::string GetEnvironmentVariable ( const std::string& name );
|
||||||
void ResolveVariablesInPath ( char* buf,
|
void ResolveVariablesInPath ( char* buf,
|
||||||
std::string path );
|
const std::string& path );
|
||||||
bool CreateDirectory ( std::string path );
|
bool CreateDirectory ( std::string path );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -354,6 +354,7 @@ private:
|
||||||
std::string entrypoint;
|
std::string entrypoint;
|
||||||
void ProcessXMLSubElement ( const XMLElement& e,
|
void ProcessXMLSubElement ( const XMLElement& e,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
|
const std::string& path_prefix,
|
||||||
ParseContext& parseContext );
|
ParseContext& parseContext );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -413,6 +414,7 @@ class File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string path_prefix;
|
||||||
bool first;
|
bool first;
|
||||||
std::string switches;
|
std::string switches;
|
||||||
bool isPreCompiledHeader;
|
bool isPreCompiledHeader;
|
||||||
|
@ -422,7 +424,14 @@ public:
|
||||||
std::string _switches,
|
std::string _switches,
|
||||||
bool _isPreCompiledHeader );
|
bool _isPreCompiledHeader );
|
||||||
|
|
||||||
|
File ( const std::string& _name,
|
||||||
|
const std::string& _path_prefix,
|
||||||
|
bool _first,
|
||||||
|
std::string _switches,
|
||||||
|
bool _isPreCompiledHeader );
|
||||||
|
|
||||||
void ProcessXML();
|
void ProcessXML();
|
||||||
|
std::string GetFullPath () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -752,6 +761,10 @@ private:
|
||||||
void ParseFiles ( const Module& module );
|
void ParseFiles ( const Module& module );
|
||||||
void ParseFile ( const Module& module,
|
void ParseFile ( const Module& module,
|
||||||
const File& file );
|
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;
|
std::map<std::string, SourceFile*> sourcefile_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -994,7 +1007,6 @@ GetSubPath (
|
||||||
const Project& project,
|
const Project& project,
|
||||||
const std::string& location,
|
const std::string& location,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
const XMLAttribute* root,
|
|
||||||
const std::string& att_value );
|
const std::string& att_value );
|
||||||
|
|
||||||
extern std::string
|
extern std::string
|
||||||
|
|
|
@ -111,7 +111,7 @@ WineResource::UnpackResourcesInModule ( Module& module,
|
||||||
NormalizeFilename ( resourceFilename ).c_str () );
|
NormalizeFilename ( resourceFilename ).c_str () );
|
||||||
string command = FixSeparatorForSystemCommand(bin2res) + " " + parameters;
|
string command = FixSeparatorForSystemCommand(bin2res) + " " + parameters;
|
||||||
|
|
||||||
Directory( outputDirectory ).GenerateTree( ".", false );
|
Directory( relativeDirectory ).GenerateTree( Environment::GetIntermediatePath(), false );
|
||||||
|
|
||||||
int exitcode = system ( command.c_str () );
|
int exitcode = system ( command.c_str () );
|
||||||
if ( exitcode != 0 )
|
if ( exitcode != 0 )
|
||||||
|
|
Loading…
Reference in a new issue