1*333d2b36SAndroid Build Coastguard Worker# Build System Best Practices 2*333d2b36SAndroid Build Coastguard Worker 3*333d2b36SAndroid Build Coastguard Worker## Read only source tree 4*333d2b36SAndroid Build Coastguard Worker 5*333d2b36SAndroid Build Coastguard WorkerNever write to the source directory during the build, always write to 6*333d2b36SAndroid Build Coastguard Worker`$OUT_DIR`. We expect to enforce this in the future. 7*333d2b36SAndroid Build Coastguard Worker 8*333d2b36SAndroid Build Coastguard WorkerIf you want to verify / provide an update to a checked in generated source 9*333d2b36SAndroid Build Coastguard Workerfile, generate that file into `$OUT_DIR` during the build, fail the build 10*333d2b36SAndroid Build Coastguard Workerasking the user to run a command (either a straight command, checked in script, 11*333d2b36SAndroid Build Coastguard Workergenerated script, etc) to explicitly copy that file from the output into the 12*333d2b36SAndroid Build Coastguard Workersource tree. 13*333d2b36SAndroid Build Coastguard Worker 14*333d2b36SAndroid Build Coastguard Worker## Network access 15*333d2b36SAndroid Build Coastguard Worker 16*333d2b36SAndroid Build Coastguard WorkerNever access the network during the build. We expect to enforce this in the 17*333d2b36SAndroid Build Coastguard Workerfuture, though there will be some level of exceptions for tools like `distcc` 18*333d2b36SAndroid Build Coastguard Workerand `goma`. 19*333d2b36SAndroid Build Coastguard Worker 20*333d2b36SAndroid Build Coastguard Worker## Paths 21*333d2b36SAndroid Build Coastguard Worker 22*333d2b36SAndroid Build Coastguard WorkerDon't use absolute paths in Ninja files (with make's `$(abspath)` or similar), 23*333d2b36SAndroid Build Coastguard Workeras that could trigger extra rebuilds when a source directory is moved. 24*333d2b36SAndroid Build Coastguard Worker 25*333d2b36SAndroid Build Coastguard WorkerAssume that the source directory is `$PWD`. If a script is going to change 26*333d2b36SAndroid Build Coastguard Workerdirectories and needs to convert an input from a relative to absolute path, 27*333d2b36SAndroid Build Coastguard Workerprefer to do that in the script. 28*333d2b36SAndroid Build Coastguard Worker 29*333d2b36SAndroid Build Coastguard WorkerDon't encode absolute paths in build intermediates or outputs. This would make 30*333d2b36SAndroid Build Coastguard Workerit difficult to reproduce builds on other machines. 31*333d2b36SAndroid Build Coastguard Worker 32*333d2b36SAndroid Build Coastguard WorkerDon't assume that `$OUT_DIR` is `out`. The source and output trees are very 33*333d2b36SAndroid Build Coastguard Workerlarge these days, so some people put these on different disks. There are many 34*333d2b36SAndroid Build Coastguard Workerother uses as well. 35*333d2b36SAndroid Build Coastguard Worker 36*333d2b36SAndroid Build Coastguard WorkerDon't assume that `$OUT_DIR` is under `$PWD`, users can set it to a relative path 37*333d2b36SAndroid Build Coastguard Workeror an absolute path. 38*333d2b36SAndroid Build Coastguard Worker 39*333d2b36SAndroid Build Coastguard Worker## $(shell) use in Android.mk files 40*333d2b36SAndroid Build Coastguard Worker 41*333d2b36SAndroid Build Coastguard WorkerDon't use `$(shell)` to write files, create symlinks, etc. We expect to 42*333d2b36SAndroid Build Coastguard Workerenforce this in the future. Encode these as build rules in the build graph 43*333d2b36SAndroid Build Coastguard Workerinstead. This can be problematic in a number of ways: 44*333d2b36SAndroid Build Coastguard Worker 45*333d2b36SAndroid Build Coastguard Worker* `$(shell)` calls run at the beginning of every build, at minimum this slows 46*333d2b36SAndroid Build Coastguard Worker down build startup, but it can also trigger more build steps to run than are 47*333d2b36SAndroid Build Coastguard Worker necessary, since these files will change more often than necessary. 48*333d2b36SAndroid Build Coastguard Worker* It's no longer possible for a stripped-down product configuration to opt-out 49*333d2b36SAndroid Build Coastguard Worker of these created files. It's better to have actual rules and dependencies set 50*333d2b36SAndroid Build Coastguard Worker up so that space isn't wasted, but the files are there when necessary. 51*333d2b36SAndroid Build Coastguard Worker 52*333d2b36SAndroid Build Coastguard Worker## Headers 53*333d2b36SAndroid Build Coastguard Worker 54*333d2b36SAndroid Build Coastguard Worker`LOCAL_COPY_HEADERS` is deprecated. Soong modules cannot use these headers, and 55*333d2b36SAndroid Build Coastguard Workerwhen the VNDK is enabled, System modules in Make cannot declare or use them 56*333d2b36SAndroid Build Coastguard Workereither. 57*333d2b36SAndroid Build Coastguard Worker 58*333d2b36SAndroid Build Coastguard WorkerThe set of global include paths provided by the build system is also being 59*333d2b36SAndroid Build Coastguard Workerremoved. They've been switched from using `-isystem` to `-I` already, and are 60*333d2b36SAndroid Build Coastguard Workerremoved entirely in some environments (vendor code when the VNDK is enabled). 61*333d2b36SAndroid Build Coastguard Worker 62*333d2b36SAndroid Build Coastguard WorkerInstead, use `LOCAL_EXPORT_C_INCLUDE_DIRS`/`export_include_dirs`. These allow 63*333d2b36SAndroid Build Coastguard Workeraccess to the headers automatically if you link to the associated code. 64*333d2b36SAndroid Build Coastguard Worker 65*333d2b36SAndroid Build Coastguard WorkerIf your library uses `LOCAL_EXPORT_C_INCLUDE_DIRS`/`export_include_dirs`, and 66*333d2b36SAndroid Build Coastguard Workerthe exported headers reference a library that you link to, use 67*333d2b36SAndroid Build Coastguard Worker`LOCAL_EXPORT_SHARED_LIBRARY_HEADERS`/`LOCAL_EXPORT_STATIC_LIBRARY_HEADERS`/`LOCAL_EXPORT_HEADER_LIBRARY_HEADERS` 68*333d2b36SAndroid Build Coastguard Worker(`export_shared_lib_headers`/`export_static_lib_headers`/`export_header_lib_headers`) 69*333d2b36SAndroid Build Coastguard Workerto re-export the necessary headers to your users. 70*333d2b36SAndroid Build Coastguard Worker 71*333d2b36SAndroid Build Coastguard WorkerDon't use non-local paths in your `LOCAL_EXPORT_C_INCLUDE_DIRS`, use one of the 72*333d2b36SAndroid Build Coastguard Worker`LOCAL_EXPORT_*_HEADERS` instead. Non-local exported include dirs are not 73*333d2b36SAndroid Build Coastguard Workersupported in Soong. You may need to either move your module definition up a 74*333d2b36SAndroid Build Coastguard Workerdirectory (for example, if you have ./src/ and ./include/, you probably want to 75*333d2b36SAndroid Build Coastguard Workerdefine the module in ./Android.bp, not ./src/Android.bp), define a header 76*333d2b36SAndroid Build Coastguard Workerlibrary and re-export it, or move the headers into a more appropriate location. 77*333d2b36SAndroid Build Coastguard Worker 78*333d2b36SAndroid Build Coastguard WorkerPrefer to use header libraries (`BUILD_HEADER_LIBRARY`/ `cc_library_headers`) 79*333d2b36SAndroid Build Coastguard Workeronly if the headers are actually standalone, and do not have associated code. 80*333d2b36SAndroid Build Coastguard WorkerSometimes there are headers that have header-only sections, but also define 81*333d2b36SAndroid Build Coastguard Workerinterfaces to a library. Prefer to split those header-only sections out to a 82*333d2b36SAndroid Build Coastguard Workerseparate header-only library containing only the header-only sections, and 83*333d2b36SAndroid Build Coastguard Workerre-export that header library from the existing library. This will prevent 84*333d2b36SAndroid Build Coastguard Workeraccidentally linking more code than you need (slower at build and/or runtime), 85*333d2b36SAndroid Build Coastguard Workeror accidentally not linking to a library that's actually necessary. 86*333d2b36SAndroid Build Coastguard Worker 87*333d2b36SAndroid Build Coastguard WorkerPrefer `LOCAL_EXPORT_C_INCLUDE_DIRS` over `LOCAL_C_INCLUDES` as well. 88*333d2b36SAndroid Build Coastguard WorkerEventually we'd like to remove `LOCAL_C_INCLUDES`, though significant cleanup 89*333d2b36SAndroid Build Coastguard Workerwill be required first. This will be necessary to detect cases where modules 90*333d2b36SAndroid Build Coastguard Workerare using headers that shouldn't be available to them -- usually due to the 91*333d2b36SAndroid Build Coastguard Workerlack of ABI/API guarantees, but for various other reasons as well: layering 92*333d2b36SAndroid Build Coastguard Workerviolations, planned deprecations, potential optimizations like C++ modules, 93*333d2b36SAndroid Build Coastguard Workeretc. 94*333d2b36SAndroid Build Coastguard Worker 95*333d2b36SAndroid Build Coastguard Worker## Use defaults over variables 96*333d2b36SAndroid Build Coastguard Worker 97*333d2b36SAndroid Build Coastguard WorkerSoong supports variable definitions in Android.bp files, but in many cases, 98*333d2b36SAndroid Build Coastguard Workerit's better to use defaults modules like `cc_defaults`, `java_defaults`, etc. 99*333d2b36SAndroid Build Coastguard Worker 100*333d2b36SAndroid Build Coastguard Worker* It moves more information next to the values -- that the array of strings 101*333d2b36SAndroid Build Coastguard Worker will be used as a list of sources is useful, both for humans and automated 102*333d2b36SAndroid Build Coastguard Worker tools. This is even more useful if it's used inside an architecture or 103*333d2b36SAndroid Build Coastguard Worker target specific property. 104*333d2b36SAndroid Build Coastguard Worker* It can collect multiple pieces of information together into logical 105*333d2b36SAndroid Build Coastguard Worker inheritable groups that can be selected with a single property. 106*333d2b36SAndroid Build Coastguard Worker 107*333d2b36SAndroid Build Coastguard Worker## Custom build tools 108*333d2b36SAndroid Build Coastguard Worker 109*333d2b36SAndroid Build Coastguard WorkerIf writing multiple files from a tool, declare them all in the build graph. 110*333d2b36SAndroid Build Coastguard Worker* Make: Use `.KATI_IMPLICIT_OUTPUTS` 111*333d2b36SAndroid Build Coastguard Worker* Android.bp: Just add them to the `out` list in genrule 112*333d2b36SAndroid Build Coastguard Worker* Custom Soong Plugin: Add to `Outputs` or `ImplicitOutputs` 113*333d2b36SAndroid Build Coastguard Worker 114*333d2b36SAndroid Build Coastguard WorkerDeclare all files read by the tool, either with a dependency if you can, or by 115*333d2b36SAndroid Build Coastguard Workerwriting a dependency file. Ninja supports a fairly limited set of dependency 116*333d2b36SAndroid Build Coastguard Workerfile formats. You can verify that the dependencies are read correctly with: 117*333d2b36SAndroid Build Coastguard Worker 118*333d2b36SAndroid Build Coastguard Worker``` 119*333d2b36SAndroid Build Coastguard WorkerNINJA_ARGS="-t deps <output_file>" m 120*333d2b36SAndroid Build Coastguard Worker``` 121*333d2b36SAndroid Build Coastguard Worker 122*333d2b36SAndroid Build Coastguard WorkerPrefer to list input files on the command line, otherwise we may not know to 123*333d2b36SAndroid Build Coastguard Workerre-run your command when a new input file is added. Ninja does not treat a 124*333d2b36SAndroid Build Coastguard Workerchange in dependencies as something that would invalidate an action -- the 125*333d2b36SAndroid Build Coastguard Workercommand line would need to change, or one of the inputs would need to be newer 126*333d2b36SAndroid Build Coastguard Workerthan the output file. If you don't include the inputs in your command line, you 127*333d2b36SAndroid Build Coastguard Workermay need to add the the directories to your dependency list or dependency file, 128*333d2b36SAndroid Build Coastguard Workerso that any additions or removals from those directories would trigger your 129*333d2b36SAndroid Build Coastguard Workertool to be re-run. That can be more expensive than necessary though, since many 130*333d2b36SAndroid Build Coastguard Workereditors will write temporary files into the same directory, so changing a 131*333d2b36SAndroid Build Coastguard WorkerREADME could trigger the directory's timestamp to be updated. 132*333d2b36SAndroid Build Coastguard Worker 133*333d2b36SAndroid Build Coastguard WorkerOnly control output files based on the command line, not by an input file. We 134*333d2b36SAndroid Build Coastguard Workerneed to know which files will be created before any inputs are read, since we 135*333d2b36SAndroid Build Coastguard Workergenerate the entire build graph before reading source files, or running your 136*333d2b36SAndroid Build Coastguard Workertool. This comes up with Java based tools fairly often -- they'll generate 137*333d2b36SAndroid Build Coastguard Workerdifferent output files based on the classes declared in their input files. 138*333d2b36SAndroid Build Coastguard WorkerWe've worked around these tools with the "srcjar" concept, which is just a jar 139*333d2b36SAndroid Build Coastguard Workerfile containing the generated sources. Our Java compilation tasks understand 140*333d2b36SAndroid Build Coastguard Worker*.srcjar files, and will extract them before passing them on to the compiler. 141*333d2b36SAndroid Build Coastguard Worker 142*333d2b36SAndroid Build Coastguard Worker## Libraries in PRODUCT_PACKAGES 143*333d2b36SAndroid Build Coastguard Worker 144*333d2b36SAndroid Build Coastguard WorkerMost libraries aren't necessary to include in `PRODUCT_PACKAGES`, unless 145*333d2b36SAndroid Build Coastguard Workerthey're used dynamically via `dlopen`. If they're only used via 146*333d2b36SAndroid Build Coastguard Worker`LOCAL_SHARED_LIBRARIES` / `shared_libs`, then those dependencies will trigger 147*333d2b36SAndroid Build Coastguard Workerthem to be installed when necessary. Adding unnecessary libraries into 148*333d2b36SAndroid Build Coastguard Worker`PRODUCT_PACKAGES` will force them to always be installed, wasting space. 149*333d2b36SAndroid Build Coastguard Worker 150*333d2b36SAndroid Build Coastguard Worker## Removing conditionals 151*333d2b36SAndroid Build Coastguard Worker 152*333d2b36SAndroid Build Coastguard WorkerOver-use of conditionals in the build files results in an untestable number 153*333d2b36SAndroid Build Coastguard Workerof build combinations, leading to more build breakages. It also makes the 154*333d2b36SAndroid Build Coastguard Workercode less testable, as it must be built with each combination of flags to 155*333d2b36SAndroid Build Coastguard Workerbe tested. 156*333d2b36SAndroid Build Coastguard Worker 157*333d2b36SAndroid Build Coastguard Worker### Conditionally compiled module 158*333d2b36SAndroid Build Coastguard Worker 159*333d2b36SAndroid Build Coastguard WorkerConditionally compiling a module can generally be replaced with conditional 160*333d2b36SAndroid Build Coastguard Workerinstallation: 161*333d2b36SAndroid Build Coastguard Worker 162*333d2b36SAndroid Build Coastguard Worker``` 163*333d2b36SAndroid Build Coastguard Workerifeq (some condition) 164*333d2b36SAndroid Build Coastguard Worker# body of the Android.mk file 165*333d2b36SAndroid Build Coastguard WorkerLOCAL_MODULE:= bt_logger 166*333d2b36SAndroid Build Coastguard Workerinclude $(BUILD_EXECUTABLE) 167*333d2b36SAndroid Build Coastguard Workerendif 168*333d2b36SAndroid Build Coastguard Worker``` 169*333d2b36SAndroid Build Coastguard Worker 170*333d2b36SAndroid Build Coastguard WorkerBecomes: 171*333d2b36SAndroid Build Coastguard Worker 172*333d2b36SAndroid Build Coastguard Worker``` 173*333d2b36SAndroid Build Coastguard Workercc_binary { 174*333d2b36SAndroid Build Coastguard Worker name: "bt_logger", 175*333d2b36SAndroid Build Coastguard Worker // body of the module 176*333d2b36SAndroid Build Coastguard Worker} 177*333d2b36SAndroid Build Coastguard Worker``` 178*333d2b36SAndroid Build Coastguard Worker 179*333d2b36SAndroid Build Coastguard WorkerAnd in a product Makefile somewhere (something included with 180*333d2b36SAndroid Build Coastguard Worker`$(call inherit-product, ...)`: 181*333d2b36SAndroid Build Coastguard Worker 182*333d2b36SAndroid Build Coastguard Worker``` 183*333d2b36SAndroid Build Coastguard Workerifeq (some condition) # Or no condition 184*333d2b36SAndroid Build Coastguard WorkerPRODUCT_PACKAGES += bt_logger 185*333d2b36SAndroid Build Coastguard Workerendif 186*333d2b36SAndroid Build Coastguard Worker``` 187*333d2b36SAndroid Build Coastguard Worker 188*333d2b36SAndroid Build Coastguard WorkerIf the condition was on a type of board or product, it can often be dropped 189*333d2b36SAndroid Build Coastguard Workercompletely by putting the `PRODUCT_PACKAGES` entry in a product makefile that 190*333d2b36SAndroid Build Coastguard Workeris included only by the correct products or boards. 191*333d2b36SAndroid Build Coastguard Worker 192*333d2b36SAndroid Build Coastguard Worker### Conditionally compiled module with multiple implementations 193*333d2b36SAndroid Build Coastguard Worker 194*333d2b36SAndroid Build Coastguard WorkerIf there are multiple implementations of the same module with one selected 195*333d2b36SAndroid Build Coastguard Workerfor compilation via a conditional, the implementations can sometimes be renamed 196*333d2b36SAndroid Build Coastguard Workerto unique values. 197*333d2b36SAndroid Build Coastguard Worker 198*333d2b36SAndroid Build Coastguard WorkerFor example, the name of the gralloc HAL module can be overridden by the 199*333d2b36SAndroid Build Coastguard Worker`ro.hardware.gralloc` system property: 200*333d2b36SAndroid Build Coastguard Worker 201*333d2b36SAndroid Build Coastguard Worker``` 202*333d2b36SAndroid Build Coastguard Worker# In hardware/acme/soc_a/gralloc/Android.mk: 203*333d2b36SAndroid Build Coastguard Workerifeq ($(TARGET_BOARD_PLATFORM),soc_a) 204*333d2b36SAndroid Build Coastguard WorkerLOCAL_MODULE := gralloc.acme 205*333d2b36SAndroid Build Coastguard Worker... 206*333d2b36SAndroid Build Coastguard Workerinclude $(BUILD_SHARED_LIBRARY) 207*333d2b36SAndroid Build Coastguard Workerendif 208*333d2b36SAndroid Build Coastguard Worker 209*333d2b36SAndroid Build Coastguard Worker# In hardware/acme/soc_b/gralloc/Android.mk: 210*333d2b36SAndroid Build Coastguard Workerifeq ($(TARGET_BOARD_PLATFORM),soc_b) 211*333d2b36SAndroid Build Coastguard WorkerLOCAL_MODULE := gralloc.acme 212*333d2b36SAndroid Build Coastguard Worker... 213*333d2b36SAndroid Build Coastguard Workerinclude $(BUILD_SHARED_LIBRARY) 214*333d2b36SAndroid Build Coastguard Workerendif 215*333d2b36SAndroid Build Coastguard Worker``` 216*333d2b36SAndroid Build Coastguard Worker 217*333d2b36SAndroid Build Coastguard WorkerBecomes: 218*333d2b36SAndroid Build Coastguard Worker``` 219*333d2b36SAndroid Build Coastguard Worker# In hardware/acme/soc_a/gralloc/Android.bp: 220*333d2b36SAndroid Build Coastguard Workercc_library { 221*333d2b36SAndroid Build Coastguard Worker name: "gralloc.soc_a", 222*333d2b36SAndroid Build Coastguard Worker ... 223*333d2b36SAndroid Build Coastguard Worker} 224*333d2b36SAndroid Build Coastguard Worker 225*333d2b36SAndroid Build Coastguard Worker# In hardware/acme/soc_b/gralloc/Android.bp: 226*333d2b36SAndroid Build Coastguard Workercc_library { 227*333d2b36SAndroid Build Coastguard Worker name: "gralloc.soc_b", 228*333d2b36SAndroid Build Coastguard Worker ... 229*333d2b36SAndroid Build Coastguard Worker} 230*333d2b36SAndroid Build Coastguard Worker``` 231*333d2b36SAndroid Build Coastguard Worker 232*333d2b36SAndroid Build Coastguard WorkerThen to select the correct gralloc implementation, a product makefile inherited 233*333d2b36SAndroid Build Coastguard Workerby products that use soc_a should contain: 234*333d2b36SAndroid Build Coastguard Worker 235*333d2b36SAndroid Build Coastguard Worker``` 236*333d2b36SAndroid Build Coastguard WorkerPRODUCT_PACKAGES += gralloc.soc_a 237*333d2b36SAndroid Build Coastguard WorkerPRODUCT_PROPERTY_OVERRIDES += ro.hardware.gralloc=soc_a 238*333d2b36SAndroid Build Coastguard Worker``` 239*333d2b36SAndroid Build Coastguard Worker 240*333d2b36SAndroid Build Coastguard WorkerIn cases where the names cannot be made unique a `soong_namespace` should be 241*333d2b36SAndroid Build Coastguard Workerused to partition a set of modules so that they are built only when the 242*333d2b36SAndroid Build Coastguard Workernamespace is listed in `PRODUCT_SOONG_NAMESPACES`. See the 243*333d2b36SAndroid Build Coastguard Worker[Referencing Modules](../README.md#referencing-modules) section of the Soong 244*333d2b36SAndroid Build Coastguard WorkerREADME.md for more on namespaces. 245*333d2b36SAndroid Build Coastguard Worker 246*333d2b36SAndroid Build Coastguard Worker### Module with name based on variable 247*333d2b36SAndroid Build Coastguard Worker 248*333d2b36SAndroid Build Coastguard WorkerHAL modules sometimes use variables like `$(TARGET_BOARD_PLATFORM)` in their 249*333d2b36SAndroid Build Coastguard Workermodule name. These can be renamed to a fixed name. 250*333d2b36SAndroid Build Coastguard Worker 251*333d2b36SAndroid Build Coastguard WorkerFor example, the name of the gralloc HAL module can be overridden by the 252*333d2b36SAndroid Build Coastguard Worker`ro.hardware.gralloc` system property: 253*333d2b36SAndroid Build Coastguard Worker 254*333d2b36SAndroid Build Coastguard Worker``` 255*333d2b36SAndroid Build Coastguard WorkerLOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM) 256*333d2b36SAndroid Build Coastguard Worker... 257*333d2b36SAndroid Build Coastguard Workerinclude $(BUILD_SHARED_LIBRARY) 258*333d2b36SAndroid Build Coastguard Worker``` 259*333d2b36SAndroid Build Coastguard Worker 260*333d2b36SAndroid Build Coastguard WorkerBecomes: 261*333d2b36SAndroid Build Coastguard Worker``` 262*333d2b36SAndroid Build Coastguard Workercc_library { 263*333d2b36SAndroid Build Coastguard Worker name: "gralloc.acme", 264*333d2b36SAndroid Build Coastguard Worker ... 265*333d2b36SAndroid Build Coastguard Worker} 266*333d2b36SAndroid Build Coastguard Worker``` 267*333d2b36SAndroid Build Coastguard Worker 268*333d2b36SAndroid Build Coastguard WorkerThen to select the correct gralloc implementation, a product makefile should 269*333d2b36SAndroid Build Coastguard Workercontain: 270*333d2b36SAndroid Build Coastguard Worker 271*333d2b36SAndroid Build Coastguard Worker``` 272*333d2b36SAndroid Build Coastguard WorkerPRODUCT_PACKAGES += gralloc.acme 273*333d2b36SAndroid Build Coastguard WorkerPRODUCT_PROPERTY_OVERRIDES += ro.hardware.gralloc=acme 274*333d2b36SAndroid Build Coastguard Worker``` 275*333d2b36SAndroid Build Coastguard Worker 276*333d2b36SAndroid Build Coastguard Worker### Conditionally used source files, libraries or flags 277*333d2b36SAndroid Build Coastguard Worker 278*333d2b36SAndroid Build Coastguard WorkerThe preferred solution is to convert the conditional to runtime, either by 279*333d2b36SAndroid Build Coastguard Workerautodetecting the correct value or loading the value from a system property 280*333d2b36SAndroid Build Coastguard Workeror a configuration file. 281*333d2b36SAndroid Build Coastguard Worker 282*333d2b36SAndroid Build Coastguard WorkerAs a last resort, if the conditional cannot be removed, a Soong plugin can 283*333d2b36SAndroid Build Coastguard Workerbe written in Go that can implement additional features for specific module 284*333d2b36SAndroid Build Coastguard Workertypes. Soong plugins are inherently tightly coupled to the build system 285*333d2b36SAndroid Build Coastguard Workerand will require ongoing maintenance as the build system is changed; so 286*333d2b36SAndroid Build Coastguard Workerplugins should be used only when absolutely required. 287*333d2b36SAndroid Build Coastguard Worker 288*333d2b36SAndroid Build Coastguard WorkerSee [art/build/art.go](https://android.googlesource.com/platform/art/+/main/build/art.go) 289*333d2b36SAndroid Build Coastguard Workeror [external/llvm/soong/llvm.go](https://android.googlesource.com/platform/external/llvm/+/main/soong/llvm.go) 290*333d2b36SAndroid Build Coastguard Workerfor examples of more complex conditionals on product variables or environment variables. 291