Simplify directory handling
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
2005-04-05 17:50:21 UTC (rev 14508)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
2005-04-05 18:20:45 UTC (rev 14509)
@@ -18,7 +18,6 @@
using std::map;
typedef set<string> set_string;
-typedef map<string,Directory*> directory_map;
string
@@ -42,33 +41,13 @@
}
-class Directory
-{
-public:
- string name;
- directory_map subdirs;
- Directory ( const string& name );
- void Add ( const char* subdir );
- void GenerateTree ( const string& parent,
- bool verbose );
-private:
- bool mkdir_p ( const char* path );
- string ReplaceVariable ( string name,
- string value,
- string path );
- string GetIntermediatePath ();
- string GetOutputPath ();
- void ResolveVariablesInPath ( char* buf,
- string path );
- bool CreateDirectory ( string path );
-};
-
Directory::Directory ( const string& name_ )
: name(name_)
{
}
-void Directory::Add ( const char* subdir )
+void
+Directory::Add ( const char* subdir )
{
size_t i;
string s1 = string ( subdir );
@@ -187,6 +166,7 @@
}
}
+
static class MingwFactory : public Backend::Factory
{
public:
@@ -200,29 +180,23 @@
MingwBackend::MingwBackend ( Project& project, bool verbose )
: Backend ( project, verbose ),
- int_directories ( new Directory("$(INTERMEDIATE)") ),
- out_directories ( new Directory("$(OUTPUT)") )
+ intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
+ outputDirectory ( new Directory ( "$(OUTPUT)" ) )
{
}
MingwBackend::~MingwBackend()
{
- delete int_directories;
- delete out_directories;
+ delete intermediateDirectory;
+ delete outputDirectory;
}
string
-MingwBackend::AddDirectoryTarget ( const string& directory, bool out )
+MingwBackend::AddDirectoryTarget ( const string& directory,
+ Directory* directoryTree )
{
- const char* dir_name = "$(INTERMEDIATE)";
- Directory* dir = int_directories;
- if ( out )
- {
- dir_name = "$(OUTPUT)";
- dir = out_directories;
- }
- dir->Add ( directory.c_str() );
- return dir_name;
+ directoryTree->Add ( directory.c_str() );
+ return directoryTree->name;
}
void
@@ -538,8 +512,8 @@
MingwBackend::GenerateDirectories ()
{
printf ( "Creating directories..." );
- int_directories->GenerateTree ( "", verbose );
- out_directories->GenerateTree ( "", verbose );
+ intermediateDirectory->GenerateTree ( "", verbose );
+ outputDirectory->GenerateTree ( "", verbose );
printf ( "done\n" );
}
@@ -625,7 +599,7 @@
string targetFilenameNoFixup = installDirectory + SSEP +
installfile.base + SSEP + installfile.newname;
string targetFilename =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( targetFilenameNoFixup ),
- true );
+ outputDirectory );
out.push_back ( targetFilename );
}
}
@@ -643,7 +617,7 @@
string targetFilenameNoFixup = installDirectory
+ SSEP + module.installBase + SSEP + module.installName;
string targetFilename =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename (
targetFilenameNoFixup ),
- true );
+ outputDirectory );
out.push_back ( targetFilename );
}
}
@@ -668,10 +642,10 @@
{
string normalizedTargetFilename =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP +
targetDirectory + SSEP + targetFilename ),
- true );
+ outputDirectory );
string normalizedTargetDirectory =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP +
targetDirectory ),
- true );
+ outputDirectory );
fprintf ( fMakefile,
"%s: %s %s\n",
normalizedTargetFilename.c_str (),
@@ -708,7 +682,7 @@
{
string sourceFilename =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( module.GetPath () ),
- true );
+ outputDirectory );
OutputInstallTarget ( installDirectory,
sourceFilename,
module.installName,
@@ -732,7 +706,7 @@
{
string system32ConfigDirectory =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP + "system32"
+ SSEP "config" ),
- true );
+ outputDirectory );
return system32ConfigDirectory + SSEP "default " +
system32ConfigDirectory + SSEP "sam " +
system32ConfigDirectory + SSEP "security " +
@@ -745,7 +719,7 @@
{
string system32ConfigDirectory =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP + "system32"
+ SSEP "config" ),
- true );
+ outputDirectory );
string registrySourceFiles = GetRegistrySourceFiles ();
string registryTargetFiles = GetRegistryTargetFiles (
installDirectory );
@@ -772,7 +746,7 @@
string installDirectoryNoFixup = "reactos";
string installDirectory =
MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectoryNoFixup ),
- true );
+ outputDirectory );
vector<string> vInstallTargetFiles;
GetInstallTargetFiles ( installDirectoryNoFixup,
vInstallTargetFiles );
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
2005-04-05 17:50:21 UTC (rev 14508)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
2005-04-05 18:20:45 UTC (rev 14509)
@@ -15,14 +15,41 @@
extern std::string
v2s ( const string_list& v, int wrap_at );
+typedef std::map<std::string,Directory*> directory_map;
+
+class Directory
+{
+public:
+ std::string name;
+ directory_map subdirs;
+ Directory ( const std::string& name );
+ void Add ( const char* subdir );
+ void GenerateTree ( const std::string& parent,
+ bool verbose );
+private:
+ bool mkdir_p ( const char* path );
+ std::string ReplaceVariable ( std::string name,
+ std::string value,
+ std::string path );
+ std::string GetIntermediatePath ();
+ std::string GetOutputPath ();
+ void ResolveVariablesInPath ( char* buf,
+ std::string path );
+ bool CreateDirectory ( std::string path );
+};
+
+
class MingwBackend : public Backend
{
public:
MingwBackend ( Project& project, bool verbose );
virtual ~MingwBackend ();
virtual void Process ();
- std::string AddDirectoryTarget ( const std::string& directory,
bool out );
+ std::string AddDirectoryTarget ( const std::string& directory,
+ Directory* directoryTree );
bool usePipe;
+ Directory* intermediateDirectory;
+ Directory* outputDirectory;
private:
void CreateMakefile ();
void CloseMakefile () const;
@@ -66,7 +93,6 @@
void GenerateInstallTarget ();
FILE* fMakefile;
bool use_pch;
- Directory *int_directories, *out_directories;
};
std::string FixupTargetFilename ( const std::string& targetFilename );
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-04-05 17:50:21 UTC (rev 14508)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-04-05 18:20:45 UTC (rev 14509)
@@ -100,10 +100,12 @@
/*static*/ string
MingwModuleHandler::PassThruCacheDirectory (
- const string &file, bool out )
+ const string &file,
+ Directory* directoryTree )
{
string directory ( GetDirectory ( RemoveVariables ( file ) ) );
- string generatedFilesDirectory = backend->AddDirectoryTarget (
directory, out );
+ string generatedFilesDirectory = backend->AddDirectoryTarget (
directory,
+
directoryTree );
if ( directory.find ( generatedFilesDirectory ) != string::npos
)
/* This path already includes the generated files
directory variable */
return file;
@@ -118,7 +120,7 @@
{
string target = PassThruCacheDirectory (
FixupTargetFilename ( module.GetPath () ),
- true );
+ backend->outputDirectory );
if ( pclean_files )
{
string_list& clean_files = *pclean_files;
@@ -134,7 +136,7 @@
{
string target = PassThruCacheDirectory (
FixupTargetFilename ( module.GetDependencyPath () ),
- true );
+ backend->outputDirectory );
if ( pclean_files )
{
string_list& clean_files = *pclean_files;
@@ -228,8 +230,8 @@
if ( extension == ".spec" || extension == ".SPEC" )
{
string basename = GetBasename ( filename );
- return PassThruCacheDirectory ( FixupTargetFilename (
basename + ".stubs.c" ),
- false );
+ return PassThruCacheDirectory ( NormalizeFilename (
basename + ".stubs.c" ),
+
backend->intermediateDirectory );
}
else
return filename;
@@ -241,8 +243,9 @@
if ( module.type == StaticLibrary )
return GetTargetFilename ( module, NULL );
return PassThruCacheDirectory ( ReplaceExtension (
- FixupTargetFilename ( module.GetPath () ),
- ".temp.a" ), false );
+ NormalizeFilename ( module.GetPath () ),
+ ".temp.a" ),
+ backend->intermediateDirectory );
}
bool
@@ -345,10 +348,10 @@
else
newExtension = ".o";
string obj_file = PassThruCacheDirectory (
- FixupTargetFilename ( ReplaceExtension (
+ NormalizeFilename ( ReplaceExtension (
RemoveVariables ( sourceFilename ),
newExtension ) ),
- false );
+ backend->intermediateDirectory );
if ( pclean_files )
{
string_list& clean_files = *pclean_files;
@@ -825,12 +828,12 @@
string def_file = PassThruCacheDirectory (
basename + ".spec.def",
- false );
+ backend->intermediateDirectory );
CLEAN_FILE(def_file);
string stub_file = PassThruCacheDirectory (
basename + ".stubs.c",
- false );
+ backend->intermediateDirectory );
CLEAN_FILE(stub_file)
fprintf ( fMakefile,
@@ -925,7 +928,7 @@
string mapFilename = PassThruCacheDirectory (
GetBasename ( module.GetPath () ) + ".map",
- true );
+ backend->outputDirectory );
CLEAN_FILE ( mapFilename );
fprintf ( fMakefile,
@@ -1475,7 +1478,8 @@
{
string defFilename = module.GetBasePath () + SSEP +
module.importLibrary->definition;
if ( IsWineModule () )
- return PassThruCacheDirectory ( defFilename, false );
+ return PassThruCacheDirectory ( NormalizeFilename (
defFilename ),
+
backend->intermediateDirectory );
else
return defFilename;
}
@@ -1522,9 +1526,13 @@
const string& filename ) const
{
string basename = GetBasename ( filename );
- string defDependency = PassThruCacheDirectory (
FixupTargetFilename ( basename + ".spec.def" ), false );
+ string defDependency = PassThruCacheDirectory (
+ NormalizeFilename ( basename + ".spec.def" ),
+ backend->intermediateDirectory );
dependencies.push_back ( defDependency );
- string stubsDependency = PassThruCacheDirectory (
FixupTargetFilename ( basename + ".stubs.c" ), false );
+ string stubsDependency = PassThruCacheDirectory (
+ NormalizeFilename ( basename + ".stubs.c" ),
+ backend->intermediateDirectory );
dependencies.push_back ( stubsDependency );
}
@@ -1533,11 +1541,6 @@
string_list& dependencies ) const
{
string dkNkmLibNoFixup = "dk/nkm/lib";
- // TODO FIXME - verify this is the correct dependency...
- // easiest way to tell is to remove it and see what breaks
- /*dependencies += PassThruCacheDirectory (
- FixupTargetFilename ( dkNkmLibNoFixup ),
- false, NULL );*/
const vector<File*>& files = module.non_if_data.files;
for ( size_t i = 0; i < files.size (); i++ )
{
@@ -2205,8 +2208,8 @@
const CDFile& cdfile = *module.project.cdfiles[i];
string targetFilenameNoFixup = bootcdDirectory + SSEP +
cdfile.base + SSEP + cdfile.nameoncd;
string targetFilename =
MingwModuleHandler::PassThruCacheDirectory (
- FixupTargetFilename ( targetFilenameNoFixup ),
- true );
+ NormalizeFilename ( targetFilenameNoFixup ),
+ backend->outputDirectory );
fprintf ( fMakefile,
"\t$(ECHO_CP)\n" );
fprintf ( fMakefile,
@@ -2229,8 +2232,8 @@
if ( directories.size () > 0 )
directories += " ";
directories += PassThruCacheDirectory (
- FixupTargetFilename ( targetDirectory ),
- true );
+ NormalizeFilename ( targetDirectory ),
+ backend->outputDirectory );
}
}
return directories;
@@ -2247,8 +2250,8 @@
if ( directories.size () > 0 )
directories += " ";
directories += PassThruCacheDirectory (
- FixupTargetFilename ( targetDirectory ),
- true );
+ NormalizeFilename ( targetDirectory ),
+ backend->outputDirectory );
}
return directories;
}
@@ -2299,8 +2302,8 @@
string isoboot = FixupTargetFilename (
"boot/freeldr/bootsect/isoboot.o" );
string bootcdReactosNoFixup = bootcdDirectory + "/reactos";
string bootcdReactos = PassThruCacheDirectory (
- FixupTargetFilename ( bootcdReactosNoFixup ),
- true );
+ NormalizeFilename ( bootcdReactosNoFixup ),
+ backend->outputDirectory );
CLEAN_FILE ( bootcdReactos );
string reactosInf = ros_temp + FixupTargetFilename (
bootcdReactosNoFixup + "/reactos.inf" );
string reactosDff = NormalizeFilename (
"bootdata/packages/reactos.dff" );
@@ -2359,7 +2362,7 @@
void
MingwTestModuleHandler::GenerateTestModuleTarget ()
{
- string targetMacro ( GetTargetMacro (module) );
+ string targetMacro ( GetTargetMacro ( module ) );
string workingDirectory = GetWorkingDirectory ( );
string objectsMacro = GetObjectsMacro ( module );
string linkDepsMacro = GetLinkingDependenciesMacro ();
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h 2005-04-05 17:50:21 UTC (rev 14508)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h 2005-04-05 18:20:45 UTC (rev 14509)
@@ -25,7 +25,8 @@
static void SetUsePch ( bool use_pch );
static std::string PassThruCacheDirectory (
- const std::string &f, bool out );
+ const std::string &f,
+ Directory* directoryTree );
static std::string GetTargetFilename (
const Module& module,