|
|
@@ -33,6 +33,12 @@ def egg2bam(_build_cmd, srcpath, dstpath):
|
|
|
])
|
|
|
return dstpath
|
|
|
|
|
|
+macosx_binary_magics = (
|
|
|
+ b'\xFE\xED\xFA\xCE', b'\xCE\xFA\xED\xFE',
|
|
|
+ b'\xFE\xED\xFA\xCF', b'\xCF\xFA\xED\xFE',
|
|
|
+ b'\xCA\xFE\xBA\xBE', b'\xBE\xBA\xFE\xCA',
|
|
|
+ b'\xCA\xFE\xBA\xBF', b'\xBF\xBA\xFE\xCA')
|
|
|
+
|
|
|
|
|
|
class build_apps(distutils.core.Command):
|
|
|
description = 'build Panda3D applications'
|
|
|
@@ -121,15 +127,11 @@ class build_apps(distutils.core.Command):
|
|
|
num_gui_apps = len(self.gui_apps)
|
|
|
num_console_apps = len(self.console_apps)
|
|
|
|
|
|
- if self.macos_main_app is None:
|
|
|
+ if not self.macos_main_app:
|
|
|
if num_gui_apps > 1:
|
|
|
- assert True, 'macos_main_app must be defined if more than one gui_app is defined'
|
|
|
+ assert False, 'macos_main_app must be defined if more than one gui_app is defined'
|
|
|
elif num_gui_apps == 1:
|
|
|
self.macos_main_app = list(self.gui_apps.keys())[0]
|
|
|
- elif num_console_apps > 1:
|
|
|
- assert True, 'macos_main_app must be defined if more than one console_app is defined with no gui_apps'
|
|
|
- elif num_console_apps == 1:
|
|
|
- self.macos_main_app = list(self.console_apps.keys())[0]
|
|
|
|
|
|
assert os.path.exists(self.requirements_path), 'Requirements.txt path does not exist: {}'.format(self.requirements_path)
|
|
|
assert num_gui_apps + num_console_apps != 0, 'Must specify at least one app in either gui_apps or console_apps'
|
|
|
@@ -209,10 +211,9 @@ class build_apps(distutils.core.Command):
|
|
|
|
|
|
if fname in self.gui_apps or self.console_apps:
|
|
|
dst = macosdir
|
|
|
- elif src.endswith('.so') or src.endswith('dylib'):
|
|
|
+ elif os.path.isfile(src) and open(src, 'rb').read(4) in macosx_binary_magics:
|
|
|
dst = fwdir
|
|
|
else:
|
|
|
- # TODO Cg still shows up in Resources when it should be in Frameworks
|
|
|
dst = resdir
|
|
|
shutil.move(src, dst)
|
|
|
|
|
|
@@ -283,7 +284,7 @@ class build_apps(distutils.core.Command):
|
|
|
target_path = os.path.join(builddir, appname)
|
|
|
|
|
|
stub_name = 'deploy-stub'
|
|
|
- if platform.startswith('win'):
|
|
|
+ if platform.startswith('win') or 'macosx' in platform:
|
|
|
if not use_console:
|
|
|
stub_name = 'deploy-stubw'
|
|
|
|
|
|
@@ -298,7 +299,7 @@ class build_apps(distutils.core.Command):
|
|
|
stub_path = os.path.join(os.path.dirname(dtool_path), '..', 'bin', stub_name)
|
|
|
stub_file = open(stub_path, 'rb')
|
|
|
|
|
|
- freezer.generateRuntimeFromStub(target_path, stub_file, {
|
|
|
+ freezer.generateRuntimeFromStub(target_path, stub_file, use_console, {
|
|
|
'prc_data': None,
|
|
|
'default_prc_dir': None,
|
|
|
'prc_dir_envvars': None,
|
|
|
@@ -481,8 +482,8 @@ class build_apps(distutils.core.Command):
|
|
|
copy_file(src, dst)
|
|
|
|
|
|
# Bundle into an .app on macOS
|
|
|
- #if 'macosx' in platform:
|
|
|
- # self.bundle_macos_app(builddir)
|
|
|
+ if self.macos_main_app and 'macosx' in platform:
|
|
|
+ self.bundle_macos_app(builddir)
|
|
|
|
|
|
def add_dependency(self, name, target_dir, search_path, referenced_by):
|
|
|
""" Searches for the given DLL on the search path. If it exists,
|
|
|
@@ -699,6 +700,10 @@ class build_apps(distutils.core.Command):
|
|
|
|
|
|
if cmd == 0x0c: # LC_LOAD_DYLIB
|
|
|
dylib = cmd_data[16:].decode('ascii').split('\x00', 1)[0]
|
|
|
+ if dylib.startswith('@loader_path/../Frameworks/'):
|
|
|
+ dylib = dylib.replace('@loader_path/../Frameworks/', '')
|
|
|
+ if dylib.startswith('@executable_path/../Frameworks/'):
|
|
|
+ dylib = dylib.replace('@executable_path/../Frameworks/', '')
|
|
|
if dylib.startswith('@loader_path/'):
|
|
|
dylib = dylib.replace('@loader_path/', '')
|
|
|
load_dylibs.append(dylib)
|