moz.configure (7825B)
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- 2 # vim: set filetype=python: 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 project_flag( 8 "MOZ_ANDROID_EXCLUDE_FONTS", 9 help="Whether to exclude font files from the build", 10 default=True, 11 ) 12 13 # tor-browser#29859 14 project_flag( 15 "MOZ_ANDROID_HLS_SUPPORT", 16 help="Enable HLS (HTTP Live Streaming) support (currently using the ExoPlayer library)", 17 default=False, 18 ) 19 20 option( 21 "--num-content-services", 22 default="40", 23 help="The number of content process services to generate in the GeckoView manifest", 24 ) 25 26 27 @depends("--num-content-services") 28 def num_content_services(value): 29 strValue = value[0] 30 intValue = int(strValue) 31 acceptableRange = range(1, 41) 32 if intValue not in acceptableRange: 33 die( 34 "Unacceptable value, must be within range [%d,%d)" 35 % (acceptableRange.start, acceptableRange.stop) 36 ) 37 return strValue 38 39 40 set_config("MOZ_ANDROID_CONTENT_SERVICE_COUNT", num_content_services) 41 set_define("MOZ_ANDROID_CONTENT_SERVICE_COUNT", num_content_services) 42 43 option( 44 "--enable-isolated-zygote-process", 45 env="MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_WITH_ZYGOTE", 46 help="Enable generating content process services with app Zygote preloading and isolated processes", 47 default=False, 48 ) 49 50 isIsolatedAppZygoteProcessEnabled = depends_if( 51 "MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_WITH_ZYGOTE" 52 )(lambda _: True) 53 set_config( 54 "MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_WITH_ZYGOTE", 55 isIsolatedAppZygoteProcessEnabled, 56 ) 57 set_define( 58 "MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_WITH_ZYGOTE", 59 isIsolatedAppZygoteProcessEnabled, 60 ) 61 62 option( 63 "--enable-isolated-process", 64 env="MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS", 65 help="Enable generating content process services with isolatedProcess=true", 66 default=False, 67 ) 68 69 isIsolatedProcessEnabled = depends_if("MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS")( 70 lambda _: True 71 ) 72 set_config( 73 "MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS", 74 isIsolatedProcessEnabled, 75 ) 76 set_define( 77 "MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS", 78 isIsolatedProcessEnabled, 79 ) 80 81 option( 82 "--enable-geckoview-lite", 83 help="Build GeckoView in Lite mode. Lite mode removes all unnecessary dependencies like Glean", 84 ) 85 86 set_config("MOZ_ANDROID_GECKOVIEW_LITE", True, when="--enable-geckoview-lite") 87 88 option( 89 "--enable-android-subproject", 90 choices=( 91 "fenix", 92 "focus", 93 "geckoview_example", 94 ), 95 nargs="?", 96 help="Build a subproject of android. Possible options: fenix/focus/geckoview_example", 97 ) 98 99 100 @depends("--enable-android-subproject") 101 def android_subproject(value): 102 if value: 103 return value[0] 104 105 106 set_config("MOZ_ANDROID_SUBPROJECT", android_subproject) 107 108 109 # The android:debuggable flag controls if a debugger can be attached on to the 110 # running app. Default this setting to follow `--enable-debug`. Use this flag to 111 # allow attaching debugging to app compiled in an optimized / release 112 # configuration. 113 # 114 # NOTE: There are numerous performance implications for a package marked as 115 # android:debuggable versus a similar one that isn't. Particularly around 116 # AOT compilation heuristics and caches. 117 118 option( 119 "--enable-android-debuggable", 120 default=moz_debug, 121 help="{Enable|Disable} the android:debuggable flag in AndroidManifest.xml", 122 ) 123 124 125 @depends("--enable-android-debuggable") 126 def android_debuggable(value): 127 if value: 128 return True 129 130 131 set_config("MOZ_ANDROID_DEBUGGABLE", android_debuggable) 132 133 134 imply_option("MOZ_NORMANDY", False) 135 # Comment this so we can imply |False| in basebrowser.configure 136 # The Build system doesn't allow multiple imply_option() 137 # calls with the same key. 138 # imply_option("MOZ_SERVICES_HEALTHREPORT", True) 139 imply_option("MOZ_GECKOVIEW_HISTORY", True) 140 141 imply_option("MOZ_APP_UA_NAME", "Firefox") 142 imply_option("MOZ_APP_VENDOR", "Mozilla") 143 imply_option("MOZ_APP_ID", "{aa3c5121-dab2-40e2-81ca-7ea25febc110}") 144 imply_option("BROWSER_CHROME_URL", "chrome://geckoview/content/geckoview.xhtml") 145 146 option( 147 "--enable-appservices-in-tree", 148 help="Enables building from an in-tree app-services", 149 ) 150 151 152 @depends("--enable-appservices-in-tree") 153 def enable_appservices_in_tree(value): 154 if value: 155 return True 156 157 158 set_config("MOZ_APPSERVICES_IN_TREE", enable_appservices_in_tree) 159 160 161 @depends(target) 162 def check_target(target): 163 if target.os != "Android": 164 log.error( 165 "You must specify --target=arm-linux-androideabi (or some " 166 "other valid Android target) when building mobile/android." 167 ) 168 die( 169 "See https://developer.mozilla.org/docs/Mozilla/Developer_guide/" 170 "Build_Instructions/Simple_Firefox_for_Android_build " 171 "for more information about the necessary options." 172 ) 173 174 175 include("basebrowser.configure") 176 177 include("../shared/moz.configure") 178 include("../../toolkit/moz.configure") 179 include("../../build/moz.configure/android-sdk.configure") 180 include("../../build/moz.configure/java.configure") 181 include("gradle.configure") 182 183 # Automation will set this via the TC environment. 184 option( 185 env="MOZ_ANDROID_FAT_AAR_ARCHITECTURES", 186 nargs="*", 187 choices=("armeabi-v7a", "arm64-v8a", "x86_64"), 188 help='Comma-separated list of Android CPU architectures like "armeabi-v7a,arm64-v8a,x86_64"', 189 ) 190 191 set_config( 192 "MOZ_ANDROID_FAT_AAR_ARCHITECTURES", 193 depends("MOZ_ANDROID_FAT_AAR_ARCHITECTURES")(lambda x: x), 194 ) 195 196 197 # Template to check for a build-time host/bin program that is either produced as 198 # part of the build or is fetched from a toolchain artifact. Also allows 199 # `--without-{prog}` to disable checking. 200 # 201 # Such compiled programs are "part of the build" but need special accommodations 202 # to distribute to artifact builds: they are distributed as toolchain builds 203 # rather than extracted from a package or a test package. In addition, these 204 # compiled programs may not be needed for very unusual jobs, in particular 205 # `android-gradle-dependencies` jobs, so they can be disabled entirely. 206 # 207 # - `var` is the name of the variable that will be set with `set_config` when 208 # the program is found, like "A_PROG". 209 # - `prog` is the name of the program, like "a-prog". 210 # - `toolchain` is the name of the toolchain (defaults to `prog`). 211 @template 212 def check_host_bin_prog(var, prog, toolchain=None): 213 option(f"--without-{prog}", help="Disable building with {prog}") 214 215 with only_when(f"--with-{prog}"): 216 with only_when(compile_environment): 217 # Produced at build-time. Look in `$DIST/host/bin`. 218 set_config( 219 var, 220 depends(build_environment.dist, bin_suffix(host))( 221 lambda dist, bin_suffix: f"{dist}/host/bin/{prog}{bin_suffix}" 222 ), 223 ) 224 225 with only_when(~compile_environment): 226 # Fetched at configure-time. Look in `~/.mozbuild` locally or 227 # `$MOZ_FETCH_DIR` in automation. 228 check_prog( 229 var, 230 [prog], 231 what=prog, 232 bootstrap=toolchain or prog, 233 ) 234 235 236 check_host_bin_prog("EMBEDDED_UNIFFI_BINDGEN", "embedded-uniffi-bindgen") 237 # tb-44669 - this was added in rebase 148 to make android compile but tracking potentially better fix 238 #check_host_bin_prog("NIMBUS_FML", "nimbus-fml") 239 240 project_flag( 241 "MOZ_ANDROID_NETWORK_STATE", 242 help="Include permission for accessing WiFi/network state on Android", 243 default=False, 244 ) 245 246 project_flag( 247 "MOZ_ANDROID_LOCATION", 248 help="Include permission for accessing fine and course-grain Location on Android", 249 default=False, 250 )