blob: c7935d3ca4b5ef86d960a003bd0605ce2666b2f4 [file] [log] [blame]
Jiyong Parkc678ad32018-04-10 13:07:10 +09001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Jaewoong Jung4b79e982020-06-01 10:45:49 -070015package etc
Jiyong Parkc678ad32018-04-10 13:07:10 +090016
Yo Chiang803c40d2020-11-16 20:32:51 +080017// This file implements module types that install prebuilt artifacts.
18//
19// There exist two classes of prebuilt modules in the Android tree. The first class are the ones
20// based on `android.Prebuilt`, such as `cc_prebuilt_library` and `java_import`. This kind of
21// modules may exist both as prebuilts and source at the same time, though only one would be
22// installed and the other would be marked disabled. The `prebuilt_postdeps` mutator would select
23// the actual modules to be installed. More details in android/prebuilt.go.
24//
25// The second class is described in this file. Unlike `android.Prebuilt` based module types,
26// `prebuilt_etc` exist only as prebuilts and cannot have a same-named source module counterpart.
27// This makes the logic of `prebuilt_etc` to be much simpler as they don't need to go through the
28// various `prebuilt_*` mutators.
Jaewoong Jung4b79e982020-06-01 10:45:49 -070029
Yo Chiang803c40d2020-11-16 20:32:51 +080030import (
Jiyong Park76a42f52021-02-16 06:50:37 +090031 "fmt"
Kiyoung Kimae11c232021-07-19 11:38:04 +090032 "path/filepath"
Inseob Kim27408bf2021-04-06 21:00:17 +090033 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090034
Jaewoong Jung4b79e982020-06-01 10:45:49 -070035 "github.com/google/blueprint/proptools"
36
37 "android/soong/android"
38)
39
40var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090041
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080042// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090043
44func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070045 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090046 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
47}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070048
Jooyung Han0703fd82020-08-26 22:11:53 +090049func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
50 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
51 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000052 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Nelson Li1fb94b22024-07-09 17:04:52 +080053 ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090054 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050055 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090056 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
57 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
yangbill63c5e192024-03-27 09:02:12 +000058 ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory)
yangbill85527e62024-04-30 08:24:50 +000059 ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory)
60 ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory)
61 ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000062 ctx.RegisterModuleType("prebuilt_usr_srec", PrebuiltUserSrecFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090063 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020064 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090065 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
Luca Stefani5daba742025-03-09 12:41:06 +010066 ctx.RegisterModuleType("prebuilt_gpu", PrebuiltGPUFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090067 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070068 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070069 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000070 ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory)
Jihoon Kangec62d842024-10-25 20:27:18 +000071 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
72 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
73 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000074 ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory)
Michael Bestase6b299a2025-03-08 20:44:34 +020075 ctx.RegisterModuleType("prebuilt_radio", PrebuiltRadioFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000076 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
77 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
78 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
79 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
80 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000081 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
Artem Borisov81732c22025-03-11 23:19:26 +030082 ctx.RegisterModuleType("prebuilt_vendor_overlay", PrebuiltVendorOverlayFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000083 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000084 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
85 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Jihoon Kangecf76dd2024-11-12 05:24:46 +000086 ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory)
Jihoon Kang3ca07a12024-12-02 19:14:30 +000087 ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory)
Jihoon Kang320ca7c2024-12-03 18:14:50 +000088 ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
89 ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
90 ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
Jihoon Kangcc1c4aa2025-03-12 22:14:39 +000091 ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000092
93 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040094
Jiyong Parkc678ad32018-04-10 13:07:10 +090095}
96
Paul Duffin1172fed2021-03-08 11:28:18 +000097var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
98
Jihoon Kang69725b32024-11-12 03:08:49 +000099type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +0800100 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100101 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -0700102 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900103
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100104 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700105 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
106 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700107 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100108
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800109 // Optional name for the installed file. If unspecified, name of the module is used as the file
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100110 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900111 Filename *string `android:"arch_variant"`
112
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800113 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900114 // is the same as the file name of the source file.
115 Filename_from_src *bool `android:"arch_variant"`
116
Yifan Hong1b3348d2020-01-21 15:53:22 -0800117 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700118 // On device without a dedicated recovery partition, the module is only
119 // available after switching root into
120 // /first_stage_ramdisk. To expose the module before switching root, install
121 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800122 Ramdisk_available *bool
123
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700124 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700125 // On device without a dedicated recovery partition, the module is only
126 // available after switching root into
127 // /first_stage_ramdisk. To expose the module before switching root, install
128 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700129 Vendor_ramdisk_available *bool
130
Inseob Kim08758f02021-04-08 21:13:22 +0900131 // Make this module available when building for debug ramdisk.
132 Debug_ramdisk_available *bool
133
Tao Bao0ba5c942018-08-14 22:20:22 -0700134 // Make this module available when building for recovery.
135 Recovery_available *bool
136
Jiyong Parkad9ce042018-10-31 22:49:57 +0900137 // Whether this module is directly installable to one of the partitions. Default: true.
138 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800139
140 // Install symlinks to the installed file.
141 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800142
Wei Li59586252024-11-04 09:25:54 -0800143 // Install to partition oem when set to true.
144 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900145}
146
Jihoon Kang6b45f842025-03-12 22:24:52 +0000147// Dsts is useful in that it allows prebuilt_* modules to easily map the source files to the
148// install path within the partition. Dsts values are allowed to contain filepath separator
149// so that the source files can be installed in subdirectories within the partition.
150// However, this functionality should not be supported for prebuilt_root module type, as it
151// allows the module to install to any arbitrary location. Thus, this property is defined in
152// a separate struct so that it's not available to be set in prebuilt_root module type.
153type PrebuiltDstsProperties struct {
154 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
155 // set filename_from_src. This can be used to install each source file to a different directory
156 // and/or change filenames when files are installed. Must be exactly one entry per source file,
157 // which means care must be taken if srcs has globs.
158 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
159}
160
Inseob Kim27408bf2021-04-06 21:00:17 +0900161type prebuiltSubdirProperties struct {
162 // Optional subdirectory under which this file is installed into, cannot be specified with
163 // relative_install_path, prefer relative_install_path.
164 Sub_dir *string `android:"arch_variant"`
165
166 // Optional subdirectory under which this file is installed into, cannot be specified with
167 // sub_dir.
168 Relative_install_path *string `android:"arch_variant"`
169}
170
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900171type prebuiltRootProperties struct {
172 // Install this module to the root directory, without partition subdirs. When this module is
173 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
174 // then be copied to the root of system.img. When this module is packaged by other modules like
175 // android_filesystem, this module will be installed to the root ("/"), unlike normal
176 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
177 Install_in_root *bool
178}
179
Jooyung Han39edb6c2019-11-06 16:53:07 +0900180type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700181 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800182
183 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900184 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800185
186 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900187 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900188}
189
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900190type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700191 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000192 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900193
Jihoon Kang69725b32024-11-12 03:08:49 +0000194 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900195
Jihoon Kang6b45f842025-03-12 22:24:52 +0000196 dstsProperties PrebuiltDstsProperties
197
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900198 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
199 // prebuilt_avb and prebuilt_root modules use this.
200 rootProperties prebuiltRootProperties
201
Inseob Kim27408bf2021-04-06 21:00:17 +0900202 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900203
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100204 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800205 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800206 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800207 installDirBase string
208 installDirBase64 string
209 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800210 // The base install location when soc_specific property is set to true, e.g. "firmware" for
211 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700212 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700213 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700214 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700215
Cole Faustfdec8722024-05-22 11:38:29 -0700216 usedSrcsProperty bool
217
Colin Crossf17e2b52023-10-30 15:17:25 -0700218 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900219}
220
Inseob Kim1e27a142021-05-06 11:46:11 +0000221type Defaults struct {
222 android.ModuleBase
223 android.DefaultsModuleBase
224}
225
Yifan Hong1b3348d2020-01-21 15:53:22 -0800226func (p *PrebuiltEtc) inRamdisk() bool {
227 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
228}
229
230func (p *PrebuiltEtc) onlyInRamdisk() bool {
231 return p.ModuleBase.InstallInRamdisk()
232}
233
234func (p *PrebuiltEtc) InstallInRamdisk() bool {
235 return p.inRamdisk()
236}
237
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700238func (p *PrebuiltEtc) inVendorRamdisk() bool {
239 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
240}
241
242func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
243 return p.ModuleBase.InstallInVendorRamdisk()
244}
245
246func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
247 return p.inVendorRamdisk()
248}
249
Inseob Kim08758f02021-04-08 21:13:22 +0900250func (p *PrebuiltEtc) inDebugRamdisk() bool {
251 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
252}
253
254func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
255 return p.ModuleBase.InstallInDebugRamdisk()
256}
257
258func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
259 return p.inDebugRamdisk()
260}
261
Kiyoung Kimae11c232021-07-19 11:38:04 +0900262func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800263 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700264}
265
266func (p *PrebuiltEtc) onlyInRecovery() bool {
267 return p.ModuleBase.InstallInRecovery()
268}
269
270func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900271 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700272}
273
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700274var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800275
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700276func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000279 return false
280}
281
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700282func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000283 return false
284}
285
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700286func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700287 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900288 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800289}
290
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700291func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700292 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800293}
294
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700295func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700296 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
297}
298
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700299func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900300 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
301}
302
Nelson Li1fb94b22024-07-09 17:04:52 +0800303func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900304 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800305}
306
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700307func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700308 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800309}
310
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700311func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800312 return nil
313}
314
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700315func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800316}
317
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700318func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700319 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100320 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
321 }
Cole Faustfdec8722024-05-22 11:38:29 -0700322 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900323}
324
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700325func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700326 if len(p.installDirPaths) != 1 {
327 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
328 }
329 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900330}
331
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900332// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
333// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700334func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900335 p.additionalDependencies = &paths
336}
337
Cole Faust4e9f5922024-11-13 16:09:23 -0800338func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700339 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100340 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
341 }
342 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900343}
344
345func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900346 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700347 return subDir
348 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900349 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900350}
351
Jooyung Han0703fd82020-08-26 22:11:53 +0900352func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900353 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900354}
355
Jiyong Parkad9ce042018-10-31 22:49:57 +0900356func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800357 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900358}
359
Kiyoung Kimae11c232021-07-19 11:38:04 +0900360func (p *PrebuiltEtc) InVendor() bool {
361 return p.ModuleBase.InstallInVendor()
362}
363
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100364func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800365 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
366 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900367 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700368 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
369 installBaseDir = p.installDirBase64
370 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900371 if p.SocSpecific() && p.socInstallDirBase != "" {
372 installBaseDir = p.socInstallDirBase
373 }
Colin Cross2f634572023-11-13 12:12:06 -0800374 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
375 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
376 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100377 return installBaseDir
378}
Colin Cross2f634572023-11-13 12:12:06 -0800379
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100380func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
381 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900382
Cole Faustfdec8722024-05-22 11:38:29 -0700383 srcProperty := p.properties.Src.Get(ctx)
384 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
385 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100386 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000387 }
Jihoon Kang6b45f842025-03-12 22:24:52 +0000388 dstsProperty := p.dstsProperties.Dsts.GetOrDefault(ctx, nil)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700389 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
390 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
391 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100392
393 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
394 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
395 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
396 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700397 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800398 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000399 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800400 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
401 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100402
403 filename := proptools.String(p.properties.Filename)
404 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700405 if srcProperty.IsPresent() {
406 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100407 // If the source was not found, set a fake source path to
408 // support AllowMissingDependencies executions.
409 if len(p.sourceFilePaths) == 0 {
410 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
411 }
412
413 // Determine the output file basename.
414 // If Filename is set, use the name specified by the property.
415 // If Filename_from_src is set, use the source file name.
416 // Otherwise use the module name.
417 if filename != "" {
418 if filenameFromSrc {
419 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
420 return
421 }
422 } else if filenameFromSrc {
423 filename = p.sourceFilePaths[0].Base()
424 } else {
425 filename = ctx.ModuleName()
426 }
427 if strings.Contains(filename, "/") {
428 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
429 return
430 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800431 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100432
433 ip := installProperties{
434 filename: filename,
435 sourceFilePath: p.sourceFilePaths[0],
436 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700437 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100438 symlinks: p.properties.Symlinks,
439 }
440 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700441 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700442 } else if len(srcsProperty) > 0 {
443 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100444 if filename != "" {
445 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
446 }
447 if len(p.properties.Symlinks) > 0 {
448 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
449 }
450 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700451 if len(dstsProperty) > 0 {
452 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
453 } else {
454 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
455 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100456 }
Cole Faustfdec8722024-05-22 11:38:29 -0700457 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700458 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
459 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
460 }
461 for i, src := range p.sourceFilePaths {
462 var filename string
463 var installDirPath android.InstallPath
464
465 if len(dstsProperty) > 0 {
466 var dstdir string
467
468 dstdir, filename = filepath.Split(dstsProperty[i])
469 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
470 } else {
471 filename = src.Base()
472 installDirPath = baseInstallDirPath
473 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800474 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100475 ip := installProperties{
476 filename: filename,
477 sourceFilePath: src,
478 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700479 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100480 }
481 p.outputFilePaths = append(p.outputFilePaths, output)
482 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700483 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100484 }
485 } else if ctx.Config().AllowMissingDependencies() {
486 // If no srcs was set and AllowMissingDependencies is enabled then
487 // mark the module as missing dependencies and set a fake source path
488 // and file name.
489 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
490 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
491 if filename == "" {
492 filename = ctx.ModuleName()
493 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800494 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100495 ip := installProperties{
496 filename: filename,
497 sourceFilePath: p.sourceFilePaths[0],
498 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700499 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100500 }
501 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700502 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100503 } else {
504 ctx.PropertyErrorf("src", "missing prebuilt source file")
505 return
506 }
507
508 // Call InstallFile even when uninstallable to make the module included in the package.
509 if !p.Installable() {
510 p.SkipInstall()
511 }
512 for _, ip := range installs {
513 ip.addInstallRules(ctx)
514 }
mrziwang89371762024-06-11 12:42:24 -0700515
516 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000517}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900518
Spandan Das756d3402023-06-05 22:49:50 +0000519type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000520 filename string
521 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800522 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100523 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000524 symlinks []string
525}
526
527// utility function to add install rules to the build graph.
528// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100529func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000530 // Copy the file from src to a location in out/ with the correct `filename`
531 // This ensures that outputFilePath has the correct name for others to
532 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000533 ctx.Build(pctx, android.BuildParams{
534 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100535 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000536 Input: ip.sourceFilePath,
537 })
538
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100539 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000540 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100541 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900542 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900543}
544
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700545func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700546 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800547 if p.inRamdisk() && !p.onlyInRamdisk() {
548 nameSuffix = ".ramdisk"
549 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700550 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
551 nameSuffix = ".vendor_ramdisk"
552 }
Inseob Kim08758f02021-04-08 21:13:22 +0900553 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
554 nameSuffix = ".debug_ramdisk"
555 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900556 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700557 nameSuffix = ".recovery"
558 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700559
560 class := p.makeClass
561 if class == "" {
562 class = "ETC"
563 }
564
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100565 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700566 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700567 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100568 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700569 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700570 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700571 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700572 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100573 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800574 if len(p.properties.Symlinks) > 0 {
575 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
576 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800577 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700578 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800579 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900580 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700581 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900582 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900583 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900584}
585
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000586func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
587 return &p.ModuleBase
588}
589
Jooyung Hana0171822019-07-22 15:48:36 +0900590func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
591 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900592 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900593 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000594 p.AddProperties(&p.rootProperties)
Jihoon Kang6b45f842025-03-12 22:24:52 +0000595 p.AddProperties(&p.dstsProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900596}
597
598func InitPrebuiltRootModule(p *PrebuiltEtc) {
599 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800600 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900601 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800602}
603
604func InitPrebuiltAvbModule(p *PrebuiltEtc) {
605 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900606 p.AddProperties(&p.properties)
Jihoon Kang6b45f842025-03-12 22:24:52 +0000607 p.AddProperties(&p.dstsProperties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900608 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900609}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900610
Patrice Arruda9e14b962019-03-11 15:58:50 -0700611// prebuilt_etc is for a prebuilt artifact that is installed in
612// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700613func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900614 module := &PrebuiltEtc{}
615 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900616 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700617 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000618 android.InitDefaultableModule(module)
619 return module
620}
621
622func defaultsFactory() android.Module {
623 return DefaultsFactory()
624}
625
626func DefaultsFactory(props ...interface{}) android.Module {
627 module := &Defaults{}
628
629 module.AddProperties(props...)
630 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000631 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000632 &prebuiltSubdirProperties{},
633 )
634
635 android.InitDefaultsModule(module)
636
Jiyong Parkc678ad32018-04-10 13:07:10 +0900637 return module
638}
Tao Bao0ba5c942018-08-14 22:20:22 -0700639
Patrice Arruda9e14b962019-03-11 15:58:50 -0700640// prebuilt_etc_host is for a host prebuilt artifact that is installed in
641// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700642func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900643 module := &PrebuiltEtc{}
644 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800645 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700646 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100647 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800648 return module
649}
650
Jihoon Kangcc1c4aa2025-03-12 22:14:39 +0000651// prebuilt_any is a special module where the module can define the subdirectory that the files
652// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
653// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
654// modules allow installing the file at the desired location, introduce a new prebuilt_* module
655// type instead.
656func PrebuiltAnyFactory() android.Module {
657 module := &PrebuiltEtc{}
658 InitPrebuiltEtcModule(module, ".")
659 // This module is device-only
660 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
661 android.InitDefaultableModule(module)
662 return module
663}
664
Miguel32b02802022-12-01 18:38:26 +0000665// prebuilt_etc_host is for a host prebuilt artifact that is installed in
666// <partition>/etc/<sub_dir> directory.
667func PrebuiltEtcCaCertsFactory() android.Module {
668 module := &PrebuiltEtc{}
669 InitPrebuiltEtcModule(module, "cacerts")
670 // This module is device-only
671 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000672 return module
673}
674
Nelson Li1fb94b22024-07-09 17:04:52 +0800675// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
676// `prebuilt_avb` will not have a `system` subdirectory.
677// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
678// root directory of the partition: <partition_root>/avb.
679// prebuilt_avb does not allow adding any other subdirectories.
680func PrebuiltAvbFactory() android.Module {
681 module := &PrebuiltEtc{}
682 InitPrebuiltAvbModule(module)
683 // This module is device-only
684 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
685 android.InitDefaultableModule(module)
686 return module
687}
688
Inseob Kim27408bf2021-04-06 21:00:17 +0900689// prebuilt_root is for a prebuilt artifact that is installed in
690// <partition>/ directory. Can't have any sub directories.
691func PrebuiltRootFactory() android.Module {
692 module := &PrebuiltEtc{}
693 InitPrebuiltRootModule(module)
694 // This module is device-only
695 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100696 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900697 return module
698}
699
Liz Kammere9ecddc2022-01-04 17:27:52 -0500700// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
701// directory.
702func PrebuiltRootHostFactory() android.Module {
703 module := &PrebuiltEtc{}
704 InitPrebuiltEtcModule(module, ".")
705 // This module is host-only
706 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
707 android.InitDefaultableModule(module)
708 return module
709}
710
Patrice Arruda9e14b962019-03-11 15:58:50 -0700711// prebuilt_usr_share is for a prebuilt artifact that is installed in
712// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700713func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900714 module := &PrebuiltEtc{}
715 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800716 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700717 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100718 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800719 return module
720}
721
Patrice Arruda9e14b962019-03-11 15:58:50 -0700722// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
723// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700724func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900725 module := &PrebuiltEtc{}
726 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800727 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700728 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100729 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800730 return module
731}
732
yangbill63c5e192024-03-27 09:02:12 +0000733// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
734// <partition>/usr/hyphen-data/<sub_dir> directory.
735func PrebuiltUserHyphenDataFactory() android.Module {
736 module := &PrebuiltEtc{}
737 InitPrebuiltEtcModule(module, "usr/hyphen-data")
738 // This module is device-only
739 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
740 android.InitDefaultableModule(module)
741 return module
742}
743
yangbill85527e62024-04-30 08:24:50 +0000744// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
745// <partition>/usr/keylayout/<sub_dir> directory.
746func PrebuiltUserKeyLayoutFactory() android.Module {
747 module := &PrebuiltEtc{}
748 InitPrebuiltEtcModule(module, "usr/keylayout")
749 // This module is device-only
750 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
751 android.InitDefaultableModule(module)
752 return module
753}
754
755// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
756// <partition>/usr/keychars/<sub_dir> directory.
757func PrebuiltUserKeyCharsFactory() android.Module {
758 module := &PrebuiltEtc{}
759 InitPrebuiltEtcModule(module, "usr/keychars")
760 // This module is device-only
761 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
762 android.InitDefaultableModule(module)
763 return module
764}
765
766// prebuilt_usr_idc is for a prebuilt artifact that is installed in
767// <partition>/usr/idc/<sub_dir> directory.
768func PrebuiltUserIdcFactory() android.Module {
769 module := &PrebuiltEtc{}
770 InitPrebuiltEtcModule(module, "usr/idc")
771 // This module is device-only
772 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
773 android.InitDefaultableModule(module)
774 return module
775}
776
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000777// prebuilt_usr_srec is for a prebuilt artifact that is installed in
778// <partition>/usr/srec/<sub_dir> directory.
779func PrebuiltUserSrecFactory() android.Module {
780 module := &PrebuiltEtc{}
781 InitPrebuiltEtcModule(module, "usr/srec")
782 // This module is device-only
783 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
784 android.InitDefaultableModule(module)
785 return module
786}
787
Patrice Arruda61583eb2019-05-14 08:20:45 -0700788// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700789func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900790 module := &PrebuiltEtc{}
791 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700792 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700793 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100794 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700795 return module
796}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700797
Kevin93f7cd82024-05-02 12:37:59 +0200798// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
799func PrebuiltOverlayFactory() android.Module {
800 module := &PrebuiltEtc{}
801 InitPrebuiltEtcModule(module, "overlay")
802 // This module is device-only
803 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
804 return module
805}
806
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800807// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
808// image.
809// If soc_specific property is set to true, the firmware file is installed to the
810// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700811func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900812 module := &PrebuiltEtc{}
813 module.socInstallDirBase = "firmware"
814 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700815 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700816 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100817 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700818 return module
819}
Patrice Arruda0f688002020-06-08 21:40:25 +0000820
Luca Stefani5daba742025-03-09 12:41:06 +0100821// prebuilt_gpu is for a prebuilt artifact in <partition>/gpu directory.
822func PrebuiltGPUFactory() android.Module {
823 module := &PrebuiltEtc{}
824 InitPrebuiltEtcModule(module, "gpu")
825 // This module is device-only
826 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
827 return module
828}
829
Patrice Arruda0f688002020-06-08 21:40:25 +0000830// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800831// If soc_specific property is set to true, the DSP related file is installed to the
832// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000833func PrebuiltDSPFactory() android.Module {
834 module := &PrebuiltEtc{}
835 module.socInstallDirBase = "dsp"
836 InitPrebuiltEtcModule(module, "etc/dsp")
837 // This module is device-only
838 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100839 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000840 return module
841}
Colin Cross83ebf232021-04-09 09:41:23 -0700842
Colin Crossf17e2b52023-10-30 15:17:25 -0700843// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
844func PrebuiltRenderScriptBitcodeFactory() android.Module {
845 module := &PrebuiltEtc{}
846 module.makeClass = "RENDERSCRIPT_BITCODE"
847 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800848 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700849 InitPrebuiltEtcModule(module, "lib")
850 // This module is device-only
851 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
852 android.InitDefaultableModule(module)
853 return module
854}
855
Colin Cross83ebf232021-04-09 09:41:23 -0700856// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
857// to the <partition>/lib/rfsa directory.
858func PrebuiltRFSAFactory() android.Module {
859 module := &PrebuiltEtc{}
860 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
861 // many places outside of the application processor. They could be moved to /vendor/dsp once
862 // that is cleaned up.
863 InitPrebuiltEtcModule(module, "lib/rfsa")
864 // This module is device-only
865 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100866 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700867 return module
868}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000869
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000870// prebuilt_media installs media files in <partition>/media directory.
871func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000872 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000873 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000874 // This module is device-only
875 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
876 android.InitDefaultableModule(module)
877 return module
878}
Jihoon Kangec62d842024-10-25 20:27:18 +0000879
880// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
881func PrebuiltVoicepackFactory() android.Module {
882 module := &PrebuiltEtc{}
883 InitPrebuiltEtcModule(module, "tts")
884 // This module is device-only
885 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
886 android.InitDefaultableModule(module)
887 return module
888}
889
890// prebuilt_bin installs files in <partition>/bin directory.
891func PrebuiltBinaryFactory() android.Module {
892 module := &PrebuiltEtc{}
893 InitPrebuiltEtcModule(module, "bin")
894 // This module is device-only
895 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
896 android.InitDefaultableModule(module)
897 return module
898}
899
900// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
901func PrebuiltWallpaperFactory() android.Module {
902 module := &PrebuiltEtc{}
903 InitPrebuiltEtcModule(module, "wallpaper")
904 // This module is device-only
905 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
906 android.InitDefaultableModule(module)
907 return module
908}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000909
910// prebuilt_priv_app installs files in <partition>/priv-app directory.
911func PrebuiltPrivAppFactory() android.Module {
912 module := &PrebuiltEtc{}
913 InitPrebuiltEtcModule(module, "priv-app")
914 // This module is device-only
915 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
916 android.InitDefaultableModule(module)
917 return module
918}
919
Michael Bestase6b299a2025-03-08 20:44:34 +0200920// prebuilt_radio installs files in <partition>/radio directory.
921func PrebuiltRadioFactory() android.Module {
922 module := &PrebuiltEtc{}
923 InitPrebuiltEtcModule(module, "radio")
924 // This module is device-only
925 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
926 android.InitDefaultableModule(module)
927 return module
928}
929
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000930// prebuilt_rfs installs files in <partition>/rfs directory.
931func PrebuiltRfsFactory() android.Module {
932 module := &PrebuiltEtc{}
933 InitPrebuiltEtcModule(module, "rfs")
934 // This module is device-only
935 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
936 android.InitDefaultableModule(module)
937 return module
938}
939
940// prebuilt_framework installs files in <partition>/framework directory.
941func PrebuiltFrameworkFactory() android.Module {
942 module := &PrebuiltEtc{}
943 InitPrebuiltEtcModule(module, "framework")
944 // This module is device-only
945 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
946 android.InitDefaultableModule(module)
947 return module
948}
949
950// prebuilt_res installs files in <partition>/res directory.
951func PrebuiltResFactory() android.Module {
952 module := &PrebuiltEtc{}
953 InitPrebuiltEtcModule(module, "res")
954 // This module is device-only
955 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
956 android.InitDefaultableModule(module)
957 return module
958}
959
960// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
961func PrebuiltWlcUptFactory() android.Module {
962 module := &PrebuiltEtc{}
963 InitPrebuiltEtcModule(module, "wlc_upt")
964 // This module is device-only
965 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
966 android.InitDefaultableModule(module)
967 return module
968}
969
970// prebuilt_odm installs files in <partition>/odm directory.
971func PrebuiltOdmFactory() android.Module {
972 module := &PrebuiltEtc{}
973 InitPrebuiltEtcModule(module, "odm")
974 // This module is device-only
975 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
976 android.InitDefaultableModule(module)
977 return module
978}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000979
980// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
981func PrebuiltVendorDlkmFactory() android.Module {
982 module := &PrebuiltEtc{}
983 InitPrebuiltEtcModule(module, "vendor_dlkm")
984 // This module is device-only
985 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
986 android.InitDefaultableModule(module)
987 return module
988}
989
990// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
991func PrebuiltBtFirmwareFactory() android.Module {
992 module := &PrebuiltEtc{}
993 InitPrebuiltEtcModule(module, "bt_firmware")
994 // This module is device-only
995 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
996 android.InitDefaultableModule(module)
997 return module
998}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000999
1000// prebuilt_tvservice installs files in <partition>/tvservice directory.
1001func PrebuiltTvServiceFactory() android.Module {
1002 module := &PrebuiltEtc{}
1003 InitPrebuiltEtcModule(module, "tvservice")
1004 // This module is device-only
1005 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1006 android.InitDefaultableModule(module)
1007 return module
1008}
1009
1010// prebuilt_optee installs files in <partition>/optee directory.
1011func PrebuiltOpteeFactory() android.Module {
1012 module := &PrebuiltEtc{}
1013 InitPrebuiltEtcModule(module, "optee")
1014 // This module is device-only
1015 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1016 android.InitDefaultableModule(module)
1017 return module
1018}
Jihoon Kangecf76dd2024-11-12 05:24:46 +00001019
1020// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
1021func PrebuiltTvConfigFactory() android.Module {
1022 module := &PrebuiltEtc{}
1023 InitPrebuiltEtcModule(module, "tvconfig")
1024 // This module is device-only
1025 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1026 android.InitDefaultableModule(module)
1027 return module
1028}
Jihoon Kang3ca07a12024-12-02 19:14:30 +00001029
1030// prebuilt_vendor installs files in <partition>/vendor directory.
1031func PrebuiltVendorFactory() android.Module {
1032 module := &PrebuiltEtc{}
1033 InitPrebuiltEtcModule(module, "vendor")
1034 // This module is device-only
1035 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1036 android.InitDefaultableModule(module)
1037 return module
1038}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001039
Artem Borisov81732c22025-03-11 23:19:26 +03001040// prebuilt_vendor_overlay is for a prebuilt artifact in <partition>/vendor_overlay directory.
1041func PrebuiltVendorOverlayFactory() android.Module {
1042 module := &PrebuiltEtc{}
1043 InitPrebuiltEtcModule(module, "vendor_overlay")
1044 // This module is device-only
1045 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1046 android.InitDefaultableModule(module)
1047 return module
1048}
1049
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001050// prebuilt_sbin installs files in <partition>/sbin directory.
1051func PrebuiltSbinFactory() android.Module {
1052 module := &PrebuiltEtc{}
1053 InitPrebuiltEtcModule(module, "sbin")
1054 // This module is device-only
1055 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1056 android.InitDefaultableModule(module)
1057 return module
1058}
1059
1060// prebuilt_system installs files in <partition>/system directory.
1061func PrebuiltSystemFactory() android.Module {
1062 module := &PrebuiltEtc{}
1063 InitPrebuiltEtcModule(module, "system")
1064 // This module is device-only
1065 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1066 android.InitDefaultableModule(module)
1067 return module
1068}
1069
1070// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1071func PrebuiltFirstStageRamdiskFactory() android.Module {
1072 module := &PrebuiltEtc{}
1073 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1074 // This module is device-only
1075 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1076 android.InitDefaultableModule(module)
1077 return module
1078}