torbrowser-resources.configure (3855B)
1 option( 2 "--with-tor-expert-bundle", 3 env="TOR_EXPERT_BUNDLE", 4 nargs=1, 5 default=None, 6 help="Path to location of tor-expert-bundle directory.", 7 when=is_desktop_build, 8 ) 9 10 11 @depends( 12 "--with-tor-expert-bundle", 13 mozbuild_state_path, 14 bootstrap_path( 15 "tor-expert-bundle", 16 when=depends("--with-tor-expert-bundle", when=is_desktop_build)( 17 lambda x: not x 18 ), 19 ), 20 when=is_desktop_build, 21 ) 22 @checking("for tor-expert-bundle") 23 @imports(_from="pathlib", _import="Path") 24 def tor_expert_bundle(value, mozbuild_state_path, _bootstrapped): 25 if value: 26 path = Path(value[0]) 27 # TODO: Do a more thorough check on the directory. 28 if path.is_dir(): 29 return value[0] 30 else: 31 die("--with-tor-expert-bundle must point to a real directory.") 32 33 bootstrapped_location = Path(mozbuild_state_path) / "tor-expert-bundle" 34 if bootstrapped_location.is_dir(): 35 return str(bootstrapped_location) 36 37 # tor-expert-bundle is not required for building. 38 return None 39 40 41 set_config("TOR_EXPERT_BUNDLE", tor_expert_bundle, when=is_desktop_build) 42 43 44 # Android 45 # ------------------------------------------------- 46 47 48 @depends(build_project) 49 def is_android_build(build_project): 50 return build_project == "mobile/android" 51 52 53 option( 54 "--with-tor-expert-bundle-aar", 55 env="TOR_EXPERT_BUNDLE_AAR", 56 nargs=1, 57 default=None, 58 help="Path to location of tor-expert-bundle.aar archive.", 59 when=is_android_build, 60 ) 61 62 63 @depends( 64 "--with-tor-expert-bundle-aar", 65 mozbuild_state_path, 66 bootstrap_path( 67 "tor-expert-bundle-aar", 68 no_unpack=True, 69 when=depends("--with-tor-expert-bundle-aar", when=is_android_build)( 70 lambda x: not x 71 ), 72 ), 73 when=is_android_build, 74 ) 75 @checking("for tor-expert-bundle.aar") 76 @imports(_from="pathlib", _import="Path") 77 def tor_expert_bundle_aar(value, mozbuild_state_path, _bootstrapped): 78 if value: 79 path = Path(value[0]) 80 if path.suffix.lower() == ".aar": 81 return value[0] 82 else: 83 die("--with-tor-expert-bundle-aar must point to a AAR archive.") 84 85 bootstrapped_location = Path(mozbuild_state_path) / "tor-expert-bundle.aar" 86 if bootstrapped_location.is_file(): 87 return str(bootstrapped_location) 88 89 die( 90 "tor-expert-bundle-aar not found. Either enable bootstrap, or provide a path with --with-tor-expert-bundle-aar." 91 ) 92 93 94 set_config("TOR_EXPERT_BUNDLE_AAR", tor_expert_bundle_aar) 95 96 97 option( 98 "--with-application-services", 99 env="APPLICATION_SERVICES", 100 nargs=1, 101 default=None, 102 help="Path to location of application-services gradle lib.", 103 when=is_android_build, 104 ) 105 106 107 @depends( 108 "--with-application-services", 109 mozbuild_state_path, 110 bootstrap_path( 111 "application-services", 112 when=depends("--with-application-services", when=is_android_build)( 113 lambda x: not x 114 ), 115 ), 116 when=is_android_build, 117 ) 118 @checking("for application-services") 119 @imports(_from="pathlib", _import="Path") 120 @imports("mozbuild.tbbutils") 121 def application_services(value, mozbuild_state_path, _bootstrapped): 122 as_location = None 123 124 if value: 125 path = Path(value[0]) 126 if path.is_dir(): 127 as_location = path 128 else: 129 die("--with-application-services must point to a directory.") 130 else: 131 bootstrapped_location = Path(mozbuild_state_path) / "application-services/maven" 132 if bootstrapped_location.is_dir(): 133 as_location = bootstrapped_location 134 135 if not as_location: 136 # application-services is required for building. 137 die( 138 "application-services not found. Either enable bootstrap, or provide a path with --with-application-services." 139 ) 140 141 return as_location