mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Support specifying custom location of thirdparty packages on makepanda command-line
This commit is contained in:
parent
0f8f4d63b0
commit
982ece639d
@ -150,6 +150,9 @@ def usage(problem):
|
|||||||
for pkg in PkgListGet():
|
for pkg in PkgListGet():
|
||||||
p = pkg.lower()
|
p = pkg.lower()
|
||||||
print(" --use-%-9s --no-%-9s (enable/disable use of %s)"%(p, p, pkg))
|
print(" --use-%-9s --no-%-9s (enable/disable use of %s)"%(p, p, pkg))
|
||||||
|
if sys.platform != 'win32':
|
||||||
|
print(" --<PKG>-incdir (custom location for header files of thirdparty package)")
|
||||||
|
print(" --<PKG>-libdir (custom location for library files of thirdparty package)")
|
||||||
print("")
|
print("")
|
||||||
print(" --nothing (disable every third-party lib)")
|
print(" --nothing (disable every third-party lib)")
|
||||||
print(" --everything (enable every third-party lib)")
|
print(" --everything (enable every third-party lib)")
|
||||||
@ -180,11 +183,13 @@ def parseopts(args):
|
|||||||
target = None
|
target = None
|
||||||
target_arch = None
|
target_arch = None
|
||||||
universal = False
|
universal = False
|
||||||
for pkg in PkgListGet(): longopts.append("no-"+pkg.lower())
|
for pkg in PkgListGet():
|
||||||
for pkg in PkgListGet(): longopts.append("use-"+pkg.lower())
|
longopts.append("no-" + pkg.lower())
|
||||||
|
longopts.append(pkg.lower() + "-incdir=")
|
||||||
|
longopts.append(pkg.lower() + "-libdir=")
|
||||||
try:
|
try:
|
||||||
opts, extras = getopt.getopt(args, "", longopts)
|
opts, extras = getopt.getopt(args, "", longopts)
|
||||||
for option,value in opts:
|
for option, value in opts:
|
||||||
if (option=="--help"): raise Exception
|
if (option=="--help"): raise Exception
|
||||||
elif (option=="--optimize"): optimize=value
|
elif (option=="--optimize"): optimize=value
|
||||||
elif (option=="--installer"): INSTALLER=1
|
elif (option=="--installer"): INSTALLER=1
|
||||||
@ -229,19 +234,25 @@ def parseopts(args):
|
|||||||
elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True
|
elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True
|
||||||
else:
|
else:
|
||||||
for pkg in PkgListGet():
|
for pkg in PkgListGet():
|
||||||
if (option=="--use-"+pkg.lower()):
|
if option == "--use-" + pkg.lower():
|
||||||
PkgEnable(pkg)
|
PkgEnable(pkg)
|
||||||
break
|
break
|
||||||
for pkg in PkgListGet():
|
elif option == "--use-" + pkg.lower():
|
||||||
if (option=="--no-"+pkg.lower()):
|
|
||||||
PkgDisable(pkg)
|
PkgDisable(pkg)
|
||||||
break
|
break
|
||||||
if (option=="--everything" or option.startswith("--use-")
|
elif option == "--" + pkg.lower() + "-incdir":
|
||||||
or option=="--nothing" or option.startswith("--no-")):
|
PkgSetCustomLocation(pkg)
|
||||||
|
IncDirectory(pkg, value)
|
||||||
|
break
|
||||||
|
elif option == "--" + pkg.lower() + "-libdir":
|
||||||
|
PkgSetCustomLocation(pkg)
|
||||||
|
LibDirectory(pkg, value)
|
||||||
|
break
|
||||||
|
if (option == "--everything" or option.startswith("--use-")
|
||||||
|
or option == "--nothing" or option.startswith("--no-")):
|
||||||
anything = 1
|
anything = 1
|
||||||
except:
|
except:
|
||||||
usage(0)
|
usage(sys.exc_info()[1])
|
||||||
print("Exception while parsing commandline:", sys.exc_info()[0])
|
|
||||||
|
|
||||||
if not anything:
|
if not anything:
|
||||||
if RUNTIME:
|
if RUNTIME:
|
||||||
@ -4179,7 +4190,7 @@ if (not RUNTIME):
|
|||||||
#
|
#
|
||||||
|
|
||||||
if (not RUNTIME and PkgSkip("GL")==0):
|
if (not RUNTIME and PkgSkip("GL")==0):
|
||||||
OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'NVIDIACG']
|
OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GL', 'NVIDIACG']
|
||||||
TargetAdd('p3glgsg_config_glgsg.obj', opts=OPTS, input='config_glgsg.cxx')
|
TargetAdd('p3glgsg_config_glgsg.obj', opts=OPTS, input='config_glgsg.cxx')
|
||||||
TargetAdd('p3glgsg_glgsg.obj', opts=OPTS, input='glgsg.cxx')
|
TargetAdd('p3glgsg_glgsg.obj', opts=OPTS, input='glgsg.cxx')
|
||||||
|
|
||||||
@ -4188,7 +4199,7 @@ if (not RUNTIME and PkgSkip("GL")==0):
|
|||||||
#
|
#
|
||||||
|
|
||||||
if (not RUNTIME and PkgSkip("GLES")==0):
|
if (not RUNTIME and PkgSkip("GLES")==0):
|
||||||
OPTS=['DIR:panda/src/glesgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES']
|
OPTS=['DIR:panda/src/glesgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES', 'GLES']
|
||||||
TargetAdd('p3glesgsg_config_glesgsg.obj', opts=OPTS, input='config_glesgsg.cxx')
|
TargetAdd('p3glesgsg_config_glesgsg.obj', opts=OPTS, input='config_glesgsg.cxx')
|
||||||
TargetAdd('p3glesgsg_glesgsg.obj', opts=OPTS, input='glesgsg.cxx')
|
TargetAdd('p3glesgsg_glesgsg.obj', opts=OPTS, input='glesgsg.cxx')
|
||||||
|
|
||||||
@ -4197,7 +4208,7 @@ if (not RUNTIME and PkgSkip("GLES")==0):
|
|||||||
#
|
#
|
||||||
|
|
||||||
if (not RUNTIME and PkgSkip("GLES2")==0):
|
if (not RUNTIME and PkgSkip("GLES2")==0):
|
||||||
OPTS=['DIR:panda/src/gles2gsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES2']
|
OPTS=['DIR:panda/src/gles2gsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES2', 'GLES2']
|
||||||
TargetAdd('p3gles2gsg_config_gles2gsg.obj', opts=OPTS, input='config_gles2gsg.cxx')
|
TargetAdd('p3gles2gsg_config_gles2gsg.obj', opts=OPTS, input='config_gles2gsg.cxx')
|
||||||
TargetAdd('p3gles2gsg_gles2gsg.obj', opts=OPTS, input='gles2gsg.cxx')
|
TargetAdd('p3gles2gsg_gles2gsg.obj', opts=OPTS, input='gles2gsg.cxx')
|
||||||
|
|
||||||
|
@ -1217,8 +1217,9 @@ def UnsetLinkAllStatic():
|
|||||||
##
|
##
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
PKG_LIST_ALL=[]
|
PKG_LIST_ALL = []
|
||||||
PKG_LIST_OMIT={}
|
PKG_LIST_OMIT = {}
|
||||||
|
PKG_LIST_CUSTOM = set()
|
||||||
|
|
||||||
def PkgListSet(pkgs):
|
def PkgListSet(pkgs):
|
||||||
global PKG_LIST_ALL
|
global PKG_LIST_ALL
|
||||||
@ -1244,6 +1245,12 @@ def PkgEnable(pkg):
|
|||||||
def PkgDisable(pkg):
|
def PkgDisable(pkg):
|
||||||
PKG_LIST_OMIT[pkg] = 1
|
PKG_LIST_OMIT[pkg] = 1
|
||||||
|
|
||||||
|
def PkgSetCustomLocation(pkg):
|
||||||
|
PKG_LIST_CUSTOM.add(pkg)
|
||||||
|
|
||||||
|
def PkgHasCustomLocation(pkg):
|
||||||
|
return pkg in PKG_LIST_CUSTOM
|
||||||
|
|
||||||
def PkgSkip(pkg):
|
def PkgSkip(pkg):
|
||||||
return PKG_LIST_OMIT[pkg]
|
return PKG_LIST_OMIT[pkg]
|
||||||
|
|
||||||
@ -1401,22 +1408,22 @@ def PkgConfigEnable(opt, pkgname, tool = "pkg-config"):
|
|||||||
for i, j in PkgConfigGetDefSymbols(pkgname, tool).items():
|
for i, j in PkgConfigGetDefSymbols(pkgname, tool).items():
|
||||||
DefSymbol(opt, i, j)
|
DefSymbol(opt, i, j)
|
||||||
|
|
||||||
def LibraryExists(lib, lpath=[]):
|
def LocateLibrary(lib, lpath=[]):
|
||||||
""" Returns True if this library was found in the given search path, False otherwise. """
|
""" Returns True if this library was found in the given search path, False otherwise. """
|
||||||
target = GetTarget()
|
target = GetTarget()
|
||||||
|
|
||||||
for dir in lpath:
|
for dir in lpath:
|
||||||
if target == 'darwin' and os.path.isfile(os.path.join(dir, 'lib%s.dylib' % lib)):
|
if target == 'darwin' and os.path.isfile(os.path.join(dir, 'lib%s.dylib' % lib)):
|
||||||
return True
|
return os.path.join(dir, 'lib%s.dylib' % lib)
|
||||||
elif target != 'darwin' and os.path.isfile(os.path.join(dir, 'lib%s.so' % lib)):
|
elif target != 'darwin' and os.path.isfile(os.path.join(dir, 'lib%s.so' % lib)):
|
||||||
return True
|
return os.path.join(dir, 'lib%s.so' % lib)
|
||||||
elif os.path.isfile(os.path.join(dir, 'lib%s.a' % lib)):
|
elif os.path.isfile(os.path.join(dir, 'lib%s.a' % lib)):
|
||||||
return True
|
return os.path.join(dir, 'lib%s.a' % lib)
|
||||||
|
|
||||||
return False
|
return None
|
||||||
|
|
||||||
def SystemLibraryExists(lib):
|
def SystemLibraryExists(lib):
|
||||||
return LibraryExists(lib, SYS_LIB_DIRS)
|
return LocateLibrary(lib, SYS_LIB_DIRS) is not None
|
||||||
|
|
||||||
def ChooseLib(libs, thirdparty=None):
|
def ChooseLib(libs, thirdparty=None):
|
||||||
""" Chooses a library from the parameters, in order of preference. Returns the first if none of them were found. """
|
""" Chooses a library from the parameters, in order of preference. Returns the first if none of them were found. """
|
||||||
@ -1430,7 +1437,7 @@ def ChooseLib(libs, thirdparty=None):
|
|||||||
libname = l
|
libname = l
|
||||||
if l.startswith("lib"):
|
if l.startswith("lib"):
|
||||||
libname = l[3:]
|
libname = l[3:]
|
||||||
if LibraryExists(libname, lpath):
|
if LocateLibrary(libname, lpath):
|
||||||
return libname
|
return libname
|
||||||
|
|
||||||
if len(libs) > 0:
|
if len(libs) > 0:
|
||||||
@ -1466,16 +1473,18 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
|
|||||||
for d in olddefs:
|
for d in olddefs:
|
||||||
defs[d] = ""
|
defs[d] = ""
|
||||||
|
|
||||||
if (pkg.lower() == "swscale" and os.path.isfile(GetThirdpartyDir() + "ffmpeg/include/libswscale/swscale.h")):
|
custom_loc = PkgHasCustomLocation(pkg)
|
||||||
|
|
||||||
|
if pkg.lower() == "swscale" and os.path.isfile(GetThirdpartyDir() + "ffmpeg/include/libswscale/swscale.h"):
|
||||||
# Let it be handled by the ffmpeg package
|
# Let it be handled by the ffmpeg package
|
||||||
LibName(target_pkg, "-lswscale")
|
LibName(target_pkg, "-lswscale")
|
||||||
return
|
return
|
||||||
if (pkg.lower() == "swresample" and os.path.isfile(GetThirdpartyDir() + "ffmpeg/include/libswresample/swresample.h")):
|
if pkg.lower() == "swresample" and os.path.isfile(GetThirdpartyDir() + "ffmpeg/include/libswresample/swresample.h"):
|
||||||
LibName(target_pkg, "-lswresample")
|
LibName(target_pkg, "-lswresample")
|
||||||
return
|
return
|
||||||
|
|
||||||
pkg_dir = os.path.join(GetThirdpartyDir(), pkg.lower())
|
pkg_dir = os.path.join(GetThirdpartyDir(), pkg.lower())
|
||||||
if (os.path.isdir(pkg_dir)):
|
if not custom_loc and os.path.isdir(pkg_dir):
|
||||||
if framework and os.path.isdir(os.path.join(pkg_dir, framework + ".framework")):
|
if framework and os.path.isdir(os.path.join(pkg_dir, framework + ".framework")):
|
||||||
FrameworkDirectory(target_pkg, pkg_dir)
|
FrameworkDirectory(target_pkg, pkg_dir)
|
||||||
LibName(target_pkg, "-framework " + framework)
|
LibName(target_pkg, "-framework " + framework)
|
||||||
@ -1515,7 +1524,7 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
|
|||||||
DefSymbol(target_pkg, d, v)
|
DefSymbol(target_pkg, d, v)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif (GetHost() == "darwin" and framework != None):
|
elif not custom_loc and GetHost() == "darwin" and framework != None:
|
||||||
prefix = SDK["MACOSX"]
|
prefix = SDK["MACOSX"]
|
||||||
if (os.path.isdir(prefix + "/Library/Frameworks/%s.framework" % framework) or
|
if (os.path.isdir(prefix + "/Library/Frameworks/%s.framework" % framework) or
|
||||||
os.path.isdir(prefix + "/System/Library/Frameworks/%s.framework" % framework) or
|
os.path.isdir(prefix + "/System/Library/Frameworks/%s.framework" % framework) or
|
||||||
@ -1529,7 +1538,7 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
|
|||||||
elif VERBOSE:
|
elif VERBOSE:
|
||||||
print(ColorText("cyan", "Couldn't find the framework %s" % (framework)))
|
print(ColorText("cyan", "Couldn't find the framework %s" % (framework)))
|
||||||
|
|
||||||
elif (LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None)):
|
elif not custom_loc and LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None):
|
||||||
if (isinstance(pkgconfig, str) or tool != "pkg-config"):
|
if (isinstance(pkgconfig, str) or tool != "pkg-config"):
|
||||||
if (PkgConfigHavePkg(pkgconfig, tool)):
|
if (PkgConfigHavePkg(pkgconfig, tool)):
|
||||||
return PkgConfigEnable(target_pkg, pkgconfig, tool)
|
return PkgConfigEnable(target_pkg, pkgconfig, tool)
|
||||||
@ -1559,22 +1568,38 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
|
|||||||
libname = l
|
libname = l
|
||||||
if l.startswith("lib"):
|
if l.startswith("lib"):
|
||||||
libname = l[3:]
|
libname = l[3:]
|
||||||
if SystemLibraryExists(libname):
|
|
||||||
|
if custom_loc:
|
||||||
|
# Try searching in the package's LibDirectories.
|
||||||
|
lpath = [dir for ppkg, dir in LIBDIRECTORIES if pkg == ppkg]
|
||||||
|
location = LocateLibrary(libname, lpath)
|
||||||
|
if location is not None:
|
||||||
|
LibName(target_pkg, location)
|
||||||
|
else:
|
||||||
|
have_pkg = False
|
||||||
|
print(GetColor("cyan") + "Couldn't find library lib" + libname + GetColor())
|
||||||
|
|
||||||
|
elif SystemLibraryExists(libname):
|
||||||
|
# It exists in a system library directory.
|
||||||
LibName(target_pkg, "-l" + libname)
|
LibName(target_pkg, "-l" + libname)
|
||||||
else:
|
else:
|
||||||
# Try searching in the package's LibDirectories.
|
# Try searching in the package's LibDirectories.
|
||||||
lpath = [dir for ppkg, dir in LIBDIRECTORIES if pkg == ppkg or ppkg == "ALWAYS"]
|
lpath = [dir for ppkg, dir in LIBDIRECTORIES if pkg == ppkg or ppkg == "ALWAYS"]
|
||||||
if LibraryExists(libname, lpath):
|
location = LocateLibrary(libname, lpath)
|
||||||
|
if location is not None:
|
||||||
LibName(target_pkg, "-l" + libname)
|
LibName(target_pkg, "-l" + libname)
|
||||||
else:
|
else:
|
||||||
have_pkg = False
|
have_pkg = False
|
||||||
if VERBOSE:
|
if VERBOSE or custom_loc:
|
||||||
print(GetColor("cyan") + "Couldn't find library lib" + libname + GetColor())
|
print(GetColor("cyan") + "Couldn't find library lib" + libname + GetColor())
|
||||||
|
|
||||||
# Determine which include directories to look in.
|
# Determine which include directories to look in.
|
||||||
incdirs = list(SYS_INC_DIRS)
|
incdirs = []
|
||||||
|
if not custom_loc:
|
||||||
|
incdirs += list(SYS_INC_DIRS)
|
||||||
|
|
||||||
for ppkg, pdir in INCDIRECTORIES:
|
for ppkg, pdir in INCDIRECTORIES:
|
||||||
if pkg == ppkg or ppkg == "ALWAYS":
|
if pkg == ppkg or (ppkg == "ALWAYS" and not custom_loc):
|
||||||
incdirs.append(pdir)
|
incdirs.append(pdir)
|
||||||
|
|
||||||
# The incs list contains both subdirectories to explicitly add to
|
# The incs list contains both subdirectories to explicitly add to
|
||||||
@ -1588,14 +1613,17 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
|
|||||||
# Note: It's possible to specify a file instead of a dir, for the sake of checking if it exists.
|
# Note: It's possible to specify a file instead of a dir, for the sake of checking if it exists.
|
||||||
if incdir is None and i.endswith(".h"):
|
if incdir is None and i.endswith(".h"):
|
||||||
have_pkg = False
|
have_pkg = False
|
||||||
if VERBOSE:
|
if VERBOSE or custom_loc:
|
||||||
print(GetColor("cyan") + "Couldn't find header file " + i + GetColor())
|
print(GetColor("cyan") + "Couldn't find header file " + i + GetColor())
|
||||||
|
|
||||||
if incdir is not None and os.path.isdir(incdir):
|
if incdir is not None and os.path.isdir(incdir):
|
||||||
IncDirectory(target_pkg, incdir)
|
IncDirectory(target_pkg, incdir)
|
||||||
|
|
||||||
if (not have_pkg):
|
if not have_pkg:
|
||||||
if (pkg in PkgListGet()):
|
if custom_loc:
|
||||||
|
print("%sERROR:%s Could not locate thirdparty package %s in specified directory, aborting build" % (GetColor("red"), GetColor(), pkg.lower()))
|
||||||
|
exit()
|
||||||
|
elif pkg in PkgListGet():
|
||||||
print("%sWARNING:%s Could not locate thirdparty package %s, excluding from build" % (GetColor("red"), GetColor(), pkg.lower()))
|
print("%sWARNING:%s Could not locate thirdparty package %s, excluding from build" % (GetColor("red"), GetColor(), pkg.lower()))
|
||||||
PkgDisable(pkg)
|
PkgDisable(pkg)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user