blob: f2bf0d24302ccecca530898240e0b614e44a59e1 [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)
68 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070069 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070070 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000071 ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory)
Jihoon Kangec62d842024-10-25 20:27:18 +000072 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
73 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
74 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000075 ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory)
76 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
77 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
78 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
79 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
80 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000081 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
82 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000083 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
84 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Jihoon Kangecf76dd2024-11-12 05:24:46 +000085 ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory)
Jihoon Kang3ca07a12024-12-02 19:14:30 +000086 ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory)
Jihoon Kang320ca7c2024-12-03 18:14:50 +000087 ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
88 ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
89 ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
Jihoon Kang002767b2025-03-12 22:14:39 +000090 ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000091
92 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040093
Jiyong Parkc678ad32018-04-10 13:07:10 +090094}
95
Yu Liu0a37d422025-02-13 02:05:00 +000096type PrebuiltEtcInfo struct {
97 // Returns the base install directory, such as "etc", "usr/share".
98 BaseDir string
99 // Returns the sub install directory relative to BaseDir().
100 SubDir string
101}
102
103var PrebuiltEtcInfoProvider = blueprint.NewProvider[PrebuiltEtcInfo]()
104
Paul Duffin1172fed2021-03-08 11:28:18 +0000105var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
106
Jihoon Kang69725b32024-11-12 03:08:49 +0000107type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +0800108 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100109 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -0700110 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900111
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100112 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700113 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
114 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700115 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100116
Douglas Anderson79688ff2024-09-27 15:08:33 -0700117 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
118 // set filename_from_src. This can be used to install each source file to a different directory
119 // and/or change filenames when files are installed. Must be exactly one entry per source file,
120 // which means care must be taken if srcs has globs.
121 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
122
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800123 // 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 +1100124 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900125 Filename *string `android:"arch_variant"`
126
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800127 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900128 // is the same as the file name of the source file.
129 Filename_from_src *bool `android:"arch_variant"`
130
Yifan Hong1b3348d2020-01-21 15:53:22 -0800131 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700132 // On device without a dedicated recovery partition, the module is only
133 // available after switching root into
134 // /first_stage_ramdisk. To expose the module before switching root, install
135 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800136 Ramdisk_available *bool
137
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700138 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700139 // On device without a dedicated recovery partition, the module is only
140 // available after switching root into
141 // /first_stage_ramdisk. To expose the module before switching root, install
142 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700143 Vendor_ramdisk_available *bool
144
Inseob Kim08758f02021-04-08 21:13:22 +0900145 // Make this module available when building for debug ramdisk.
146 Debug_ramdisk_available *bool
147
Tao Bao0ba5c942018-08-14 22:20:22 -0700148 // Make this module available when building for recovery.
149 Recovery_available *bool
150
Jiyong Parkad9ce042018-10-31 22:49:57 +0900151 // Whether this module is directly installable to one of the partitions. Default: true.
152 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800153
154 // Install symlinks to the installed file.
155 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800156
Wei Li59586252024-11-04 09:25:54 -0800157 // Install to partition oem when set to true.
158 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900159}
160
Inseob Kim27408bf2021-04-06 21:00:17 +0900161type prebuiltSubdirProperties struct {
162 // Optional subdirectory under which this file is installed into, cannot be specified with
163 // relative_install_path, prefer relative_install_path.
164 Sub_dir *string `android:"arch_variant"`
165
166 // Optional subdirectory under which this file is installed into, cannot be specified with
167 // sub_dir.
168 Relative_install_path *string `android:"arch_variant"`
169}
170
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900171type prebuiltRootProperties struct {
172 // Install this module to the root directory, without partition subdirs. When this module is
173 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
174 // then be copied to the root of system.img. When this module is packaged by other modules like
175 // android_filesystem, this module will be installed to the root ("/"), unlike normal
176 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
177 Install_in_root *bool
178}
179
Jooyung Han39edb6c2019-11-06 16:53:07 +0900180type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700181 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800182
183 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900184 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800185
186 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900187 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900188}
189
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900190type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700191 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000192 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900193
Jihoon Kang69725b32024-11-12 03:08:49 +0000194 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900195
196 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
197 // prebuilt_avb and prebuilt_root modules use this.
198 rootProperties prebuiltRootProperties
199
Inseob Kim27408bf2021-04-06 21:00:17 +0900200 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900201
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100202 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800203 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800204 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800205 installDirBase string
206 installDirBase64 string
207 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800208 // The base install location when soc_specific property is set to true, e.g. "firmware" for
209 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700210 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700211 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700212 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700213
Cole Faustfdec8722024-05-22 11:38:29 -0700214 usedSrcsProperty bool
215
Colin Crossf17e2b52023-10-30 15:17:25 -0700216 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900217}
218
Inseob Kim1e27a142021-05-06 11:46:11 +0000219type Defaults struct {
220 android.ModuleBase
221 android.DefaultsModuleBase
222}
223
Yifan Hong1b3348d2020-01-21 15:53:22 -0800224func (p *PrebuiltEtc) inRamdisk() bool {
225 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
226}
227
228func (p *PrebuiltEtc) onlyInRamdisk() bool {
229 return p.ModuleBase.InstallInRamdisk()
230}
231
232func (p *PrebuiltEtc) InstallInRamdisk() bool {
233 return p.inRamdisk()
234}
235
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700236func (p *PrebuiltEtc) inVendorRamdisk() bool {
237 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
238}
239
240func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
241 return p.ModuleBase.InstallInVendorRamdisk()
242}
243
244func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
245 return p.inVendorRamdisk()
246}
247
Inseob Kim08758f02021-04-08 21:13:22 +0900248func (p *PrebuiltEtc) inDebugRamdisk() bool {
249 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
250}
251
252func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
253 return p.ModuleBase.InstallInDebugRamdisk()
254}
255
256func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
257 return p.inDebugRamdisk()
258}
259
Kiyoung Kimae11c232021-07-19 11:38:04 +0900260func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800261 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700262}
263
264func (p *PrebuiltEtc) onlyInRecovery() bool {
265 return p.ModuleBase.InstallInRecovery()
266}
267
268func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900269 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700270}
271
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700272var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800273
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700274func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800275
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700276func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000277 return false
278}
279
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700280func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000281 return false
282}
283
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700284func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700285 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900286 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800287}
288
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700289func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700290 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800291}
292
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700293func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700294 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
295}
296
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700297func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900298 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
299}
300
Nelson Li1fb94b22024-07-09 17:04:52 +0800301func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900302 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800303}
304
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700305func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700306 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800307}
308
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700309func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800310 return nil
311}
312
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700313func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800314}
315
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700316func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700317 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100318 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
319 }
Cole Faustfdec8722024-05-22 11:38:29 -0700320 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900321}
322
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700323func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700324 if len(p.installDirPaths) != 1 {
325 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
326 }
327 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900328}
329
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900330// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
331// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700332func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900333 p.additionalDependencies = &paths
334}
335
Cole Faust4e9f5922024-11-13 16:09:23 -0800336func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700337 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100338 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
339 }
340 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900341}
342
343func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900344 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700345 return subDir
346 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900347 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900348}
349
Jooyung Han0703fd82020-08-26 22:11:53 +0900350func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900351 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900352}
353
Jiyong Parkad9ce042018-10-31 22:49:57 +0900354func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800355 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900356}
357
Kiyoung Kimae11c232021-07-19 11:38:04 +0900358func (p *PrebuiltEtc) InVendor() bool {
359 return p.ModuleBase.InstallInVendor()
360}
361
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100362func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800363 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
364 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900365 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700366 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
367 installBaseDir = p.installDirBase64
368 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900369 if p.SocSpecific() && p.socInstallDirBase != "" {
370 installBaseDir = p.socInstallDirBase
371 }
Colin Cross2f634572023-11-13 12:12:06 -0800372 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
373 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
374 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100375 return installBaseDir
376}
Colin Cross2f634572023-11-13 12:12:06 -0800377
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100378func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
379 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900380
Cole Faustfdec8722024-05-22 11:38:29 -0700381 srcProperty := p.properties.Src.Get(ctx)
382 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
383 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100384 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000385 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700386 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
387 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
388 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
389 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100390
391 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
392 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
393 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
394 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700395 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800396 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000397 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800398 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
399 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100400
401 filename := proptools.String(p.properties.Filename)
402 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700403 if srcProperty.IsPresent() {
404 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100405 // If the source was not found, set a fake source path to
406 // support AllowMissingDependencies executions.
407 if len(p.sourceFilePaths) == 0 {
408 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
409 }
410
411 // Determine the output file basename.
412 // If Filename is set, use the name specified by the property.
413 // If Filename_from_src is set, use the source file name.
414 // Otherwise use the module name.
415 if filename != "" {
416 if filenameFromSrc {
417 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
418 return
419 }
420 } else if filenameFromSrc {
421 filename = p.sourceFilePaths[0].Base()
422 } else {
423 filename = ctx.ModuleName()
424 }
425 if strings.Contains(filename, "/") {
426 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
427 return
428 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800429 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100430
431 ip := installProperties{
432 filename: filename,
433 sourceFilePath: p.sourceFilePaths[0],
434 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700435 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100436 symlinks: p.properties.Symlinks,
437 }
438 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700439 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700440 } else if len(srcsProperty) > 0 {
441 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100442 if filename != "" {
443 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
444 }
445 if len(p.properties.Symlinks) > 0 {
446 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
447 }
448 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700449 if len(dstsProperty) > 0 {
450 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
451 } else {
452 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
453 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100454 }
Cole Faustfdec8722024-05-22 11:38:29 -0700455 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700456 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
457 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
458 }
459 for i, src := range p.sourceFilePaths {
460 var filename string
461 var installDirPath android.InstallPath
462
463 if len(dstsProperty) > 0 {
464 var dstdir string
465
466 dstdir, filename = filepath.Split(dstsProperty[i])
467 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
468 } else {
469 filename = src.Base()
470 installDirPath = baseInstallDirPath
471 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800472 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100473 ip := installProperties{
474 filename: filename,
475 sourceFilePath: src,
476 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700477 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100478 }
479 p.outputFilePaths = append(p.outputFilePaths, output)
480 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700481 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100482 }
483 } else if ctx.Config().AllowMissingDependencies() {
484 // If no srcs was set and AllowMissingDependencies is enabled then
485 // mark the module as missing dependencies and set a fake source path
486 // and file name.
487 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
488 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
489 if filename == "" {
490 filename = ctx.ModuleName()
491 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800492 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100493 ip := installProperties{
494 filename: filename,
495 sourceFilePath: p.sourceFilePaths[0],
496 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700497 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100498 }
499 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700500 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100501 } else {
502 ctx.PropertyErrorf("src", "missing prebuilt source file")
503 return
504 }
505
506 // Call InstallFile even when uninstallable to make the module included in the package.
507 if !p.Installable() {
508 p.SkipInstall()
509 }
510 for _, ip := range installs {
511 ip.addInstallRules(ctx)
512 }
mrziwang89371762024-06-11 12:42:24 -0700513
mrziwanga25adf32025-02-05 23:50:55 +0000514 p.updateModuleInfoJSON(ctx)
515
mrziwang89371762024-06-11 12:42:24 -0700516 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Yu Liu0a37d422025-02-13 02:05:00 +0000517
518 SetCommonPrebuiltEtcInfo(ctx, p)
519}
520
521func SetCommonPrebuiltEtcInfo(ctx android.ModuleContext, p PrebuiltEtcModule) {
522 android.SetProvider(ctx, PrebuiltEtcInfoProvider, PrebuiltEtcInfo{
523 BaseDir: p.BaseDir(),
524 SubDir: p.SubDir(),
525 })
Spandan Das756d3402023-06-05 22:49:50 +0000526}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900527
mrziwanga25adf32025-02-05 23:50:55 +0000528func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
529 moduleInfoJSON := ctx.ModuleInfoJSON()
530 moduleInfoJSON.Class = []string{"ETC"}
531 if p.makeClass != "" {
532 moduleInfoJSON.Class = []string{p.makeClass}
533 }
534 moduleInfoJSON.SystemSharedLibs = []string{"none"}
535 moduleInfoJSON.Tags = []string{"optional"}
536}
537
Spandan Das756d3402023-06-05 22:49:50 +0000538type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000539 filename string
540 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800541 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100542 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000543 symlinks []string
544}
545
546// utility function to add install rules to the build graph.
547// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100548func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000549 // Copy the file from src to a location in out/ with the correct `filename`
550 // This ensures that outputFilePath has the correct name for others to
551 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000552 ctx.Build(pctx, android.BuildParams{
553 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100554 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000555 Input: ip.sourceFilePath,
556 })
557
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100558 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000559 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100560 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900561 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900562}
563
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700564func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700565 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800566 if p.inRamdisk() && !p.onlyInRamdisk() {
567 nameSuffix = ".ramdisk"
568 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700569 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
570 nameSuffix = ".vendor_ramdisk"
571 }
Inseob Kim08758f02021-04-08 21:13:22 +0900572 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
573 nameSuffix = ".debug_ramdisk"
574 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900575 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700576 nameSuffix = ".recovery"
577 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700578
579 class := p.makeClass
580 if class == "" {
581 class = "ETC"
582 }
583
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100584 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700585 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700586 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100587 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700588 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700589 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700590 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700591 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100592 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800593 if len(p.properties.Symlinks) > 0 {
594 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
595 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800596 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700597 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800598 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900599 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700600 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900601 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900602 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900603}
604
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000605func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
606 return &p.ModuleBase
607}
608
Jooyung Hana0171822019-07-22 15:48:36 +0900609func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
610 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900611 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900612 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000613 p.AddProperties(&p.rootProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900614}
615
616func InitPrebuiltRootModule(p *PrebuiltEtc) {
617 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800618 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900619 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800620}
621
622func InitPrebuiltAvbModule(p *PrebuiltEtc) {
623 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900624 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900625 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900626}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900627
Patrice Arruda9e14b962019-03-11 15:58:50 -0700628// prebuilt_etc is for a prebuilt artifact that is installed in
629// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700630func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900631 module := &PrebuiltEtc{}
632 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900633 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700634 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000635 android.InitDefaultableModule(module)
636 return module
637}
638
639func defaultsFactory() android.Module {
640 return DefaultsFactory()
641}
642
643func DefaultsFactory(props ...interface{}) android.Module {
644 module := &Defaults{}
645
646 module.AddProperties(props...)
647 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000648 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000649 &prebuiltSubdirProperties{},
650 )
651
652 android.InitDefaultsModule(module)
653
Jiyong Parkc678ad32018-04-10 13:07:10 +0900654 return module
655}
Tao Bao0ba5c942018-08-14 22:20:22 -0700656
Patrice Arruda9e14b962019-03-11 15:58:50 -0700657// prebuilt_etc_host is for a host prebuilt artifact that is installed in
658// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700659func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900660 module := &PrebuiltEtc{}
661 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800662 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700663 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100664 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800665 return module
666}
667
Jihoon Kang002767b2025-03-12 22:14:39 +0000668// prebuilt_any is a special module where the module can define the subdirectory that the files
669// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
670// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
671// modules allow installing the file at the desired location, introduce a new prebuilt_* module
672// type instead.
673func PrebuiltAnyFactory() android.Module {
674 module := &PrebuiltEtc{}
675 InitPrebuiltEtcModule(module, ".")
676 // This module is device-only
677 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
678 android.InitDefaultableModule(module)
679 return module
680}
681
Miguel32b02802022-12-01 18:38:26 +0000682// prebuilt_etc_host is for a host prebuilt artifact that is installed in
683// <partition>/etc/<sub_dir> directory.
684func PrebuiltEtcCaCertsFactory() android.Module {
685 module := &PrebuiltEtc{}
686 InitPrebuiltEtcModule(module, "cacerts")
687 // This module is device-only
688 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000689 return module
690}
691
Nelson Li1fb94b22024-07-09 17:04:52 +0800692// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
693// `prebuilt_avb` will not have a `system` subdirectory.
694// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
695// root directory of the partition: <partition_root>/avb.
696// prebuilt_avb does not allow adding any other subdirectories.
697func PrebuiltAvbFactory() android.Module {
698 module := &PrebuiltEtc{}
699 InitPrebuiltAvbModule(module)
700 // This module is device-only
701 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
702 android.InitDefaultableModule(module)
703 return module
704}
705
Inseob Kim27408bf2021-04-06 21:00:17 +0900706// prebuilt_root is for a prebuilt artifact that is installed in
707// <partition>/ directory. Can't have any sub directories.
708func PrebuiltRootFactory() android.Module {
709 module := &PrebuiltEtc{}
710 InitPrebuiltRootModule(module)
711 // This module is device-only
712 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100713 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900714 return module
715}
716
Liz Kammere9ecddc2022-01-04 17:27:52 -0500717// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
718// directory.
719func PrebuiltRootHostFactory() android.Module {
720 module := &PrebuiltEtc{}
721 InitPrebuiltEtcModule(module, ".")
722 // This module is host-only
723 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
724 android.InitDefaultableModule(module)
725 return module
726}
727
Patrice Arruda9e14b962019-03-11 15:58:50 -0700728// prebuilt_usr_share is for a prebuilt artifact that is installed in
729// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700730func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900731 module := &PrebuiltEtc{}
732 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800733 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700734 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100735 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800736 return module
737}
738
Patrice Arruda9e14b962019-03-11 15:58:50 -0700739// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
740// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700741func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900742 module := &PrebuiltEtc{}
743 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800744 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700745 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100746 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800747 return module
748}
749
yangbill63c5e192024-03-27 09:02:12 +0000750// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
751// <partition>/usr/hyphen-data/<sub_dir> directory.
752func PrebuiltUserHyphenDataFactory() android.Module {
753 module := &PrebuiltEtc{}
754 InitPrebuiltEtcModule(module, "usr/hyphen-data")
755 // This module is device-only
756 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
757 android.InitDefaultableModule(module)
758 return module
759}
760
yangbill85527e62024-04-30 08:24:50 +0000761// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
762// <partition>/usr/keylayout/<sub_dir> directory.
763func PrebuiltUserKeyLayoutFactory() android.Module {
764 module := &PrebuiltEtc{}
765 InitPrebuiltEtcModule(module, "usr/keylayout")
766 // This module is device-only
767 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
768 android.InitDefaultableModule(module)
769 return module
770}
771
772// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
773// <partition>/usr/keychars/<sub_dir> directory.
774func PrebuiltUserKeyCharsFactory() android.Module {
775 module := &PrebuiltEtc{}
776 InitPrebuiltEtcModule(module, "usr/keychars")
777 // This module is device-only
778 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
779 android.InitDefaultableModule(module)
780 return module
781}
782
783// prebuilt_usr_idc is for a prebuilt artifact that is installed in
784// <partition>/usr/idc/<sub_dir> directory.
785func PrebuiltUserIdcFactory() android.Module {
786 module := &PrebuiltEtc{}
787 InitPrebuiltEtcModule(module, "usr/idc")
788 // This module is device-only
789 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
790 android.InitDefaultableModule(module)
791 return module
792}
793
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000794// prebuilt_usr_srec is for a prebuilt artifact that is installed in
795// <partition>/usr/srec/<sub_dir> directory.
796func PrebuiltUserSrecFactory() android.Module {
797 module := &PrebuiltEtc{}
798 InitPrebuiltEtcModule(module, "usr/srec")
799 // This module is device-only
800 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
801 android.InitDefaultableModule(module)
802 return module
803}
804
Agi Sferro243c7d72025-02-24 15:45:53 -0800805// prebuilt_usr_odml is for a prebuilt artifact that is installed in
806// <partition>/usr/odml/<sub_dir> directory.
807func PrebuiltUserOdmlFactory() android.Module {
808 module := &PrebuiltEtc{}
809 InitPrebuiltEtcModule(module, "usr/odml")
810 // This module is device-only
811 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
812 android.InitDefaultableModule(module)
813 return module
814}
815
Patrice Arruda61583eb2019-05-14 08:20:45 -0700816// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700817func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900818 module := &PrebuiltEtc{}
819 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700820 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700821 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100822 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700823 return module
824}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700825
Kevin93f7cd82024-05-02 12:37:59 +0200826// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
827func PrebuiltOverlayFactory() android.Module {
828 module := &PrebuiltEtc{}
829 InitPrebuiltEtcModule(module, "overlay")
830 // This module is device-only
831 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
832 return module
833}
834
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800835// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
836// image.
837// If soc_specific property is set to true, the firmware file is installed to the
838// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700839func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900840 module := &PrebuiltEtc{}
841 module.socInstallDirBase = "firmware"
842 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700843 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700844 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100845 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700846 return module
847}
Patrice Arruda0f688002020-06-08 21:40:25 +0000848
849// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800850// If soc_specific property is set to true, the DSP related file is installed to the
851// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000852func PrebuiltDSPFactory() android.Module {
853 module := &PrebuiltEtc{}
854 module.socInstallDirBase = "dsp"
855 InitPrebuiltEtcModule(module, "etc/dsp")
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)
Patrice Arruda0f688002020-06-08 21:40:25 +0000859 return module
860}
Colin Cross83ebf232021-04-09 09:41:23 -0700861
Colin Crossf17e2b52023-10-30 15:17:25 -0700862// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
863func PrebuiltRenderScriptBitcodeFactory() android.Module {
864 module := &PrebuiltEtc{}
865 module.makeClass = "RENDERSCRIPT_BITCODE"
866 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800867 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700868 InitPrebuiltEtcModule(module, "lib")
869 // This module is device-only
870 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
871 android.InitDefaultableModule(module)
872 return module
873}
874
Colin Cross83ebf232021-04-09 09:41:23 -0700875// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
876// to the <partition>/lib/rfsa directory.
877func PrebuiltRFSAFactory() android.Module {
878 module := &PrebuiltEtc{}
879 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
880 // many places outside of the application processor. They could be moved to /vendor/dsp once
881 // that is cleaned up.
882 InitPrebuiltEtcModule(module, "lib/rfsa")
883 // This module is device-only
884 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100885 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700886 return module
887}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000888
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000889// prebuilt_media installs media files in <partition>/media directory.
890func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000891 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000892 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000893 // This module is device-only
894 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
895 android.InitDefaultableModule(module)
896 return module
897}
Jihoon Kangec62d842024-10-25 20:27:18 +0000898
899// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
900func PrebuiltVoicepackFactory() android.Module {
901 module := &PrebuiltEtc{}
902 InitPrebuiltEtcModule(module, "tts")
903 // This module is device-only
904 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
905 android.InitDefaultableModule(module)
906 return module
907}
908
909// prebuilt_bin installs files in <partition>/bin directory.
910func PrebuiltBinaryFactory() android.Module {
911 module := &PrebuiltEtc{}
912 InitPrebuiltEtcModule(module, "bin")
913 // This module is device-only
914 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
915 android.InitDefaultableModule(module)
916 return module
917}
918
919// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
920func PrebuiltWallpaperFactory() android.Module {
921 module := &PrebuiltEtc{}
922 InitPrebuiltEtcModule(module, "wallpaper")
923 // This module is device-only
924 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
925 android.InitDefaultableModule(module)
926 return module
927}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000928
929// prebuilt_priv_app installs files in <partition>/priv-app directory.
930func PrebuiltPrivAppFactory() android.Module {
931 module := &PrebuiltEtc{}
932 InitPrebuiltEtcModule(module, "priv-app")
933 // This module is device-only
934 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
935 android.InitDefaultableModule(module)
936 return module
937}
938
939// prebuilt_rfs installs files in <partition>/rfs directory.
940func PrebuiltRfsFactory() android.Module {
941 module := &PrebuiltEtc{}
942 InitPrebuiltEtcModule(module, "rfs")
943 // This module is device-only
944 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
945 android.InitDefaultableModule(module)
946 return module
947}
948
949// prebuilt_framework installs files in <partition>/framework directory.
950func PrebuiltFrameworkFactory() android.Module {
951 module := &PrebuiltEtc{}
952 InitPrebuiltEtcModule(module, "framework")
953 // This module is device-only
954 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
955 android.InitDefaultableModule(module)
956 return module
957}
958
959// prebuilt_res installs files in <partition>/res directory.
960func PrebuiltResFactory() android.Module {
961 module := &PrebuiltEtc{}
962 InitPrebuiltEtcModule(module, "res")
963 // This module is device-only
964 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
965 android.InitDefaultableModule(module)
966 return module
967}
968
969// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
970func PrebuiltWlcUptFactory() android.Module {
971 module := &PrebuiltEtc{}
972 InitPrebuiltEtcModule(module, "wlc_upt")
973 // This module is device-only
974 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
975 android.InitDefaultableModule(module)
976 return module
977}
978
979// prebuilt_odm installs files in <partition>/odm directory.
980func PrebuiltOdmFactory() android.Module {
981 module := &PrebuiltEtc{}
982 InitPrebuiltEtcModule(module, "odm")
983 // This module is device-only
984 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
985 android.InitDefaultableModule(module)
986 return module
987}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000988
989// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
990func PrebuiltVendorDlkmFactory() android.Module {
991 module := &PrebuiltEtc{}
992 InitPrebuiltEtcModule(module, "vendor_dlkm")
993 // This module is device-only
994 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
995 android.InitDefaultableModule(module)
996 return module
997}
998
999// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
1000func PrebuiltBtFirmwareFactory() android.Module {
1001 module := &PrebuiltEtc{}
1002 InitPrebuiltEtcModule(module, "bt_firmware")
1003 // This module is device-only
1004 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1005 android.InitDefaultableModule(module)
1006 return module
1007}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +00001008
1009// prebuilt_tvservice installs files in <partition>/tvservice directory.
1010func PrebuiltTvServiceFactory() android.Module {
1011 module := &PrebuiltEtc{}
1012 InitPrebuiltEtcModule(module, "tvservice")
1013 // This module is device-only
1014 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1015 android.InitDefaultableModule(module)
1016 return module
1017}
1018
1019// prebuilt_optee installs files in <partition>/optee directory.
1020func PrebuiltOpteeFactory() android.Module {
1021 module := &PrebuiltEtc{}
1022 InitPrebuiltEtcModule(module, "optee")
1023 // This module is device-only
1024 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1025 android.InitDefaultableModule(module)
1026 return module
1027}
Jihoon Kangecf76dd2024-11-12 05:24:46 +00001028
1029// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
1030func PrebuiltTvConfigFactory() android.Module {
1031 module := &PrebuiltEtc{}
1032 InitPrebuiltEtcModule(module, "tvconfig")
1033 // This module is device-only
1034 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1035 android.InitDefaultableModule(module)
1036 return module
1037}
Jihoon Kang3ca07a12024-12-02 19:14:30 +00001038
1039// prebuilt_vendor installs files in <partition>/vendor directory.
1040func PrebuiltVendorFactory() android.Module {
1041 module := &PrebuiltEtc{}
1042 InitPrebuiltEtcModule(module, "vendor")
1043 // This module is device-only
1044 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1045 android.InitDefaultableModule(module)
1046 return module
1047}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001048
1049// prebuilt_sbin installs files in <partition>/sbin directory.
1050func PrebuiltSbinFactory() android.Module {
1051 module := &PrebuiltEtc{}
1052 InitPrebuiltEtcModule(module, "sbin")
1053 // This module is device-only
1054 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1055 android.InitDefaultableModule(module)
1056 return module
1057}
1058
1059// prebuilt_system installs files in <partition>/system directory.
1060func PrebuiltSystemFactory() android.Module {
1061 module := &PrebuiltEtc{}
1062 InitPrebuiltEtcModule(module, "system")
1063 // This module is device-only
1064 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1065 android.InitDefaultableModule(module)
1066 return module
1067}
1068
1069// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1070func PrebuiltFirstStageRamdiskFactory() android.Module {
1071 module := &PrebuiltEtc{}
1072 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1073 // This module is device-only
1074 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1075 android.InitDefaultableModule(module)
1076 return module
1077}