Packaging & macos exec fixes

- Use "open -a" to launch Camoufox.app
- Fix fonts not copying correctly
- Find & move asset files to dist/ correctly
This commit is contained in:
daijro 2024-08-14 05:22:01 -05:00
parent 40bcdc6def
commit 80a657268e
3 changed files with 13 additions and 5 deletions

View file

@ -74,6 +74,12 @@ func runCamoufox(execName string, args []string, addonsList []string) {
debugPortInt = getDebugPort(&args)
}
// For macOS, use "open" command to launch the app
if normalizeOS(runtime.GOOS) == "macos" {
args = append([]string{"-a", execName}, args...)
execName = "open"
}
// Print args
cmd := exec.Command(execName, args...)

View file

@ -64,7 +64,7 @@ class BSYS:
@property
def assets(self) -> List[str]:
"""Get the list of assets"""
package_pattern = 'camoufox-*.en-US.*.zip'
package_pattern = f'camoufox-*-{self.target[:3]}.{self.arch}.zip'
return glob.glob(package_pattern)
@staticmethod
@ -84,6 +84,7 @@ def run_build(target, arch):
# Run package
builder.package()
# Move assets to dist
print('Assets:', ', '.join(builder.assets))
for asset in builder.assets:
os.rename(asset, f'dist/{asset}')

View file

@ -37,10 +37,10 @@ def add_includes_to_package(package_file, includes, fonts, new_file, target):
)
if target == 'macos':
# Move Nightly/Nightly.app -> Camoufox.app
nightly_dir = os.path.join(temp_dir, 'Nightly')
# Move Camoufox/Camoufox.app -> Camoufox.app
nightly_dir = os.path.join(temp_dir, 'Camoufox')
shutil.move(
os.path.join(nightly_dir, 'Nightly.app'), os.path.join(temp_dir, 'Camoufox.app')
os.path.join(nightly_dir, 'Camoufox.app'), os.path.join(temp_dir, 'Camoufox.app')
)
# Remove old app dir and all content in it
shutil.rmtree(nightly_dir)
@ -85,9 +85,10 @@ def add_includes_to_package(package_file, includes, fonts, new_file, target):
# Non-linux systems cannot read fonts within subfolders.
# Instead, we walk the fonts/ directory and copy all files.
else:
os.makedirs(fonts_dir, exist_ok=True)
for font in fonts or []:
for file in list_files(root_dir=os.path.join('bundle', 'fonts', font), suffix='*'):
shutil.copy2(file, fonts_dir)
shutil.copy2(file, os.path.join(fonts_dir, os.path.basename(file)))
# Add launcher from launcher/dist/launch to temp_dir
launch_file = 'launch' + ('.exe' if target == 'windows' else '')