Browse Source

Support for building the web plugin via makepanda

rdb 16 years ago
parent
commit
4bbf69c07b
2 changed files with 104 additions and 8 deletions
  1. 102 8
      makepanda/makepanda.py
  2. 2 0
      makepanda/makepandacore.py

+ 102 - 8
makepanda/makepanda.py

@@ -40,10 +40,10 @@ THREADCOUNT=0
 CFLAGS=""
 CFLAGS=""
 
 
 PkgListSet(MAYAVERSIONS + MAXVERSIONS + DXVERSIONS + [
 PkgListSet(MAYAVERSIONS + MAXVERSIONS + DXVERSIONS + [
-  "PYTHON","ZLIB","PNG","JPEG","TIFF","VRPN",
+  "PYTHON","ZLIB","PNG","JPEG","TIFF","VRPN","TINYXML",
   "FMODEX","OPENAL","NVIDIACG","OPENSSL","FREETYPE",
   "FMODEX","OPENAL","NVIDIACG","OPENSSL","FREETYPE",
-  "FFTW","ARTOOLKIT","SQUISH","ODE","DIRECTCAM",
-  "OPENCV","FFMPEG","FCOLLADA","PANDATOOL"
+  "FFTW","ARTOOLKIT","SQUISH","ODE","DIRECTCAM","NPAPI",
+  "OPENCV","FFMPEG","FCOLLADA","PLUGIN","PANDATOOL"
 ])
 ])
 
 
 CheckPandaSourceTree()
 CheckPandaSourceTree()
@@ -72,7 +72,7 @@ def usage(problem):
     print "compiled copy of Panda3D.  Command-line arguments are:"
     print "compiled copy of Panda3D.  Command-line arguments are:"
     print ""
     print ""
     print "  --help            (print the help message you're reading now)"
     print "  --help            (print the help message you're reading now)"
-    print "  --target T        (target can be 'all','panda3d','plugins','installer')"
+    print "  --installer       (build an installer)"
     print "  --optimize X      (optimization level can be 1,2,3,4)"
     print "  --optimize X      (optimization level can be 1,2,3,4)"
     print "  --version         (set the panda version number)"
     print "  --version         (set the panda version number)"
     print "  --lzma            (use lzma compression when building installer)"
     print "  --lzma            (use lzma compression when building installer)"
@@ -306,6 +306,7 @@ if (COMPILER=="MSVC"):
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/cvaux.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/cvaux.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/ml.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/ml.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/cxcore.lib")
     if (PkgSkip("OPENCV")==0):   LibName("OPENCV",   THIRDPARTYLIBS + "opencv/lib/cxcore.lib")
+    if (PkgSkip("TINYXML")==0):  LibName("TINYXML",  THIRDPARTYLIBS + "tinyxml/lib/tinyxml.lib")
     for pkg in MAYAVERSIONS:
     for pkg in MAYAVERSIONS:
         if (PkgSkip(pkg)==0):
         if (PkgSkip(pkg)==0):
             LibName(pkg, '"' + SDK[pkg] + '/lib/Foundation.lib"')
             LibName(pkg, '"' + SDK[pkg] + '/lib/Foundation.lib"')
@@ -338,9 +339,9 @@ if (COMPILER=="LINUX"):
     PkgConfigEnable("GTK2", "gtk+-2.0")
     PkgConfigEnable("GTK2", "gtk+-2.0")
     
     
     if (sys.platform == "darwin"):
     if (sys.platform == "darwin"):
-        pkgs = ["VRPN", "FFTW", "FMODEX", "ARTOOLKIT", "ODE", "OPENCV", "FCOLLADA", "SQUISH", "FFMPEG", "PNG", "JPEG", "TIFF"]
+        pkgs = ["VRPN", "FFTW", "FMODEX", "ARTOOLKIT", "ODE", "OPENCV", "FCOLLADA", "SQUISH", "FFMPEG", "PNG", "JPEG", "TIFF", "TINYXML"]
     else:
     else:
-        pkgs = ["VRPN", "FFTW", "FMODEX", "ARTOOLKIT", "ODE", "OPENCV", "FCOLLADA", "SQUISH", "NVIDIACG", "FFMPEG", "OPENAL"]
+        pkgs = ["VRPN", "FFTW", "FMODEX", "ARTOOLKIT", "ODE", "OPENCV", "FCOLLADA", "SQUISH", "NVIDIACG", "FFMPEG", "OPENAL", "TINYXML"]
     for pkg in pkgs:
     for pkg in pkgs:
         if (PkgSkip(pkg)==0):
         if (PkgSkip(pkg)==0):
             if (os.path.isdir(THIRDPARTYLIBS + pkg.lower())):
             if (os.path.isdir(THIRDPARTYLIBS + pkg.lower())):
@@ -505,9 +506,9 @@ def CompileCxx(obj,src,opts):
         cmd += "/wd4996 /wd4275 /wd4267 /wd4101 /Fo" + obj + " /nologo /c "
         cmd += "/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' + BracketNameWithQuotes(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'
         if (opts.count('MSFORSCOPE')): cmd = cmd + ' /Zc:forScope-'
         if (opts.count('MSFORSCOPE')): cmd = cmd + ' /Zc:forScope-'
         optlevel = GetOptimizeOption(opts,OPTIMIZE)
         optlevel = GetOptimizeOption(opts,OPTIMIZE)
@@ -767,6 +768,26 @@ def CompileEggPZ(eggpz, src, opts):
         oscmd(GetOutputDir()+"/bin/flt2egg -ps keep -o " + BracketNameWithQuotes(eggpz[:-3]) + " " + BracketNameWithQuotes(src))
         oscmd(GetOutputDir()+"/bin/flt2egg -ps keep -o " + BracketNameWithQuotes(eggpz[:-3]) + " " + BracketNameWithQuotes(src))
     oscmd(GetOutputDir()+"/bin/pzip " + BracketNameWithQuotes(eggpz[:-3]))
     oscmd(GetOutputDir()+"/bin/pzip " + BracketNameWithQuotes(eggpz[:-3]))
 
 
+##########################################################################################
+#
+# CompileRC
+#
+##########################################################################################
+
+def CompileRC(target, src, opts):
+    ipath = GetListOption(opts, "DIR:")
+    if (COMPILER=="MSVC"):
+        cmd = "rc "
+        cmd += "/Fo" + BracketNameWithQuotes(target)
+        for x in ipath: cmd = cmd + " /I" + x
+        for (opt,dir) in INCDIRECTORIES:
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + " /I" + BracketNameWithQuotes(dir)
+        for (opt,var,val) in DEFSYMBOLS:
+            if (opt=="ALWAYS") or (opts.count(opt)): cmd = cmd + " /D" + var + "=" + val
+        cmd += " " + BracketNameWithQuotes(src)
+
+        oscmd(cmd)
+
 ##########################################################################################
 ##########################################################################################
 #
 #
 # CompileAnything
 # CompileAnything
@@ -788,6 +809,8 @@ def CompileAnything(target, inputs, opts):
         return CompileIgate(target, inputs, opts)
         return CompileIgate(target, inputs, opts)
     elif (origsuffix==".pz"):
     elif (origsuffix==".pz"):
         return CompileEggPZ(target, infile, opts)
         return CompileEggPZ(target, infile, opts)
+    elif (origsuffix==".res"):
+        return CompileRC(target, infile, opts)
     elif (origsuffix==".obj"):
     elif (origsuffix==".obj"):
         if (infile.endswith(".cxx") or infile.endswith(".c") or infile.endswith(".mm")):
         if (infile.endswith(".cxx") or infile.endswith(".c") or infile.endswith(".mm")):
             return CompileCxx(target, infile, opts)
             return CompileCxx(target, infile, opts)
@@ -797,6 +820,8 @@ def CompileAnything(target, inputs, opts):
             return CompileFlex(target, infile, opts)
             return CompileFlex(target, infile, opts)
         elif (infile.endswith(".in")):
         elif (infile.endswith(".in")):
             return CompileImod(target, inputs, opts)
             return CompileImod(target, inputs, opts)
+        elif (infile.endswith(".rc")):
+            return CompileRC(target, infile, opts)
     exit("Don't know how to compile: "+target)
     exit("Don't know how to compile: "+target)
 
 
 ##########################################################################################
 ##########################################################################################
@@ -927,6 +952,7 @@ DTOOL_CONFIG=[
     ("HAVE_DIRECTCAM",                 'UNDEF',                  'UNDEF'),
     ("HAVE_DIRECTCAM",                 'UNDEF',                  'UNDEF'),
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
     ("HAVE_FCOLLADA",                  'UNDEF',                  'UNDEF'),
     ("HAVE_FCOLLADA",                  'UNDEF',                  'UNDEF'),
+    ("HAVE_NPAPI",                     'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL_FRAMEWORK",          'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL_FRAMEWORK",          'UNDEF',                  'UNDEF'),
     ("PRC_SAVE_DESCRIPTIONS",          '1',                      '1'),
     ("PRC_SAVE_DESCRIPTIONS",          '1',                      '1'),
 ]
 ]
@@ -949,6 +975,7 @@ PRC_PARAMETERS=[
 def WriteConfigSettings():
 def WriteConfigSettings():
     dtool_config={}
     dtool_config={}
     prc_parameters={}
     prc_parameters={}
+    plugin_config={}
 
 
     if (sys.platform == "win32") or (sys.platform == "win64"):
     if (sys.platform == "win32") or (sys.platform == "win64"):
         for key,win,unix in DTOOL_CONFIG:
         for key,win,unix in DTOOL_CONFIG:
@@ -1016,6 +1043,16 @@ def WriteConfigSettings():
     if (sys.platform.startswith('win') and platform.architecture()[0] == '64bit'):
     if (sys.platform.startswith('win') and platform.architecture()[0] == '64bit'):
         dtool_config["SIMPLE_THREADS"] = 'UNDEF'
         dtool_config["SIMPLE_THREADS"] = 'UNDEF'
 
 
+    if (PkgSkip("PLUGIN")==0):
+        #FIXME: do this at runtime or so.
+        plugin_config["P3D_PLUGIN_DOWNLOAD"] = "file://C:\\p3dstage"
+        plugin_config["P3D_PLUGIN_LOGFILE1"] = ""
+        plugin_config["P3D_PLUGIN_LOGFILE2"] = ""
+        plugin_config["P3D_PLUGIN_P3DPYTHON"] = ""
+        plugin_config["P3D_PLUGIN_P3D_PLUGIN"] = ""
+        if sys.platform.startswith("win"):
+          plugin_config["P3D_PLUGIN_PLATFORM"] = sys.platform
+
     conf = "/* prc_parameters.h.  Generated automatically by makepanda.py */\n"
     conf = "/* prc_parameters.h.  Generated automatically by makepanda.py */\n"
     for key in prc_parameters.keys():
     for key in prc_parameters.keys():
         if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")):
         if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")):
@@ -1033,6 +1070,15 @@ def WriteConfigSettings():
         del dtool_config[key]
         del dtool_config[key]
     ConditionalWriteFile(GetOutputDir() + '/include/dtool_config.h', conf)
     ConditionalWriteFile(GetOutputDir() + '/include/dtool_config.h', conf)
 
 
+    if (PkgSkip("PLUGIN")==0):
+        conf = "/* p3d_plugin_config.h.  Generated automatically by makepanda.py */\n"
+        for key in plugin_config.keys():
+            val = plugin_config[key]
+            if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
+            else:                conf = conf + "#define " + key + " \"" + val + "\"\n"
+            del plugin_config[key]
+        ConditionalWriteFile(GetOutputDir() + '/include/p3d_plugin_config.h', conf)
+
     for x in PkgListGet():
     for x in PkgListGet():
         if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\n")
         if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\n")
         else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"1\n")
         else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"1\n")
@@ -1312,6 +1358,9 @@ CopyAllHeaders('direct/src/showbase')
 CopyAllHeaders('direct/metalibs/direct')
 CopyAllHeaders('direct/metalibs/direct')
 CopyAllHeaders('direct/src/dcparse')
 CopyAllHeaders('direct/src/dcparse')
 CopyAllHeaders('direct/src/heapq')
 CopyAllHeaders('direct/src/heapq')
+CopyAllHeaders('direct/src/plugin')
+CopyAllHeaders('direct/src/plugin_npapi')
+CopyAllHeaders('direct/src/plugin_standalone')
 
 
 CopyAllHeaders('pandatool/src/pandatoolbase')
 CopyAllHeaders('pandatool/src/pandatoolbase')
 CopyAllHeaders('pandatool/src/converter')
 CopyAllHeaders('pandatool/src/converter')
@@ -2768,6 +2817,51 @@ if (PkgSkip("PYTHON")==0):
   TargetAdd('libp3heapq.dll', input=COMMON_DTOOL_LIBS)
   TargetAdd('libp3heapq.dll', input=COMMON_DTOOL_LIBS)
   TargetAdd('libp3heapq.dll', opts=['ADVAPI'])
   TargetAdd('libp3heapq.dll', opts=['ADVAPI'])
 
 
+#
+# DIRECTORY: direct/src/plugin/
+#
+
+if (PkgSkip("PLUGIN")==0 and PkgSkip("TINYXML")==0):
+  OPTS=['DIR:direct/src/plugin', 'TINYXML', 'OPENSSL']
+  TargetAdd('plugin_common.obj', opts=OPTS, input='plugin_common_composite1.cxx')
+  
+  OPTS=['DIR:direct/src/plugin', 'TINYXML', 'ZLIB', 'JPEG']
+  TargetAdd('plugin_plugin.obj', opts=OPTS, input='p3d_plugin_composite1.cxx')
+  TargetAdd('plugin_handleStream.obj', opts=OPTS, input='handleStream.cxx')
+  TargetAdd('plugin_handleStreamBuf.obj', opts=OPTS, input='handleStreamBuf.cxx')
+  TargetAdd('p3d_plugin.dll', input='plugin_common.obj')
+  TargetAdd('p3d_plugin.dll', input='plugin_plugin.obj')
+  TargetAdd('p3d_plugin.dll', input='plugin_handleStream.obj')
+  TargetAdd('p3d_plugin.dll', input='plugin_handleStreamBuf.obj')
+  TargetAdd('p3d_plugin.dll', opts=['TINYXML', 'OPENSSL', 'ZLIB', 'JPEG', 'WINUSER', 'WINGDI', 'WINSHELL', 'WINCOMCTL'])
+
+  if (PkgSkip("PYTHON")==0):
+    TargetAdd('plugin_p3dCInstance.obj', opts=OPTS, input='p3dCInstance.cxx')
+    TargetAdd('plugin_p3dPythonRun.obj', opts=OPTS, input='p3dPythonRun.cxx')
+    TargetAdd('p3dpython.exe', input='plugin_p3dCInstance.obj')
+    TargetAdd('p3dpython.exe', input='plugin_handleStream.obj')
+    TargetAdd('p3dpython.exe', input='plugin_handleStreamBuf.obj')
+    TargetAdd('p3dpython.exe', input='plugin_p3dPythonRun.obj')
+    TargetAdd('p3dpython.exe', input=COMMON_PANDA_LIBS)
+    TargetAdd('p3dpython.exe', opts=['TINYXML'])
+
+#
+# DIRECTORY: direct/src/plugin_npapi/
+#
+
+if (PkgSkip("PLUGIN")==0 and PkgSkip("TINYXML")==0 and PkgSkip("NPAPI")==0):
+  OPTS=['DIR:direct/src/plugin_npapi']
+  ConditionalWriteFile(GetOutputDir()+"/include/resource.h", "")
+  TargetAdd('nppanda3d.res', opts=OPTS, input='nppanda3d.rc')
+  
+  OPTS=['DIR:direct/src/plugin_npapi', 'NPAPI', 'TINYXML']
+  TargetAdd('plugin_npapi_nppanda3d_composite1.obj', opts=OPTS, input='nppanda3d_composite1.cxx')
+  TargetAdd('nppanda3d.dll', input='plugin_common.obj')
+  TargetAdd('nppanda3d.dll', input='plugin_npapi_nppanda3d_composite1.obj')
+  TargetAdd('nppanda3d.dll', input='nppanda3d.res')
+  TargetAdd('nppanda3d.dll', input='nppanda3d.def', ipath=OPTS)
+  TargetAdd('nppanda3d.dll', opts=['NPAPI', 'TINYXML', 'OPENSSL', 'WINUSER', 'WINSHELL'])
+
 #
 #
 # DIRECTORY: pandatool/src/pandatoolbase/
 # DIRECTORY: pandatool/src/pandatoolbase/
 #
 #

+ 2 - 0
makepanda/makepandacore.py

@@ -1126,7 +1126,9 @@ def CalcLocation(fn, ipath):
     if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn
     if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn
     if (sys.platform == "win32"):
     if (sys.platform == "win32"):
         if (fn.endswith(".def")): return CxxFindSource(fn, ipath)
         if (fn.endswith(".def")): return CxxFindSource(fn, ipath)
+        if (fn.endswith(".rc")):  return CxxFindSource(fn, ipath)
         if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn
         if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn
+        if (fn.endswith(".res")): return OUTPUTDIR+"/tmp/"+fn
         if (fn.endswith(".dll")): return OUTPUTDIR+"/bin/"+fn
         if (fn.endswith(".dll")): return OUTPUTDIR+"/bin/"+fn
         if (fn.endswith(".dlo")): return OUTPUTDIR+"/plugins/"+fn
         if (fn.endswith(".dlo")): return OUTPUTDIR+"/plugins/"+fn
         if (fn.endswith(".dli")): return OUTPUTDIR+"/plugins/"+fn
         if (fn.endswith(".dli")): return OUTPUTDIR+"/plugins/"+fn