Accept ROS_INSTALL environment variable

svn path=/branches/xmlbuildsystem/; revision=14520
This commit is contained in:
Casper Hornstrup 2005-04-05 20:24:26 +00:00
parent dcdd51410c
commit f81cbc31f1
5 changed files with 95 additions and 79 deletions

View file

@ -178,6 +178,13 @@ else
endif endif
OUTPUT_ := $(OUTPUT)$(SEP) OUTPUT_ := $(OUTPUT)$(SEP)
ifneq ($(ROS_INSTALL),)
INSTALL := $(ROS_INSTALL)
else
INSTALL := reactos
endif
INSTALL_ := $(INSTALL)$(SEP)
$(INTERMEDIATE): $(INTERMEDIATE):
${mkdir} $@ ${mkdir} $@
@ -186,6 +193,7 @@ $(OUTPUT):
${mkdir} $@ ${mkdir} $@
endif endif
NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc
KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc
BUILDNO_H = include$(SEP)reactos$(SEP)buildno.h BUILDNO_H = include$(SEP)reactos$(SEP)buildno.h

View file

@ -119,6 +119,28 @@ Directory::ReplaceVariable ( string name,
return path; return path;
} }
string
Directory::GetEnvironmentVariable ( const string& name )
{
char* value = getenv ( name.c_str () );
if ( value != NULL && strlen ( value ) > 0 )
return ssprintf ( "%s",
value );
else
return "";
}
string
Directory::GetEnvironmentVariablePathOrDefault ( const string& name,
const string& defaultValue )
{
const string& environmentVariableValue = GetEnvironmentVariable ( name );
if ( environmentVariableValue.length () > 0 )
return NormalizeFilename ( environmentVariableValue );
else
return defaultValue;
}
string string
Directory::GetIntermediatePath () Directory::GetIntermediatePath ()
{ {
@ -131,12 +153,20 @@ Directory::GetOutputPath ()
return "output-i386"; return "output-i386";
} }
string
Directory::GetInstallPath ()
{
return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
"reactos" );
}
void void
Directory::ResolveVariablesInPath ( char* buf, Directory::ResolveVariablesInPath ( char* buf,
string path ) string path )
{ {
string s = ReplaceVariable ( "$(INTERMEDIATE)", GetIntermediatePath (), path ); string s = ReplaceVariable ( "$(INTERMEDIATE)", GetIntermediatePath (), path );
s = ReplaceVariable ( "$(OUTPUT)", GetOutputPath (), s ); s = ReplaceVariable ( "$(OUTPUT)", GetOutputPath (), s );
s = ReplaceVariable ( "$(INSTALL)", GetInstallPath (), s );
strcpy ( buf, s.c_str () ); strcpy ( buf, s.c_str () );
} }
@ -181,7 +211,8 @@ public:
MingwBackend::MingwBackend ( Project& project, bool verbose ) MingwBackend::MingwBackend ( Project& project, bool verbose )
: Backend ( project, verbose ), : Backend ( project, verbose ),
intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ), intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
outputDirectory ( new Directory ( "$(OUTPUT)" ) ) outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
installDirectory ( new Directory ( "$(INSTALL)" ) )
{ {
} }
@ -189,6 +220,7 @@ MingwBackend::~MingwBackend()
{ {
delete intermediateDirectory; delete intermediateDirectory;
delete outputDirectory; delete outputDirectory;
delete installDirectory;
} }
string string
@ -514,15 +546,10 @@ MingwBackend::GenerateDirectories ()
printf ( "Creating directories..." ); printf ( "Creating directories..." );
intermediateDirectory->GenerateTree ( "", verbose ); intermediateDirectory->GenerateTree ( "", verbose );
outputDirectory->GenerateTree ( "", verbose ); outputDirectory->GenerateTree ( "", verbose );
installDirectory->GenerateTree ( "", verbose );
printf ( "done\n" ); printf ( "done\n" );
} }
string
FixupTargetFilename ( const string& targetFilename )
{
return NormalizeFilename ( targetFilename );
}
void void
MingwBackend::DetectPipeSupport () MingwBackend::DetectPipeSupport ()
{ {
@ -551,9 +578,6 @@ MingwBackend::DetectPipeSupport ()
printf ( "detected\n" ); printf ( "detected\n" );
else else
printf ( "not detected\n" ); printf ( "not detected\n" );
// TODO FIXME - eventually check for ROS_USE_PCH env var and
// allow that to override use_pch if true
} }
void void
@ -583,30 +607,25 @@ MingwBackend::DetectPCHSupport ()
printf ( "detected\n" ); printf ( "detected\n" );
else else
printf ( "not detected\n" ); printf ( "not detected\n" );
// TODO FIXME - eventually check for ROS_USE_PCH env var and
// allow that to override use_pch if true
} }
void void
MingwBackend::GetNonModuleInstallTargetFiles ( MingwBackend::GetNonModuleInstallTargetFiles (
string installDirectory,
vector<string>& out ) const vector<string>& out ) const
{ {
for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ )
{ {
const InstallFile& installfile = *ProjectNode.installfiles[i]; const InstallFile& installfile = *ProjectNode.installfiles[i];
string targetFilenameNoFixup = installDirectory + SSEP + installfile.base + SSEP + installfile.newname; string targetFilenameNoFixup = installfile.base + SSEP + installfile.newname;
string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( string targetFilename = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( targetFilenameNoFixup ), NormalizeFilename ( targetFilenameNoFixup ),
outputDirectory ); installDirectory );
out.push_back ( targetFilename ); out.push_back ( targetFilename );
} }
} }
void void
MingwBackend::GetModuleInstallTargetFiles ( MingwBackend::GetModuleInstallTargetFiles (
string installDirectory,
vector<string>& out ) const vector<string>& out ) const
{ {
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
@ -614,10 +633,10 @@ MingwBackend::GetModuleInstallTargetFiles (
const Module& module = *ProjectNode.modules[i]; const Module& module = *ProjectNode.modules[i];
if ( module.installName.length () > 0 ) if ( module.installName.length () > 0 )
{ {
string targetFilenameNoFixup = installDirectory + SSEP + module.installBase + SSEP + module.installName; string targetFilenameNoFixup = module.installBase + SSEP + module.installName;
string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( string targetFilename = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( targetFilenameNoFixup ), NormalizeFilename ( targetFilenameNoFixup ),
outputDirectory ); installDirectory );
out.push_back ( targetFilename ); out.push_back ( targetFilename );
} }
} }
@ -625,27 +644,23 @@ MingwBackend::GetModuleInstallTargetFiles (
void void
MingwBackend::GetInstallTargetFiles ( MingwBackend::GetInstallTargetFiles (
string installDirectory,
vector<string>& out ) const vector<string>& out ) const
{ {
GetNonModuleInstallTargetFiles ( installDirectory, GetNonModuleInstallTargetFiles ( out );
out ); GetModuleInstallTargetFiles ( out );
GetModuleInstallTargetFiles ( installDirectory,
out );
} }
void void
MingwBackend::OutputInstallTarget ( const string& installDirectory, MingwBackend::OutputInstallTarget ( const string& sourceFilename,
const string& sourceFilename,
const string& targetFilename, const string& targetFilename,
const string& targetDirectory ) const string& targetDirectory )
{ {
string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP + targetDirectory + SSEP + targetFilename ), NormalizeFilename ( targetDirectory + SSEP + targetFilename ),
outputDirectory ); installDirectory );
string normalizedTargetDirectory = MingwModuleHandler::PassThruCacheDirectory ( string normalizedTargetDirectory = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectory + SSEP + targetDirectory ), NormalizeFilename ( targetDirectory ),
outputDirectory ); installDirectory );
fprintf ( fMakefile, fprintf ( fMakefile,
"%s: %s %s\n", "%s: %s %s\n",
normalizedTargetFilename.c_str (), normalizedTargetFilename.c_str (),
@ -660,20 +675,19 @@ MingwBackend::OutputInstallTarget ( const string& installDirectory,
} }
void void
MingwBackend::OutputNonModuleInstallTargets ( const string& installDirectory ) MingwBackend::OutputNonModuleInstallTargets ()
{ {
for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ )
{ {
const InstallFile& installfile = *ProjectNode.installfiles[i]; const InstallFile& installfile = *ProjectNode.installfiles[i];
OutputInstallTarget ( installDirectory, OutputInstallTarget ( installfile.GetPath (),
installfile.GetPath (),
installfile.newname, installfile.newname,
installfile.base ); installfile.base );
} }
} }
void void
MingwBackend::OutputModuleInstallTargets ( const string& installDirectory ) MingwBackend::OutputModuleInstallTargets ()
{ {
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ ) for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
{ {
@ -683,8 +697,7 @@ MingwBackend::OutputModuleInstallTargets ( const string& installDirectory )
string sourceFilename = MingwModuleHandler::PassThruCacheDirectory ( string sourceFilename = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( module.GetPath () ), NormalizeFilename ( module.GetPath () ),
outputDirectory ); outputDirectory );
OutputInstallTarget ( installDirectory, OutputInstallTarget ( sourceFilename,
sourceFilename,
module.installName, module.installName,
module.installBase ); module.installBase );
} }
@ -702,11 +715,12 @@ MingwBackend::GetRegistrySourceFiles ()
} }
string string
MingwBackend::GetRegistryTargetFiles ( const string& installDirectory ) MingwBackend::GetRegistryTargetFiles ()
{ {
string system32ConfigDirectory = MingwModuleHandler::PassThruCacheDirectory ( string system32ConfigDirectory = NormalizeFilename (
NormalizeFilename ( installDirectory + SSEP + "system32" + SSEP "config" ), MingwModuleHandler::PassThruCacheDirectory (
outputDirectory ); "system32" SSEP "config" SSEP,
installDirectory ) );
return system32ConfigDirectory + SSEP "default " + return system32ConfigDirectory + SSEP "default " +
system32ConfigDirectory + SSEP "sam " + system32ConfigDirectory + SSEP "sam " +
system32ConfigDirectory + SSEP "security " + system32ConfigDirectory + SSEP "security " +
@ -715,14 +729,15 @@ MingwBackend::GetRegistryTargetFiles ( const string& installDirectory )
} }
void void
MingwBackend::OutputRegistryInstallTarget ( const string& installDirectory ) MingwBackend::OutputRegistryInstallTarget ()
{ {
string system32ConfigDirectory = MingwModuleHandler::PassThruCacheDirectory ( string system32ConfigDirectory = NormalizeFilename (
NormalizeFilename ( installDirectory + SSEP + "system32" + SSEP "config" ), MingwModuleHandler::PassThruCacheDirectory (
outputDirectory ); "system32" SSEP "config" SSEP,
installDirectory ) );
string registrySourceFiles = GetRegistrySourceFiles (); string registrySourceFiles = GetRegistrySourceFiles ();
string registryTargetFiles = GetRegistryTargetFiles ( installDirectory ); string registryTargetFiles = GetRegistryTargetFiles ();
fprintf ( fMakefile, fprintf ( fMakefile,
"install_registry: %s\n", "install_registry: %s\n",
registryTargetFiles.c_str () ); registryTargetFiles.c_str () );
@ -743,22 +758,16 @@ MingwBackend::OutputRegistryInstallTarget ( const string& installDirectory )
void void
MingwBackend::GenerateInstallTarget () MingwBackend::GenerateInstallTarget ()
{ {
string installDirectoryNoFixup = "reactos";
string installDirectory = MingwModuleHandler::PassThruCacheDirectory (
NormalizeFilename ( installDirectoryNoFixup ),
outputDirectory );
vector<string> vInstallTargetFiles; vector<string> vInstallTargetFiles;
GetInstallTargetFiles ( installDirectoryNoFixup, GetInstallTargetFiles ( vInstallTargetFiles );
vInstallTargetFiles );
string installTargetFiles = v2s ( vInstallTargetFiles, 5 ); string installTargetFiles = v2s ( vInstallTargetFiles, 5 );
fprintf ( fMakefile, fprintf ( fMakefile,
"install: %s %s install_registry\n", "install: %s install_registry\n",
installDirectory.c_str (),
installTargetFiles.c_str () ); installTargetFiles.c_str () );
OutputNonModuleInstallTargets ( installDirectoryNoFixup ); OutputNonModuleInstallTargets ();
OutputModuleInstallTargets ( installDirectoryNoFixup ); OutputModuleInstallTargets ();
OutputRegistryInstallTarget ( installDirectoryNoFixup ); OutputRegistryInstallTarget ();
fprintf ( fMakefile, fprintf ( fMakefile,
"\n" ); "\n" );
} }

View file

@ -31,8 +31,12 @@ private:
std::string ReplaceVariable ( std::string name, std::string ReplaceVariable ( std::string name,
std::string value, std::string value,
std::string path ); std::string path );
std::string GetEnvironmentVariable ( const std::string& name );
std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
const std::string& defaultValue );
std::string GetIntermediatePath (); std::string GetIntermediatePath ();
std::string GetOutputPath (); std::string GetOutputPath ();
std::string GetInstallPath ();
void ResolveVariablesInPath ( char* buf, void ResolveVariablesInPath ( char* buf,
std::string path ); std::string path );
bool CreateDirectory ( std::string path ); bool CreateDirectory ( std::string path );
@ -50,6 +54,7 @@ public:
bool usePipe; bool usePipe;
Directory* intermediateDirectory; Directory* intermediateDirectory;
Directory* outputDirectory; Directory* outputDirectory;
Directory* installDirectory;
private: private:
void CreateMakefile (); void CreateMakefile ();
void CloseMakefile () const; void CloseMakefile () const;
@ -75,26 +80,20 @@ private:
std::string GetInstallDirectories ( const std::string& installDirectory ); std::string GetInstallDirectories ( const std::string& installDirectory );
void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const; void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const;
void GetInstallFiles ( std::vector<std::string>& out ) const; void GetInstallFiles ( std::vector<std::string>& out ) const;
void GetNonModuleInstallTargetFiles ( std::string installDirectory, void GetNonModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
std::vector<std::string>& out ) const; void GetModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
void GetModuleInstallTargetFiles ( std::string installDirectory, void GetInstallTargetFiles ( std::vector<std::string>& out ) const;
std::vector<std::string>& out ) const; void OutputInstallTarget ( const std::string& sourceFilename,
void GetInstallTargetFiles ( std::string installDirectory,
std::vector<std::string>& out ) const;
void OutputInstallTarget ( const std::string& installDirectory,
const std::string& sourceFilename,
const std::string& targetFilename, const std::string& targetFilename,
const std::string& targetDirectory ); const std::string& targetDirectory );
void OutputNonModuleInstallTargets ( const std::string& installDirectory ); void OutputNonModuleInstallTargets ();
void OutputModuleInstallTargets ( const std::string& installDirectory ); void OutputModuleInstallTargets ();
std::string GetRegistrySourceFiles (); std::string GetRegistrySourceFiles ();
std::string GetRegistryTargetFiles ( const std::string& installDirectory ); std::string GetRegistryTargetFiles ();
void OutputRegistryInstallTarget ( const std::string& installDirectory ); void OutputRegistryInstallTarget ();
void GenerateInstallTarget (); void GenerateInstallTarget ();
FILE* fMakefile; FILE* fMakefile;
bool use_pch; bool use_pch;
}; };
std::string FixupTargetFilename ( const std::string& targetFilename );
#endif /* MINGW_H */ #endif /* MINGW_H */

View file

@ -119,7 +119,7 @@ MingwModuleHandler::GetTargetFilename (
string_list* pclean_files ) string_list* pclean_files )
{ {
string target = PassThruCacheDirectory ( string target = PassThruCacheDirectory (
FixupTargetFilename ( module.GetPath () ), NormalizeFilename ( module.GetPath () ),
backend->outputDirectory ); backend->outputDirectory );
if ( pclean_files ) if ( pclean_files )
{ {
@ -135,7 +135,7 @@ MingwModuleHandler::GetImportLibraryFilename (
string_list* pclean_files ) string_list* pclean_files )
{ {
string target = PassThruCacheDirectory ( string target = PassThruCacheDirectory (
FixupTargetFilename ( module.GetDependencyPath () ), NormalizeFilename ( module.GetDependencyPath () ),
backend->outputDirectory ); backend->outputDirectory );
if ( pclean_files ) if ( pclean_files )
{ {
@ -1402,11 +1402,11 @@ MingwModuleHandler::GenerateInvocations () const
invoke_targets[i].c_str () ); invoke_targets[i].c_str () );
fprintf ( fMakefile, fprintf ( fMakefile,
": %s\n", ": %s\n",
FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () ); NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_INVOKE)\n" ); fprintf ( fMakefile, "\t$(ECHO_INVOKE)\n" );
fprintf ( fMakefile, fprintf ( fMakefile,
"\t%s %s\n\n", "\t%s %s\n\n",
FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (), NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str (),
invoke.GetParameters ().c_str () ); invoke.GetParameters ().c_str () );
} }
} }
@ -1932,7 +1932,7 @@ MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
string extension = GetExtension ( file.name ); string extension = GetExtension ( file.name );
if ( extension == ".rc" || extension == ".RC" ) if ( extension == ".rc" || extension == ".RC" )
{ {
string resource = FixupTargetFilename ( file.name ); string resource = NormalizeFilename ( file.name );
fprintf ( fMakefile, "\t$(ECHO_BIN2RES)\n" ); fprintf ( fMakefile, "\t$(ECHO_BIN2RES)\n" );
fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n", fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n",
resource.c_str () ); resource.c_str () );
@ -2272,7 +2272,7 @@ MingwIsoModuleHandler::GetBootstrapCdFiles (
{ {
const Module& m = *module.project.modules[i]; const Module& m = *module.project.modules[i];
if ( m.bootstrap != NULL ) if ( m.bootstrap != NULL )
out.push_back ( FixupTargetFilename ( m.GetPath () ) ); out.push_back ( NormalizeFilename ( m.GetPath () ) );
} }
} }
@ -2299,13 +2299,13 @@ void
MingwIsoModuleHandler::GenerateIsoModuleTarget () MingwIsoModuleHandler::GenerateIsoModuleTarget ()
{ {
string bootcdDirectory = "cd"; string bootcdDirectory = "cd";
string isoboot = FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" ); string isoboot = NormalizeFilename ( "boot/freeldr/bootsect/isoboot.o" );
string bootcdReactosNoFixup = bootcdDirectory + "/reactos"; string bootcdReactosNoFixup = bootcdDirectory + "/reactos";
string bootcdReactos = PassThruCacheDirectory ( string bootcdReactos = PassThruCacheDirectory (
NormalizeFilename ( bootcdReactosNoFixup ), NormalizeFilename ( bootcdReactosNoFixup ),
backend->outputDirectory ); backend->outputDirectory );
CLEAN_FILE ( bootcdReactos ); CLEAN_FILE ( bootcdReactos );
string reactosInf = ros_temp + FixupTargetFilename ( bootcdReactosNoFixup + "/reactos.inf" ); string reactosInf = ros_temp + NormalizeFilename ( bootcdReactosNoFixup + "/reactos.inf" );
string reactosDff = NormalizeFilename ( "bootdata/packages/reactos.dff" ); string reactosDff = NormalizeFilename ( "bootdata/packages/reactos.dff" );
string cdDirectories = GetCdDirectories ( bootcdDirectory ); string cdDirectories = GetCdDirectories ( bootcdDirectory );
vector<string> vCdFiles; vector<string> vCdFiles;

View file

@ -4,6 +4,6 @@ using std::string;
void FunctionTest::Run () void FunctionTest::Run ()
{ {
string fixedupFilename = FixupTargetFilename ( "." SSEP "dir1" SSEP "dir2" SSEP ".." SSEP "filename.txt" ); string fixedupFilename = NormalizeFilename ( "." SSEP "dir1" SSEP "dir2" SSEP ".." SSEP "filename.txt" );
ARE_EQUAL ( "dir1" SSEP "filename.txt", fixedupFilename ); ARE_EQUAL ( "dir1" SSEP "filename.txt", fixedupFilename );
} }