Resource file generation (not for activex yet), cleaner system for moving around potentially conflicting ppremake files, and bugfix for --osxtarget

This commit is contained in:
rdb 2009-11-11 12:37:44 +00:00
parent 54ea5fbf3b
commit a565600ea0
2 changed files with 126 additions and 38 deletions

View File

@ -145,7 +145,7 @@ def parseopts(args):
usage("Options --runtime and --rtdist cannot be specified at the same time!")
if (optimize=="" and (RTDIST or RUNTIME)): optimize = "4"
elif (optimize==""): optimize = "3"
if (OSXTARGET.strip() == ""):
if (OSXTARGET != None and OSXTARGET.strip() == ""):
OSXTARGET = None
elif (OSXTARGET != None):
OSXTARGET = OSXTARGET.strip()
@ -1383,21 +1383,11 @@ def WriteConfigSettings():
WriteConfigSettings()
# Move any potentially conflicting files out of the way.
if os.path.isfile("dtool/src/dtoolutil/pandaVersion.h"):
os.rename("dtool/src/dtoolutil/pandaVersion.h", "dtool/src/dtoolutil/pandaVersion.h.moved")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.h"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.h", "dtool/src/dtoolutil/checkPandaVersion.h.moved")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.cxx"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.cxx", "dtool/src/dtoolutil/checkPandaVersion.cxx.moved")
if os.path.isfile("dtool/src/prc/prc_parameters.h"):
os.rename("dtool/src/prc/prc_parameters.h", "dtool/src/prc/prc_parameters.h.moved")
if os.path.isfile("direct/src/plugin/p3d_plugin_config.h"):
os.rename("direct/src/plugin/p3d_plugin_config.h", "direct/src/plugin/p3d_plugin_config.h.moved")
MoveAwayConflictingFiles()
##########################################################################################
#
# Generate pandaVersion.h, pythonversion, null.cxx
# Generate pandaVersion.h, pythonversion, null.cxx, etc.
#
##########################################################################################
@ -1443,6 +1433,7 @@ extern EXPCL_DTOOL int panda_version_$VERSION1_$VERSION2_$VERSION3;
static int check_panda_version = panda_version_$VERSION1_$VERSION2_$VERSION3;
# endif
"""
def CreatePandaVersionFiles():
version1=int(VERSION.split(".")[0])
version2=int(VERSION.split(".")[1])
@ -3273,7 +3264,14 @@ if (RTDIST or RUNTIME):
if (RUNTIME and PkgSkip("NPAPI")==0):
OPTS=['DIR:direct/src/plugin_npapi', 'RUNTIME']
if (sys.platform.startswith("win")):
TargetAdd('nppanda3d.res', opts=OPTS, input='nppanda3d.rc')
nppanda3d_rc = {"name" : "Panda3D Game Engine Plug-in",
"version" : VERSION,
"description" : "Runs 3-D games and interactive applets",
"filename" : "nppanda3d.dll",
"mimetype" : "application/x-panda3d",
"extension" : "p3d",
"filedesc" : "Panda3D applet"}
TargetAdd('nppanda3d.res', opts=OPTS, winrc=nppanda3d_rc)
elif (sys.platform=="darwin"):
TargetAdd('nppanda3d.rsrc', opts=OPTS, input='nppanda3d.r')
@ -3320,12 +3318,25 @@ if (RUNTIME):
OPTS=['DIR:direct/src/plugin_standalone', 'RUNTIME', 'TINYXML', 'OPENSSL']
TargetAdd('plugin_standalone_panda3d.obj', opts=OPTS, input='panda3d.cxx')
if (sys.platform.startswith("win")):
panda3d_rc = {"name" : "Panda3D Game Engine Plug-in",
"version" : VERSION,
"description" : "Runs 3-D games and interactive applets",
"filename" : "panda3d.exe",
"mimetype" : "application/x-panda3d",
"extension" : "p3d",
"filedesc" : "Panda3D applet",
"icon" : "panda3d.ico"}
TargetAdd('panda3d.res', opts=OPTS, winrc=panda3d_rc)
TargetAdd('plugin_standalone_panda3dMain.obj', opts=OPTS, input='panda3dMain.cxx')
TargetAdd('panda3d.exe', input='plugin_standalone_panda3d.obj')
TargetAdd('panda3d.exe', input='plugin_standalone_panda3dMain.obj')
TargetAdd('panda3d.exe', input='plugin_common.obj')
if (sys.platform == "darwin"):
TargetAdd('panda3d.exe', input='plugin_find_root_dir_assist.obj')
elif (sys.platform.startswith("win")):
TargetAdd('panda3d.exe', input='panda3d.res')
TargetAdd('panda3d.exe', input='libpandaexpress.dll')
TargetAdd('panda3d.exe', input='libp3dtoolconfig.dll')
TargetAdd('panda3d.exe', input='libp3dtool.dll')
@ -4666,18 +4677,7 @@ if (INSTALLER != 0):
##########################################################################################
SaveDependencyCache()
# Move any files we've moved away back.
if os.path.isfile("dtool/src/dtoolutil/pandaVersion.h.moved"):
os.rename("dtool/src/dtoolutil/pandaVersion.h.moved", "dtool/src/dtoolutil/pandaVersion.h")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.h.moved"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.h.moved", "dtool/src/dtoolutil/checkPandaVersion.h")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.cxx.moved"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.cxx.moved", "dtool/src/dtoolutil/checkPandaVersion.cxx")
if os.path.isfile("dtool/src/prc/prc_parameters.h.moved"):
os.rename("dtool/src/prc/prc_parameters.h.moved", "dtool/src/prc/prc_parameters.h")
if os.path.isfile("direct/src/plugin/p3d_plugin_config.h.moved"):
os.rename("direct/src/plugin/p3d_plugin_config.h.moved", "direct/src/plugin/p3d_plugin_config.h")
MoveBackConflictingFiles()
WARNINGS.append("Elapsed Time: "+PrettyTime(time.time() - STARTTIME))

View File

@ -57,6 +57,36 @@ for (ver,key) in MAYAVERSIONINFO:
for (ver,key1,key2,subdir) in MAXVERSIONINFO:
MAXVERSIONS.append(ver)
########################################################################
##
## Potentially Conflicting Files
##
## The next few functions can automatically move away files that
## are commonly generated by ppremake that may conflict with the
## build. When makepanda exits, those files will automatically be
## put back to their original location.
##
########################################################################
CONFLICTING_FILES=["dtool/src/dtoolutil/pandaVersion.h",
"dtool/src/dtoolutil/checkPandaVersion.h",
"dtool/src/dtoolutil/checkPandaVersion.cxx",
"dtool/src/prc/prc_parameters.h",
"direct/src/plugin/p3d_plugin_config.h",
"direct/src/plugin_activex/P3DActiveX.rc",
"direct/src/plugin_npapi/nppanda3d.rc",
"direct/src/plugin_standalone/panda3d.rc"]
def MoveAwayConflictingFiles():
for cfile in CONFLICTING_FILES:
if os.path.exists(cfile):
os.rename(cfile, cfile + ".moved")
def MoveBackConflictingFiles():
for cfile in CONFLICTING_FILES:
if os.path.exists(cfile + ".moved"):
os.rename(cfile + ".moved", cfile)
########################################################################
##
## The exit routine will normally
@ -140,19 +170,11 @@ def ProgressOutput(progress, msg, target = None):
print "%s%s%s" % (GetColor("green"), target, GetColor())
def exit(msg = ""):
sys.stdout.flush()
sys.stderr.flush()
if (threading.currentThread() == MAINTHREAD):
SaveDependencyCache()
# Move any files we've moved away back.
if os.path.isfile("dtool/src/dtoolutil/pandaVersion.h.moved"):
os.rename("dtool/src/dtoolutil/pandaVersion.h.moved", "dtool/src/dtoolutil/pandaVersion.h")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.h.moved"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.h.moved", "dtool/src/dtoolutil/checkPandaVersion.h")
if os.path.isfile("dtool/src/dtoolutil/checkPandaVersion.cxx.moved"):
os.rename("dtool/src/dtoolutil/checkPandaVersion.cxx.moved", "dtool/src/dtoolutil/checkPandaVersion.cxx")
if os.path.isfile("dtool/src/prc/prc_parameters.h.moved"):
os.rename("dtool/src/prc/prc_parameters.h.moved", "dtool/src/prc/prc_parameters.h")
if os.path.isfile("direct/src/plugin/p3d_plugin_config.h.moved"):
os.rename("direct/src/plugin/p3d_plugin_config.h.moved", "direct/src/plugin/p3d_plugin_config.h")
MoveAwayConflictingFiles()
print "Elapsed Time: "+PrettyTime(time.time() - STARTTIME)
print msg
print GetColor("red") + "Build terminated." + GetColor()
@ -1572,6 +1594,70 @@ def ParsePluginVersion(fn):
except: pass
return "0.0.0"
##########################################################################################
#
# Utility function to generate a resource file
#
##########################################################################################
RESOURCE_FILE_TEMPLATE = """#define APSTUDIO_READONLY_SYMBOLS
#include "winresrc.h"
#undef APSTUDIO_READONLY_SYMBOLS
VS_VERSION_INFO VERSIONINFO
FILEVERSION %(commaversion)s
PRODUCTVERSION %(commaversion)s
FILEFLAGSMASK 0x3fL
FILEFLAGS $(debugflag)s
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "FileDescription", "%(description)s\0"
VALUE "FileVersion", "%(dotversion)s"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "%(mimetype)s\0"
VALUE "FileExtents", "%(extension)s\0"
VALUE "FileOpenName", "%(filedesc)s\0"
VALUE "OriginalFilename", "%(filename)s\0"
VALUE "ProductName", "%(name)s %(version)s\0"
VALUE "ProductVersion", "%(dotversion)s"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
"""
def GenerateResourceFile(basename, **kwargs):
if "debugflag" not in kwargs:
if GetOptimize() <= 2:
kwargs["debugflag"] = "0x1L"
else:
kwargs["debugflag"] = "0x0L"
kwargs["dotversion"] = kwargs["version"]
if len(kwargs["dotversion"].split(".")) == 3:
kwargs["dotversion"] += ".0"
if "commaversion" not in kwargs:
kwargs["commaversion"] = kwargs["dotversion"].replace(".", ",")
rcdata = RESOURCE_FILE_TEMPLATE % kwargs
if "icon" in kwargs:
rcdata += "\nICON_FILE ICON \"%s\"\n" % kwargs["icon"]
if not basename.endswith(".rc"):
basename += ".rc"
basename = GetOutputDir() + "/include/" + basename
ConditionalWriteFile(basename, rcdata)
return basename
########################################################################
##
## FindLocation
@ -1707,7 +1793,7 @@ class Target:
TARGET_LIST=[]
TARGET_TABLE={}
def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0):
def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0):
if (dummy != 0):
exit("Syntax error in TargetAdd "+target)
if (ipath == 0): ipath = opts
@ -1746,6 +1832,8 @@ def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0):
for x in dep:
fulldep = FindLocation(x, ipath)
t.deps[fulldep] = 1
if (winrc != 0 and sys.platform.startswith("win")):
t.deps[GenerateResourceFile(target.split("/")[-1].split(".")[0], **winrc)] = 1
if (target.endswith(".in")):
t.deps[FindLocation("interrogate.exe",[])] = 1
t.deps[FindLocation("dtool_have_python.dat",[])] = 1