-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_extension.py
52 lines (41 loc) · 1.54 KB
/
build_extension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/evn python3
import json
from shutil import make_archive, rmtree, copytree, copy
from os.path import isdir, exists
VERSION_NUM = "1.1"
def reset_build_dir():
if isdir("build") and exists("build"):
rmtree('build')
copytree("extension","build/firefox")
copytree("extension","build/chromium")
copy("extension/background.js", "build/firefox")
copy("extension/background.js", "build/chromium")
def build_firefox():
with open("extension/manifest.json", "r") as fin, open("build/firefox/manifest.json", "w") as fout:
manifest = json.load(fin)
manifest["applications"] = {
"gecko": {
"id": "[email protected]",
"strict_min_version": "45.0"
}
}
manifest["version"] = VERSION_NUM
json.dump(manifest, fout, indent=4, sort_keys=True)
make_archive("build/netflixshuffle_ffx", 'zip', 'build/firefox/')
def build_chromium():
with open("extension/manifest.json", "r") as fin, open("build/chromium/manifest.json", "w") as fout:
manifest = json.load(fin)
manifest["version"] = VERSION_NUM
manifest["background"]["persistent"] = False
json.dump(manifest, fout, indent=4, sort_keys=True)
make_archive("build/netflixshuffle_chr", 'zip', 'build/chromium/')
def main():
print("Removing old build")
reset_build_dir()
print("Building firefox extension")
build_firefox()
print("Building chromium extension")
build_chromium()
print("Done!")
if __name__ == '__main__':
main()