mirror of
https://github.com/reactos/reactos.git
synced 2024-10-14 21:25:14 +00:00
Continue rbuild cleanup (File class)
svn path=/trunk/; revision=28990
This commit is contained in:
parent
f19c8990fb
commit
d1a39218b2
|
@ -321,7 +321,8 @@ AutomaticDependency::GetModuleFiles ( const Module& module,
|
|||
|
||||
if ( module.pch != NULL )
|
||||
{
|
||||
File *file = new File ( module.pch->file.relative_path + sSep + module.pch->file.name , false, "", true );
|
||||
const FileLocation& pch = module.pch->file;
|
||||
File *file = new File ( pch.directory, pch.relative_path, pch.name , false, "", true );
|
||||
files.push_back ( file );
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +542,7 @@ AutomaticDependency::CheckAutomaticDependencies ( const Module& module,
|
|||
for ( size_t fi = 0; fi < files.size (); fi++ )
|
||||
{
|
||||
File& file = *files[fi];
|
||||
string normalizedFilename = NormalizeFilename ( file.name );
|
||||
string normalizedFilename = NormalizeFilename ( file.GetFullPath () );
|
||||
|
||||
SourceFile* sourceFile = RetrieveFromCache ( normalizedFilename );
|
||||
if ( sourceFile != NULL )
|
||||
|
|
|
@ -251,7 +251,7 @@ CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size (); i++ )
|
||||
{
|
||||
string file = files[i]->name;
|
||||
string file = files[i]->file.relative_path + sSep + files[i]->file.name;
|
||||
string::size_type pos = file.find_last_of ("\\");
|
||||
if ( pos != string::npos )
|
||||
file.erase ( 0, pos+1 );
|
||||
|
@ -418,7 +418,8 @@ CBBackend::_generate_cbproj ( const Module& module )
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size(); i++ )
|
||||
{
|
||||
string file = string(".") + &files[i]->name[cbproj_path.size()];
|
||||
string fullpath = files[i]->file.relative_path + sSep + files[i]->file.name;
|
||||
string file = string(".") + &fullpath[cbproj_path.size()];
|
||||
|
||||
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
|
||||
resource_files.push_back ( file );
|
||||
|
|
|
@ -133,7 +133,7 @@ void DevCppBackend::ProcessModules()
|
|||
{
|
||||
File &file = *module.non_if_data.files[k];
|
||||
|
||||
ProcessFile(file.name);
|
||||
ProcessFile( file.file.relative_path + sSep + file.file.name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ bool FileExists(string &filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
void DevCppBackend::ProcessFile(string &filepath)
|
||||
void DevCppBackend::ProcessFile(string filepath)
|
||||
{
|
||||
// Remove the .\ at the start of the filenames
|
||||
if ((filepath[0] == '.') && (filepath[1] == '\\')) filepath.erase(0, 2);
|
||||
|
|
|
@ -45,7 +45,7 @@ class DevCppBackend : public Backend
|
|||
private:
|
||||
|
||||
void ProcessModules();
|
||||
void ProcessFile(std::string &filename);
|
||||
void ProcessFile(std::string filename);
|
||||
|
||||
bool CheckFolderAdded(std::string &folder);
|
||||
void AddFolders(std::string &folder);
|
||||
|
|
|
@ -336,7 +336,7 @@ MingwModuleHandler::GetCompilationUnitDependencies (
|
|||
for ( size_t i = 0; i < compilationUnit.files.size (); i++ )
|
||||
{
|
||||
File& file = *compilationUnit.files[i];
|
||||
sourceFiles.push_back ( NormalizeFilename ( file.name ) );
|
||||
sourceFiles.push_back ( strFile ( &file.file ) );
|
||||
}
|
||||
return v2s ( sourceFiles, 10 );
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ MingwModuleHandler::GetModuleArchiveFilename () const
|
|||
bool
|
||||
MingwModuleHandler::IsGeneratedFile ( const File& file ) const
|
||||
{
|
||||
string extension = GetExtension ( file.name );
|
||||
string extension = GetExtension ( file.file.name );
|
||||
return ( extension == ".spec" || extension == ".SPEC" );
|
||||
}
|
||||
|
||||
|
@ -3533,10 +3533,9 @@ MingwTestModuleHandler::Process ()
|
|||
void
|
||||
MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUnit*>& compilationUnits )
|
||||
{
|
||||
string basePath = "$(INTERMEDIATE)" + sSep + module.output->relative_path;
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_hooks.c", false, "", false ) ) );
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_stubs.S", false, "", false ) ) );
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_startup.c", false, "", false ) ) );
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_hooks.c", false, "", false ) ) );
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_stubs.S", false, "", false ) ) );
|
||||
compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_startup.c", false, "", false ) ) );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -113,8 +113,7 @@ MsBuildBackend::_generate_sources ( const Module& module )
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size(); i++ )
|
||||
{
|
||||
string file = &files[i]->name[proj_path.size()+1];
|
||||
source_files.push_back ( file );
|
||||
source_files.push_back ( files[i]->file.name );
|
||||
}
|
||||
const vector<Include*>& incs = data.includes;
|
||||
for ( i = 0; i < incs.size(); i++ )
|
||||
|
|
|
@ -337,7 +337,7 @@ MSVCBackend::_get_object_files ( const Module& module, vector<string>& out) cons
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size (); i++ )
|
||||
{
|
||||
string file = files[i]->name;
|
||||
string file = files[i]->file.relative_path + sSep + files[i]->file.name;
|
||||
string::size_type pos = file.find_last_of (DEF_SSEP);
|
||||
if ( pos != string::npos )
|
||||
file.erase ( 0, pos+1 );
|
||||
|
|
|
@ -102,8 +102,8 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size(); i++ )
|
||||
{
|
||||
// TODO FIXME - do we want the full path of the file here?
|
||||
string file = string(".") + &files[i]->name[dsp_path.size()];
|
||||
// TODO FIXME - do we want only the name of the file here?
|
||||
string file = files[i]->file.name;
|
||||
|
||||
source_files.push_back ( file );
|
||||
if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
|
||||
|
|
|
@ -157,8 +157,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
|||
const vector<File*>& files = data.files;
|
||||
for ( i = 0; i < files.size(); i++ )
|
||||
{
|
||||
// TODO FIXME - do we want the full path of the file here?
|
||||
string file = string(".") + &files[i]->name[vcproj_path.size()];
|
||||
// TODO FIXME - do we want only the name of the file here?
|
||||
string file = files[i]->file.name;
|
||||
|
||||
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
|
||||
resource_files.push_back ( file );
|
||||
|
|
|
@ -28,8 +28,8 @@ CompilationUnit::CompilationUnit ( File* file )
|
|||
module(NULL),
|
||||
node(NULL)
|
||||
{
|
||||
local_name = file->name;
|
||||
name = file->name;
|
||||
local_name = file->file.name;
|
||||
name = file->file.relative_path + sSep + file->file.name;
|
||||
files.push_back ( file );
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ CompilationUnit::IsGeneratedFile () const
|
|||
if ( files.size () != 1 )
|
||||
return false;
|
||||
File* file = files[0];
|
||||
string extension = GetExtension ( file->name );
|
||||
string extension = GetExtension ( file->file.name );
|
||||
return ( extension == ".spec" || extension == ".SPEC" );
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ CompilationUnit::HasFileWithExtension ( const std::string& extension ) const
|
|||
for ( i = 0; i < files.size (); i++ )
|
||||
{
|
||||
File& file = *files[i];
|
||||
string fileExtension = GetExtension ( file.name );
|
||||
string fileExtension = GetExtension ( file.file.name );
|
||||
if ( !stricmp ( fileExtension.c_str (), extension.c_str () ) )
|
||||
return true;
|
||||
}
|
||||
|
@ -106,28 +106,7 @@ CompilationUnit::GetFilename () const
|
|||
}
|
||||
|
||||
File* file = files[0];
|
||||
|
||||
DirectoryLocation directory;
|
||||
if ( file->path_prefix.length () == 0 )
|
||||
directory = SourceDirectory;
|
||||
else if ( file->path_prefix == "$(INTERMEDIATE)" )
|
||||
directory = IntermediateDirectory;
|
||||
else
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
__LINE__,
|
||||
"Invalid path prefix '%s'",
|
||||
file->path_prefix.c_str () );
|
||||
|
||||
size_t pos = file->name.find_last_of ( "/\\" );
|
||||
assert ( pos != string::npos );
|
||||
string relative_path = file->name.substr ( 0, pos );
|
||||
string name = file->name.substr ( pos + 1 );
|
||||
if ( relative_path.compare ( 0, 15, "$(INTERMEDIATE)") == 0 )
|
||||
{
|
||||
directory = IntermediateDirectory;
|
||||
relative_path.erase ( 0, 16 );
|
||||
}
|
||||
return new FileLocation ( directory, relative_path, name );
|
||||
return new FileLocation ( file->file );
|
||||
}
|
||||
|
||||
std::string
|
||||
|
|
|
@ -86,7 +86,7 @@ CompilationUnitSupportCode::WriteCompilationUnitFile ( Module& module,
|
|||
for ( size_t i = 0; i < compilationUnit.files.size () ; i++ )
|
||||
{
|
||||
File& file = *compilationUnit.files[i];
|
||||
s = s + sprintf ( s, "#include <%s>\n", ChangeSeparator ( file.name, '\\', '/' ).c_str () );
|
||||
s = s + sprintf ( s, "#include <%s/%s>\n", ChangeSeparator ( file.file.relative_path, '\\', '/' ).c_str (), file.file.name.c_str () );
|
||||
}
|
||||
|
||||
s = s + sprintf ( s, "\n" );
|
||||
|
|
|
@ -538,7 +538,7 @@ Module::ProcessXML()
|
|||
for ( i = 0; i < node.subElements.size(); i++ )
|
||||
{
|
||||
ParseContext parseContext;
|
||||
ProcessXMLSubElement ( *node.subElements[i], output->relative_path, "", parseContext );
|
||||
ProcessXMLSubElement ( *node.subElements[i], SourceDirectory, output->relative_path, parseContext );
|
||||
}
|
||||
for ( i = 0; i < invocations.size(); i++ )
|
||||
invocations[i]->ProcessXML ();
|
||||
|
@ -561,15 +561,15 @@ Module::ProcessXML()
|
|||
|
||||
void
|
||||
Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||
const string& path,
|
||||
const string& path_prefix,
|
||||
DirectoryLocation directory,
|
||||
const string& relative_path,
|
||||
ParseContext& parseContext )
|
||||
{
|
||||
If* pOldIf = parseContext.ifData;
|
||||
CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit;
|
||||
bool subs_invalid = false;
|
||||
string subpath ( path );
|
||||
string subpath_prefix ( "" );
|
||||
string subpath ( relative_path );
|
||||
DirectoryLocation subdirectory = SourceDirectory;
|
||||
if ( e.name == "file" && e.value.size () > 0 )
|
||||
{
|
||||
bool first = false;
|
||||
|
@ -600,8 +600,9 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
else if ( !stricmp ( ext.c_str(), ".cxx" ) )
|
||||
cplusplus = true;
|
||||
}
|
||||
File* pFile = new File ( FixSeparator ( path + cSep + e.value ),
|
||||
path_prefix,
|
||||
File* pFile = new File ( directory,
|
||||
relative_path,
|
||||
e.value,
|
||||
first,
|
||||
switches,
|
||||
false );
|
||||
|
@ -644,9 +645,9 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
if ( root )
|
||||
{
|
||||
if ( root->value == "intermediate" )
|
||||
subpath_prefix = "$(INTERMEDIATE)";
|
||||
subdirectory = IntermediateDirectory;
|
||||
else if ( root->value == "output" )
|
||||
subpath_prefix = "$(OUTPUT)";
|
||||
subdirectory = OutputDirectory;
|
||||
else
|
||||
{
|
||||
throw InvalidAttributeValueException (
|
||||
|
@ -655,7 +656,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
root->value );
|
||||
}
|
||||
}
|
||||
subpath = GetSubPath ( this->project, e.location, path, att->value );
|
||||
subpath = GetSubPath ( this->project, e.location, relative_path, att->value );
|
||||
}
|
||||
else if ( e.name == "include" )
|
||||
{
|
||||
|
@ -802,14 +803,14 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
if ( pos == string::npos )
|
||||
{
|
||||
pch = new PchFile (
|
||||
e, *this, FileLocation ( SourceDirectory, path, e.value ) );
|
||||
e, *this, FileLocation ( SourceDirectory, relative_path, e.value ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
string dir = e.value.substr ( 0, pos );
|
||||
string name = e.value.substr ( pos + 1);
|
||||
pch = new PchFile (
|
||||
e, *this, FileLocation ( SourceDirectory, path + sSep + dir, name ) );
|
||||
e, *this, FileLocation ( SourceDirectory, relative_path + sSep + dir, name ) );
|
||||
}
|
||||
subs_invalid = true;
|
||||
}
|
||||
|
@ -846,7 +847,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
e.name.c_str() );
|
||||
}
|
||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXMLSubElement ( *e.subElements[i], subpath, subpath_prefix, parseContext );
|
||||
ProcessXMLSubElement ( *e.subElements[i], subdirectory, subpath, parseContext );
|
||||
parseContext.ifData = pOldIf;
|
||||
parseContext.compilationUnit = pOldCompilationUnit;
|
||||
}
|
||||
|
@ -1233,12 +1234,13 @@ Module::SetImportLibrary ( ImportLibrary* importLibrary )
|
|||
}
|
||||
|
||||
|
||||
File::File ( const string& _name,
|
||||
File::File ( DirectoryLocation directory,
|
||||
const string& relative_path,
|
||||
const string& name,
|
||||
bool _first,
|
||||
std::string _switches,
|
||||
const string& _switches,
|
||||
bool _isPreCompiledHeader )
|
||||
: name(_name),
|
||||
path_prefix(""),
|
||||
: file ( directory, relative_path, name ),
|
||||
first(_first),
|
||||
switches(_switches),
|
||||
isPreCompiledHeader(_isPreCompiledHeader)
|
||||
|
@ -1246,19 +1248,6 @@ File::File ( const string& _name,
|
|||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -1267,10 +1256,11 @@ File::ProcessXML()
|
|||
|
||||
std::string File::GetFullPath () const
|
||||
{
|
||||
if ( path_prefix.length () > 0 )
|
||||
return path_prefix + sSep + name;
|
||||
// TODO FIXME take care of file.directory? return a full path?
|
||||
if ( file.relative_path.length () > 0 )
|
||||
return file.relative_path + sSep + file.name;
|
||||
else
|
||||
return name;
|
||||
return file.name;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -311,6 +311,20 @@ enum DirectoryLocation
|
|||
TemporaryDirectory,
|
||||
};
|
||||
|
||||
class FileLocation
|
||||
{
|
||||
public:
|
||||
DirectoryLocation directory;
|
||||
std::string relative_path;
|
||||
std::string name;
|
||||
|
||||
FileLocation ( const DirectoryLocation directory,
|
||||
const std::string& relative_path,
|
||||
const std::string& name );
|
||||
|
||||
FileLocation ( const FileLocation& other );
|
||||
};
|
||||
|
||||
class Module
|
||||
{
|
||||
public:
|
||||
|
@ -377,8 +391,8 @@ private:
|
|||
std::string GetDefaultModuleBaseaddress () const;
|
||||
std::string entrypoint;
|
||||
void ProcessXMLSubElement ( const XMLElement& e,
|
||||
const std::string& path,
|
||||
const std::string& path_prefix,
|
||||
DirectoryLocation directory,
|
||||
const std::string& relative_path,
|
||||
ParseContext& parseContext );
|
||||
};
|
||||
|
||||
|
@ -435,21 +449,16 @@ private:
|
|||
class File
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string path_prefix;
|
||||
FileLocation file;
|
||||
bool first;
|
||||
std::string switches;
|
||||
bool isPreCompiledHeader;
|
||||
|
||||
File ( const std::string& _name,
|
||||
File ( DirectoryLocation directory,
|
||||
const std::string& relative_path,
|
||||
const std::string& name,
|
||||
bool _first,
|
||||
std::string _switches,
|
||||
bool _isPreCompiledHeader );
|
||||
|
||||
File ( const std::string& _name,
|
||||
const std::string& _path_prefix,
|
||||
bool _first,
|
||||
std::string _switches,
|
||||
const std::string& _switches,
|
||||
bool _isPreCompiledHeader );
|
||||
|
||||
void ProcessXML();
|
||||
|
@ -829,21 +838,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class FileLocation
|
||||
{
|
||||
public:
|
||||
DirectoryLocation directory;
|
||||
std::string relative_path;
|
||||
std::string name;
|
||||
|
||||
FileLocation ( const DirectoryLocation directory,
|
||||
const std::string& relative_path,
|
||||
const std::string& name );
|
||||
|
||||
FileLocation ( const FileLocation& other );
|
||||
};
|
||||
|
||||
|
||||
class CDFile : public XmlNode
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -37,7 +37,7 @@ WineResource::~WineResource ()
|
|||
bool
|
||||
WineResource::IsSpecFile ( const File& file )
|
||||
{
|
||||
string extension = GetExtension ( file.name );
|
||||
string extension = GetExtension ( file.file.name );
|
||||
if ( extension == ".spec" || extension == ".SPEC" )
|
||||
return true;
|
||||
return false;
|
||||
|
@ -58,7 +58,7 @@ WineResource::IsWineModule ( const Module& module )
|
|||
bool
|
||||
WineResource::IsResourceFile ( const File& file )
|
||||
{
|
||||
string extension = GetExtension ( file.name );
|
||||
string extension = GetExtension ( file.file.name );
|
||||
if ( extension == ".rc" || extension == ".RC" )
|
||||
return true;
|
||||
return false;
|
||||
|
@ -71,7 +71,7 @@ WineResource::GetResourceFilename ( const Module& module )
|
|||
for ( size_t i = 0; i < files.size (); i++ )
|
||||
{
|
||||
if ( IsResourceFile ( *files[i] ) )
|
||||
return files[i]->name;
|
||||
return files[i]->file.relative_path + sSep + files[i]->file.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue