diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 587e7dd0dda..4211cc84d96 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -564,8 +564,13 @@ class MachCommands(CommandBase): # Do some additional things if the build succeeded if status == 0: if android and not no_package: + flavor = None + if "googlevr" in features: + flavor = "googlevr" + elif "oculusvr" in features: + flavor = "oculusvr" rv = Registrar.dispatch("package", context=self.context, - release=release, dev=dev, target=target) + release=release, dev=dev, target=target, flavor=flavor) if rv: return rv diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index aa8a80af7a2..5449cfc509a 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -169,19 +169,24 @@ def copy_windows_dependencies(binary_path, destination): shutil.copy(nspr4_path, destination) -def change_prefs(resources_path, platform): +def change_prefs(resources_path, platform, vr=False): print("Swapping prefs") prefs_path = path.join(resources_path, "prefs.json") package_prefs_path = path.join(resources_path, "package-prefs.json") - os_type = "os:{}".format(platform) with open(prefs_path) as prefs, open(package_prefs_path) as package_prefs: prefs = json.load(prefs) + pref_sets = [] package_prefs = json.load(package_prefs) - for pref in package_prefs: - if os_type in pref: - prefs[pref.split(";")[1]] = package_prefs[pref] - if pref in prefs: - prefs[pref] = package_prefs[pref] + if "all" in package_prefs: + pref_sets += [package_prefs["all"]] + if vr and "vr" in package_prefs: + pref_sets += [package_prefs["vr"]] + if platform in package_prefs: + pref_sets += [package_prefs[platform]] + for pref_set in pref_sets: + for pref in pref_set: + if pref in prefs: + prefs[pref] = pref_set[pref] with open(prefs_path, "w") as out: json.dump(prefs, out, sort_keys=True, indent=2) delete(package_prefs_path) @@ -276,6 +281,15 @@ class PackageCommands(CommandBase): if flavor is not None: flavor_name = flavor.title() + vr = flavor == "googlevr" or flavor == "oculusvr" + + dir_to_resources = path.join(self.get_top_dir(), 'target', 'android', 'resources') + if path.exists(dir_to_resources): + delete(dir_to_resources) + + shutil.copytree(path.join(dir_to_root, 'resources'), dir_to_resources) + change_prefs(dir_to_resources, "android", vr=vr) + variant = ":assemble" + flavor_name + build_type + build_mode apk_task_name = ":servoapp" + variant aar_task_name = ":servoview" + variant diff --git a/resources/package-prefs.json b/resources/package-prefs.json index 0762de26cbc..7a64a1f1531 100644 --- a/resources/package-prefs.json +++ b/resources/package-prefs.json @@ -1,3 +1,12 @@ { - "_comment": "this file is used to add some specific preferences to the Servo package (nightly builds)" + "_comment": "this file is used to add some specific preferences to the Servo package (nightly builds)", + "all": {}, + "macosx": {}, + "linux": {}, + "android": {}, + "windows": {}, + "vr": { + "_comment": "settings specific to VR builds", + "dom.webvr.enabled": true + } } diff --git a/support/android/apk/servoview/build.gradle b/support/android/apk/servoview/build.gradle index 257742af826..0e97838f816 100644 --- a/support/android/apk/servoview/build.gradle +++ b/support/android/apk/servoview/build.gradle @@ -111,7 +111,7 @@ android { sourceSets { main { - assets.srcDirs = ['../../../../resources'] + assets.srcDirs = [rootDir.absolutePath + "/../../../target/android/resources"] } armDebug { jniLibs.srcDirs = [getJniLibsPath(true, 'arm')]