Browse Source

work in progress, test code is ifd off

Dave Schuyler 21 years ago
parent
commit
e35bf8af49
1 changed files with 60 additions and 25 deletions
  1. 60 25
      doc/makepanda/makepanda.py

+ 60 - 25
doc/makepanda/makepanda.py

@@ -27,26 +27,29 @@ import sys,os,time,stat,string,re,getopt,cPickle
 
 
 global FileDateCache
 global FileDateCache
 FileDateCache = {}
 FileDateCache = {}
+skylerTest=0
 
 
-def filedate(path) :
+def filedate(path):
   global FileDateCache
   global FileDateCache
   if (FileDateCache.has_key(path)):
   if (FileDateCache.has_key(path)):
     return(FileDateCache[path])
     return(FileDateCache[path])
-  try : date = os.path.getmtime(path)
-  except : date = 0
+  try: date = os.path.getmtime(path)
+  except: date = 0
   FileDateCache[path] = date
   FileDateCache[path] = date
   return(date)
   return(date)
 
 
-def updatefiledate(path) :
+def updatefiledate(path):
   global FileDateCache
   global FileDateCache
-  try : date = os.path.getmtime(path)
-  except : date = 0
+  try: date = os.path.getmtime(path)
+  except: date = 0
   FileDateCache[path] = date
   FileDateCache[path] = date
 
 
 def youngest(files):
 def youngest(files):
   if (type(files) == str):
   if (type(files) == str):
     source = filedate(files)
     source = filedate(files)
-    if (source==0): sys.exit("Error: source file not readable: "+files)
+    if (source==0):
+      import pdb; pdb.set_trace()
+      sys.exit("Error: source file not readable: "+files)
     return(source)
     return(source)
   result = 0
   result = 0
   for sfile in files:
   for sfile in files:
@@ -127,6 +130,17 @@ if 1:
     exitCode = os.spawnv(os.P_WAIT, cmd, cmdLine)
     exitCode = os.spawnv(os.P_WAIT, cmd, cmdLine)
     if exitCode:
     if exitCode:
       sys.exit("Failed: \"%s\" returned exit code (%s)"%(cmd, exitCode))
       sys.exit("Failed: \"%s\" returned exit code (%s)"%(cmd, exitCode))
+
+  def osCmdEnv(cmd, environment):
+    global VERBOSE
+    if VERBOSE >= 1:
+      print cmd
+    sys.stdout.flush()
+    cmdLine = cmd.split()
+    cmd = getExecutablePath(cmdLine[0])
+    exitCode = os.spawnve(os.P_WAIT, cmd, cmdLine, environment)
+    if exitCode:
+      sys.exit("Failed: \"%s\" returned exit code (%s)"%(cmd, exitCode))
 else:
 else:
   from distutils.spawn import spawn
   from distutils.spawn import spawn
   # This version seems more "standard" and may be updated
   # This version seems more "standard" and may be updated
@@ -841,7 +855,7 @@ def printStatus(header,warnings):
     tomit = ""
     tomit = ""
     for x in PACKAGES:
     for x in PACKAGES:
       if (OMIT.count(x)==0): tkeep = tkeep + x + " "
       if (OMIT.count(x)==0): tkeep = tkeep + x + " "
-      else                 : tomit = tomit + x + " "
+      else:                  tomit = tomit + x + " "
     print "Makepanda: Prefix Directory:",PREFIX
     print "Makepanda: Prefix Directory:",PREFIX
     print "Makepanda: Compiler:",COMPILER
     print "Makepanda: Compiler:",COMPILER
     print "Makepanda: Optimize:",OPTIMIZE
     print "Makepanda: Optimize:",OPTIMIZE
@@ -1162,12 +1176,12 @@ def CompileFlex(pre,dst,src,dashi):
     if (COMPILER=="MSVC7"):
     if (COMPILER=="MSVC7"):
       flexFullPath=os.path.abspath(STDTHIRDPARTY+"win-util/flex.exe")
       flexFullPath=os.path.abspath(STDTHIRDPARTY+"win-util/flex.exe")
       if (dashi): oscdcmd(PREFIX+"/tmp", flexFullPath+" -i -P" + pre + " -olex.yy.c " + fn)
       if (dashi): oscdcmd(PREFIX+"/tmp", flexFullPath+" -i -P" + pre + " -olex.yy.c " + fn)
-      else      : oscdcmd(PREFIX+"/tmp", flexFullPath+"    -P" + pre + " -olex.yy.c " + fn)
+      else:       oscdcmd(PREFIX+"/tmp", flexFullPath+"    -P" + pre + " -olex.yy.c " + fn)
       replaceInFile(PREFIX+'/tmp/lex.yy.c', dst, '#include <unistd.h>', '')
       replaceInFile(PREFIX+'/tmp/lex.yy.c', dst, '#include <unistd.h>', '')
       #WriteFile(wdst, ReadFile("built\\tmp\\lex.yy.c").replace("#include <unistd.h>",""))
       #WriteFile(wdst, ReadFile("built\\tmp\\lex.yy.c").replace("#include <unistd.h>",""))
     if (COMPILER=="LINUXA"):
     if (COMPILER=="LINUXA"):
       if (dashi): oscdcmd(PREFIX+"/tmp", "flex -i -P" + pre + " -olex.yy.c " + fn)
       if (dashi): oscdcmd(PREFIX+"/tmp", "flex -i -P" + pre + " -olex.yy.c " + fn)
-      else      : oscdcmd(PREFIX+"/tmp", "flex    -P" + pre + " -olex.yy.c " + fn)
+      else:       oscdcmd(PREFIX+"/tmp", "flex    -P" + pre + " -olex.yy.c " + fn)
       oscmd('cp built/tmp/lex.yy.c '+dst)
       oscmd('cp built/tmp/lex.yy.c '+dst)
     updatefiledate(dst)
     updatefiledate(dst)
 
 
@@ -1288,6 +1302,7 @@ def CompileRES(obj=0,src=0,ipath=[],opts=[]):
 def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, files=0):
 def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, files=0):
   if ((ipath==0)|(opts==0)|(outd==0)|(outc==0)|(src==0)|(module==0)|(library==0)|(files==0)):
   if ((ipath==0)|(opts==0)|(outd==0)|(outc==0)|(src==0)|(module==0)|(library==0)|(files==0)):
     sys.exit("syntax error in Interrogate directive")
     sys.exit("syntax error in Interrogate directive")
+  ALLIN.append(outd)
   ipath = [PREFIX+"/tmp"] + ipath + [PREFIX+"/include"]
   ipath = [PREFIX+"/tmp"] + ipath + [PREFIX+"/include"]
   outd = PREFIX+"/etc/"+outd
   outd = PREFIX+"/etc/"+outd
   outc = PREFIX+"/tmp/"+outc
   outc = PREFIX+"/tmp/"+outc
@@ -1295,7 +1310,6 @@ def Interrogate(ipath=0, opts=0, outd=0, outc=0, src=0, module=0, library=0, fil
   dep = CxxCalcDependenciesAll(paths, ipath)
   dep = CxxCalcDependenciesAll(paths, ipath)
   dotdots = ""
   dotdots = ""
   for i in range(0,src.count("/")+1): dotdots = dotdots + "../"
   for i in range(0,src.count("/")+1): dotdots = dotdots + "../"
-  ALLIN.append(outd)
   building = 0
   building = 0
   for x in opts:
   for x in opts:
     if (x[:9]=="BUILDING_"): building = x[9:]
     if (x[:9]=="BUILDING_"): building = x[9:]
@@ -1350,6 +1364,9 @@ def InterrogateModule(outc=0, module=0, library=0, files=0):
   outc = PREFIX+"/tmp/"+outc
   outc = PREFIX+"/tmp/"+outc
   files = xpaths(PREFIX+"/etc/",files,"")
   files = xpaths(PREFIX+"/etc/",files,"")
   if (older(outc, files)):
   if (older(outc, files)):
+    global VERBOSE
+    if VERBOSE >= 1:
+      print "Generating Python-stub cxx file for %s"%(library,)
     if (COMPILER=="MSVC7"):
     if (COMPILER=="MSVC7"):
         cmd = PREFIX+"/bin/interrogate_module.exe "
         cmd = PREFIX+"/bin/interrogate_module.exe "
     if (COMPILER=="LINUXA"):
     if (COMPILER=="LINUXA"):
@@ -1679,7 +1696,7 @@ conf = "/* dtool_config.h.  Generated automatically by makepanda.py */\n"
 for key,win,unix in DTOOLDEFAULTS:
 for key,win,unix in DTOOLDEFAULTS:
   val = DTOOLCONFIG[key]
   val = DTOOLCONFIG[key]
   if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
   if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
-  else               : conf = conf + "#define " + key + " " + val + "\n"
+  else:                conf = conf + "#define " + key + " " + val + "\n"
 ConditionalWriteFile(PREFIX+'/include/dtool_config.h',conf)
 ConditionalWriteFile(PREFIX+'/include/dtool_config.h',conf)
 
 
 ##########################################################################################
 ##########################################################################################
@@ -1717,12 +1734,16 @@ if (sys.platform == "win32"):
 ##
 ##
 ########################################################################
 ########################################################################
 
 
-IPATH=['direct/src/directbase']
-CompileC(ipath=IPATH, opts=['BUILDING_PPYTHON'], src='ppython.cxx', obj='ppython.obj')
-CompileLink(opts=['WINUSER'], dll='ppython.exe', obj=['ppython.obj'])
-IPATH=['direct/src/directbase']
-CompileC(ipath=IPATH, opts=['BUILDING_GENPYCODE'], src='ppython.cxx', obj='genpycode.obj')
-CompileLink(opts=['WINUSER'], dll='genpycode.exe', obj=['genpycode.obj'])
+WANT_PPYTHON=not skylerTest
+WANT_GENPYCODE_EXE=not skylerTest
+if WANT_PPYTHON:
+  IPATH=['direct/src/directbase']
+  CompileC(ipath=IPATH, opts=['BUILDING_PPYTHON'], src='ppython.cxx', obj='ppython.obj')
+  CompileLink(opts=['WINUSER'], dll='ppython.exe', obj=['ppython.obj'])
+if WANT_GENPYCODE_EXE:
+  IPATH=['direct/src/directbase']
+  CompileC(ipath=IPATH, opts=['BUILDING_GENPYCODE'], src='ppython.cxx', obj='genpycode.obj')
+  CompileLink(opts=['WINUSER'], dll='genpycode.exe', obj=['genpycode.obj'])
 
 
 ########################################################################
 ########################################################################
 #
 #
@@ -6072,13 +6093,27 @@ CompileLink(opts=['ADVAPI', 'NSPR', 'FFTW'], dll='stitch-image.exe', obj=[
 #
 #
 ##########################################################################################
 ##########################################################################################
 
 
-if (older(PREFIX+'/lib/pandac/PandaModules.pyz',xpaths(PREFIX+"/etc/",ALLIN,""))):
-  ALLTARGETS.append(PREFIX+'/lib/pandac/PandaModules.pyz')
-  if (sys.platform=="win32"):
-    oscmd(PREFIX+"/bin/genpycode.exe")
-  else:
-    oscmd(PREFIX+"/bin/genpycode")
-  updatefiledate(PREFIX+'/lib/pandac/PandaModules.pyz')
+if skylerTest:
+  if older(PREFIX+'/lib/pandac/PandaModules.pyz', xpaths(PREFIX+"/etc/", ALLIN, "")):
+    ALLTARGETS.append(PREFIX+'/lib/pandac/PandaModules.pyz')
+    if (sys.platform=="win32"):
+      env=os.environ.copy()
+      env["PYTHONPATH"]="%s;%s\\bin;%s\\lib;%s;%s"%(
+        PREFIX, PREFIX, PREFIX, PANDASOURCE, os.getenv("PYTHONPATH"))
+      env["PATH"]="%s\\bin;%s"%(PREFIX, os.getenv("PATH"))
+      env["PANDAROOT"]=PANDASOURCE
+      osCmdEnv("python.exe \""+PANDASOURCE+"\\direct\\src/ffi/jGenPyCode.py\"", env)
+    else:
+      oscmd(PREFIX+"/bin/genpycode")
+    updatefiledate(PREFIX+'/lib/pandac/PandaModules.pyz')
+else:
+  if (older(PREFIX+'/lib/pandac/PandaModules.pyz',xpaths(PREFIX+"/etc/",ALLIN,""))):
+    ALLTARGETS.append(PREFIX+'/lib/pandac/PandaModules.pyz')
+    if (sys.platform=="win32"):
+      oscmd(PREFIX+"/bin/genpycode.exe")
+    else:
+      oscmd(PREFIX+"/bin/genpycode")
+    updatefiledate(PREFIX+'/lib/pandac/PandaModules.pyz')
 
 
 ########################################################################
 ########################################################################
 ##
 ##