blob: 68bffd4d19f56fed6344d63aa46e46e06ba5f4a0 [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
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800117 // 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 +1100118 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900119 Filename *string `android:"arch_variant"`
120
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800121 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900122 // is the same as the file name of the source file.
123 Filename_from_src *bool `android:"arch_variant"`
124
Yifan Hong1b3348d2020-01-21 15:53:22 -0800125 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700126 // On device without a dedicated recovery partition, the module is only
127 // available after switching root into
128 // /first_stage_ramdisk. To expose the module before switching root, install
129 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800130 Ramdisk_available *bool
131
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700132 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700133 // On device without a dedicated recovery partition, the module is only
134 // available after switching root into
135 // /first_stage_ramdisk. To expose the module before switching root, install
136 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700137 Vendor_ramdisk_available *bool
138
Inseob Kim08758f02021-04-08 21:13:22 +0900139 // Make this module available when building for debug ramdisk.
140 Debug_ramdisk_available *bool
141
Tao Bao0ba5c942018-08-14 22:20:22 -0700142 // Make this module available when building for recovery.
143 Recovery_available *bool
144
Jiyong Parkad9ce042018-10-31 22:49:57 +0900145 // Whether this module is directly installable to one of the partitions. Default: true.
146 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800147
148 // Install symlinks to the installed file.
149 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800150
Wei Li59586252024-11-04 09:25:54 -0800151 // Install to partition oem when set to true.
152 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900153}
154
Jihoon Kangf729d2e2025-03-12 22:24:52 +0000155// Dsts is useful in that it allows prebuilt_* modules to easily map the source files to the
156// install path within the partition. Dsts values are allowed to contain filepath separator
157// so that the source files can be installed in subdirectories within the partition.
158// However, this functionality should not be supported for prebuilt_root module type, as it
159// allows the module to install to any arbitrary location. Thus, this property is defined in
160// a separate struct so that it's not available to be set in prebuilt_root module type.
161type PrebuiltDstsProperties struct {
162 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
163 // set filename_from_src. This can be used to install each source file to a different directory
164 // and/or change filenames when files are installed. Must be exactly one entry per source file,
165 // which means care must be taken if srcs has globs.
166 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
167}
168
Inseob Kim27408bf2021-04-06 21:00:17 +0900169type prebuiltSubdirProperties struct {
170 // Optional subdirectory under which this file is installed into, cannot be specified with
171 // relative_install_path, prefer relative_install_path.
172 Sub_dir *string `android:"arch_variant"`
173
174 // Optional subdirectory under which this file is installed into, cannot be specified with
175 // sub_dir.
176 Relative_install_path *string `android:"arch_variant"`
177}
178
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900179type prebuiltRootProperties struct {
180 // Install this module to the root directory, without partition subdirs. When this module is
181 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
182 // then be copied to the root of system.img. When this module is packaged by other modules like
183 // android_filesystem, this module will be installed to the root ("/"), unlike normal
184 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
185 Install_in_root *bool
186}
187
Jooyung Han39edb6c2019-11-06 16:53:07 +0900188type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700189 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800190
191 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900192 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800193
194 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900195 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900196}
197
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900198type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700199 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000200 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900201
Jihoon Kang69725b32024-11-12 03:08:49 +0000202 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900203
Jihoon Kangf729d2e2025-03-12 22:24:52 +0000204 dstsProperties PrebuiltDstsProperties
205
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900206 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
207 // prebuilt_avb and prebuilt_root modules use this.
208 rootProperties prebuiltRootProperties
209
Inseob Kim27408bf2021-04-06 21:00:17 +0900210 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900211
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100212 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800213 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800214 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800215 installDirBase string
216 installDirBase64 string
217 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800218 // The base install location when soc_specific property is set to true, e.g. "firmware" for
219 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700220 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700221 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700222 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700223
Cole Faustfdec8722024-05-22 11:38:29 -0700224 usedSrcsProperty bool
225
Colin Crossf17e2b52023-10-30 15:17:25 -0700226 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900227}
228
Inseob Kim1e27a142021-05-06 11:46:11 +0000229type Defaults struct {
230 android.ModuleBase
231 android.DefaultsModuleBase
232}
233
Yifan Hong1b3348d2020-01-21 15:53:22 -0800234func (p *PrebuiltEtc) inRamdisk() bool {
235 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
236}
237
238func (p *PrebuiltEtc) onlyInRamdisk() bool {
239 return p.ModuleBase.InstallInRamdisk()
240}
241
242func (p *PrebuiltEtc) InstallInRamdisk() bool {
243 return p.inRamdisk()
244}
245
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700246func (p *PrebuiltEtc) inVendorRamdisk() bool {
247 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
248}
249
250func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
251 return p.ModuleBase.InstallInVendorRamdisk()
252}
253
254func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
255 return p.inVendorRamdisk()
256}
257
Inseob Kim08758f02021-04-08 21:13:22 +0900258func (p *PrebuiltEtc) inDebugRamdisk() bool {
259 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
260}
261
262func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
263 return p.ModuleBase.InstallInDebugRamdisk()
264}
265
266func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
267 return p.inDebugRamdisk()
268}
269
Kiyoung Kimae11c232021-07-19 11:38:04 +0900270func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800271 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700272}
273
274func (p *PrebuiltEtc) onlyInRecovery() bool {
275 return p.ModuleBase.InstallInRecovery()
276}
277
278func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900279 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700280}
281
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700282var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800283
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700284func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800285
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700286func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000287 return false
288}
289
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700290func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000291 return false
292}
293
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700294func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700295 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900296 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800297}
298
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700299func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700300 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800301}
302
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700303func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700304 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
305}
306
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700307func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900308 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
309}
310
Nelson Li1fb94b22024-07-09 17:04:52 +0800311func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900312 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800313}
314
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700315func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700316 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800317}
318
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700319func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800320 return nil
321}
322
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700323func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800324}
325
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700326func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700327 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100328 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
329 }
Cole Faustfdec8722024-05-22 11:38:29 -0700330 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900331}
332
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700333func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700334 if len(p.installDirPaths) != 1 {
335 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
336 }
337 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900338}
339
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900340// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
341// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700342func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900343 p.additionalDependencies = &paths
344}
345
Cole Faust4e9f5922024-11-13 16:09:23 -0800346func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700347 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100348 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
349 }
350 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900351}
352
353func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900354 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700355 return subDir
356 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900357 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900358}
359
Jooyung Han0703fd82020-08-26 22:11:53 +0900360func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900361 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900362}
363
Jiyong Parkad9ce042018-10-31 22:49:57 +0900364func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800365 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900366}
367
Kiyoung Kimae11c232021-07-19 11:38:04 +0900368func (p *PrebuiltEtc) InVendor() bool {
369 return p.ModuleBase.InstallInVendor()
370}
371
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100372func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800373 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
374 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900375 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700376 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
377 installBaseDir = p.installDirBase64
378 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900379 if p.SocSpecific() && p.socInstallDirBase != "" {
380 installBaseDir = p.socInstallDirBase
381 }
Colin Cross2f634572023-11-13 12:12:06 -0800382 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
383 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
384 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100385 return installBaseDir
386}
Colin Cross2f634572023-11-13 12:12:06 -0800387
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100388func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
389 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900390
Cole Faustfdec8722024-05-22 11:38:29 -0700391 srcProperty := p.properties.Src.Get(ctx)
392 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
393 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100394 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000395 }
Jihoon Kangf729d2e2025-03-12 22:24:52 +0000396 dstsProperty := p.dstsProperties.Dsts.GetOrDefault(ctx, nil)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700397 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
398 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
399 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100400
401 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
402 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
403 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
404 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700405 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800406 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000407 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800408 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
409 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100410
411 filename := proptools.String(p.properties.Filename)
412 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700413 if srcProperty.IsPresent() {
414 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100415 // If the source was not found, set a fake source path to
416 // support AllowMissingDependencies executions.
417 if len(p.sourceFilePaths) == 0 {
418 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
419 }
420
421 // Determine the output file basename.
422 // If Filename is set, use the name specified by the property.
423 // If Filename_from_src is set, use the source file name.
424 // Otherwise use the module name.
425 if filename != "" {
426 if filenameFromSrc {
427 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
428 return
429 }
430 } else if filenameFromSrc {
431 filename = p.sourceFilePaths[0].Base()
432 } else {
433 filename = ctx.ModuleName()
434 }
435 if strings.Contains(filename, "/") {
436 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
437 return
438 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800439 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100440
441 ip := installProperties{
442 filename: filename,
443 sourceFilePath: p.sourceFilePaths[0],
444 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700445 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100446 symlinks: p.properties.Symlinks,
447 }
448 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700449 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700450 } else if len(srcsProperty) > 0 {
451 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100452 if filename != "" {
453 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
454 }
455 if len(p.properties.Symlinks) > 0 {
456 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
457 }
458 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700459 if len(dstsProperty) > 0 {
460 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
461 } else {
462 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
463 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100464 }
Cole Faustfdec8722024-05-22 11:38:29 -0700465 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700466 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
467 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
468 }
469 for i, src := range p.sourceFilePaths {
470 var filename string
471 var installDirPath android.InstallPath
472
473 if len(dstsProperty) > 0 {
474 var dstdir string
475
476 dstdir, filename = filepath.Split(dstsProperty[i])
477 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
478 } else {
479 filename = src.Base()
480 installDirPath = baseInstallDirPath
481 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800482 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100483 ip := installProperties{
484 filename: filename,
485 sourceFilePath: src,
486 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700487 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100488 }
489 p.outputFilePaths = append(p.outputFilePaths, output)
490 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700491 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100492 }
493 } else if ctx.Config().AllowMissingDependencies() {
494 // If no srcs was set and AllowMissingDependencies is enabled then
495 // mark the module as missing dependencies and set a fake source path
496 // and file name.
497 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
498 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
499 if filename == "" {
500 filename = ctx.ModuleName()
501 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800502 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100503 ip := installProperties{
504 filename: filename,
505 sourceFilePath: p.sourceFilePaths[0],
506 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700507 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100508 }
509 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700510 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100511 } else {
512 ctx.PropertyErrorf("src", "missing prebuilt source file")
513 return
514 }
515
516 // Call InstallFile even when uninstallable to make the module included in the package.
517 if !p.Installable() {
518 p.SkipInstall()
519 }
520 for _, ip := range installs {
521 ip.addInstallRules(ctx)
522 }
mrziwang89371762024-06-11 12:42:24 -0700523
mrziwanga25adf32025-02-05 23:50:55 +0000524 p.updateModuleInfoJSON(ctx)
525
mrziwang89371762024-06-11 12:42:24 -0700526 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Yu Liu0a37d422025-02-13 02:05:00 +0000527
528 SetCommonPrebuiltEtcInfo(ctx, p)
529}
530
531func SetCommonPrebuiltEtcInfo(ctx android.ModuleContext, p PrebuiltEtcModule) {
532 android.SetProvider(ctx, PrebuiltEtcInfoProvider, PrebuiltEtcInfo{
533 BaseDir: p.BaseDir(),
534 SubDir: p.SubDir(),
535 })
Spandan Das756d3402023-06-05 22:49:50 +0000536}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900537
mrziwanga25adf32025-02-05 23:50:55 +0000538func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
539 moduleInfoJSON := ctx.ModuleInfoJSON()
540 moduleInfoJSON.Class = []string{"ETC"}
541 if p.makeClass != "" {
542 moduleInfoJSON.Class = []string{p.makeClass}
543 }
544 moduleInfoJSON.SystemSharedLibs = []string{"none"}
545 moduleInfoJSON.Tags = []string{"optional"}
546}
547
Spandan Das756d3402023-06-05 22:49:50 +0000548type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000549 filename string
550 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800551 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100552 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000553 symlinks []string
554}
555
556// utility function to add install rules to the build graph.
557// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100558func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000559 // Copy the file from src to a location in out/ with the correct `filename`
560 // This ensures that outputFilePath has the correct name for others to
561 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000562 ctx.Build(pctx, android.BuildParams{
563 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100564 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000565 Input: ip.sourceFilePath,
566 })
567
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100568 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000569 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100570 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900571 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900572}
573
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700574func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700575 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800576 if p.inRamdisk() && !p.onlyInRamdisk() {
577 nameSuffix = ".ramdisk"
578 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700579 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
580 nameSuffix = ".vendor_ramdisk"
581 }
Inseob Kim08758f02021-04-08 21:13:22 +0900582 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
583 nameSuffix = ".debug_ramdisk"
584 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900585 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700586 nameSuffix = ".recovery"
587 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700588
589 class := p.makeClass
590 if class == "" {
591 class = "ETC"
592 }
593
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100594 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700595 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700596 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100597 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700598 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700599 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700600 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700601 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100602 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800603 if len(p.properties.Symlinks) > 0 {
604 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
605 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800606 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700607 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800608 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900609 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700610 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900611 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900612 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900613}
614
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000615func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
616 return &p.ModuleBase
617}
618
Jooyung Hana0171822019-07-22 15:48:36 +0900619func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
620 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900621 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900622 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000623 p.AddProperties(&p.rootProperties)
Jihoon Kangf729d2e2025-03-12 22:24:52 +0000624 p.AddProperties(&p.dstsProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900625}
626
627func InitPrebuiltRootModule(p *PrebuiltEtc) {
628 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800629 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900630 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800631}
632
633func InitPrebuiltAvbModule(p *PrebuiltEtc) {
634 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900635 p.AddProperties(&p.properties)
Jihoon Kangf729d2e2025-03-12 22:24:52 +0000636 p.AddProperties(&p.dstsProperties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900637 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900638}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900639
Patrice Arruda9e14b962019-03-11 15:58:50 -0700640// prebuilt_etc is for a prebuilt artifact that is installed in
641// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700642func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900643 module := &PrebuiltEtc{}
644 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900645 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700646 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000647 android.InitDefaultableModule(module)
648 return module
649}
650
651func defaultsFactory() android.Module {
652 return DefaultsFactory()
653}
654
655func DefaultsFactory(props ...interface{}) android.Module {
656 module := &Defaults{}
657
658 module.AddProperties(props...)
659 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000660 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000661 &prebuiltSubdirProperties{},
662 )
663
664 android.InitDefaultsModule(module)
665
Jiyong Parkc678ad32018-04-10 13:07:10 +0900666 return module
667}
Tao Bao0ba5c942018-08-14 22:20:22 -0700668
Patrice Arruda9e14b962019-03-11 15:58:50 -0700669// prebuilt_etc_host is for a host prebuilt artifact that is installed in
670// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700671func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900672 module := &PrebuiltEtc{}
673 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800674 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700675 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100676 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800677 return module
678}
679
Jihoon Kang002767b2025-03-12 22:14:39 +0000680// prebuilt_any is a special module where the module can define the subdirectory that the files
681// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
682// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
683// modules allow installing the file at the desired location, introduce a new prebuilt_* module
684// type instead.
685func PrebuiltAnyFactory() android.Module {
686 module := &PrebuiltEtc{}
687 InitPrebuiltEtcModule(module, ".")
688 // This module is device-only
689 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
690 android.InitDefaultableModule(module)
691 return module
692}
693
Miguel32b02802022-12-01 18:38:26 +0000694// prebuilt_etc_host is for a host prebuilt artifact that is installed in
695// <partition>/etc/<sub_dir> directory.
696func PrebuiltEtcCaCertsFactory() android.Module {
697 module := &PrebuiltEtc{}
698 InitPrebuiltEtcModule(module, "cacerts")
699 // This module is device-only
700 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000701 return module
702}
703
Nelson Li1fb94b22024-07-09 17:04:52 +0800704// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
705// `prebuilt_avb` will not have a `system` subdirectory.
706// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
707// root directory of the partition: <partition_root>/avb.
708// prebuilt_avb does not allow adding any other subdirectories.
709func PrebuiltAvbFactory() android.Module {
710 module := &PrebuiltEtc{}
711 InitPrebuiltAvbModule(module)
712 // This module is device-only
713 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
714 android.InitDefaultableModule(module)
715 return module
716}
717
Inseob Kim27408bf2021-04-06 21:00:17 +0900718// prebuilt_root is for a prebuilt artifact that is installed in
719// <partition>/ directory. Can't have any sub directories.
720func PrebuiltRootFactory() android.Module {
721 module := &PrebuiltEtc{}
722 InitPrebuiltRootModule(module)
723 // This module is device-only
724 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100725 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900726 return module
727}
728
Liz Kammere9ecddc2022-01-04 17:27:52 -0500729// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
730// directory.
731func PrebuiltRootHostFactory() android.Module {
732 module := &PrebuiltEtc{}
733 InitPrebuiltEtcModule(module, ".")
734 // This module is host-only
735 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
736 android.InitDefaultableModule(module)
737 return module
738}
739
Patrice Arruda9e14b962019-03-11 15:58:50 -0700740// prebuilt_usr_share is for a prebuilt artifact that is installed in
741// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700742func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900743 module := &PrebuiltEtc{}
744 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800745 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700746 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100747 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800748 return module
749}
750
Patrice Arruda9e14b962019-03-11 15:58:50 -0700751// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
752// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700753func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900754 module := &PrebuiltEtc{}
755 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800756 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700757 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100758 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800759 return module
760}
761
yangbill63c5e192024-03-27 09:02:12 +0000762// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
763// <partition>/usr/hyphen-data/<sub_dir> directory.
764func PrebuiltUserHyphenDataFactory() android.Module {
765 module := &PrebuiltEtc{}
766 InitPrebuiltEtcModule(module, "usr/hyphen-data")
767 // This module is device-only
768 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
769 android.InitDefaultableModule(module)
770 return module
771}
772
yangbill85527e62024-04-30 08:24:50 +0000773// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
774// <partition>/usr/keylayout/<sub_dir> directory.
775func PrebuiltUserKeyLayoutFactory() android.Module {
776 module := &PrebuiltEtc{}
777 InitPrebuiltEtcModule(module, "usr/keylayout")
778 // This module is device-only
779 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
780 android.InitDefaultableModule(module)
781 return module
782}
783
784// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
785// <partition>/usr/keychars/<sub_dir> directory.
786func PrebuiltUserKeyCharsFactory() android.Module {
787 module := &PrebuiltEtc{}
788 InitPrebuiltEtcModule(module, "usr/keychars")
789 // This module is device-only
790 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
791 android.InitDefaultableModule(module)
792 return module
793}
794
795// prebuilt_usr_idc is for a prebuilt artifact that is installed in
796// <partition>/usr/idc/<sub_dir> directory.
797func PrebuiltUserIdcFactory() android.Module {
798 module := &PrebuiltEtc{}
799 InitPrebuiltEtcModule(module, "usr/idc")
800 // This module is device-only
801 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
802 android.InitDefaultableModule(module)
803 return module
804}
805
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000806// prebuilt_usr_srec is for a prebuilt artifact that is installed in
807// <partition>/usr/srec/<sub_dir> directory.
808func PrebuiltUserSrecFactory() android.Module {
809 module := &PrebuiltEtc{}
810 InitPrebuiltEtcModule(module, "usr/srec")
811 // This module is device-only
812 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
813 android.InitDefaultableModule(module)
814 return module
815}
816
Agi Sferro243c7d72025-02-24 15:45:53 -0800817// prebuilt_usr_odml is for a prebuilt artifact that is installed in
818// <partition>/usr/odml/<sub_dir> directory.
819func PrebuiltUserOdmlFactory() android.Module {
820 module := &PrebuiltEtc{}
821 InitPrebuiltEtcModule(module, "usr/odml")
822 // This module is device-only
823 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
824 android.InitDefaultableModule(module)
825 return module
826}
827
Patrice Arruda61583eb2019-05-14 08:20:45 -0700828// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700829func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900830 module := &PrebuiltEtc{}
831 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700832 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700833 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100834 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700835 return module
836}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700837
Kevin93f7cd82024-05-02 12:37:59 +0200838// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
839func PrebuiltOverlayFactory() android.Module {
840 module := &PrebuiltEtc{}
841 InitPrebuiltEtcModule(module, "overlay")
842 // This module is device-only
843 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
844 return module
845}
846
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800847// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
848// image.
849// If soc_specific property is set to true, the firmware file is installed to the
850// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700851func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900852 module := &PrebuiltEtc{}
853 module.socInstallDirBase = "firmware"
854 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700855 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700856 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100857 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700858 return module
859}
Patrice Arruda0f688002020-06-08 21:40:25 +0000860
861// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800862// If soc_specific property is set to true, the DSP related file is installed to the
863// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000864func PrebuiltDSPFactory() android.Module {
865 module := &PrebuiltEtc{}
866 module.socInstallDirBase = "dsp"
867 InitPrebuiltEtcModule(module, "etc/dsp")
868 // This module is device-only
869 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100870 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000871 return module
872}
Colin Cross83ebf232021-04-09 09:41:23 -0700873
Colin Crossf17e2b52023-10-30 15:17:25 -0700874// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
875func PrebuiltRenderScriptBitcodeFactory() android.Module {
876 module := &PrebuiltEtc{}
877 module.makeClass = "RENDERSCRIPT_BITCODE"
878 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800879 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700880 InitPrebuiltEtcModule(module, "lib")
881 // This module is device-only
882 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
883 android.InitDefaultableModule(module)
884 return module
885}
886
Colin Cross83ebf232021-04-09 09:41:23 -0700887// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
888// to the <partition>/lib/rfsa directory.
889func PrebuiltRFSAFactory() android.Module {
890 module := &PrebuiltEtc{}
891 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
892 // many places outside of the application processor. They could be moved to /vendor/dsp once
893 // that is cleaned up.
894 InitPrebuiltEtcModule(module, "lib/rfsa")
895 // This module is device-only
896 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100897 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700898 return module
899}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000900
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000901// prebuilt_media installs media files in <partition>/media directory.
902func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000903 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000904 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000905 // This module is device-only
906 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
907 android.InitDefaultableModule(module)
908 return module
909}
Jihoon Kangec62d842024-10-25 20:27:18 +0000910
911// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
912func PrebuiltVoicepackFactory() android.Module {
913 module := &PrebuiltEtc{}
914 InitPrebuiltEtcModule(module, "tts")
915 // This module is device-only
916 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
917 android.InitDefaultableModule(module)
918 return module
919}
920
921// prebuilt_bin installs files in <partition>/bin directory.
922func PrebuiltBinaryFactory() android.Module {
923 module := &PrebuiltEtc{}
924 InitPrebuiltEtcModule(module, "bin")
925 // This module is device-only
926 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
927 android.InitDefaultableModule(module)
928 return module
929}
930
931// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
932func PrebuiltWallpaperFactory() android.Module {
933 module := &PrebuiltEtc{}
934 InitPrebuiltEtcModule(module, "wallpaper")
935 // This module is device-only
936 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
937 android.InitDefaultableModule(module)
938 return module
939}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000940
941// prebuilt_priv_app installs files in <partition>/priv-app directory.
942func PrebuiltPrivAppFactory() android.Module {
943 module := &PrebuiltEtc{}
944 InitPrebuiltEtcModule(module, "priv-app")
945 // This module is device-only
946 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
947 android.InitDefaultableModule(module)
948 return module
949}
950
951// prebuilt_rfs installs files in <partition>/rfs directory.
952func PrebuiltRfsFactory() android.Module {
953 module := &PrebuiltEtc{}
954 InitPrebuiltEtcModule(module, "rfs")
955 // This module is device-only
956 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
957 android.InitDefaultableModule(module)
958 return module
959}
960
961// prebuilt_framework installs files in <partition>/framework directory.
962func PrebuiltFrameworkFactory() android.Module {
963 module := &PrebuiltEtc{}
964 InitPrebuiltEtcModule(module, "framework")
965 // This module is device-only
966 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
967 android.InitDefaultableModule(module)
968 return module
969}
970
971// prebuilt_res installs files in <partition>/res directory.
972func PrebuiltResFactory() android.Module {
973 module := &PrebuiltEtc{}
974 InitPrebuiltEtcModule(module, "res")
975 // This module is device-only
976 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
977 android.InitDefaultableModule(module)
978 return module
979}
980
981// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
982func PrebuiltWlcUptFactory() android.Module {
983 module := &PrebuiltEtc{}
984 InitPrebuiltEtcModule(module, "wlc_upt")
985 // This module is device-only
986 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
987 android.InitDefaultableModule(module)
988 return module
989}
990
991// prebuilt_odm installs files in <partition>/odm directory.
992func PrebuiltOdmFactory() android.Module {
993 module := &PrebuiltEtc{}
994 InitPrebuiltEtcModule(module, "odm")
995 // This module is device-only
996 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
997 android.InitDefaultableModule(module)
998 return module
999}
Jihoon Kang2e2b7442024-11-05 00:26:20 +00001000
1001// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
1002func PrebuiltVendorDlkmFactory() android.Module {
1003 module := &PrebuiltEtc{}
1004 InitPrebuiltEtcModule(module, "vendor_dlkm")
1005 // This module is device-only
1006 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1007 android.InitDefaultableModule(module)
1008 return module
1009}
1010
1011// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
1012func PrebuiltBtFirmwareFactory() android.Module {
1013 module := &PrebuiltEtc{}
1014 InitPrebuiltEtcModule(module, "bt_firmware")
1015 // This module is device-only
1016 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1017 android.InitDefaultableModule(module)
1018 return module
1019}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +00001020
1021// prebuilt_tvservice installs files in <partition>/tvservice directory.
1022func PrebuiltTvServiceFactory() android.Module {
1023 module := &PrebuiltEtc{}
1024 InitPrebuiltEtcModule(module, "tvservice")
1025 // This module is device-only
1026 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1027 android.InitDefaultableModule(module)
1028 return module
1029}
1030
1031// prebuilt_optee installs files in <partition>/optee directory.
1032func PrebuiltOpteeFactory() android.Module {
1033 module := &PrebuiltEtc{}
1034 InitPrebuiltEtcModule(module, "optee")
1035 // This module is device-only
1036 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1037 android.InitDefaultableModule(module)
1038 return module
1039}
Jihoon Kangecf76dd2024-11-12 05:24:46 +00001040
1041// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
1042func PrebuiltTvConfigFactory() android.Module {
1043 module := &PrebuiltEtc{}
1044 InitPrebuiltEtcModule(module, "tvconfig")
1045 // This module is device-only
1046 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1047 android.InitDefaultableModule(module)
1048 return module
1049}
Jihoon Kang3ca07a12024-12-02 19:14:30 +00001050
1051// prebuilt_vendor installs files in <partition>/vendor directory.
1052func PrebuiltVendorFactory() android.Module {
1053 module := &PrebuiltEtc{}
1054 InitPrebuiltEtcModule(module, "vendor")
1055 // This module is device-only
1056 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1057 android.InitDefaultableModule(module)
1058 return module
1059}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001060
1061// prebuilt_sbin installs files in <partition>/sbin directory.
1062func PrebuiltSbinFactory() android.Module {
1063 module := &PrebuiltEtc{}
1064 InitPrebuiltEtcModule(module, "sbin")
1065 // This module is device-only
1066 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1067 android.InitDefaultableModule(module)
1068 return module
1069}
1070
1071// prebuilt_system installs files in <partition>/system directory.
1072func PrebuiltSystemFactory() android.Module {
1073 module := &PrebuiltEtc{}
1074 InitPrebuiltEtcModule(module, "system")
1075 // This module is device-only
1076 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1077 android.InitDefaultableModule(module)
1078 return module
1079}
1080
1081// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1082func PrebuiltFirstStageRamdiskFactory() android.Module {
1083 module := &PrebuiltEtc{}
1084 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1085 // This module is device-only
1086 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1087 android.InitDefaultableModule(module)
1088 return module
1089}