blob: a440c9113133318a74568e9f122feae3aeef691a [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)
Jooyung Han0703fd82020-08-26 22:11:53 +090064 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020065 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090066 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
67 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)
75 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
76 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
77 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
78 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
79 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000080 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
81 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000082 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
83 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Jihoon Kangecf76dd2024-11-12 05:24:46 +000084 ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory)
Jihoon Kang3ca07a12024-12-02 19:14:30 +000085 ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory)
Jihoon Kang320ca7c2024-12-03 18:14:50 +000086 ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
87 ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
88 ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000089
90 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040091
Jiyong Parkc678ad32018-04-10 13:07:10 +090092}
93
Yu Liu0a37d422025-02-13 02:05:00 +000094type PrebuiltEtcInfo struct {
95 // Returns the base install directory, such as "etc", "usr/share".
96 BaseDir string
97 // Returns the sub install directory relative to BaseDir().
98 SubDir string
99}
100
101var PrebuiltEtcInfoProvider = blueprint.NewProvider[PrebuiltEtcInfo]()
102
Paul Duffin1172fed2021-03-08 11:28:18 +0000103var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
104
Jihoon Kang69725b32024-11-12 03:08:49 +0000105type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +0800106 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100107 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -0700108 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900109
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100110 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700111 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
112 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700113 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100114
Douglas Anderson79688ff2024-09-27 15:08:33 -0700115 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
116 // set filename_from_src. This can be used to install each source file to a different directory
117 // and/or change filenames when files are installed. Must be exactly one entry per source file,
118 // which means care must be taken if srcs has globs.
119 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
120
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800121 // 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 +1100122 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900123 Filename *string `android:"arch_variant"`
124
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800125 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900126 // is the same as the file name of the source file.
127 Filename_from_src *bool `android:"arch_variant"`
128
Yifan Hong1b3348d2020-01-21 15:53:22 -0800129 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700130 // On device without a dedicated recovery partition, the module is only
131 // available after switching root into
132 // /first_stage_ramdisk. To expose the module before switching root, install
133 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800134 Ramdisk_available *bool
135
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700136 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700137 // On device without a dedicated recovery partition, the module is only
138 // available after switching root into
139 // /first_stage_ramdisk. To expose the module before switching root, install
140 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700141 Vendor_ramdisk_available *bool
142
Inseob Kim08758f02021-04-08 21:13:22 +0900143 // Make this module available when building for debug ramdisk.
144 Debug_ramdisk_available *bool
145
Tao Bao0ba5c942018-08-14 22:20:22 -0700146 // Make this module available when building for recovery.
147 Recovery_available *bool
148
Jiyong Parkad9ce042018-10-31 22:49:57 +0900149 // Whether this module is directly installable to one of the partitions. Default: true.
150 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800151
152 // Install symlinks to the installed file.
153 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800154
Wei Li59586252024-11-04 09:25:54 -0800155 // Install to partition oem when set to true.
156 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900157}
158
Inseob Kim27408bf2021-04-06 21:00:17 +0900159type prebuiltSubdirProperties struct {
160 // Optional subdirectory under which this file is installed into, cannot be specified with
161 // relative_install_path, prefer relative_install_path.
162 Sub_dir *string `android:"arch_variant"`
163
164 // Optional subdirectory under which this file is installed into, cannot be specified with
165 // sub_dir.
166 Relative_install_path *string `android:"arch_variant"`
167}
168
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900169type prebuiltRootProperties struct {
170 // Install this module to the root directory, without partition subdirs. When this module is
171 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
172 // then be copied to the root of system.img. When this module is packaged by other modules like
173 // android_filesystem, this module will be installed to the root ("/"), unlike normal
174 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
175 Install_in_root *bool
176}
177
Jooyung Han39edb6c2019-11-06 16:53:07 +0900178type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700179 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800180
181 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900182 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800183
184 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900185 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900186}
187
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900188type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700189 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000190 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900191
Jihoon Kang69725b32024-11-12 03:08:49 +0000192 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900193
194 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
195 // prebuilt_avb and prebuilt_root modules use this.
196 rootProperties prebuiltRootProperties
197
Inseob Kim27408bf2021-04-06 21:00:17 +0900198 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900199
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100200 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800201 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800202 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800203 installDirBase string
204 installDirBase64 string
205 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800206 // The base install location when soc_specific property is set to true, e.g. "firmware" for
207 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700208 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700209 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700210 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700211
Cole Faustfdec8722024-05-22 11:38:29 -0700212 usedSrcsProperty bool
213
Colin Crossf17e2b52023-10-30 15:17:25 -0700214 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900215}
216
Inseob Kim1e27a142021-05-06 11:46:11 +0000217type Defaults struct {
218 android.ModuleBase
219 android.DefaultsModuleBase
220}
221
Yifan Hong1b3348d2020-01-21 15:53:22 -0800222func (p *PrebuiltEtc) inRamdisk() bool {
223 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
224}
225
226func (p *PrebuiltEtc) onlyInRamdisk() bool {
227 return p.ModuleBase.InstallInRamdisk()
228}
229
230func (p *PrebuiltEtc) InstallInRamdisk() bool {
231 return p.inRamdisk()
232}
233
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700234func (p *PrebuiltEtc) inVendorRamdisk() bool {
235 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
236}
237
238func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
239 return p.ModuleBase.InstallInVendorRamdisk()
240}
241
242func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
243 return p.inVendorRamdisk()
244}
245
Inseob Kim08758f02021-04-08 21:13:22 +0900246func (p *PrebuiltEtc) inDebugRamdisk() bool {
247 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
248}
249
250func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
251 return p.ModuleBase.InstallInDebugRamdisk()
252}
253
254func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
255 return p.inDebugRamdisk()
256}
257
Kiyoung Kimae11c232021-07-19 11:38:04 +0900258func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800259 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700260}
261
262func (p *PrebuiltEtc) onlyInRecovery() bool {
263 return p.ModuleBase.InstallInRecovery()
264}
265
266func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900267 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700268}
269
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700270var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800271
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700272func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800273
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700274func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000275 return false
276}
277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) ProductVariantNeeded(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) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700283 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900284 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800285}
286
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700287func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700288 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800289}
290
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700291func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700292 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
293}
294
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700295func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900296 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
297}
298
Nelson Li1fb94b22024-07-09 17:04:52 +0800299func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900300 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800301}
302
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700303func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700304 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800305}
306
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700307func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800308 return nil
309}
310
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700311func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800312}
313
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700314func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700315 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100316 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
317 }
Cole Faustfdec8722024-05-22 11:38:29 -0700318 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900319}
320
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700321func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700322 if len(p.installDirPaths) != 1 {
323 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
324 }
325 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900326}
327
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900328// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
329// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700330func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900331 p.additionalDependencies = &paths
332}
333
Cole Faust4e9f5922024-11-13 16:09:23 -0800334func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700335 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100336 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
337 }
338 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900339}
340
341func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900342 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700343 return subDir
344 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900345 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900346}
347
Jooyung Han0703fd82020-08-26 22:11:53 +0900348func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900349 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900350}
351
Jiyong Parkad9ce042018-10-31 22:49:57 +0900352func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800353 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900354}
355
Kiyoung Kimae11c232021-07-19 11:38:04 +0900356func (p *PrebuiltEtc) InVendor() bool {
357 return p.ModuleBase.InstallInVendor()
358}
359
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100360func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800361 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
362 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900363 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700364 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
365 installBaseDir = p.installDirBase64
366 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900367 if p.SocSpecific() && p.socInstallDirBase != "" {
368 installBaseDir = p.socInstallDirBase
369 }
Colin Cross2f634572023-11-13 12:12:06 -0800370 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
371 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
372 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100373 return installBaseDir
374}
Colin Cross2f634572023-11-13 12:12:06 -0800375
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100376func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
377 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900378
Cole Faustfdec8722024-05-22 11:38:29 -0700379 srcProperty := p.properties.Src.Get(ctx)
380 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
381 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100382 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000383 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700384 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
385 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
386 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
387 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100388
389 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
390 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
391 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
392 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700393 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800394 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000395 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800396 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
397 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100398
399 filename := proptools.String(p.properties.Filename)
400 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700401 if srcProperty.IsPresent() {
402 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100403 // If the source was not found, set a fake source path to
404 // support AllowMissingDependencies executions.
405 if len(p.sourceFilePaths) == 0 {
406 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
407 }
408
409 // Determine the output file basename.
410 // If Filename is set, use the name specified by the property.
411 // If Filename_from_src is set, use the source file name.
412 // Otherwise use the module name.
413 if filename != "" {
414 if filenameFromSrc {
415 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
416 return
417 }
418 } else if filenameFromSrc {
419 filename = p.sourceFilePaths[0].Base()
420 } else {
421 filename = ctx.ModuleName()
422 }
423 if strings.Contains(filename, "/") {
424 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
425 return
426 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800427 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100428
429 ip := installProperties{
430 filename: filename,
431 sourceFilePath: p.sourceFilePaths[0],
432 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700433 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100434 symlinks: p.properties.Symlinks,
435 }
436 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700437 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700438 } else if len(srcsProperty) > 0 {
439 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100440 if filename != "" {
441 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
442 }
443 if len(p.properties.Symlinks) > 0 {
444 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
445 }
446 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700447 if len(dstsProperty) > 0 {
448 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
449 } else {
450 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
451 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100452 }
Cole Faustfdec8722024-05-22 11:38:29 -0700453 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700454 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
455 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
456 }
457 for i, src := range p.sourceFilePaths {
458 var filename string
459 var installDirPath android.InstallPath
460
461 if len(dstsProperty) > 0 {
462 var dstdir string
463
464 dstdir, filename = filepath.Split(dstsProperty[i])
465 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
466 } else {
467 filename = src.Base()
468 installDirPath = baseInstallDirPath
469 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800470 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100471 ip := installProperties{
472 filename: filename,
473 sourceFilePath: src,
474 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700475 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100476 }
477 p.outputFilePaths = append(p.outputFilePaths, output)
478 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700479 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100480 }
481 } else if ctx.Config().AllowMissingDependencies() {
482 // If no srcs was set and AllowMissingDependencies is enabled then
483 // mark the module as missing dependencies and set a fake source path
484 // and file name.
485 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
486 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
487 if filename == "" {
488 filename = ctx.ModuleName()
489 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800490 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100491 ip := installProperties{
492 filename: filename,
493 sourceFilePath: p.sourceFilePaths[0],
494 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700495 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100496 }
497 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700498 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100499 } else {
500 ctx.PropertyErrorf("src", "missing prebuilt source file")
501 return
502 }
503
504 // Call InstallFile even when uninstallable to make the module included in the package.
505 if !p.Installable() {
506 p.SkipInstall()
507 }
508 for _, ip := range installs {
509 ip.addInstallRules(ctx)
510 }
mrziwang89371762024-06-11 12:42:24 -0700511
mrziwanga25adf32025-02-05 23:50:55 +0000512 p.updateModuleInfoJSON(ctx)
513
mrziwang89371762024-06-11 12:42:24 -0700514 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Yu Liu0a37d422025-02-13 02:05:00 +0000515
516 SetCommonPrebuiltEtcInfo(ctx, p)
517}
518
519func SetCommonPrebuiltEtcInfo(ctx android.ModuleContext, p PrebuiltEtcModule) {
520 android.SetProvider(ctx, PrebuiltEtcInfoProvider, PrebuiltEtcInfo{
521 BaseDir: p.BaseDir(),
522 SubDir: p.SubDir(),
523 })
Spandan Das756d3402023-06-05 22:49:50 +0000524}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900525
mrziwanga25adf32025-02-05 23:50:55 +0000526func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
527 moduleInfoJSON := ctx.ModuleInfoJSON()
528 moduleInfoJSON.Class = []string{"ETC"}
529 if p.makeClass != "" {
530 moduleInfoJSON.Class = []string{p.makeClass}
531 }
532 moduleInfoJSON.SystemSharedLibs = []string{"none"}
533 moduleInfoJSON.Tags = []string{"optional"}
534}
535
Spandan Das756d3402023-06-05 22:49:50 +0000536type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000537 filename string
538 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800539 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100540 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000541 symlinks []string
542}
543
544// utility function to add install rules to the build graph.
545// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100546func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000547 // Copy the file from src to a location in out/ with the correct `filename`
548 // This ensures that outputFilePath has the correct name for others to
549 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000550 ctx.Build(pctx, android.BuildParams{
551 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100552 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000553 Input: ip.sourceFilePath,
554 })
555
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100556 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000557 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100558 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900559 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900560}
561
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700562func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700563 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800564 if p.inRamdisk() && !p.onlyInRamdisk() {
565 nameSuffix = ".ramdisk"
566 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700567 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
568 nameSuffix = ".vendor_ramdisk"
569 }
Inseob Kim08758f02021-04-08 21:13:22 +0900570 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
571 nameSuffix = ".debug_ramdisk"
572 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900573 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700574 nameSuffix = ".recovery"
575 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700576
577 class := p.makeClass
578 if class == "" {
579 class = "ETC"
580 }
581
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100582 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700583 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700584 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100585 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700586 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700587 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700588 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700589 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100590 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800591 if len(p.properties.Symlinks) > 0 {
592 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
593 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800594 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700595 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800596 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900597 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700598 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900599 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900600 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900601}
602
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000603func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
604 return &p.ModuleBase
605}
606
Jooyung Hana0171822019-07-22 15:48:36 +0900607func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
608 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900609 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900610 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000611 p.AddProperties(&p.rootProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900612}
613
614func InitPrebuiltRootModule(p *PrebuiltEtc) {
615 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800616 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900617 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800618}
619
620func InitPrebuiltAvbModule(p *PrebuiltEtc) {
621 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900622 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900623 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900624}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900625
Patrice Arruda9e14b962019-03-11 15:58:50 -0700626// prebuilt_etc is for a prebuilt artifact that is installed in
627// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700628func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900629 module := &PrebuiltEtc{}
630 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900631 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700632 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000633 android.InitDefaultableModule(module)
634 return module
635}
636
637func defaultsFactory() android.Module {
638 return DefaultsFactory()
639}
640
641func DefaultsFactory(props ...interface{}) android.Module {
642 module := &Defaults{}
643
644 module.AddProperties(props...)
645 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000646 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000647 &prebuiltSubdirProperties{},
648 )
649
650 android.InitDefaultsModule(module)
651
Jiyong Parkc678ad32018-04-10 13:07:10 +0900652 return module
653}
Tao Bao0ba5c942018-08-14 22:20:22 -0700654
Patrice Arruda9e14b962019-03-11 15:58:50 -0700655// prebuilt_etc_host is for a host prebuilt artifact that is installed in
656// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700657func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900658 module := &PrebuiltEtc{}
659 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800660 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700661 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100662 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800663 return module
664}
665
Miguel32b02802022-12-01 18:38:26 +0000666// prebuilt_etc_host is for a host prebuilt artifact that is installed in
667// <partition>/etc/<sub_dir> directory.
668func PrebuiltEtcCaCertsFactory() android.Module {
669 module := &PrebuiltEtc{}
670 InitPrebuiltEtcModule(module, "cacerts")
671 // This module is device-only
672 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000673 return module
674}
675
Nelson Li1fb94b22024-07-09 17:04:52 +0800676// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
677// `prebuilt_avb` will not have a `system` subdirectory.
678// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
679// root directory of the partition: <partition_root>/avb.
680// prebuilt_avb does not allow adding any other subdirectories.
681func PrebuiltAvbFactory() android.Module {
682 module := &PrebuiltEtc{}
683 InitPrebuiltAvbModule(module)
684 // This module is device-only
685 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
686 android.InitDefaultableModule(module)
687 return module
688}
689
Inseob Kim27408bf2021-04-06 21:00:17 +0900690// prebuilt_root is for a prebuilt artifact that is installed in
691// <partition>/ directory. Can't have any sub directories.
692func PrebuiltRootFactory() android.Module {
693 module := &PrebuiltEtc{}
694 InitPrebuiltRootModule(module)
695 // This module is device-only
696 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100697 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900698 return module
699}
700
Liz Kammere9ecddc2022-01-04 17:27:52 -0500701// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
702// directory.
703func PrebuiltRootHostFactory() android.Module {
704 module := &PrebuiltEtc{}
705 InitPrebuiltEtcModule(module, ".")
706 // This module is host-only
707 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
708 android.InitDefaultableModule(module)
709 return module
710}
711
Patrice Arruda9e14b962019-03-11 15:58:50 -0700712// prebuilt_usr_share is for a prebuilt artifact that is installed in
713// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700714func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900715 module := &PrebuiltEtc{}
716 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800717 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700718 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100719 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800720 return module
721}
722
Patrice Arruda9e14b962019-03-11 15:58:50 -0700723// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
724// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700725func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900726 module := &PrebuiltEtc{}
727 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800728 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700729 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100730 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800731 return module
732}
733
yangbill63c5e192024-03-27 09:02:12 +0000734// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
735// <partition>/usr/hyphen-data/<sub_dir> directory.
736func PrebuiltUserHyphenDataFactory() android.Module {
737 module := &PrebuiltEtc{}
738 InitPrebuiltEtcModule(module, "usr/hyphen-data")
739 // This module is device-only
740 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
741 android.InitDefaultableModule(module)
742 return module
743}
744
yangbill85527e62024-04-30 08:24:50 +0000745// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
746// <partition>/usr/keylayout/<sub_dir> directory.
747func PrebuiltUserKeyLayoutFactory() android.Module {
748 module := &PrebuiltEtc{}
749 InitPrebuiltEtcModule(module, "usr/keylayout")
750 // This module is device-only
751 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
752 android.InitDefaultableModule(module)
753 return module
754}
755
756// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
757// <partition>/usr/keychars/<sub_dir> directory.
758func PrebuiltUserKeyCharsFactory() android.Module {
759 module := &PrebuiltEtc{}
760 InitPrebuiltEtcModule(module, "usr/keychars")
761 // This module is device-only
762 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
763 android.InitDefaultableModule(module)
764 return module
765}
766
767// prebuilt_usr_idc is for a prebuilt artifact that is installed in
768// <partition>/usr/idc/<sub_dir> directory.
769func PrebuiltUserIdcFactory() android.Module {
770 module := &PrebuiltEtc{}
771 InitPrebuiltEtcModule(module, "usr/idc")
772 // This module is device-only
773 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
774 android.InitDefaultableModule(module)
775 return module
776}
777
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000778// prebuilt_usr_srec is for a prebuilt artifact that is installed in
779// <partition>/usr/srec/<sub_dir> directory.
780func PrebuiltUserSrecFactory() android.Module {
781 module := &PrebuiltEtc{}
782 InitPrebuiltEtcModule(module, "usr/srec")
783 // This module is device-only
784 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
785 android.InitDefaultableModule(module)
786 return module
787}
788
Patrice Arruda61583eb2019-05-14 08:20:45 -0700789// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700790func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900791 module := &PrebuiltEtc{}
792 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700793 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700794 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100795 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700796 return module
797}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700798
Kevin93f7cd82024-05-02 12:37:59 +0200799// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
800func PrebuiltOverlayFactory() android.Module {
801 module := &PrebuiltEtc{}
802 InitPrebuiltEtcModule(module, "overlay")
803 // This module is device-only
804 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
805 return module
806}
807
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800808// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
809// image.
810// If soc_specific property is set to true, the firmware file is installed to the
811// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700812func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900813 module := &PrebuiltEtc{}
814 module.socInstallDirBase = "firmware"
815 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700816 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700817 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100818 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700819 return module
820}
Patrice Arruda0f688002020-06-08 21:40:25 +0000821
822// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800823// If soc_specific property is set to true, the DSP related file is installed to the
824// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000825func PrebuiltDSPFactory() android.Module {
826 module := &PrebuiltEtc{}
827 module.socInstallDirBase = "dsp"
828 InitPrebuiltEtcModule(module, "etc/dsp")
829 // This module is device-only
830 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100831 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000832 return module
833}
Colin Cross83ebf232021-04-09 09:41:23 -0700834
Colin Crossf17e2b52023-10-30 15:17:25 -0700835// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
836func PrebuiltRenderScriptBitcodeFactory() android.Module {
837 module := &PrebuiltEtc{}
838 module.makeClass = "RENDERSCRIPT_BITCODE"
839 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800840 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700841 InitPrebuiltEtcModule(module, "lib")
842 // This module is device-only
843 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
844 android.InitDefaultableModule(module)
845 return module
846}
847
Colin Cross83ebf232021-04-09 09:41:23 -0700848// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
849// to the <partition>/lib/rfsa directory.
850func PrebuiltRFSAFactory() android.Module {
851 module := &PrebuiltEtc{}
852 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
853 // many places outside of the application processor. They could be moved to /vendor/dsp once
854 // that is cleaned up.
855 InitPrebuiltEtcModule(module, "lib/rfsa")
856 // This module is device-only
857 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100858 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700859 return module
860}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000861
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000862// prebuilt_media installs media files in <partition>/media directory.
863func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000864 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000865 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000866 // This module is device-only
867 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
868 android.InitDefaultableModule(module)
869 return module
870}
Jihoon Kangec62d842024-10-25 20:27:18 +0000871
872// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
873func PrebuiltVoicepackFactory() android.Module {
874 module := &PrebuiltEtc{}
875 InitPrebuiltEtcModule(module, "tts")
876 // This module is device-only
877 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
878 android.InitDefaultableModule(module)
879 return module
880}
881
882// prebuilt_bin installs files in <partition>/bin directory.
883func PrebuiltBinaryFactory() android.Module {
884 module := &PrebuiltEtc{}
885 InitPrebuiltEtcModule(module, "bin")
886 // This module is device-only
887 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
888 android.InitDefaultableModule(module)
889 return module
890}
891
892// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
893func PrebuiltWallpaperFactory() android.Module {
894 module := &PrebuiltEtc{}
895 InitPrebuiltEtcModule(module, "wallpaper")
896 // This module is device-only
897 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
898 android.InitDefaultableModule(module)
899 return module
900}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000901
902// prebuilt_priv_app installs files in <partition>/priv-app directory.
903func PrebuiltPrivAppFactory() android.Module {
904 module := &PrebuiltEtc{}
905 InitPrebuiltEtcModule(module, "priv-app")
906 // This module is device-only
907 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
908 android.InitDefaultableModule(module)
909 return module
910}
911
912// prebuilt_rfs installs files in <partition>/rfs directory.
913func PrebuiltRfsFactory() android.Module {
914 module := &PrebuiltEtc{}
915 InitPrebuiltEtcModule(module, "rfs")
916 // This module is device-only
917 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
918 android.InitDefaultableModule(module)
919 return module
920}
921
922// prebuilt_framework installs files in <partition>/framework directory.
923func PrebuiltFrameworkFactory() android.Module {
924 module := &PrebuiltEtc{}
925 InitPrebuiltEtcModule(module, "framework")
926 // This module is device-only
927 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
928 android.InitDefaultableModule(module)
929 return module
930}
931
932// prebuilt_res installs files in <partition>/res directory.
933func PrebuiltResFactory() android.Module {
934 module := &PrebuiltEtc{}
935 InitPrebuiltEtcModule(module, "res")
936 // This module is device-only
937 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
938 android.InitDefaultableModule(module)
939 return module
940}
941
942// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
943func PrebuiltWlcUptFactory() android.Module {
944 module := &PrebuiltEtc{}
945 InitPrebuiltEtcModule(module, "wlc_upt")
946 // This module is device-only
947 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
948 android.InitDefaultableModule(module)
949 return module
950}
951
952// prebuilt_odm installs files in <partition>/odm directory.
953func PrebuiltOdmFactory() android.Module {
954 module := &PrebuiltEtc{}
955 InitPrebuiltEtcModule(module, "odm")
956 // This module is device-only
957 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
958 android.InitDefaultableModule(module)
959 return module
960}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000961
962// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
963func PrebuiltVendorDlkmFactory() android.Module {
964 module := &PrebuiltEtc{}
965 InitPrebuiltEtcModule(module, "vendor_dlkm")
966 // This module is device-only
967 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
968 android.InitDefaultableModule(module)
969 return module
970}
971
972// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
973func PrebuiltBtFirmwareFactory() android.Module {
974 module := &PrebuiltEtc{}
975 InitPrebuiltEtcModule(module, "bt_firmware")
976 // This module is device-only
977 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
978 android.InitDefaultableModule(module)
979 return module
980}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000981
982// prebuilt_tvservice installs files in <partition>/tvservice directory.
983func PrebuiltTvServiceFactory() android.Module {
984 module := &PrebuiltEtc{}
985 InitPrebuiltEtcModule(module, "tvservice")
986 // This module is device-only
987 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
988 android.InitDefaultableModule(module)
989 return module
990}
991
992// prebuilt_optee installs files in <partition>/optee directory.
993func PrebuiltOpteeFactory() android.Module {
994 module := &PrebuiltEtc{}
995 InitPrebuiltEtcModule(module, "optee")
996 // This module is device-only
997 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
998 android.InitDefaultableModule(module)
999 return module
1000}
Jihoon Kangecf76dd2024-11-12 05:24:46 +00001001
1002// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
1003func PrebuiltTvConfigFactory() android.Module {
1004 module := &PrebuiltEtc{}
1005 InitPrebuiltEtcModule(module, "tvconfig")
1006 // This module is device-only
1007 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1008 android.InitDefaultableModule(module)
1009 return module
1010}
Jihoon Kang3ca07a12024-12-02 19:14:30 +00001011
1012// prebuilt_vendor installs files in <partition>/vendor directory.
1013func PrebuiltVendorFactory() android.Module {
1014 module := &PrebuiltEtc{}
1015 InitPrebuiltEtcModule(module, "vendor")
1016 // This module is device-only
1017 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1018 android.InitDefaultableModule(module)
1019 return module
1020}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001021
1022// prebuilt_sbin installs files in <partition>/sbin directory.
1023func PrebuiltSbinFactory() android.Module {
1024 module := &PrebuiltEtc{}
1025 InitPrebuiltEtcModule(module, "sbin")
1026 // This module is device-only
1027 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1028 android.InitDefaultableModule(module)
1029 return module
1030}
1031
1032// prebuilt_system installs files in <partition>/system directory.
1033func PrebuiltSystemFactory() android.Module {
1034 module := &PrebuiltEtc{}
1035 InitPrebuiltEtcModule(module, "system")
1036 // This module is device-only
1037 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1038 android.InitDefaultableModule(module)
1039 return module
1040}
1041
1042// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1043func PrebuiltFirstStageRamdiskFactory() android.Module {
1044 module := &PrebuiltEtc{}
1045 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1046 // This module is device-only
1047 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1048 android.InitDefaultableModule(module)
1049 return module
1050}