From: Hartmut Birr Date: Wed, 2 Nov 2005 23:24:05 +0000 (+0000) Subject: - The separator (slash or back slash), exepostfix and exeprefix are initialized from... X-Git-Tag: backups/ros-branch-0_2_9@19949~924 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=8bbbecaa8773ae4fefbd1687457a0b455807b22e - The separator (slash or back slash), exepostfix and exeprefix are initialized from environment variables. - The separators in the path for the system command are always converted for the host system. - Our own build utilities must convert paths itself (bin2res). svn path=/trunk/; revision=18961 --- diff --git a/reactos/Makefile b/reactos/Makefile index 35d8b9a58ef..593fa3a063f 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -115,7 +115,11 @@ all: makefile.auto ifeq ($(HOST),) ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32) +ifeq ($(OSTYPE),msys) +HOST=mingw32-linux +else HOST=mingw32-windows +endif else HOST=mingw32-linux endif @@ -207,9 +211,13 @@ host_ld = $(Q)ld host_ar = $(Q)ar host_objcopy = $(Q)objcopy ifeq ($(HOST),mingw32-linux) - EXEPREFIX = ./ - EXEPOSTFIX = - SEP = / + export EXEPREFIX = ./ +ifeq ($(OSTYPE),msys) + export EXEPOSTFIX = .exe +else + export EXEPOSTFIX = +endif + export SEP = / mkdir = -$(Q)mkdir -p gcc = $(Q)$(PREFIX)-gcc gpp = $(Q)$(PREFIX)-g++ @@ -224,10 +232,29 @@ ifeq ($(HOST),mingw32-linux) cp = $(Q)cp NUL = /dev/null else # mingw32-windows - EXEPREFIX = - EXEPOSTFIX = .exe + ifeq ($(OSTYPE),msys) + HOST=mingw32-linux + export EXEPREFIX = ./ + export EXEPOSTFIX = .exe + export SEP = / + mkdir = -$(Q)mkdir -p + gcc = $(Q)gcc + gpp = $(Q)g++ + ld = $(Q)ld + nm = $(Q)nm + objdump = $(Q)objdump + ar = $(Q)ar + objcopy = $(Q)objcopy + dlltool = $(Q)dlltool + windres = $(Q)windres + rm = $(Q)rm -f + cp = $(Q)cp + NUL = /dev/null + else + export EXEPREFIX = + export EXEPOSTFIX = .exe ROS_EMPTY = - SEP = \$(ROS_EMPTY) + export SEP = \$(ROS_EMPTY) mkdir = -$(Q)mkdir gcc = $(Q)gcc gpp = $(Q)g++ @@ -241,6 +268,7 @@ else # mingw32-windows rm = $(Q)del /f /q cp = $(Q)copy /y NUL = NUL + endif endif ifneq ($(ROS_INTERMEDIATE),) diff --git a/reactos/tools/bin2res/bin2res.c b/reactos/tools/bin2res/bin2res.c index 25dcc051107..4399d52f06b 100644 --- a/reactos/tools/bin2res/bin2res.c +++ b/reactos/tools/bin2res/bin2res.c @@ -37,8 +37,12 @@ #if defined(WIN32) #define DIR_SEPARATOR "\\" +#define C_SEP '\\' +#define C_BAD_SEP '/' #else #define DIR_SEPARATOR "/" +#define C_SEP '/' +#define C_BAD_SEP '\\' #endif extern int mkstemps(char *template, int suffix_len); @@ -275,6 +279,22 @@ int process_resources(const char* input_file_name, const char* specific_file_nam return c == EOF; } +char* fix_path_sep(char* name) +{ + char *new_name, *ptr; + + ptr = new_name = strdup(name); + while(*ptr) + { + if (*ptr == C_BAD_SEP) + { + *ptr = C_SEP; + } + ptr++; + } + return new_name; +} + int main(int argc, char **argv) { int convert_dir = 0, optc; @@ -295,14 +315,14 @@ int main(int argc, char **argv) case 'i': case 'o': if (specific_file_name) usage(); - specific_file_name = optarg; + specific_file_name = fix_path_sep(optarg); optc = ((optc == 'i') ? 'a' : 'x'); if (convert_dir && convert_dir != optc) usage(); convert_dir = optc; break; case 'b': if (relative_path) usage(); - relative_path = optarg; + relative_path = fix_path_sep(optarg); break; case 'f': force_overwrite = 1; @@ -320,7 +340,7 @@ int main(int argc, char **argv) } if (optind + 1 != argc) usage(); - input_file_name = argv[optind]; + input_file_name = fix_path_sep(argv[optind]); if (!convert_dir) usage(); diff --git a/reactos/tools/rbuild/automaticdependency.cpp b/reactos/tools/rbuild/automaticdependency.cpp index 93e31076adb..84174a94431 100644 --- a/reactos/tools/rbuild/automaticdependency.cpp +++ b/reactos/tools/rbuild/automaticdependency.cpp @@ -46,7 +46,7 @@ SourceFile::SourceFile ( AutomaticDependency* automaticDependency, void SourceFile::GetDirectoryAndFilenameParts () { - size_t index = filename.find_last_of ( CSEP ); + size_t index = filename.find_last_of ( cSep ); if ( index != string::npos ) { directoryPart = filename.substr ( 0, index ); @@ -347,7 +347,7 @@ AutomaticDependency::LocateIncludedFile ( const string& directory, const string& includedFilename, string& resolvedFilename ) { - string normalizedFilename = NormalizeFilename ( directory + SSEP + includedFilename ); + string normalizedFilename = NormalizeFilename ( directory + sSep + includedFilename ); FILE* f = fopen ( normalizedFilename.c_str (), "rb" ); if ( f != NULL ) { @@ -362,7 +362,7 @@ AutomaticDependency::LocateIncludedFile ( const string& directory, string AutomaticDependency::GetFilename ( const string& filename ) { - size_t index = filename.find_last_of ( CSEP ); + size_t index = filename.find_last_of ( cSep ); if (index == string::npos) return filename; else diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 55a25371efd..13905bd232b 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -119,17 +119,17 @@ Directory::CreateDirectory ( string path ) { size_t index = 0; size_t nextIndex; - if ( isalpha ( path[0] ) && path[1] == ':' && path[2] == CSEP ) + if ( isalpha ( path[0] ) && path[1] == ':' && path[2] == cSep ) { - nextIndex = path.find ( CSEP, 3); + nextIndex = path.find ( cSep, 3); } else - nextIndex = path.find ( CSEP ); + nextIndex = path.find ( cSep ); bool directoryWasCreated = false; while ( nextIndex != string::npos ) { - nextIndex = path.find ( CSEP, index + 1 ); + nextIndex = path.find ( cSep, index + 1 ); directoryWasCreated = mkdir_p ( path.substr ( 0, nextIndex ).c_str () ); index = nextIndex; } @@ -168,7 +168,7 @@ Directory::GenerateTree ( const string& parent, { char buf[256]; - path = parent + SSEP + name; + path = parent + sSep + name; ResolveVariablesInPath ( buf, path ); if ( CreateDirectory ( buf ) && verbose ) printf ( "Created %s\n", buf ); @@ -212,7 +212,7 @@ Directory::CreateRule ( FILE* f, fprintf ( f, "%s%c%s: | %s\n", escapedParent.c_str (), - CSEP, + cSep, EscapeSpaces ( name ).c_str (), escapedParent.c_str () ); @@ -222,7 +222,7 @@ Directory::CreateRule ( FILE* f, fprintf ( f, "\t${mkdir} $@\n" ); - path = parent + SSEP + name; + path = parent + sSep + name; } else path = name; @@ -687,7 +687,7 @@ MingwBackend::GenerateXmlBuildFilesMacro() const string MingwBackend::GetBin2ResExecutable () { - return NormalizeFilename ( Environment::GetOutputPath () + SSEP + "tools/bin2res/bin2res" + EXEPOSTFIX ); + return NormalizeFilename ( Environment::GetOutputPath () + sSep + "tools/bin2res/bin2res" + ExePostfix ); } void @@ -743,7 +743,7 @@ MingwBackend::CheckAutomaticDependencies () bool MingwBackend::IncludeDirectoryTarget ( const string& directory ) const { - if ( directory == "$(INTERMEDIATE)" SSEP "tools") + if ( directory == "$(INTERMEDIATE)" + sSep + "tools") return false; else return true; @@ -765,7 +765,7 @@ MingwBackend::TryToDetectThisCompiler ( const string& compiler ) { string command = ssprintf ( "%s -v 1>%s 2>%s", - compiler.c_str (), + FixSeparatorForSystemCommand(compiler).c_str (), NUL, NUL ); int exitcode = system ( command.c_str () ); @@ -810,7 +810,7 @@ MingwBackend::TryToDetectThisNetwideAssembler ( const string& assembler ) { string command = ssprintf ( "%s -h 1>%s 2>%s", - assembler.c_str (), + FixSeparatorForSystemCommand(assembler).c_str (), NUL, NUL ); int exitcode = system ( command.c_str () ); @@ -822,7 +822,7 @@ MingwBackend::TryToDetectThisBinutils ( const string& binutils ) { string command = ssprintf ( "%s -v 1>%s", - binutils.c_str (), + FixSeparatorForSystemCommand(binutils).c_str (), NUL, NUL ); int exitcode = system ( command.c_str () ); @@ -955,12 +955,12 @@ MingwBackend::DetectPipeSupport () { printf ( "Detecting compiler -pipe support..." ); - string pipe_detection = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pipe_detection.c"; + string pipe_detection = "tools" + sSep + "rbuild" + sSep + "backend" + sSep + "mingw" + sSep + "pipe_detection.c"; string pipe_detectionObjectFilename = ReplaceExtension ( pipe_detection, ".o" ); string command = ssprintf ( "%s -pipe -c %s -o %s 1>%s 2>%s", - compilerCommand.c_str (), + FixSeparatorForSystemCommand(compilerCommand).c_str (), pipe_detection.c_str (), pipe_detectionObjectFilename.c_str (), NUL, @@ -987,10 +987,10 @@ MingwBackend::DetectPCHSupport () { printf ( "Detecting compiler pre-compiled header support..." ); - string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h"; + string path = "tools" + sSep + "rbuild" + sSep + "backend" + sSep + "mingw" + sSep + "pch_detection.h"; string cmd = ssprintf ( "%s -c %s 1>%s 2>%s", - compilerCommand.c_str (), + FixSeparatorForSystemCommand(compilerCommand).c_str (), path.c_str (), NUL, NUL ); @@ -1020,7 +1020,7 @@ MingwBackend::GetNonModuleInstallTargetFiles ( for ( size_t i = 0; i < ProjectNode.installfiles.size (); i++ ) { const InstallFile& installfile = *ProjectNode.installfiles[i]; - string targetFilenameNoFixup = installfile.base + SSEP + installfile.newname; + string targetFilenameNoFixup = installfile.base + sSep + installfile.newname; string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( NormalizeFilename ( targetFilenameNoFixup ), installDirectory ); @@ -1041,7 +1041,7 @@ MingwBackend::GetModuleInstallTargetFiles ( { string targetFilenameNoFixup; if ( module.installBase.length () > 0 ) - targetFilenameNoFixup = module.installBase + SSEP + module.installName; + targetFilenameNoFixup = module.installBase + sSep + module.installName; else targetFilenameNoFixup = module.installName; string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( @@ -1067,7 +1067,7 @@ MingwBackend::OutputInstallTarget ( const string& sourceFilename, { string fullTargetFilename; if ( targetDirectory.length () > 0) - fullTargetFilename = targetDirectory + SSEP + targetFilename; + fullTargetFilename = targetDirectory + sSep + targetFilename; else fullTargetFilename = targetFilename; string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( @@ -1138,11 +1138,11 @@ MingwBackend::OutputModuleInstallTargets () string MingwBackend::GetRegistrySourceFiles () { - return "bootdata" SSEP "hivecls.inf " - "bootdata" SSEP "hivedef.inf " - "bootdata" SSEP "hiveinst.inf " - "bootdata" SSEP "hivesft.inf " - "bootdata" SSEP "hivesys.inf"; + return "bootdata" + sSep + "hivecls.inf " + "bootdata" + sSep + "hivedef.inf " + "bootdata" + sSep + "hiveinst.inf " + "bootdata" + sSep + "hivesft.inf " + "bootdata" + sSep + "hivesys.inf"; } string @@ -1150,13 +1150,13 @@ MingwBackend::GetRegistryTargetFiles () { string system32ConfigDirectory = NormalizeFilename ( MingwModuleHandler::PassThruCacheDirectory ( - "system32" SSEP "config" SSEP, + "system32" + sSep + "config" + sSep, installDirectory ) ); - return system32ConfigDirectory + SSEP "default " + - system32ConfigDirectory + SSEP "sam " + - system32ConfigDirectory + SSEP "security " + - system32ConfigDirectory + SSEP "software " + - system32ConfigDirectory + SSEP "system"; + return system32ConfigDirectory + sSep + "default " + + system32ConfigDirectory + sSep + "sam " + + system32ConfigDirectory + sSep + "security " + + system32ConfigDirectory + sSep + "software " + + system32ConfigDirectory + sSep + "system"; } void @@ -1164,7 +1164,7 @@ MingwBackend::OutputRegistryInstallTarget () { string system32ConfigDirectory = NormalizeFilename ( MingwModuleHandler::PassThruCacheDirectory ( - "system32" SSEP "config" SSEP, + "system32" + sSep + "config" + sSep, installDirectory ) ); string registrySourceFiles = GetRegistrySourceFiles (); @@ -1180,8 +1180,9 @@ MingwBackend::OutputRegistryInstallTarget () fprintf ( fMakefile, "\t$(ECHO_MKHIVE)\n" ); fprintf ( fMakefile, - "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP "hiveinst.inf\n", - system32ConfigDirectory.c_str () ); + "\t$(MKHIVE_TARGET) bootdata %s bootdata%chiveinst.inf\n", + system32ConfigDirectory.c_str (), + cSep ); fprintf ( fMakefile, "\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 15214162e24..d32e6f39667 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -50,7 +50,7 @@ PrefixFilename ( { if ( p2 > p1 ) p1 = p2; - out += string(pfilename,p1-pfilename) + CSEP; + out += string(pfilename,p1-pfilename) + cSep; pfilename = p1 + 1; } out += prefix + pfilename; @@ -106,7 +106,7 @@ MingwModuleHandler::RemoveVariables ( string path) size_t j = path.find ( ')', i ); if ( j != string::npos ) { - if ( j + 2 < path.length () && path[j + 1] == CSEP ) + if ( j + 2 < path.length () && path[j + 1] == cSep ) return path.substr ( j + 2); else return path.substr ( j + 1); @@ -130,7 +130,7 @@ MingwModuleHandler::PassThruCacheDirectory ( { if ( file == "" ) return generatedFilesDirectory; - return generatedFilesDirectory + SSEP + file; + return generatedFilesDirectory + sSep + file; } } @@ -518,7 +518,7 @@ MingwModuleHandler::GenerateInstallTarget () const return; fprintf ( fMakefile, ".PHONY: %s_install\n", module.name.c_str() ); string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( module.installBase + SSEP + module.installName ), + NormalizeFilename ( module.installBase + sSep + module.installName ), backend->installDirectory ); fprintf ( fMakefile, "%s_install: %s\n", @@ -581,7 +581,7 @@ MingwModuleHandler::GenerateGccDefineParametersFromVector ( return parameters; } -string +string MingwModuleHandler::GenerateGccDefineParameters () const { string parameters = GenerateGccDefineParametersFromVector ( module.project.non_if_data.defines ); @@ -601,10 +601,10 @@ MingwModuleHandler::ConcatenatePaths ( { if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) ) return path2; - if ( path1[path1.length ()] == CSEP ) + if ( path1[path1.length ()] == cSep ) return path1 + path2; else - return path1 + CSEP + path2; + return path1 + cSep + path2; } /* static */ string @@ -1838,7 +1838,7 @@ MingwModuleHandler::GenerateRules () if ( module.name != "zlib" ) /* Avoid make warning */ { string proxyMakefile = PassThruCacheDirectory ( - NormalizeFilename ( module.GetBasePath () + SSEP + "makefile" ), + NormalizeFilename ( module.GetBasePath () + sSep + "makefile" ), backend->outputDirectory ); CLEAN_FILE ( proxyMakefile ); } @@ -2009,7 +2009,7 @@ MingwModuleHandler::GetDefinitionFilename () const { if ( module.importLibrary != NULL ) { - string defFilename = module.GetBasePath () + SSEP + module.importLibrary->definition; + string defFilename = module.GetBasePath () + sSep + module.importLibrary->definition; if ( IsWineModule () ) return PassThruCacheDirectory ( NormalizeFilename ( defFilename ), backend->intermediateDirectory ); @@ -2017,7 +2017,7 @@ MingwModuleHandler::GetDefinitionFilename () const return defFilename; } else - return "tools" SSEP "rbuild" SSEP "empty.def"; + return "tools" + sSep + "rbuild" + sSep + "empty.def"; } void @@ -2181,8 +2181,9 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget () string dependencies = linkDepsMacro + " " + objectsMacro; - string linkerParameters = ssprintf ( "-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared", + string linkerParameters = ssprintf ( "-Wl,-T,%s%cntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -shared", module.GetBasePath ().c_str (), + cSep, module.entrypoint.c_str (), module.baseaddress.c_str () ); GenerateLinkerCommand ( dependencies, @@ -2693,7 +2694,7 @@ MingwIsoModuleHandler::OutputBootstrapfileCopyCommands ( string sourceFilename = PassThruCacheDirectory ( NormalizeFilename ( m.GetPath () ), backend->outputDirectory ); - string targetFilenameNoFixup ( bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd ); + string targetFilenameNoFixup ( bootcdDirectory + sSep + m.bootstrap->base + sSep + m.bootstrap->nameoncd ); string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( NormalizeFilename ( targetFilenameNoFixup ), backend->outputDirectory ); @@ -2714,7 +2715,7 @@ MingwIsoModuleHandler::OutputCdfileCopyCommands ( for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) { const CDFile& cdfile = *module.project.cdfiles[i]; - string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd; + string targetFilenameNoFixup = bootcdDirectory + sSep + cdfile.base + sSep + cdfile.nameoncd; string targetFilename = MingwModuleHandler::PassThruCacheDirectory ( NormalizeFilename ( targetFilenameNoFixup ), backend->outputDirectory ); @@ -2738,7 +2739,7 @@ MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string& bootcdDirectory continue; if ( m.bootstrap != NULL ) { - string targetDirectory ( bootcdDirectory + SSEP + m.bootstrap->base ); + string targetDirectory ( bootcdDirectory + sSep + m.bootstrap->base ); if ( directories.size () > 0 ) directories += " "; directories += PassThruCacheDirectory ( @@ -2756,7 +2757,7 @@ MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string& bootcdDirectory for ( size_t i = 0; i < module.project.cdfiles.size (); i++ ) { const CDFile& cdfile = *module.project.cdfiles[i]; - string targetDirectory ( bootcdDirectory + SSEP + cdfile.base ); + string targetDirectory ( bootcdDirectory + sSep + cdfile.base ); if ( directories.size () > 0 ) directories += " "; directories += PassThruCacheDirectory ( @@ -2817,20 +2818,20 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget () { string bootcdDirectory = "cd"; string bootcd = PassThruCacheDirectory ( - NormalizeFilename ( bootcdDirectory + SSEP ), + NormalizeFilename ( bootcdDirectory + sSep ), backend->outputDirectory ); string isoboot = PassThruCacheDirectory ( - NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ), + NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "bootsect" + sSep + "isoboot.o" ), backend->outputDirectory ); - string bootcdReactosNoFixup = bootcdDirectory + SSEP "reactos"; + string bootcdReactosNoFixup = bootcdDirectory + sSep + "reactos"; string bootcdReactos = PassThruCacheDirectory ( - NormalizeFilename ( bootcdReactosNoFixup + SSEP ), + NormalizeFilename ( bootcdReactosNoFixup + sSep ), backend->outputDirectory ); CLEAN_FILE ( bootcdReactos ); string reactosInf = PassThruCacheDirectory ( - NormalizeFilename ( bootcdReactosNoFixup + SSEP "reactos.inf" ), + NormalizeFilename ( bootcdReactosNoFixup + sSep + "reactos.inf" ), backend->outputDirectory ); - string reactosDff = NormalizeFilename ( "bootdata" SSEP "packages" SSEP "reactos.dff" ); + string reactosDff = NormalizeFilename ( "bootdata" + sSep + "packages" + sSep + "reactos.dff" ); string cdDirectories = GetCdDirectories ( bootcdDirectory ); vector vCdFiles; GetCdFiles ( vCdFiles ); @@ -2887,7 +2888,7 @@ void MingwLiveIsoModuleHandler::CreateDirectory ( const string& directory ) { string normalizedDirectory = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( directory ) + SSEP, + NormalizeFilename ( directory ) + sSep, backend->outputDirectory ); } @@ -2897,7 +2898,7 @@ MingwLiveIsoModuleHandler::OutputCopyCommand ( const string& sourceFilename, const string& targetDirectory ) { string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory ( - NormalizeFilename ( targetDirectory + SSEP + targetFilename ), + NormalizeFilename ( targetDirectory + sSep + targetFilename ), backend->outputDirectory ); fprintf ( fMakefile, "\t$(ECHO_CP)\n" ); @@ -2924,7 +2925,7 @@ MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string& livecdDirectory, backend->outputDirectory ); OutputCopyCommand ( sourceFilename, m.installName, - livecdDirectory + SSEP + reactosDirectory + SSEP + m.installBase ); + livecdDirectory + sSep + reactosDirectory + sSep + m.installBase ); } } } @@ -2938,21 +2939,21 @@ MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string& livecdDirectory const InstallFile& installfile = *module.project.installfiles[i]; OutputCopyCommand ( installfile.GetPath (), installfile.newname, - livecdDirectory + SSEP + reactosDirectory + SSEP + installfile.base ); + livecdDirectory + sSep + reactosDirectory + sSep + installfile.base ); } } void MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string& livecdDirectory ) { - CreateDirectory ( livecdDirectory + SSEP "Profiles" ); - CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users") ; - CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users" SSEP "Desktop" ); - CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" ); - CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "Desktop" ); - CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "My Documents" ); + CreateDirectory ( livecdDirectory + sSep + "Profiles" ); + CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "All Users") ; + CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "All Users" + sSep + "Desktop" ); + CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "Default User" ); + CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "Default User" + sSep + "Desktop" ); + CreateDirectory ( livecdDirectory + sSep + "Profiles" + sSep + "Default User" + sSep + "My Documents" ); - string livecdIni = "bootdata" SSEP "livecd.ini"; + string livecdIni = "bootdata" + sSep + "livecd.ini"; OutputCopyCommand ( livecdIni, "freeldr.ini", livecdDirectory ); @@ -2962,12 +2963,12 @@ void MingwLiveIsoModuleHandler::OutputLoaderCommands ( string& livecdDirectory ) { string freeldr = PassThruCacheDirectory ( - NormalizeFilename ( "boot" SSEP "freeldr" SSEP "freeldr" SSEP "freeldr.sys" ), + NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "freeldr" + sSep + "freeldr.sys" ), backend->outputDirectory ); - CreateDirectory ( livecdDirectory + SSEP "loader" ); + CreateDirectory ( livecdDirectory + sSep + "loader" ); OutputCopyCommand ( freeldr, "setupldr.sys", - livecdDirectory + SSEP + "loader" ); + livecdDirectory + sSep + "loader" ); } void @@ -2975,13 +2976,15 @@ MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory ) { string reactosSystem32ConfigDirectory = NormalizeFilename ( MingwModuleHandler::PassThruCacheDirectory ( - livecdDirectory + SSEP "reactos" SSEP "system32" SSEP "config" SSEP, + livecdDirectory + sSep + "reactos" + sSep + "system32" + sSep + "config" + sSep, backend->outputDirectory ) ); fprintf ( fMakefile, "\t$(ECHO_MKHIVE)\n" ); fprintf ( fMakefile, - "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP "livecd.inf bootdata" SSEP "hiveinst.inf\n", - reactosSystem32ConfigDirectory.c_str () ); + "\t$(MKHIVE_TARGET) bootdata %s bootdata%clivecd.inf bootdata%chiveinst.inf\n", + reactosSystem32ConfigDirectory.c_str (), + cSep, + cSep ); } void @@ -2989,15 +2992,15 @@ MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget () { string livecdDirectory = "livecd"; string livecd = PassThruCacheDirectory ( - NormalizeFilename ( livecdDirectory + SSEP ), + NormalizeFilename ( livecdDirectory + sSep ), backend->outputDirectory ); string isoboot = PassThruCacheDirectory ( - NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ), + NormalizeFilename ( "boot" + sSep + "freeldr" + sSep + "bootsect" + sSep + "isoboot.o" ), backend->outputDirectory ); string reactosDirectory = "reactos"; - string livecdReactosNoFixup = livecdDirectory + SSEP + reactosDirectory; + string livecdReactosNoFixup = livecdDirectory + sSep + reactosDirectory; string livecdReactos = NormalizeFilename ( PassThruCacheDirectory ( - NormalizeFilename ( livecdReactosNoFixup + SSEP ), + NormalizeFilename ( livecdReactosNoFixup + sSep ), backend->outputDirectory ) ); CLEAN_FILE ( livecdReactos ); @@ -3041,10 +3044,10 @@ MingwTestModuleHandler::Process () void MingwTestModuleHandler::GetModuleSpecificSourceFiles ( vector& sourceFiles ) { - string basePath = "$(INTERMEDIATE)" SSEP + module.GetBasePath (); - sourceFiles.push_back ( new File ( basePath + SSEP "_hooks.c", false, "", false ) ); - sourceFiles.push_back ( new File ( basePath + SSEP "_stubs.S", false, "", false ) ); - sourceFiles.push_back ( new File ( basePath + SSEP "_startup.c", false, "", false ) ); + string basePath = "$(INTERMEDIATE)" + sSep + module.GetBasePath (); + sourceFiles.push_back ( new File ( basePath + sSep + "_hooks.c", false, "", false ) ); + sourceFiles.push_back ( new File ( basePath + sSep + "_stubs.S", false, "", false ) ); + sourceFiles.push_back ( new File ( basePath + sSep + "_startup.c", false, "", false ) ); } void diff --git a/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp b/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp index fde86b38a15..9c4b5fc9406 100644 --- a/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp +++ b/reactos/tools/rbuild/backend/mingw/proxymakefile.cpp @@ -62,7 +62,7 @@ ProxyMakefile::GeneratePathToParentDirectory ( int numberOfParentDirectories ) for ( int i = 0; i < numberOfParentDirectories; i++ ) { if ( path != "" ) - path += SSEP; + path += sSep; path += ".."; } return path; @@ -75,7 +75,7 @@ ProxyMakefile::GetPathToTopDirectory ( Module& module ) string basePath = NormalizeFilename ( module.GetBasePath () ); for ( size_t i = 0; i < basePath.length (); i++ ) { - if ( basePath[i] == CSEP ) + if ( basePath[i] == cSep ) numberOfDirectories++; } return GeneratePathToParentDirectory ( numberOfDirectories ); @@ -99,7 +99,7 @@ ProxyMakefile::GenerateProxyMakefileForModule ( Module& module, string pathToTopDirectory; if ( outputTree.length () > 0 ) { - base = outputTree + SSEP + module.GetBasePath (); + base = outputTree + sSep + module.GetBasePath (); Path path; pathToTopDirectory = working_directory; } @@ -108,7 +108,7 @@ ProxyMakefile::GenerateProxyMakefileForModule ( Module& module, base = module.GetBasePath (); pathToTopDirectory = GetPathToTopDirectory ( module ); } - string proxyMakefile = NormalizeFilename ( base + SSEP "GNUmakefile" ); + string proxyMakefile = NormalizeFilename ( base + sSep + "GNUmakefile" ); string defaultTarget = module.name; buf = (char*) malloc ( 10*1024 ); diff --git a/reactos/tools/rbuild/cdfile.cpp b/reactos/tools/rbuild/cdfile.cpp index dc89deb24cd..107a3375557 100644 --- a/reactos/tools/rbuild/cdfile.cpp +++ b/reactos/tools/rbuild/cdfile.cpp @@ -50,7 +50,7 @@ CDFile::~CDFile () string CDFile::GetPath () const { - return path + SSEP + name; + return path + sSep + name; } void diff --git a/reactos/tools/rbuild/include.cpp b/reactos/tools/rbuild/include.cpp index 7488e6e30d3..edab10f1a4f 100644 --- a/reactos/tools/rbuild/include.cpp +++ b/reactos/tools/rbuild/include.cpp @@ -50,7 +50,7 @@ Include::Include ( const Project& project, node ( NULL ), baseModule ( NULL ) { - this->directory = NormalizeFilename ( basePath + SSEP + directory ); + this->directory = NormalizeFilename ( basePath + sSep + directory ); this->basePath = NormalizeFilename ( basePath ); } @@ -91,7 +91,7 @@ Include::ProcessXML() node->location, " attribute 'base' references non-existant project or module '%s'", att->value.c_str() ); - directory = NormalizeFilename ( basePath + SSEP + node->value ); + directory = NormalizeFilename ( basePath + sSep + node->value ); } else directory = NormalizeFilename ( node->value ); diff --git a/reactos/tools/rbuild/installfile.cpp b/reactos/tools/rbuild/installfile.cpp index bd24a256178..f427b0bf96a 100644 --- a/reactos/tools/rbuild/installfile.cpp +++ b/reactos/tools/rbuild/installfile.cpp @@ -50,7 +50,7 @@ InstallFile::~InstallFile () string InstallFile::GetPath () const { - return path + SSEP + name; + return path + sSep + name; } void diff --git a/reactos/tools/rbuild/linkerscript.cpp b/reactos/tools/rbuild/linkerscript.cpp index 955b8cfc691..56fa3a37388 100644 --- a/reactos/tools/rbuild/linkerscript.cpp +++ b/reactos/tools/rbuild/linkerscript.cpp @@ -66,7 +66,7 @@ LinkerScript::ProcessXML() node.location, " attribute 'base' references non-existant project or module '%s'", att->value.c_str() ); - directory = NormalizeFilename ( basePath + SSEP + node.value ); + directory = NormalizeFilename ( basePath + sSep + node.value ); } else directory = NormalizeFilename ( node.value ); diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 8bf14653653..1b5644bce8c 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -55,11 +55,24 @@ string FixSeparator ( const string& s ) { string s2(s); - char* p = strchr ( &s2[0], CBAD_SEP ); + char* p = strchr ( &s2[0], cBadSep ); while ( p ) { - *p++ = CSEP; - p = strchr ( p, CBAD_SEP ); + *p++ = cSep; + p = strchr ( p, cBadSep ); + } + return s2; +} + +string +FixSeparatorForSystemCommand ( const string& s ) +{ + string s2(s); + char* p = strchr ( &s2[0], DEF_CBAD_SEP ); + while ( p ) + { + *p++ = DEF_CSEP; + p = strchr ( p, DEF_CBAD_SEP ); } return s2; } @@ -111,7 +124,7 @@ GetSubPath ( " tag has invalid characters in 'name' attribute" ); if ( !path.size() ) return att_value; - return FixSeparator(path + CSEP + att_value); + return FixSeparator(path + cSep + att_value); } string @@ -129,7 +142,7 @@ GetExtension ( const string& filename ) string GetDirectory ( const string& filename ) { - size_t index = filename.find_last_of ( CSEP ); + size_t index = filename.find_last_of ( cSep ); if ( index == string::npos ) return ""; else @@ -139,7 +152,7 @@ GetDirectory ( const string& filename ) string GetFilename ( const string& filename ) { - size_t index = filename.find_last_of ( CSEP ); + size_t index = filename.find_last_of ( cSep ); if ( index == string::npos ) return filename; else @@ -453,7 +466,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e, else if ( !stricmp ( ext.c_str(), ".cxx" ) ) cplusplus = true; } - File* pFile = new File ( FixSeparator ( path + CSEP + e.value ), + File* pFile = new File ( FixSeparator ( path + cSep + e.value ), first, switches, false ); @@ -597,7 +610,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e, e.location, "Only one is valid per module" ); pch = new PchFile ( - e, *this, File ( FixSeparator ( path + CSEP + e.value ), false, "", true ) ); + e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) ); subs_invalid = true; } if ( subs_invalid && e.subElements.size() > 0 ) @@ -661,7 +674,7 @@ Module::GetDefaultModuleExtension () const switch (type) { case BuildTool: - return EXEPOSTFIX; + return ExePostfix; case StaticLibrary: return ".a"; case ObjectLibrary: @@ -868,7 +881,7 @@ string Module::GetPath () const { if ( path.length() > 0 ) - return path + CSEP + GetTargetName (); + return path + cSep + GetTargetName (); else return GetTargetName (); } @@ -876,7 +889,7 @@ Module::GetPath () const string Module::GetPathWithPrefix ( const string& prefix ) const { - return path + CSEP + prefix + GetTargetName (); + return path + cSep + prefix + GetTargetName (); } string @@ -914,7 +927,7 @@ Module::InvokeModule () const for ( size_t i = 0; i < invocations.size (); i++ ) { Invoke& invoke = *invocations[i]; - string command = invoke.invokeModule->GetPath () + " " + invoke.GetParameters (); + string command = FixSeparatorForSystemCommand(invoke.invokeModule->GetPath ()) + " " + invoke.GetParameters (); printf ( "Executing '%s'\n\n", command.c_str () ); int exitcode = system ( command.c_str () ); if ( exitcode != 0 ) @@ -1034,7 +1047,7 @@ Invoke::ProcessXMLSubElementInput ( const XMLElement& e ) bool subs_invalid = false; if ( e.name == "inputfile" && e.value.size () > 0 ) { - input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) ); + input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + cSep + e.value ) ) ); subs_invalid = true; } if ( subs_invalid && e.subElements.size() > 0 ) @@ -1049,7 +1062,7 @@ Invoke::ProcessXMLSubElementOutput ( const XMLElement& e ) bool subs_invalid = false; if ( e.name == "outputfile" && e.value.size () > 0 ) { - output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) ); + output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + cSep + e.value ) ) ); subs_invalid = true; } if ( subs_invalid && e.subElements.size() > 0 ) diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 2ace6e2d0b5..00ab3ab50a2 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -198,7 +198,7 @@ Project::WriteConfigurationFile () s = s + sprintf ( s, "#endif /* __INCLUDE_CONFIG_H */\n" ); - FileSupportCode::WriteIfChanged ( buf, "include" SSEP "roscfg.h" ); + FileSupportCode::WriteIfChanged ( buf, "include" + sSep + "roscfg.h" ); free ( buf ); } diff --git a/reactos/tools/rbuild/rbuild.cpp b/reactos/tools/rbuild/rbuild.cpp index 377e6f53030..d7edd1349fb 100644 --- a/reactos/tools/rbuild/rbuild.cpp +++ b/reactos/tools/rbuild/rbuild.cpp @@ -35,6 +35,13 @@ static string BuildSystem; static string RootXmlFile = "ReactOS.xml"; static Configuration configuration; +string ExePrefix; +string ExePostfix; +string sSep; +string sBadSep; +char cSep; +char cBadSep; + bool ParseAutomaticDependencySwitch ( char switchChar2, char* switchStart ) @@ -186,6 +193,43 @@ ParseArguments ( int argc, char** argv ) int main ( int argc, char** argv ) { + char *SepValue, *ExePostfixValue, *ExePrefixValue;; + + SepValue = getenv("SEP"); + if (SepValue && (0 == strcmp(SepValue, DEF_SSEP) || 0 == strcmp(SepValue, DEF_SBAD_SEP))) + { + cSep = SepValue[0]; + sSep = SepValue; + } + else + { + cSep = DEF_CSEP; + sSep = DEF_SSEP; + } + if (cSep == DEF_CSEP) + { + cBadSep = DEF_CBAD_SEP; + sBadSep = DEF_SBAD_SEP; + } + else + { + cBadSep = DEF_CSEP; + sBadSep = DEF_SSEP; + } + ExePostfixValue = getenv("EXEPOSTFIX"); + ExePrefixValue = getenv("EXEPREFIX"); + if ((ExePostfixValue == NULL || 0 == strlen(ExePostfixValue)) && + (ExePrefixValue == NULL || 0 == strlen(ExePrefixValue))) + { + ExePostfix = DEF_EXEPOSTFIX; + ExePrefix = DEF_EXEPREFIX; + } + else + { + ExePostfix = ExePostfixValue ? ExePostfixValue : ""; + ExePrefix = ExePrefixValue ? ExePrefixValue : ""; + } + if ( !ParseArguments ( argc, argv ) ) { printf ( "Generates project files for buildsystems\n\n" ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 1f1a1918d94..53ab14e364a 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -41,20 +41,27 @@ typedef std::vector string_list; +extern std::string ExePrefix; +extern std::string ExePostfix; +extern std::string sSep; +extern std::string sBadSep; +extern char cSep; +extern char cBadSep; + #ifdef WIN32 -#define EXEPREFIX "" -#define EXEPOSTFIX ".exe" -#define CSEP '\\' -#define CBAD_SEP '/' -#define SSEP "\\" -#define SBAD_SEP "/" +#define DEF_EXEPREFIX "" +#define DEF_EXEPOSTFIX ".exe" +#define DEF_CSEP '\\' +#define DEF_CBAD_SEP '/' +#define DEF_SSEP "\\" +#define DEF_SBAD_SEP "/" #else -#define EXEPREFIX "./" -#define EXEPOSTFIX "" -#define CSEP '/' -#define CBAD_SEP '\\' -#define SSEP "/" -#define SBAD_SEP "\\" +#define DEF_EXEPREFIX "./" +#define DEF_EXEPOSTFIX "" +#define DEF_CSEP '/' +#define DEF_CBAD_SEP '\\' +#define DEF_SSEP "/" +#define DEF_SBAD_SEP "\\" #endif #define MS_VS_DEF_VERSION "7.10" @@ -773,6 +780,9 @@ Replace ( const std::string& s, const std::string& find, const std::string& with extern std::string FixSeparator ( const std::string& s ); +extern std::string +FixSeparatorForSystemCommand ( const std::string& s ); + extern std::string DosSeparator ( const std::string& s ); diff --git a/reactos/tools/rbuild/testsupportcode.cpp b/reactos/tools/rbuild/testsupportcode.cpp index 32ceb23aa4e..713bc3e759c 100644 --- a/reactos/tools/rbuild/testsupportcode.cpp +++ b/reactos/tools/rbuild/testsupportcode.cpp @@ -69,7 +69,7 @@ TestSupportCode::GenerateTestSupportCodeForModule ( Module& module, string TestSupportCode::GetHooksFilename ( Module& module ) { - return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_hooks.c" ); + return NormalizeFilename ( Environment::GetIntermediatePath () + sSep + module.GetBasePath () + sSep + "_hooks.c" ); } char* @@ -135,7 +135,7 @@ TestSupportCode::WriteHooksFile ( Module& module ) string TestSupportCode::GetStubsFilename ( Module& module ) { - return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_stubs.S" ); + return NormalizeFilename ( Environment::GetIntermediatePath () + sSep + module.GetBasePath () + sSep + "_stubs.S" ); } string @@ -226,7 +226,7 @@ TestSupportCode::WriteStubsFile ( Module& module ) string TestSupportCode::GetStartupFilename ( Module& module ) { - return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_startup.c" ); + return NormalizeFilename ( Environment::GetIntermediatePath () + sSep + module.GetBasePath () + sSep + "_startup.c" ); } bool diff --git a/reactos/tools/rbuild/wineresource.cpp b/reactos/tools/rbuild/wineresource.cpp index 8da1c969dec..0fcf8b1af83 100644 --- a/reactos/tools/rbuild/wineresource.cpp +++ b/reactos/tools/rbuild/wineresource.cpp @@ -104,10 +104,10 @@ WineResource::UnpackResourcesInModule ( Module& module, } string outputDirectory = module.GetBasePath (); - string parameters = ssprintf ( "-b %s -f -x %s", + string parameters = ssprintf ( "-b %s -f -x %s", NormalizeFilename ( outputDirectory ).c_str (), NormalizeFilename ( resourceFilename ).c_str () ); - string command = bin2res + " " + parameters; + string command = FixSeparatorForSystemCommand(bin2res) + " " + parameters; int exitcode = system ( command.c_str () ); if ( exitcode != 0 ) {