Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2020-12-18 12:56:31 +01:00
commit a5ae292c3e
8 changed files with 107 additions and 36 deletions

View File

@ -211,7 +211,7 @@ class CompilationEnvironment:
self.linkDll = 'link /nologo /DLL /MAP:NUL /FIXED:NO /OPT:REF /INCREMENTAL:NO /LIBPATH:"%(PSDK)s\\lib" /LIBPATH:"%(MSVC)s\\lib%(suffix64)s" /LIBPATH:"%(python)s\\libs" /out:%(basename)s%(dllext)s.pyd %(basename)s.obj' self.linkDll = 'link /nologo /DLL /MAP:NUL /FIXED:NO /OPT:REF /INCREMENTAL:NO /LIBPATH:"%(PSDK)s\\lib" /LIBPATH:"%(MSVC)s\\lib%(suffix64)s" /LIBPATH:"%(python)s\\libs" /out:%(basename)s%(dllext)s.pyd %(basename)s.obj'
elif self.platform.startswith('osx_'): elif self.platform.startswith('osx_'):
# OSX # macOS
proc = self.platform.split('_', 1)[1] proc = self.platform.split('_', 1)[1]
if proc == 'i386': if proc == 'i386':
self.arch = '-arch i386' self.arch = '-arch i386'
@ -219,6 +219,8 @@ class CompilationEnvironment:
self.arch = '-arch ppc' self.arch = '-arch ppc'
elif proc == 'amd64': elif proc == 'amd64':
self.arch = '-arch x86_64' self.arch = '-arch x86_64'
elif proc in ('arm64', 'aarch64'):
self.arch = '-arch arm64'
self.compileObjExe = "gcc -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s" self.compileObjExe = "gcc -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s"
self.compileObjDll = "gcc -fPIC -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s" self.compileObjDll = "gcc -fPIC -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s"
self.linkExe = "gcc %(arch)s -o %(basename)s %(basename)s.o -framework Python" self.linkExe = "gcc %(arch)s -o %(basename)s %(basename)s.o -framework Python"

View File

@ -42,8 +42,9 @@ class OnscreenGeom(DirectObject, NodePath):
""" """
# We ARE a node path. Initially, we're an empty node path. # We ARE a node path. Initially, we're an empty node path.
NodePath.__init__(self) NodePath.__init__(self)
if parent == None: if parent is None:
parent = aspect2d from direct.showbase import ShowBaseGlobal
parent = ShowBaseGlobal.aspect2d
self.setGeom(geom, parent = parent, sort = sort, color = color) self.setGeom(geom, parent = parent, sort = sort, color = color)

View File

@ -48,8 +48,9 @@ class OnscreenImage(DirectObject, NodePath):
# We ARE a node path. Initially, we're an empty node path. # We ARE a node path. Initially, we're an empty node path.
NodePath.__init__(self) NodePath.__init__(self)
if parent == None: if parent is None:
parent = aspect2d from direct.showbase import ShowBaseGlobal
parent = ShowBaseGlobal.aspect2d
self.setImage(image, parent = parent, sort = sort) self.setImage(image, parent = parent, sort = sort)
# Adjust pose # Adjust pose

View File

@ -103,8 +103,9 @@ class OnscreenText(NodePath):
direction: this can be set to 'ltr' or 'rtl' to override the direction: this can be set to 'ltr' or 'rtl' to override the
direction of the text. direction of the text.
""" """
if parent == None: if parent is None:
parent = aspect2d from direct.showbase import ShowBaseGlobal
parent = ShowBaseGlobal.aspect2d
# make a text node # make a text node
textNode = TextNode('') textNode = TextNode('')

View File

@ -187,7 +187,7 @@ def parseopts(args):
anything = 0 anything = 0
optimize = "" optimize = ""
target = None target = None
target_arch = None target_archs = []
universal = False universal = False
clean_build = False clean_build = False
for pkg in PkgListGet(): for pkg in PkgListGet():
@ -214,7 +214,7 @@ def parseopts(args):
elif (option=="--osxtarget"): OSXTARGET=value.strip() elif (option=="--osxtarget"): OSXTARGET=value.strip()
elif (option=="--universal"): universal = True elif (option=="--universal"): universal = True
elif (option=="--target"): target = value.strip() elif (option=="--target"): target = value.strip()
elif (option=="--arch"): target_arch = value.strip() elif (option=="--arch"): target_archs.append(value.strip())
elif (option=="--nocolor"): DisableColors() elif (option=="--nocolor"): DisableColors()
elif (option=="--version"): elif (option=="--version"):
match = re.match(r'^\d+\.\d+(\.\d+)+', value) match = re.match(r'^\d+\.\d+(\.\d+)+', value)
@ -273,12 +273,17 @@ def parseopts(args):
if (optimize==""): optimize = "3" if (optimize==""): optimize = "3"
if OSXTARGET: if OSXTARGET:
parts = OSXTARGET.strip().split('.')
try: try:
maj, min = OSXTARGET.strip().split('.') assert len(parts) <= 2
OSXTARGET = int(maj), int(min) maj = int(parts[0])
assert OSXTARGET[0] >= 10 min = 0
if len(parts) > 1:
min = int(parts[1])
OSXTARGET = maj, min
assert OSXTARGET >= (10, 4)
except: except:
usage("Invalid setting for OSXTARGET") usage("Invalid setting for --osxtarget")
if OSXTARGET < (10, 9): if OSXTARGET < (10, 9):
warn_prefix = "%sERROR:%s " % (GetColor("red"), GetColor()) warn_prefix = "%sERROR:%s " % (GetColor("red"), GetColor())
@ -293,11 +298,11 @@ def parseopts(args):
else: else:
OSXTARGET = None OSXTARGET = None
if target is not None or target_arch is not None: if target is not None or target_archs:
SetTarget(target, target_arch) SetTarget(target, target_archs[-1] if target_archs else None)
if universal: if universal:
if target_arch: if target_archs:
exit("--universal is incompatible with --arch") exit("--universal is incompatible with --arch")
if OSXTARGET: if OSXTARGET:
@ -311,8 +316,11 @@ def parseopts(args):
if osxver >= (11, 0): if osxver >= (11, 0):
OSX_ARCHS.append("arm64") OSX_ARCHS.append("arm64")
elif HasTargetArch(): elif target_archs:
OSX_ARCHS.append(GetTargetArch()) OSX_ARCHS = target_archs
if 'arm64' in target_archs and OSXTARGET and OSXTARGET < (10, 9):
exit("Must have at least --osxtarget 10.9 when targeting arm64")
try: try:
SetOptimize(int(optimize)) SetOptimize(int(optimize))
@ -412,6 +420,10 @@ elif target == 'darwin':
if osxver < (10, 9): if osxver < (10, 9):
osxver = (10, 9) osxver = (10, 9)
if osxver[0] == 11:
# I think Python pins minor version to 0 from macOS 11 onward
osxver = (osxver[0], 0)
arch_tag = None arch_tag = None
if not OSX_ARCHS: if not OSX_ARCHS:
arch_tag = GetTargetArch() arch_tag = GetTargetArch()
@ -515,7 +527,7 @@ MakeBuildTree()
SdkLocateDirectX(STRDXSDKVERSION) SdkLocateDirectX(STRDXSDKVERSION)
SdkLocateMaya() SdkLocateMaya()
SdkLocateMax() SdkLocateMax()
SdkLocateMacOSX(OSXTARGET) SdkLocateMacOSX(OSXTARGET, OSX_ARCHS)
SdkLocatePython(False) SdkLocatePython(False)
SdkLocateWindows(WINDOWS_SDK) SdkLocateWindows(WINDOWS_SDK)
SdkLocateSpeedTree() SdkLocateSpeedTree()
@ -788,6 +800,18 @@ if (COMPILER=="GCC"):
if GetTarget() != "darwin": if GetTarget() != "darwin":
PkgDisable("COCOA") PkgDisable("COCOA")
if GetTarget() == 'darwin':
if 'x86_64' not in OSX_ARCHS and 'i386' not in OSX_ARCHS:
# These support only these archs, so don't build them if we're not
# targeting any of the supported archs.
PkgDisable("FMODEX")
PkgDisable("NVIDIACG")
elif (OSX_ARCHS and 'arm64' in OSX_ARCHS) or \
(OSXTARGET and OSXTARGET >= (10, 14)) or \
(not OSXTARGET and not os.path.isfile('/usr/lib/libstdc++.6.0.9.dylib')):
# Also, we can't target FMOD Ex with the 10.14 SDK
PkgDisable("FMODEX")
#if (PkgSkip("PYTHON")==0): #if (PkgSkip("PYTHON")==0):
# IncDirectory("PYTHON", SDK["PYTHON"]) # IncDirectory("PYTHON", SDK["PYTHON"])
if (GetHost() == "darwin"): if (GetHost() == "darwin"):
@ -1295,6 +1319,8 @@ def CompileCxx(obj,src,opts):
if OSXTARGET is not None: if OSXTARGET is not None:
cmd += " -isysroot " + SDK["MACOSX"] cmd += " -isysroot " + SDK["MACOSX"]
cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET) cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET)
elif platform.mac_ver()[0].startswith('11.'):
cmd += " -mmacosx-version-min=11.0"
# Use libc++ to enable C++11 features. # Use libc++ to enable C++11 features.
cmd += " -stdlib=libc++" cmd += " -stdlib=libc++"
@ -1814,6 +1840,8 @@ def CompileLink(dll, obj, opts):
if OSXTARGET is not None: if OSXTARGET is not None:
cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"] cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"]
cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET) cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET)
elif platform.mac_ver()[0].startswith('11.'):
cmd += " -mmacosx-version-min=11.0"
# Use libc++ to enable C++11 features. # Use libc++ to enable C++11 features.
cmd += " -stdlib=libc++" cmd += " -stdlib=libc++"
@ -2479,8 +2507,19 @@ def WriteConfigSettings():
conf = "/* dtool_config.h. Generated automatically by makepanda.py */\n" conf = "/* dtool_config.h. Generated automatically by makepanda.py */\n"
for key in sorted(dtool_config.keys()): for key in sorted(dtool_config.keys()):
val = OverrideValue(key, dtool_config[key]) val = OverrideValue(key, dtool_config[key])
if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
else: conf = conf + "#define " + key + " " + val + "\n" if key in ('HAVE_CG', 'HAVE_CGGL', 'HAVE_CGDX9') and val != 'UNDEF':
# These are not available for ARM, period.
conf = conf + "#ifdef __aarch64__\n"
conf = conf + "#undef " + key + "\n"
conf = conf + "#else\n"
conf = conf + "#define " + key + " " + val + "\n"
conf = conf + "#endif\n"
elif val == 'UNDEF':
conf = conf + "#undef " + key + "\n"
else:
conf = conf + "#define " + key + " " + val + "\n"
ConditionalWriteFile(GetOutputDir() + '/include/dtool_config.h', conf) ConditionalWriteFile(GetOutputDir() + '/include/dtool_config.h', conf)
if (PkgSkip("SPEEDTREE")==0): if (PkgSkip("SPEEDTREE")==0):

View File

@ -2345,10 +2345,17 @@ def SdkLocateWindows(version=None):
else: else:
print("Using Windows SDK %s" % (version)) print("Using Windows SDK %s" % (version))
def SdkLocateMacOSX(osxtarget = None): def SdkLocateMacOSX(osxtarget = None, archs = []):
if (GetHost() != "darwin"): return if (GetHost() != "darwin"): return
if (osxtarget != None): if (osxtarget != None):
sdkname = "MacOSX%d.%d" % osxtarget if osxtarget < (11, 0) and 'arm64' in archs:
# Building for arm64 requires the 11.0 SDK, with which we can still
# target 10.9.
assert osxtarget >= (10, 9)
sdkname = "MacOSX11.0"
else:
sdkname = "MacOSX%d.%d" % osxtarget
if (os.path.exists("/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname)): if (os.path.exists("/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname)):
SDK["MACOSX"] = "/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname SDK["MACOSX"] = "/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname
elif (os.path.exists("/Developer/SDKs/%su.sdk" % sdkname)): elif (os.path.exists("/Developer/SDKs/%su.sdk" % sdkname)):
@ -2365,8 +2372,10 @@ def SdkLocateMacOSX(osxtarget = None):
handle.close() handle.close()
if (os.path.exists("%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname))): if (os.path.exists("%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname))):
SDK["MACOSX"] = "%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname) SDK["MACOSX"] = "%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname)
elif sdkname == "MacOSX11.0" and os.path.exists("/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk"):
SDK["MACOSX"] = "/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk"
else: else:
exit("Couldn't find any MacOSX SDK for OSX version %s!" % sdkname) exit("Couldn't find any MacOSX SDK for macOS version %s!" % sdkname)
else: else:
SDK["MACOSX"] = "" SDK["MACOSX"] = ""

View File

@ -806,23 +806,33 @@ process_events() {
button_changed(_dpad_up_button, events[i].value < 0); button_changed(_dpad_up_button, events[i].value < 0);
button_changed(_dpad_up_button+1, events[i].value > 0); button_changed(_dpad_up_button+1, events[i].value > 0);
} }
nassertd(code >= 0 && (size_t)code < _axis_indices.size()) break; if (code >= 0 && (size_t)code < _axis_indices.size()) {
index = _axis_indices[code]; index = _axis_indices[code];
if (index >= 0) { if (index >= 0) {
axis_changed(index, events[i].value); axis_changed(index, events[i].value);
}
}
else if (device_cat.is_debug()) {
device_cat.debug()
<< "Ignoring EV_ABS event with unknown code " << code << "\n";
} }
break; break;
case EV_KEY: case EV_KEY:
nassertd(code >= 0 && (size_t)code < _button_indices.size()) break; if (code >= 0 && (size_t)code < _button_indices.size()) {
index = _button_indices[code]; index = _button_indices[code];
if (index >= 0) { if (index >= 0) {
button_changed(index, events[i].value != 0); button_changed(index, events[i].value != 0);
}
if (code == _ltrigger_code) {
axis_changed(_ltrigger_axis, events[i].value);
} else if (code == _rtrigger_code) {
axis_changed(_ltrigger_axis + 1, events[i].value);
}
} }
if (code == _ltrigger_code) { else if (device_cat.is_debug()) {
axis_changed(_ltrigger_axis, events[i].value); device_cat.debug()
} else if (code == _rtrigger_code) { << "Ignoring EV_KEY event with unknown code " << code << "\n";
axis_changed(_ltrigger_axis + 1, events[i].value);
} }
break; break;

View File

@ -1627,6 +1627,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
for (; i < cdata->_num_vertices; ++i) { for (; i < cdata->_num_vertices; ++i) {
reader.set_row_unsafe(cdata->_first_vertex + i); reader.set_row_unsafe(cdata->_first_vertex + i);
nassertv(!reader.is_at_end());
LPoint3 vertex = mat.xform_point_general(reader.get_data3()); LPoint3 vertex = mat.xform_point_general(reader.get_data3());
min_point.set(min(min_point[0], vertex[0]), min_point.set(min(min_point[0], vertex[0]),
@ -1653,6 +1655,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
for (; i < cdata->_num_vertices; ++i) { for (; i < cdata->_num_vertices; ++i) {
reader.set_row_unsafe(cdata->_first_vertex + i); reader.set_row_unsafe(cdata->_first_vertex + i);
nassertv(!reader.is_at_end());
const LVecBase3 &vertex = reader.get_data3(); const LVecBase3 &vertex = reader.get_data3();
min_point.set(min(min_point[0], vertex[0]), min_point.set(min(min_point[0], vertex[0]),
@ -1696,6 +1700,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
continue; continue;
} }
reader.set_row_unsafe(ii); reader.set_row_unsafe(ii);
nassertv(!reader.is_at_end());
LPoint3 vertex = mat.xform_point_general(reader.get_data3()); LPoint3 vertex = mat.xform_point_general(reader.get_data3());
min_point.set(min(min_point[0], vertex[0]), min_point.set(min(min_point[0], vertex[0]),
@ -1728,6 +1734,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
continue; continue;
} }
reader.set_row_unsafe(ii); reader.set_row_unsafe(ii);
nassertv(!reader.is_at_end());
const LVecBase3 &vertex = reader.get_data3(); const LVecBase3 &vertex = reader.get_data3();
min_point.set(min(min_point[0], vertex[0]), min_point.set(min(min_point[0], vertex[0]),