Restructure package-specific preferences, add support for VR-only prefs

This commit is contained in:
Manish Goregaokar 2018-11-28 15:38:19 -08:00
parent 2625950ac2
commit 6eb396874a
2 changed files with 22 additions and 8 deletions

View file

@ -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)

View file

@ -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
}
}