diff options
-rw-r--r-- | Info.plist | 50 | ||||
-rw-r--r-- | components/util/resource_files.rs | 17 | ||||
-rw-r--r-- | python/servo/package_commands.py | 76 | ||||
-rw-r--r-- | resources/package-prefs.json | 63 | ||||
-rw-r--r-- | resources/servo.icns | bin | 0 -> 1454237 bytes |
5 files changed, 164 insertions, 42 deletions
diff --git a/Info.plist b/Info.plist index b59f7a85bce..3b8a4248cba 100644 --- a/Info.plist +++ b/Info.plist @@ -1,34 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>Servo</string> - <key>CFBundleIconFile</key> - <string>Calculator.icns</string> - <key>CFBundleIdentifier</key> - <string>org.mozilla.servo</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>Servo</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleShortVersionString</key> - <string>0.1</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleVersion</key> - <string>0.1</string> - <key>LSHasLocalizedDisplayName</key> - <true/> - <key>LSMinimumSystemVersion</key> - <string>10.3</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> - <key>NSSupportsSuddenTermination</key> - <false/> +<key>CFBundleGetInfoString</key> +<string>Servo</string> +<key>CFBundleExecutable</key> +<string>run-servo</string> +<key>CFBundleIdentifier</key> +<string>org.servo.Servo22</string> +<key>CFBundleName</key> +<string>Servo</string> +<key>CFBundleIconFile</key> +<string>servo.icns</string> +<key>CFBundleShortVersionString</key> +<string>0.0.1</string> +<key>CFBundleInfoDictionaryVersion</key> +<string>6.0</string> +<key>CFBundlePackageType</key> +<string>APPL</string> +<key>NSHighResolutionCapable</key> +<true/> +<key>NSPrincipalClass</key> +<string>NSApplication</string> </dict> </plist> diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs index 58d6a17441c..d580b6f8a1e 100644 --- a/components/util/resource_files.rs +++ b/components/util/resource_files.rs @@ -39,20 +39,13 @@ pub fn resources_dir_path() -> PathBuf { let mut path = env::current_exe().expect("can't get exe path"); // Follow symlink path = path.canonicalize().expect("path does not exist"); - path.pop(); - path.push("resources"); - if !path.is_dir() { // resources dir not in same dir as exe? - // exe is probably in target/{debug,release} so we need to go back to topdir - path.pop(); - path.pop(); - path.pop(); + + while path.pop() { path.push("resources"); - if !path.is_dir() { - // exe is probably in target/$target_triple/{debug,release} so go back one more - path.pop(); - path.pop(); - path.push("resources"); + if path.is_dir() { + break; } + path.pop(); } *dir = Some(path.to_str().unwrap().to_owned()); path diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 434e9113bf7..83cab370f04 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -24,7 +24,7 @@ from mach.decorators import ( Command, ) -from servo.command_base import CommandBase, cd, BuildNotFound +from servo.command_base import CommandBase, cd, BuildNotFound, is_macosx from servo.post_build_commands import find_dep_path_newest @@ -35,6 +35,17 @@ def delete(path): shutil.rmtree(path) # Remove it and all its contents. +def otool(s): + o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE) + for l in o.stdout: + if l[0] == '\t': + yield l.split(' ', 1)[0][1:] + + +def install_name_tool(old, new, binary): + subprocess.call(['install_name_tool', '-change', old, '@executable_path/' + new, binary]) + + @CommandProvider class PackageCommands(CommandBase): @Command('package', @@ -71,6 +82,69 @@ class PackageCommands(CommandBase): except subprocess.CalledProcessError as e: print("Packaging Android exited with return value %d" % e.returncode) return e.returncode + elif is_macosx(): + dir_to_build = '/'.join(binary_path.split('/')[:-1]) + dir_to_dmg = '/'.join(binary_path.split('/')[:-2]) + '/dmg' + dir_to_app = dir_to_dmg + '/Servo.app' + dir_to_resources = dir_to_app + '/Contents/Resources/' + dir_to_root = '/'.join(binary_path.split('/')[:-3]) + if os.path.exists(dir_to_dmg): + print("Cleaning up from previous packaging") + delete(dir_to_dmg) + browserhtml_path = find_dep_path_newest('browserhtml', binary_path) + if browserhtml_path is None: + print("Could not find browserhtml package; perhaps you haven't built Servo.") + return 1 + + print("Copying files") + shutil.copytree(dir_to_root + '/resources', dir_to_resources) + shutil.copytree(browserhtml_path, dir_to_resources + browserhtml_path.split('/')[-1]) + shutil.copy2(dir_to_root + '/Info.plist', dir_to_app + '/Contents/Info.plist') + os.makedirs(dir_to_app + '/Contents/MacOS/') + shutil.copy2(dir_to_build + '/servo', dir_to_app + '/Contents/MacOS/') + + print("Swapping prefs") + delete(dir_to_resources + '/prefs.json') + shutil.copy2(dir_to_resources + 'package-prefs.json', dir_to_resources + 'prefs.json') + delete(dir_to_resources + '/package-prefs.json') + + print("Finding dylibs to be copied") + need = set([dir_to_app + '/Contents/MacOS/servo']) + done = set() + + while need: + needed = set(need) + need = set() + for f in needed: + need.update(otool(f)) + done.update(needed) + need.difference_update(done) + + print("Copying dylibs") + for f in sorted(done): + if '/System/Library' not in f and '/usr/lib' not in f and 'servo' not in f: + shutil.copyfile(f, dir_to_app + '/Contents/MacOS/' + f.split('/')[-1]) + install_name_tool(f, f.split('/')[-1], dir_to_app + '/Contents/MacOS/servo') + + print("Writing run-servo") + bhtml_path = path.join('${0%/*}/../Resources', browserhtml_path.split('/')[-1], 'out', 'index.html') + runservo = os.open(dir_to_app + '/Contents/MacOS/run-servo', os.O_WRONLY | os.O_CREAT, int("0755", 8)) + os.write(runservo, '#!/bin/bash\nexec ${0%/*}/servo ' + bhtml_path) + os.close(runservo) + + print("Creating dmg") + os.symlink('/Applications', dir_to_dmg + '/Applications') + dmg_path = '/'.join(dir_to_build.split('/')[:-1]) + '/' + dmg_path += datetime.utcnow().replace(microsecond=0).isoformat() + dmg_path += "-servo-tech-demo.dmg" + try: + subprocess.check_call(['hdiutil', 'create', '-volname', 'Servo', dmg_path, '-srcfolder', dir_to_dmg]) + except subprocess.CalledProcessError as e: + print("Packaging MacOS dmg exited with return value %d" % e.returncode) + return e.returncode + print("Cleaning up") + delete(dir_to_dmg) + print("Packaged Servo into " + dmg_path) else: dir_to_package = '/'.join(binary_path.split('/')[:-1]) browserhtml_path = find_dep_path_newest('browserhtml', binary_path) diff --git a/resources/package-prefs.json b/resources/package-prefs.json new file mode 100644 index 00000000000..55dc8c72e89 --- /dev/null +++ b/resources/package-prefs.json @@ -0,0 +1,63 @@ +{ + "dom.bluetooth.enabled": false, + "dom.forcetouch.enabled": true, + "dom.mouseevent.which.enabled": false, + "dom.mozbrowser.enabled": true, + "dom.serviceworker.timeout_seconds": 60, + "dom.testable_crash.enabled": false, + "dom.testbinding.enabled": false, + "gfx.webrender.enabled": true, + "js.baseline.enabled": true, + "js.ion.enabled": true, + "js.asmjs.enabled": true, + "js.strict.enabled": false, + "js.strict.debug.enabled": false, + "js.throw_on_asmjs_validation_failure.enabled": false, + "js.native_regexp.enabled": true, + "js.parallel_parsing.enabled": true, + "js.ion.offthread_compilation.enabled": true, + "js.baseline.unsafe_eager_compilation.enabled": false, + "js.ion.unsafe_eager_compilation.enabled": false, + "js.discard_system_source.enabled": false, + "js.asyncstack.enabled": false, + "js.throw_on_debuggee_would_run.enabled": false, + "js.dump_stack_on_debuggee_would_run.enabled": false, + "js.werror.enabled": false, + "js.strict.enabled": false, + "js.shared_memory.enabled": true, + "js.mem.high_water_mark": 128, + "js.mem.max": -1, + "js.mem.gc.per_compartment.enabled": true, + "js.mem.gc.incremental.enabled": true, + "js.mem.gc.incremental.slice_ms": 10, + "js.mem.gc.compacting.enabled": true, + "js.mem.gc.high_frequency_time_limit_ms": 1000, + "js.mem.gc.dynamic_mark_slice.enabled": true, + "js.mem.gc.refresh_frame_slices.enabled": true, + "js.mem.gc.dynamic_heap_growth.enabled": true, + "js.mem.gc.low_frequency_heap_growth": 150, + "js.mem.gc.high_frequency_heap_growth_min": 150, + "js.mem.gc.high_frequency_heap_growth_max": 300, + "js.mem.gc.high_frequency_low_limit_mb": 100, + "js.mem.gc.high_frequency_high_limit_mb": 500, + "js.mem.gc.allocation_threshold_mb": 30, + "js.mem.gc.decommit_threshold_mb": 32, + "js.mem.gc.empty_chunk_count_min": 1, + "js.mem.gc.empty_chunk_count_max": 30, + "js.mem.gc.zeal.level": 0, + "js.mem.gc.zeal.frequency": 100, + "layout.columns.enabled": false, + "layout.column-width.enabled": false, + "layout.column-count.enabled": false, + "layout.column-gap.enabled": false, + "layout.flex.enabled": false, + "layout.flex-direction.enabled": false, + "layout.text-orientation.enabled": false, + "layout.viewport.enabled": false, + "layout.writing-mode.enabled": false, + "network.http.redirection-limit": 20, + "network.mime.sniff": false, + "shell.homepage": "https://servo.org", + "shell.native-titlebar.enabled": false, + "shell.builtin-key-shortcuts.enabled": false +} diff --git a/resources/servo.icns b/resources/servo.icns Binary files differnew file mode 100644 index 00000000000..f17fe835a91 --- /dev/null +++ b/resources/servo.icns |