blob: 79d52692f6608438999b62357f58d192997f21b7 [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
Yu Liu0a37d422025-02-13 02:05:00 +000035 "github.com/google/blueprint"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070036 "github.com/google/blueprint/proptools"
37
38 "android/soong/android"
39)
40
41var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090042
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080043// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090044
45func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070046 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090047 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
48}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070049
Jooyung Han0703fd82020-08-26 22:11:53 +090050func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
51 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
52 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000053 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Nelson Li1fb94b22024-07-09 17:04:52 +080054 ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090055 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050056 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090057 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
58 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
yangbill63c5e192024-03-27 09:02:12 +000059 ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory)
yangbill85527e62024-04-30 08:24:50 +000060 ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory)
61 ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory)
62 ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000063 ctx.RegisterModuleType("prebuilt_usr_srec", PrebuiltUserSrecFactory)
Agi Sferro243c7d72025-02-24 15:45:53 -080064 ctx.RegisterModuleType("prebuilt_usr_odml", PrebuiltUserOdmlFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090065 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020066 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090067 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
Luca Stefani04812eb2025-03-09 12:41:06 +010068 ctx.RegisterModuleType("prebuilt_gpu", PrebuiltGPUFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090069 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070070 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070071 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000072 ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory)
Jihoon Kangec62d842024-10-25 20:27:18 +000073 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
74 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
75 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000076 ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory)
Michael Bestas137fab42025-03-08 20:44:34 +020077 ctx.RegisterModuleType("prebuilt_radio", PrebuiltRadioFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000078 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
79 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
80 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
81 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
82 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000083 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
Artem Borisov49f074b2025-03-11 23:19:26 +030084 ctx.RegisterModuleType("prebuilt_vendor_overlay", PrebuiltVendorOverlayFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000085 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000086 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
87 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Jihoon Kangecf76dd2024-11-12 05:24:46 +000088 ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory)
Jihoon Kang3ca07a12024-12-02 19:14:30 +000089 ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory)
Jihoon Kang320ca7c2024-12-03 18:14:50 +000090 ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
91 ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
92 ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000093
94 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040095
Jiyong Parkc678ad32018-04-10 13:07:10 +090096}
97
Yu Liu0a37d422025-02-13 02:05:00 +000098type PrebuiltEtcInfo struct {
99 // Returns the base install directory, such as "etc", "usr/share".
100 BaseDir string
101 // Returns the sub install directory relative to BaseDir().
102 SubDir string
103}
104
105var PrebuiltEtcInfoProvider = blueprint.NewProvider[PrebuiltEtcInfo]()
106
Paul Duffin1172fed2021-03-08 11:28:18 +0000107var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
108
Jihoon Kang69725b32024-11-12 03:08:49 +0000109type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +0800110 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100111 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -0700112 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900113
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100114 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700115 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
116 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700117 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100118
Douglas Anderson79688ff2024-09-27 15:08:33 -0700119 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
120 // set filename_from_src. This can be used to install each source file to a different directory
121 // and/or change filenames when files are installed. Must be exactly one entry per source file,
122 // which means care must be taken if srcs has globs.
123 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
124
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800125 // 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 +1100126 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900127 Filename *string `android:"arch_variant"`
128
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800129 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900130 // is the same as the file name of the source file.
131 Filename_from_src *bool `android:"arch_variant"`
132
Yifan Hong1b3348d2020-01-21 15:53:22 -0800133 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700134 // On device without a dedicated recovery partition, the module is only
135 // available after switching root into
136 // /first_stage_ramdisk. To expose the module before switching root, install
137 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800138 Ramdisk_available *bool
139
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700140 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700141 // On device without a dedicated recovery partition, the module is only
142 // available after switching root into
143 // /first_stage_ramdisk. To expose the module before switching root, install
144 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700145 Vendor_ramdisk_available *bool
146
Inseob Kim08758f02021-04-08 21:13:22 +0900147 // Make this module available when building for debug ramdisk.
148 Debug_ramdisk_available *bool
149
Tao Bao0ba5c942018-08-14 22:20:22 -0700150 // Make this module available when building for recovery.
151 Recovery_available *bool
152
Jiyong Parkad9ce042018-10-31 22:49:57 +0900153 // Whether this module is directly installable to one of the partitions. Default: true.
154 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800155
156 // Install symlinks to the installed file.
157 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800158
Wei Li59586252024-11-04 09:25:54 -0800159 // Install to partition oem when set to true.
160 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900161}
162
Inseob Kim27408bf2021-04-06 21:00:17 +0900163type prebuiltSubdirProperties struct {
164 // Optional subdirectory under which this file is installed into, cannot be specified with
165 // relative_install_path, prefer relative_install_path.
166 Sub_dir *string `android:"arch_variant"`
167
168 // Optional subdirectory under which this file is installed into, cannot be specified with
169 // sub_dir.
170 Relative_install_path *string `android:"arch_variant"`
171}
172
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900173type prebuiltRootProperties struct {
174 // Install this module to the root directory, without partition subdirs. When this module is
175 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
176 // then be copied to the root of system.img. When this module is packaged by other modules like
177 // android_filesystem, this module will be installed to the root ("/"), unlike normal
178 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
179 Install_in_root *bool
180}
181
Jooyung Han39edb6c2019-11-06 16:53:07 +0900182type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700183 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800184
185 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900186 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800187
188 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900189 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900190}
191
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900192type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700193 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000194 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900195
Jihoon Kang69725b32024-11-12 03:08:49 +0000196 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900197
198 // 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 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700388 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
389 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
mrziwanga25adf32025-02-05 23:50:55 +0000516 p.updateModuleInfoJSON(ctx)
517
mrziwang89371762024-06-11 12:42:24 -0700518 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Yu Liu0a37d422025-02-13 02:05:00 +0000519
520 SetCommonPrebuiltEtcInfo(ctx, p)
521}
522
523func SetCommonPrebuiltEtcInfo(ctx android.ModuleContext, p PrebuiltEtcModule) {
524 android.SetProvider(ctx, PrebuiltEtcInfoProvider, PrebuiltEtcInfo{
525 BaseDir: p.BaseDir(),
526 SubDir: p.SubDir(),
527 })
Spandan Das756d3402023-06-05 22:49:50 +0000528}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900529
mrziwanga25adf32025-02-05 23:50:55 +0000530func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
531 moduleInfoJSON := ctx.ModuleInfoJSON()
532 moduleInfoJSON.Class = []string{"ETC"}
533 if p.makeClass != "" {
534 moduleInfoJSON.Class = []string{p.makeClass}
535 }
536 moduleInfoJSON.SystemSharedLibs = []string{"none"}
537 moduleInfoJSON.Tags = []string{"optional"}
538}
539
Spandan Das756d3402023-06-05 22:49:50 +0000540type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000541 filename string
542 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800543 outputFilePath android.WritablePath
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100544 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000545 symlinks []string
546}
547
548// utility function to add install rules to the build graph.
549// Reduces code duplication between Soong and Mixed build analysis
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100550func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000551 // Copy the file from src to a location in out/ with the correct `filename`
552 // This ensures that outputFilePath has the correct name for others to
553 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000554 ctx.Build(pctx, android.BuildParams{
555 Rule: android.Cp,
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100556 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000557 Input: ip.sourceFilePath,
558 })
559
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100560 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000561 for _, sl := range ip.symlinks {
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100562 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900563 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900564}
565
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700566func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700567 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800568 if p.inRamdisk() && !p.onlyInRamdisk() {
569 nameSuffix = ".ramdisk"
570 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700571 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
572 nameSuffix = ".vendor_ramdisk"
573 }
Inseob Kim08758f02021-04-08 21:13:22 +0900574 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
575 nameSuffix = ".debug_ramdisk"
576 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900577 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700578 nameSuffix = ".recovery"
579 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700580
581 class := p.makeClass
582 if class == "" {
583 class = "ETC"
584 }
585
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100586 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700587 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700588 SubName: nameSuffix,
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100589 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700590 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700591 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700592 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700593 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
ThiƩbaud Weksteen00e8b312024-03-18 14:06:00 +1100594 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800595 if len(p.properties.Symlinks) > 0 {
596 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
597 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800598 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700599 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800600 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900601 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700602 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900603 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900604 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900605}
606
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000607func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
608 return &p.ModuleBase
609}
610
Jooyung Hana0171822019-07-22 15:48:36 +0900611func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
612 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900613 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900614 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000615 p.AddProperties(&p.rootProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900616}
617
618func InitPrebuiltRootModule(p *PrebuiltEtc) {
619 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800620 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900621 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800622}
623
624func InitPrebuiltAvbModule(p *PrebuiltEtc) {
625 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900626 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900627 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900628}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900629
Patrice Arruda9e14b962019-03-11 15:58:50 -0700630// prebuilt_etc is for a prebuilt artifact that is installed in
631// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700632func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900633 module := &PrebuiltEtc{}
634 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900635 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700636 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000637 android.InitDefaultableModule(module)
638 return module
639}
640
641func defaultsFactory() android.Module {
642 return DefaultsFactory()
643}
644
645func DefaultsFactory(props ...interface{}) android.Module {
646 module := &Defaults{}
647
648 module.AddProperties(props...)
649 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000650 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000651 &prebuiltSubdirProperties{},
652 )
653
654 android.InitDefaultsModule(module)
655
Jiyong Parkc678ad32018-04-10 13:07:10 +0900656 return module
657}
Tao Bao0ba5c942018-08-14 22:20:22 -0700658
Patrice Arruda9e14b962019-03-11 15:58:50 -0700659// prebuilt_etc_host is for a host prebuilt artifact that is installed in
660// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700661func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900662 module := &PrebuiltEtc{}
663 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800664 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700665 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100666 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800667 return module
668}
669
Miguel32b02802022-12-01 18:38:26 +0000670// prebuilt_etc_host is for a host prebuilt artifact that is installed in
671// <partition>/etc/<sub_dir> directory.
672func PrebuiltEtcCaCertsFactory() android.Module {
673 module := &PrebuiltEtc{}
674 InitPrebuiltEtcModule(module, "cacerts")
675 // This module is device-only
676 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000677 return module
678}
679
Nelson Li1fb94b22024-07-09 17:04:52 +0800680// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
681// `prebuilt_avb` will not have a `system` subdirectory.
682// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
683// root directory of the partition: <partition_root>/avb.
684// prebuilt_avb does not allow adding any other subdirectories.
685func PrebuiltAvbFactory() android.Module {
686 module := &PrebuiltEtc{}
687 InitPrebuiltAvbModule(module)
688 // This module is device-only
689 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
690 android.InitDefaultableModule(module)
691 return module
692}
693
Inseob Kim27408bf2021-04-06 21:00:17 +0900694// prebuilt_root is for a prebuilt artifact that is installed in
695// <partition>/ directory. Can't have any sub directories.
696func PrebuiltRootFactory() android.Module {
697 module := &PrebuiltEtc{}
698 InitPrebuiltRootModule(module)
699 // This module is device-only
700 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100701 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900702 return module
703}
704
Liz Kammere9ecddc2022-01-04 17:27:52 -0500705// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
706// directory.
707func PrebuiltRootHostFactory() android.Module {
708 module := &PrebuiltEtc{}
709 InitPrebuiltEtcModule(module, ".")
710 // This module is host-only
711 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
712 android.InitDefaultableModule(module)
713 return module
714}
715
Patrice Arruda9e14b962019-03-11 15:58:50 -0700716// prebuilt_usr_share is for a prebuilt artifact that is installed in
717// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700718func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900719 module := &PrebuiltEtc{}
720 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800721 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700722 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100723 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800724 return module
725}
726
Patrice Arruda9e14b962019-03-11 15:58:50 -0700727// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
728// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700729func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900730 module := &PrebuiltEtc{}
731 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800732 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700733 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100734 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800735 return module
736}
737
yangbill63c5e192024-03-27 09:02:12 +0000738// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
739// <partition>/usr/hyphen-data/<sub_dir> directory.
740func PrebuiltUserHyphenDataFactory() android.Module {
741 module := &PrebuiltEtc{}
742 InitPrebuiltEtcModule(module, "usr/hyphen-data")
743 // This module is device-only
744 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
745 android.InitDefaultableModule(module)
746 return module
747}
748
yangbill85527e62024-04-30 08:24:50 +0000749// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
750// <partition>/usr/keylayout/<sub_dir> directory.
751func PrebuiltUserKeyLayoutFactory() android.Module {
752 module := &PrebuiltEtc{}
753 InitPrebuiltEtcModule(module, "usr/keylayout")
754 // This module is device-only
755 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
756 android.InitDefaultableModule(module)
757 return module
758}
759
760// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
761// <partition>/usr/keychars/<sub_dir> directory.
762func PrebuiltUserKeyCharsFactory() android.Module {
763 module := &PrebuiltEtc{}
764 InitPrebuiltEtcModule(module, "usr/keychars")
765 // This module is device-only
766 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
767 android.InitDefaultableModule(module)
768 return module
769}
770
771// prebuilt_usr_idc is for a prebuilt artifact that is installed in
772// <partition>/usr/idc/<sub_dir> directory.
773func PrebuiltUserIdcFactory() android.Module {
774 module := &PrebuiltEtc{}
775 InitPrebuiltEtcModule(module, "usr/idc")
776 // This module is device-only
777 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
778 android.InitDefaultableModule(module)
779 return module
780}
781
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000782// prebuilt_usr_srec is for a prebuilt artifact that is installed in
783// <partition>/usr/srec/<sub_dir> directory.
784func PrebuiltUserSrecFactory() android.Module {
785 module := &PrebuiltEtc{}
786 InitPrebuiltEtcModule(module, "usr/srec")
787 // This module is device-only
788 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
789 android.InitDefaultableModule(module)
790 return module
791}
792
Agi Sferro243c7d72025-02-24 15:45:53 -0800793// prebuilt_usr_odml is for a prebuilt artifact that is installed in
794// <partition>/usr/odml/<sub_dir> directory.
795func PrebuiltUserOdmlFactory() android.Module {
796 module := &PrebuiltEtc{}
797 InitPrebuiltEtcModule(module, "usr/odml")
798 // This module is device-only
799 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
800 android.InitDefaultableModule(module)
801 return module
802}
803
Patrice Arruda61583eb2019-05-14 08:20:45 -0700804// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700805func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900806 module := &PrebuiltEtc{}
807 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700808 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700809 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100810 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700811 return module
812}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700813
Kevin93f7cd82024-05-02 12:37:59 +0200814// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
815func PrebuiltOverlayFactory() android.Module {
816 module := &PrebuiltEtc{}
817 InitPrebuiltEtcModule(module, "overlay")
818 // This module is device-only
819 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
820 return module
821}
822
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800823// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
824// image.
825// If soc_specific property is set to true, the firmware file is installed to the
826// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700827func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900828 module := &PrebuiltEtc{}
829 module.socInstallDirBase = "firmware"
830 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700831 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700832 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100833 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700834 return module
835}
Patrice Arruda0f688002020-06-08 21:40:25 +0000836
Luca Stefani04812eb2025-03-09 12:41:06 +0100837// prebuilt_gpu is for a prebuilt artifact in <partition>/gpu directory.
838func PrebuiltGPUFactory() android.Module {
839 module := &PrebuiltEtc{}
840 InitPrebuiltEtcModule(module, "gpu")
841 // This module is device-only
842 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
843 return module
844}
845
Patrice Arruda0f688002020-06-08 21:40:25 +0000846// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800847// If soc_specific property is set to true, the DSP related file is installed to the
848// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000849func PrebuiltDSPFactory() android.Module {
850 module := &PrebuiltEtc{}
851 module.socInstallDirBase = "dsp"
852 InitPrebuiltEtcModule(module, "etc/dsp")
853 // This module is device-only
854 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100855 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000856 return module
857}
Colin Cross83ebf232021-04-09 09:41:23 -0700858
Colin Crossf17e2b52023-10-30 15:17:25 -0700859// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
860func PrebuiltRenderScriptBitcodeFactory() android.Module {
861 module := &PrebuiltEtc{}
862 module.makeClass = "RENDERSCRIPT_BITCODE"
863 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800864 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700865 InitPrebuiltEtcModule(module, "lib")
866 // This module is device-only
867 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
868 android.InitDefaultableModule(module)
869 return module
870}
871
Colin Cross83ebf232021-04-09 09:41:23 -0700872// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
873// to the <partition>/lib/rfsa directory.
874func PrebuiltRFSAFactory() android.Module {
875 module := &PrebuiltEtc{}
876 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
877 // many places outside of the application processor. They could be moved to /vendor/dsp once
878 // that is cleaned up.
879 InitPrebuiltEtcModule(module, "lib/rfsa")
880 // This module is device-only
881 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100882 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700883 return module
884}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000885
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000886// prebuilt_media installs media files in <partition>/media directory.
887func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000888 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000889 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000890 // This module is device-only
891 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
892 android.InitDefaultableModule(module)
893 return module
894}
Jihoon Kangec62d842024-10-25 20:27:18 +0000895
896// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
897func PrebuiltVoicepackFactory() android.Module {
898 module := &PrebuiltEtc{}
899 InitPrebuiltEtcModule(module, "tts")
900 // This module is device-only
901 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
902 android.InitDefaultableModule(module)
903 return module
904}
905
906// prebuilt_bin installs files in <partition>/bin directory.
907func PrebuiltBinaryFactory() android.Module {
908 module := &PrebuiltEtc{}
909 InitPrebuiltEtcModule(module, "bin")
910 // This module is device-only
911 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
912 android.InitDefaultableModule(module)
913 return module
914}
915
916// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
917func PrebuiltWallpaperFactory() android.Module {
918 module := &PrebuiltEtc{}
919 InitPrebuiltEtcModule(module, "wallpaper")
920 // This module is device-only
921 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
922 android.InitDefaultableModule(module)
923 return module
924}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000925
926// prebuilt_priv_app installs files in <partition>/priv-app directory.
927func PrebuiltPrivAppFactory() android.Module {
928 module := &PrebuiltEtc{}
929 InitPrebuiltEtcModule(module, "priv-app")
930 // This module is device-only
931 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
932 android.InitDefaultableModule(module)
933 return module
934}
935
Michael Bestas137fab42025-03-08 20:44:34 +0200936// prebuilt_radio installs files in <partition>/radio directory.
937func PrebuiltRadioFactory() android.Module {
938 module := &PrebuiltEtc{}
939 InitPrebuiltEtcModule(module, "radio")
940 // This module is device-only
941 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
942 android.InitDefaultableModule(module)
943 return module
944}
945
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000946// prebuilt_rfs installs files in <partition>/rfs directory.
947func PrebuiltRfsFactory() android.Module {
948 module := &PrebuiltEtc{}
949 InitPrebuiltEtcModule(module, "rfs")
950 // This module is device-only
951 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
952 android.InitDefaultableModule(module)
953 return module
954}
955
956// prebuilt_framework installs files in <partition>/framework directory.
957func PrebuiltFrameworkFactory() android.Module {
958 module := &PrebuiltEtc{}
959 InitPrebuiltEtcModule(module, "framework")
960 // This module is device-only
961 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
962 android.InitDefaultableModule(module)
963 return module
964}
965
966// prebuilt_res installs files in <partition>/res directory.
967func PrebuiltResFactory() android.Module {
968 module := &PrebuiltEtc{}
969 InitPrebuiltEtcModule(module, "res")
970 // This module is device-only
971 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
972 android.InitDefaultableModule(module)
973 return module
974}
975
976// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
977func PrebuiltWlcUptFactory() android.Module {
978 module := &PrebuiltEtc{}
979 InitPrebuiltEtcModule(module, "wlc_upt")
980 // This module is device-only
981 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
982 android.InitDefaultableModule(module)
983 return module
984}
985
986// prebuilt_odm installs files in <partition>/odm directory.
987func PrebuiltOdmFactory() android.Module {
988 module := &PrebuiltEtc{}
989 InitPrebuiltEtcModule(module, "odm")
990 // This module is device-only
991 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
992 android.InitDefaultableModule(module)
993 return module
994}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000995
996// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
997func PrebuiltVendorDlkmFactory() android.Module {
998 module := &PrebuiltEtc{}
999 InitPrebuiltEtcModule(module, "vendor_dlkm")
1000 // This module is device-only
1001 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1002 android.InitDefaultableModule(module)
1003 return module
1004}
1005
1006// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
1007func PrebuiltBtFirmwareFactory() android.Module {
1008 module := &PrebuiltEtc{}
1009 InitPrebuiltEtcModule(module, "bt_firmware")
1010 // This module is device-only
1011 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1012 android.InitDefaultableModule(module)
1013 return module
1014}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +00001015
1016// prebuilt_tvservice installs files in <partition>/tvservice directory.
1017func PrebuiltTvServiceFactory() android.Module {
1018 module := &PrebuiltEtc{}
1019 InitPrebuiltEtcModule(module, "tvservice")
1020 // This module is device-only
1021 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1022 android.InitDefaultableModule(module)
1023 return module
1024}
1025
1026// prebuilt_optee installs files in <partition>/optee directory.
1027func PrebuiltOpteeFactory() android.Module {
1028 module := &PrebuiltEtc{}
1029 InitPrebuiltEtcModule(module, "optee")
1030 // This module is device-only
1031 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1032 android.InitDefaultableModule(module)
1033 return module
1034}
Jihoon Kangecf76dd2024-11-12 05:24:46 +00001035
1036// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
1037func PrebuiltTvConfigFactory() android.Module {
1038 module := &PrebuiltEtc{}
1039 InitPrebuiltEtcModule(module, "tvconfig")
1040 // This module is device-only
1041 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1042 android.InitDefaultableModule(module)
1043 return module
1044}
Jihoon Kang3ca07a12024-12-02 19:14:30 +00001045
1046// prebuilt_vendor installs files in <partition>/vendor directory.
1047func PrebuiltVendorFactory() android.Module {
1048 module := &PrebuiltEtc{}
1049 InitPrebuiltEtcModule(module, "vendor")
1050 // This module is device-only
1051 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1052 android.InitDefaultableModule(module)
1053 return module
1054}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001055
Artem Borisov49f074b2025-03-11 23:19:26 +03001056// prebuilt_vendor_overlay is for a prebuilt artifact in <partition>/vendor_overlay directory.
1057func PrebuiltVendorOverlayFactory() android.Module {
1058 module := &PrebuiltEtc{}
1059 InitPrebuiltEtcModule(module, "vendor_overlay")
1060 // This module is device-only
1061 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1062 android.InitDefaultableModule(module)
1063 return module
1064}
1065
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001066// prebuilt_sbin installs files in <partition>/sbin directory.
1067func PrebuiltSbinFactory() android.Module {
1068 module := &PrebuiltEtc{}
1069 InitPrebuiltEtcModule(module, "sbin")
1070 // This module is device-only
1071 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1072 android.InitDefaultableModule(module)
1073 return module
1074}
1075
1076// prebuilt_system installs files in <partition>/system directory.
1077func PrebuiltSystemFactory() android.Module {
1078 module := &PrebuiltEtc{}
1079 InitPrebuiltEtcModule(module, "system")
1080 // This module is device-only
1081 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1082 android.InitDefaultableModule(module)
1083 return module
1084}
1085
1086// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1087func PrebuiltFirstStageRamdiskFactory() android.Module {
1088 module := &PrebuiltEtc{}
1089 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1090 // This module is device-only
1091 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1092 android.InitDefaultableModule(module)
1093 return module
1094}