basebrowser-resources.configure (2312B)
1 # Helpers 2 # ------------------------------------------------- 3 4 5 @depends(build_project) 6 def is_desktop_build(build_project): 7 return build_project == "browser" 8 9 10 # Bootstrap resources 11 # ------------------------------------------------- 12 13 14 option( 15 "--with-noscript", 16 env="NOSCRIPT", 17 nargs=1, 18 default=None, 19 help="Path to noscript .xpi extension archive.", 20 ) 21 22 23 @depends( 24 "--with-noscript", 25 mozbuild_state_path, 26 bootstrap_path( 27 "noscript", no_unpack=True, when=depends("--with-noscript")(lambda x: not x) 28 ), 29 ) 30 @checking("for noscript extension") 31 @imports(_from="pathlib", _import="Path") 32 def noscript(value, mozbuild_state_path, _bootstrapped): 33 if value: 34 path = Path(value[0]) 35 if path.is_file() and path.suffix == ".xpi": 36 return value[0] 37 else: 38 die("--with-noscript must be an existing .xpi file") 39 40 bootstrapped_location = Path(mozbuild_state_path) / "browser" 41 for file in bootstrapped_location.glob(f"*.xpi"): 42 if "noscript" in file.name: 43 return str(bootstrapped_location / file) 44 45 # noscript is not required for building. 46 return None 47 48 49 set_config("NOSCRIPT", noscript) 50 51 52 option( 53 "--with-tor-browser-fonts", 54 env="TOR_BROWSER_FONTS", 55 nargs=1, 56 default=None, 57 help="Path to location of fonts directory.", 58 when=is_desktop_build, 59 ) 60 61 62 @depends( 63 "--with-tor-browser-fonts", 64 mozbuild_state_path, 65 bootstrap_path( 66 "fonts", 67 when=depends("--with-tor-browser-fonts", when=is_desktop_build)( 68 lambda x: not x 69 ), 70 ), 71 when=is_desktop_build, 72 ) 73 @checking("for tor-browser fonts directory") 74 @imports(_from="pathlib", _import="Path") 75 def tor_browser_fonts(value, mozbuild_state_path, _bootstrapped): 76 if value: 77 path = Path(value[0]) 78 # TODO: Do a more thorough check on the directory. 79 if path.is_dir(): 80 return value[0] 81 else: 82 die("--with-tor-browser-fonts must point to a real directory.") 83 84 bootstrapped_location = Path(mozbuild_state_path) / "fonts" 85 if bootstrapped_location.is_dir(): 86 return str(bootstrapped_location) 87 88 # tor browser fonts directory is not required for building. 89 return None 90 91 92 set_config("TOR_BROWSER_FONTS", tor_browser_fonts)