Browse Source

Changes from MikeC to allow spaces in filenames

rdb 16 years ago
parent
commit
469db88a00
1 changed files with 39 additions and 28 deletions
  1. 39 28
      makepanda/makepanda.py

+ 39 - 28
makepanda/makepanda.py

@@ -142,9 +142,9 @@ parseopts(sys.argv[1:])
 
 
 # Now check if CFLAGS happens to be set
 # Now check if CFLAGS happens to be set
 if (os.environ.has_key("CFLAGS")):
 if (os.environ.has_key("CFLAGS")):
-  CFLAGS=os.environ["CFLAGS"]
+    CFLAGS=os.environ["CFLAGS"]
 if (os.environ.has_key("RPM_OPT_FLAGS")):
 if (os.environ.has_key("RPM_OPT_FLAGS")):
-  CFLAGS+=os.environ["RPM_OPT_FLAGS"]
+    CFLAGS+=os.environ["RPM_OPT_FLAGS"]
 
 
 ########################################################################
 ########################################################################
 ##
 ##
@@ -156,8 +156,8 @@ MakeBuildTree()
 
 
 SdkLocateDirectX()
 SdkLocateDirectX()
 if TARGET in ["all", "plugins"]:
 if TARGET in ["all", "plugins"]:
-  SdkLocateMaya()
-  SdkLocateMax()
+    SdkLocateMaya()
+    SdkLocateMax()
 SdkLocateMacOSX()
 SdkLocateMacOSX()
 SdkLocatePython()
 SdkLocatePython()
 SdkLocateVisualStudio()
 SdkLocateVisualStudio()
@@ -165,8 +165,8 @@ SdkLocateMSPlatform()
 
 
 SdkAutoDisableDirectX()
 SdkAutoDisableDirectX()
 if TARGET in ["all", "plugins"]:
 if TARGET in ["all", "plugins"]:
-  SdkAutoDisableMaya()
-  SdkAutoDisableMax()
+    SdkAutoDisableMaya()
+    SdkAutoDisableMax()
 
 
 ########################################################################
 ########################################################################
 ##
 ##
@@ -466,6 +466,17 @@ def printStatus(header,warnings):
 
 
 printStatus("Makepanda Initial Status Report", WARNINGS)
 printStatus("Makepanda Initial Status Report", WARNINGS)
 
 
+########################################################################
+##
+## BracketNameWithQuotes
+##
+########################################################################
+
+def BracketNameWithQuotes(name):
+    # Account for quoted name (leave as is) but quote everything else (e.g., to protect spaces within paths from improper parsing)
+    if (name.startswith('"') and name.endswith('"')): return name
+    else: return '"' + name + '"'
+
 ########################################################################
 ########################################################################
 ##
 ##
 ## CompileCxx
 ## CompileCxx
@@ -478,7 +489,7 @@ def CompileCxx(obj,src,opts):
         cmd = "cl /favor:blend /wd4996 /wd4275 /wd4267 /wd4101 /Fo" + obj + " /nologo /c "
         cmd = "cl /favor:blend /wd4996 /wd4275 /wd4267 /wd4101 /Fo" + obj + " /nologo /c "
         for x in ipath: cmd = cmd + " /I" + x
         for x in ipath: cmd = cmd + " /I" + x
         for (opt,dir) in INCDIRECTORIES:
         for (opt,dir) in INCDIRECTORIES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /I"' + dir + '"'
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /I' + BracketNameWithQuotes(dir)
         for (opt,var,val) in DEFSYMBOLS:
         for (opt,var,val) in DEFSYMBOLS:
             if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /D' + var + "=" + val
             if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /D' + var + "=" + val
         if (opts.count('NOFLOATWARN')): cmd = cmd + ' /wd4244 /wd4305'
         if (opts.count('NOFLOATWARN')): cmd = cmd + ' /wd4244 /wd4305'
@@ -493,13 +504,13 @@ def CompileCxx(obj,src,opts):
         if (building): cmd = cmd + " /DBUILDING_" + building
         if (building): cmd = cmd + " /DBUILDING_" + building
         bigObjFlag = GetValueOption(opts, "BIGOBJ:")
         bigObjFlag = GetValueOption(opts, "BIGOBJ:")
         if (bigObjFlag): cmd += " /bigobj"
         if (bigObjFlag): cmd += " /bigobj"
-        cmd = cmd + " /EHsc /Zm300 /DWIN32_VC /DWIN32 /W3 " + src
+        cmd = cmd + " /EHsc /Zm300 /DWIN32_VC /DWIN32 /W3 " + BracketNameWithQuotes(src)
         oscmd(cmd)
         oscmd(cmd)
     if (COMPILER=="LINUX"):
     if (COMPILER=="LINUX"):
         if (src.endswith(".c")): cmd = 'gcc -fPIC -c -o ' + obj
         if (src.endswith(".c")): cmd = 'gcc -fPIC -c -o ' + obj
         else:                    cmd = 'g++ -ftemplate-depth-30 -fPIC -c -o ' + obj
         else:                    cmd = 'g++ -ftemplate-depth-30 -fPIC -c -o ' + obj
         for (opt, dir) in INCDIRECTORIES:
         for (opt, dir) in INCDIRECTORIES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -I"' + dir + '"'
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -I' + BracketNameWithQuotes(dir)
         for (opt,var,val) in DEFSYMBOLS:
         for (opt,var,val) in DEFSYMBOLS:
             if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -D' + var + '=' + val
             if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -D' + var + '=' + val
         for x in ipath: cmd = cmd + ' -I' + x
         for x in ipath: cmd = cmd + ' -I' + x
@@ -513,7 +524,7 @@ def CompileCxx(obj,src,opts):
         if (CFLAGS !=""): cmd = cmd + " " + CFLAGS
         if (CFLAGS !=""): cmd = cmd + " " + CFLAGS
         building = GetValueOption(opts, "BUILDING:")
         building = GetValueOption(opts, "BUILDING:")
         if (building): cmd = cmd + " -DBUILDING_" + building
         if (building): cmd = cmd + " -DBUILDING_" + building
-        cmd = cmd + ' ' + src
+        cmd = cmd + ' ' + BracketNameWithQuotes(src)
         oscmd(cmd)
         oscmd(cmd)
 
 
 ########################################################################
 ########################################################################
@@ -594,15 +605,15 @@ def CompileIgate(woutd,wsrc,opts):
     cmd = cmd + ' -oc ' + woutc + ' -od ' + woutd
     cmd = cmd + ' -oc ' + woutc + ' -od ' + woutd
     cmd = cmd + ' -fnames -string -refcount -assert -python-native'
     cmd = cmd + ' -fnames -string -refcount -assert -python-native'
     cmd = cmd + ' -S' + GetOutputDir() + '/include/parser-inc'
     cmd = cmd + ' -S' + GetOutputDir() + '/include/parser-inc'
-    for x in ipath: cmd = cmd + ' -I' + x
+    for x in ipath: cmd = cmd + ' -I' + BracketNameWithQuotes(x)
     for (opt,dir) in INCDIRECTORIES:
     for (opt,dir) in INCDIRECTORIES:
-        if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -S"' + dir + '"'
+        if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -S' + BracketNameWithQuotes(dir)
     for (opt,var,val) in DEFSYMBOLS:
     for (opt,var,val) in DEFSYMBOLS:
         if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -D' + var + '=' + val
         if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -D' + var + '=' + val
     building = GetValueOption(opts, "BUILDING:")
     building = GetValueOption(opts, "BUILDING:")
     if (building): cmd = cmd + " -DBUILDING_"+building
     if (building): cmd = cmd + " -DBUILDING_"+building
     cmd = cmd + ' -module ' + module + ' -library ' + library
     cmd = cmd + ' -module ' + module + ' -library ' + library
-    for x in wsrc: cmd = cmd + ' ' + os.path.basename(x)
+    for x in wsrc: cmd = cmd + ' ' + BracketNameWithQuotes(os.path.basename(x))
     oscmd(cmd)
     oscmd(cmd)
     CompileCxx(wobj,woutc,opts)
     CompileCxx(wobj,woutc,opts)
     return
     return
@@ -626,7 +637,7 @@ def CompileImod(wobj, wsrc, opts):
         return
         return
     cmd = GetOutputDir() + '/bin/interrogate_module '
     cmd = GetOutputDir() + '/bin/interrogate_module '
     cmd = cmd + ' -oc ' + woutc + ' -module ' + module + ' -library ' + library + ' -python-native '
     cmd = cmd + ' -oc ' + woutc + ' -module ' + module + ' -library ' + library + ' -python-native '
-    for x in wsrc: cmd = cmd + ' ' + x
+    for x in wsrc: cmd = cmd + ' ' + BracketNameWithQuotes(x)
     oscmd(cmd)
     oscmd(cmd)
     CompileCxx(wobj,woutc,opts)
     CompileCxx(wobj,woutc,opts)
     return
     return
@@ -643,15 +654,15 @@ def CompileLib(lib, obj, opts):
         (arch, osName) = platform.architecture()
         (arch, osName) = platform.architecture()
         if arch=='64bit':
         if arch=='64bit':
             cmd += "/MACHINE:X64 "
             cmd += "/MACHINE:X64 "
-        cmd += '/OUT:' + lib
-        for x in obj: cmd = cmd + ' ' + x
+        cmd += '/OUT:' + BracketNameWithQuotes(lib)
+        for x in obj: cmd = cmd + ' ' + BracketNameWithQuotes(x)
         oscmd(cmd)
         oscmd(cmd)
     if (COMPILER=="LINUX"):
     if (COMPILER=="LINUX"):
         if sys.platform == 'darwin':
         if sys.platform == 'darwin':
-            cmd = 'libtool -static -o ' + lib
+            cmd = 'libtool -static -o ' + BracketNameWithQuotes(lib)
         else:
         else:
             cmd = 'ar cru ' + lib
             cmd = 'ar cru ' + lib
-        for x in obj: cmd=cmd + ' ' + x
+        for x in obj: cmd=cmd + ' ' + BracketNameWithQuotes(x)
         oscmd(cmd)
         oscmd(cmd)
 
 
 ########################################################################
 ########################################################################
@@ -675,11 +686,11 @@ def CompileLink(dll, obj, opts):
         if (optlevel==3): cmd = cmd + " /MAP:NUL "
         if (optlevel==3): cmd = cmd + " /MAP:NUL "
         if (optlevel==4): cmd = cmd + " /MAP:NUL /LTCG "
         if (optlevel==4): cmd = cmd + " /MAP:NUL /LTCG "
         cmd = cmd + " /FIXED:NO /OPT:REF /STACK:4194304 /INCREMENTAL:NO "
         cmd = cmd + " /FIXED:NO /OPT:REF /STACK:4194304 /INCREMENTAL:NO "
-        cmd = cmd + ' /OUT:' + dll
+        cmd = cmd + ' /OUT:' + BracketNameWithQuotes(dll)
         if (dll.endswith(".dll")):
         if (dll.endswith(".dll")):
             cmd = cmd + ' /IMPLIB:' + GetOutputDir() + '/lib/'+dll[len(GetOutputDir()+"/bin/"):-4]+".lib"
             cmd = cmd + ' /IMPLIB:' + GetOutputDir() + '/lib/'+dll[len(GetOutputDir()+"/bin/"):-4]+".lib"
         for (opt, dir) in LIBDIRECTORIES:
         for (opt, dir) in LIBDIRECTORIES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /LIBPATH:"' + dir + '"'
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' /LIBPATH:' + BracketNameWithQuotes(dir)
         for x in obj:
         for x in obj:
             if (x.endswith(".dll")):
             if (x.endswith(".dll")):
                 cmd = cmd + ' ' + GetOutputDir() + '/lib/' + x[len(GetOutputDir()+"/bin/"):-4] + ".lib"
                 cmd = cmd + ' ' + GetOutputDir() + '/lib/' + x[len(GetOutputDir()+"/bin/"):-4] + ".lib"
@@ -687,16 +698,16 @@ def CompileLink(dll, obj, opts):
                 dname = x[:-4]+".dll"
                 dname = x[:-4]+".dll"
                 if (os.path.exists(GetOutputDir()+"/bin/" + x[len(GetOutputDir()+"/bin/"):-4] + ".dll")):
                 if (os.path.exists(GetOutputDir()+"/bin/" + x[len(GetOutputDir()+"/bin/"):-4] + ".dll")):
                     exit("Error: in makepanda, specify "+dname+", not "+x)
                     exit("Error: in makepanda, specify "+dname+", not "+x)
-                cmd = cmd + ' ' + x
+                cmd = cmd + ' ' + BracketNameWithQuotes(x)
             elif (x.endswith(".def")):
             elif (x.endswith(".def")):
-                cmd = cmd + ' /DEF:"' + x + '"'
+                cmd = cmd + ' /DEF:' + BracketNameWithQuotes(x)
             elif (x.endswith(".dat")):
             elif (x.endswith(".dat")):
                 pass
                 pass
-            else: cmd = cmd + ' ' + x
+            else: cmd = cmd + ' ' + BracketNameWithQuotes(x)
         if (GetOrigExt(dll)==".exe" and platform.architecture()[0] == "32bit"):
         if (GetOrigExt(dll)==".exe" and platform.architecture()[0] == "32bit"):
             cmd = cmd + ' panda/src/configfiles/pandaIcon.obj'
             cmd = cmd + ' panda/src/configfiles/pandaIcon.obj'
         for (opt, name) in LIBNAMES:
         for (opt, name) in LIBNAMES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' ' + name
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' ' + BracketNameWithQuotes(name)
         oscmd(cmd)
         oscmd(cmd)
         SetVC90CRTVersion(dll+".manifest", VC90CRTVERSION)
         SetVC90CRTVersion(dll+".manifest", VC90CRTVERSION)
         mtcmd = 'mt -manifest ' + dll + '.manifest -outputresource:' + dll
         mtcmd = 'mt -manifest ' + dll + '.manifest -outputresource:' + dll
@@ -718,9 +729,9 @@ def CompileLink(dll, obj, opts):
                 else:
                 else:
                     cmd = cmd + ' ' + x
                     cmd = cmd + ' ' + x
         for (opt, dir) in LIBDIRECTORIES:
         for (opt, dir) in LIBDIRECTORIES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -L"' + dir + '"'
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' -L' + BracketNameWithQuotes(dir)
         for (opt, name) in LIBNAMES:
         for (opt, name) in LIBNAMES:
-            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' ' + name
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + ' ' + BracketNameWithQuotes(name)
         cmd = cmd + " -lpthread -ldl"
         cmd = cmd + " -lpthread -ldl"
         if (sys.platform == "darwin"):
         if (sys.platform == "darwin"):
             cmd = cmd + " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"] + " -arch ppc -arch i386"
             cmd = cmd + " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"] + " -arch ppc -arch i386"
@@ -737,8 +748,8 @@ def CompileEggPZ(eggpz, src, opts):
     if (src.endswith(".egg")):
     if (src.endswith(".egg")):
         CopyFile(eggpz[:-3], src)
         CopyFile(eggpz[:-3], src)
     elif (src.endswith(".flt")):
     elif (src.endswith(".flt")):
-        oscmd(GetOutputDir()+"/bin/flt2egg -ps keep -o " + eggpz[:-3] + " " + src)
-    oscmd(GetOutputDir()+"/bin/pzip " + eggpz[:-3])
+        oscmd(GetOutputDir()+"/bin/flt2egg -ps keep -o " + BracketNameWithQuotes(eggpz[:-3]) + " " + BracketNameWithQuotes(src))
+    oscmd(GetOutputDir()+"/bin/pzip " + BracketNameWithQuotes(eggpz[:-3]))
 
 
 ##########################################################################################
 ##########################################################################################
 #
 #