makepanda: remove --osxtarget option

We can target 10.9 (the minimum supported) even with the 11.1 SDK, so we should just check for whichever SDK is available, and always target 10.9 (or 11.0 when building for arm64 only, since arm64 requires 11.0 to begin with).

This also means that --universal will always add both x86_64 and arm64 to the build.
This commit is contained in:
rdb 2020-12-18 13:09:37 +01:00
parent a5ae292c3e
commit 8231bc12bf
2 changed files with 52 additions and 102 deletions

View File

@ -58,7 +58,6 @@ WHLVERSION=None
RPMRELEASE="1"
GIT_COMMIT=None
MAJOR_VERSION=None
OSXTARGET=None
OSX_ARCHS=[]
global STRDXSDKVERSION, BOOUSEINTELCOMPILER
STRDXSDKVERSION = 'default'
@ -69,9 +68,6 @@ OPENCV_VER_23 = False
PLATFORM = None
COPY_PYTHON = True
if "MACOSX_DEPLOYMENT_TARGET" in os.environ:
OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"]
PkgListSet(["PYTHON", "DIRECT", # Python support
"GL", "GLES", "GLES2"] + DXVERSIONS + ["TINYDISPLAY", "NVIDIACG", # 3D graphics
"EGL", # OpenGL (ES) integration
@ -133,7 +129,6 @@ def usage(problem):
print(" --distributor X (short string identifying the distributor of the build)")
print(" --outputdir X (use the specified directory instead of 'built')")
print(" --threads N (use the multithreaded build system. see manual)")
print(" --osxtarget N (the macOS version number to build for (macOS only))")
print(" --universal (build universal binaries (macOS 11.0+ only))")
print(" --override \"O=V\" (override dtool_config/prc option value)")
print(" --static (builds libraries for static linking)")
@ -162,7 +157,7 @@ def usage(problem):
def parseopts(args):
global INSTALLER,WHEEL,RUNTESTS,GENMAN,DISTRIBUTOR,VERSION
global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS
global COMPRESSOR,THREADCOUNT,OSX_ARCHS
global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT
global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER
global COPY_PYTHON
@ -170,12 +165,12 @@ def parseopts(args):
# Options for which to display a deprecation warning.
removedopts = [
"use-touchinput", "no-touchinput", "no-awesomium", "no-directscripts",
"no-carbon", "no-physx", "no-rocket", "host"
"no-carbon", "no-physx", "no-rocket", "host", "osxtarget=",
]
# All recognized options.
longopts = [
"help","distributor=","verbose","osxtarget=","tests",
"help","distributor=","verbose","tests",
"optimize=","everything","nothing","installer","wheel","rtdist","nocolor",
"version=","lzma","no-python","threads=","outputdir=","override=",
"static","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
@ -211,7 +206,6 @@ def parseopts(args):
elif (option=="--nothing"): PkgDisableAll()
elif (option=="--threads"): THREADCOUNT=int(value)
elif (option=="--outputdir"): SetOutputDir(value.strip())
elif (option=="--osxtarget"): OSXTARGET=value.strip()
elif (option=="--universal"): universal = True
elif (option=="--target"): target = value.strip()
elif (option=="--arch"): target_archs.append(value.strip())
@ -243,7 +237,7 @@ def parseopts(args):
elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True
elif (option=="--clean"): clean_build = True
elif (option=="--no-copy-python"): COPY_PYTHON = False
elif (option[2:] in removedopts):
elif (option[2:] in removedopts or option[2:]+'=' in removedopts):
Warn("Ignoring removed option %s" % (option))
else:
for pkg in PkgListGet() + ['CGGL']:
@ -272,32 +266,6 @@ def parseopts(args):
if (optimize==""): optimize = "3"
if OSXTARGET:
parts = OSXTARGET.strip().split('.')
try:
assert len(parts) <= 2
maj = int(parts[0])
min = 0
if len(parts) > 1:
min = int(parts[1])
OSXTARGET = maj, min
assert OSXTARGET >= (10, 4)
except:
usage("Invalid setting for --osxtarget")
if OSXTARGET < (10, 9):
warn_prefix = "%sERROR:%s " % (GetColor("red"), GetColor())
print("=========================================================================")
print(warn_prefix + "Support for macOS versions before 10.9 has been discontinued.")
print(warn_prefix + "For more information, or any questions, please visit:")
print(" https://github.com/panda3d/panda3d/issues/300")
print("=========================================================================")
sys.stdout.flush()
time.sleep(1.0)
sys.exit(1)
else:
OSXTARGET = None
if target is not None or target_archs:
SetTarget(target, target_archs[-1] if target_archs else None)
@ -305,23 +273,11 @@ def parseopts(args):
if target_archs:
exit("--universal is incompatible with --arch")
if OSXTARGET:
osxver = OSXTARGET
else:
maj, min = platform.mac_ver()[0].split('.')[:2]
osxver = int(maj), int(min)
OSX_ARCHS.append("x86_64")
if osxver >= (11, 0):
OSX_ARCHS.append("arm64")
OSX_ARCHS.append("arm64")
elif target_archs:
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:
SetOptimize(int(optimize))
assert GetOptimize() in [1, 2, 3, 4]
@ -380,8 +336,11 @@ if ("LDFLAGS" in os.environ):
LDFLAGS = os.environ["LDFLAGS"].strip()
os.environ["MAKEPANDA"] = os.path.abspath(sys.argv[0])
if GetHost() == "darwin" and OSXTARGET is not None:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "%d.%d" % OSXTARGET
if GetHost() == "darwin":
if tuple(OSX_ARCHS) == ('arm64',):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "11.0"
else:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
########################################################################
##
@ -412,18 +371,6 @@ if target == 'windows':
PLATFORM = 'win32'
elif target == 'darwin':
if OSXTARGET:
osxver = OSXTARGET
else:
maj, min = platform.mac_ver()[0].split('.')[:2]
osxver = int(maj), int(min)
if 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
if not OSX_ARCHS:
arch_tag = GetTargetArch()
@ -444,7 +391,10 @@ elif target == 'darwin':
else:
raise RuntimeError('No arch tag for arch combination %s' % OSX_ARCHS)
PLATFORM = 'macosx-{0}.{1}-{2}'.format(osxver[0], osxver[1], arch_tag)
if arch_tag == 'arm64':
PLATFORM = 'macosx-11.0-' + arch_tag
else:
PLATFORM = 'macosx-10.9-' + arch_tag
elif target == 'linux' and (os.path.isfile("/lib/libc-2.5.so") or os.path.isfile("/lib64/libc-2.5.so")) and os.path.isdir("/opt/python"):
# This is manylinux1. A bit of a sloppy check, though.
@ -527,7 +477,7 @@ MakeBuildTree()
SdkLocateDirectX(STRDXSDKVERSION)
SdkLocateMaya()
SdkLocateMax()
SdkLocateMacOSX(OSXTARGET, OSX_ARCHS)
SdkLocateMacOSX(OSX_ARCHS)
SdkLocatePython(False)
SdkLocateWindows(WINDOWS_SDK)
SdkLocateSpeedTree()
@ -807,9 +757,8 @@ if (COMPILER=="GCC"):
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
not os.path.isfile('/usr/lib/libstdc++.6.0.9.dylib'):
# Also, we can't target FMOD Ex on 10.14 and above
PkgDisable("FMODEX")
#if (PkgSkip("PYTHON")==0):
@ -1316,11 +1265,13 @@ def CompileCxx(obj,src,opts):
# Mac-specific flags.
if GetTarget() == "darwin":
cmd += " -Wno-deprecated-declarations"
if OSXTARGET is not None:
if SDK.get("MACOSX"):
cmd += " -isysroot " + SDK["MACOSX"]
cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET)
elif platform.mac_ver()[0].startswith('11.'):
if tuple(OSX_ARCHS) == ('arm64',):
cmd += " -mmacosx-version-min=11.0"
else:
cmd += " -mmacosx-version-min=10.9"
# Use libc++ to enable C++11 features.
cmd += " -stdlib=libc++"
@ -1837,11 +1788,13 @@ def CompileLink(dll, obj, opts):
# macOS specific flags.
if GetTarget() == 'darwin':
cmd += " -headerpad_max_install_names"
if OSXTARGET is not None:
if SDK.get("MACOSX"):
cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"]
cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET)
elif platform.mac_ver()[0].startswith('11.'):
if tuple(OSX_ARCHS) == ('arm64',):
cmd += " -mmacosx-version-min=11.0"
else:
cmd += " -mmacosx-version-min=10.9"
# Use libc++ to enable C++11 features.
cmd += " -stdlib=libc++"

View File

@ -2345,39 +2345,36 @@ def SdkLocateWindows(version=None):
else:
print("Using Windows SDK %s" % (version))
def SdkLocateMacOSX(osxtarget = None, archs = []):
def SdkLocateMacOSX(archs = []):
if (GetHost() != "darwin"): return
if (osxtarget != None):
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)):
handle = os.popen("xcode-select -print-path")
xcode_dir = handle.read().strip().rstrip('/')
handle.close()
# Make a list of SDK versions that will work for us.
sdk_versions = []
if 'arm64' not in archs:
sdk_versions += ["10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15"]
sdk_versions += ["11.0", "11.1"]
for version in sdk_versions:
sdkname = "MacOSX" + version
if os.path.exists("/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)):
SDK["MACOSX"] = "/Developer/SDKs/%su.sdk" % sdkname
elif (os.path.exists("/Developer/SDKs/%s.sdk" % sdkname)):
return
elif os.path.exists("/Developer/SDKs/%s.sdk" % sdkname):
SDK["MACOSX"] = "/Developer/SDKs/%s.sdk" % sdkname
elif (os.path.exists("/Developer/SDKs/%s.0.sdk" % sdkname)):
SDK["MACOSX"] = "/Developer/SDKs/%s.0.sdk" % sdkname
elif (os.path.exists("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % sdkname)):
return
elif os.path.exists("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % sdkname):
SDK["MACOSX"] = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % sdkname
else:
handle = os.popen("xcode-select -print-path")
result = handle.read().strip().rstrip('/')
handle.close()
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)
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:
exit("Couldn't find any MacOSX SDK for macOS version %s!" % sdkname)
else:
SDK["MACOSX"] = ""
return
elif xcode_dir and os.path.exists("%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (xcode_dir, sdkname)):
SDK["MACOSX"] = "%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (xcode_dir, sdkname)
return
exit("Couldn't find any suitable MacOSX SDK!")
def SdkLocateSpeedTree():
# Look for all of the SpeedTree SDK directories within the