blob: e6d50cc7a001977a14b85f36452f1c8ffcd8f719 [file] [log] [blame]
Jiyong Parkc678ad32018-04-10 13:07:10 +09001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Jaewoong Jung4b79e982020-06-01 10:45:49 -070015package etc
Jiyong Parkc678ad32018-04-10 13:07:10 +090016
Yo Chiang803c40d2020-11-16 20:32:51 +080017// This file implements module types that install prebuilt artifacts.
18//
19// There exist two classes of prebuilt modules in the Android tree. The first class are the ones
20// based on `android.Prebuilt`, such as `cc_prebuilt_library` and `java_import`. This kind of
21// modules may exist both as prebuilts and source at the same time, though only one would be
22// installed and the other would be marked disabled. The `prebuilt_postdeps` mutator would select
23// the actual modules to be installed. More details in android/prebuilt.go.
24//
25// The second class is described in this file. Unlike `android.Prebuilt` based module types,
26// `prebuilt_etc` exist only as prebuilts and cannot have a same-named source module counterpart.
27// This makes the logic of `prebuilt_etc` to be much simpler as they don't need to go through the
28// various `prebuilt_*` mutators.
Jaewoong Jung4b79e982020-06-01 10:45:49 -070029
Yo Chiang803c40d2020-11-16 20:32:51 +080030import (
Jiyong Park76a42f52021-02-16 06:50:37 +090031 "fmt"
Kiyoung Kimae11c232021-07-19 11:38:04 +090032 "path/filepath"
Inseob Kim27408bf2021-04-06 21:00:17 +090033 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090034
Jaewoong Jung4b79e982020-06-01 10:45:49 -070035 "github.com/google/blueprint/proptools"
36
37 "android/soong/android"
38)
39
40var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090041
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080042// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090043
44func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070045 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090046 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
47}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070048
Jooyung Han0703fd82020-08-26 22:11:53 +090049func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
50 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
51 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000052 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Nelson Li1fb94b22024-07-09 17:04:52 +080053 ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090054 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050055 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090056 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
57 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
yangbill63c5e192024-03-27 09:02:12 +000058 ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory)
yangbill85527e62024-04-30 08:24:50 +000059 ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory)
60 ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory)
61 ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000062 ctx.RegisterModuleType("prebuilt_usr_srec", PrebuiltUserSrecFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090063 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020064 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090065 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
66 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070067 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070068 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000069 ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory)
Jihoon Kangec62d842024-10-25 20:27:18 +000070 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
71 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
72 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000073 ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory)
74 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
75 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
76 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
77 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
78 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000079 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
80 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000081 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
82 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Jihoon Kangecf76dd2024-11-12 05:24:46 +000083 ctx.RegisterModuleType("prebuilt_tvconfig", PrebuiltTvConfigFactory)
Jihoon Kang3ca07a12024-12-02 19:14:30 +000084 ctx.RegisterModuleType("prebuilt_vendor", PrebuiltVendorFactory)
Jihoon Kang320ca7c2024-12-03 18:14:50 +000085 ctx.RegisterModuleType("prebuilt_sbin", PrebuiltSbinFactory)
86 ctx.RegisterModuleType("prebuilt_system", PrebuiltSystemFactory)
87 ctx.RegisterModuleType("prebuilt_first_stage_ramdisk", PrebuiltFirstStageRamdiskFactory)
Jihoon Kang3e149662025-03-12 22:14:39 +000088 ctx.RegisterModuleType("prebuilt_any", PrebuiltAnyFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000089
90 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040091
Jiyong Parkc678ad32018-04-10 13:07:10 +090092}
93
Paul Duffin1172fed2021-03-08 11:28:18 +000094var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
95
Jihoon Kang69725b32024-11-12 03:08:49 +000096type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080097 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110098 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070099 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900100
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100101 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700102 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
103 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700104 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100105
Douglas Anderson79688ff2024-09-27 15:08:33 -0700106 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
107 // set filename_from_src. This can be used to install each source file to a different directory
108 // and/or change filenames when files are installed. Must be exactly one entry per source file,
109 // which means care must be taken if srcs has globs.
110 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
111
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800112 // 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 +1100113 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900114 Filename *string `android:"arch_variant"`
115
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800116 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900117 // is the same as the file name of the source file.
118 Filename_from_src *bool `android:"arch_variant"`
119
Yifan Hong1b3348d2020-01-21 15:53:22 -0800120 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700121 // On device without a dedicated recovery partition, the module is only
122 // available after switching root into
123 // /first_stage_ramdisk. To expose the module before switching root, install
124 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800125 Ramdisk_available *bool
126
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700127 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700128 // On device without a dedicated recovery partition, the module is only
129 // available after switching root into
130 // /first_stage_ramdisk. To expose the module before switching root, install
131 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700132 Vendor_ramdisk_available *bool
133
Inseob Kim08758f02021-04-08 21:13:22 +0900134 // Make this module available when building for debug ramdisk.
135 Debug_ramdisk_available *bool
136
Tao Bao0ba5c942018-08-14 22:20:22 -0700137 // Make this module available when building for recovery.
138 Recovery_available *bool
139
Jiyong Parkad9ce042018-10-31 22:49:57 +0900140 // Whether this module is directly installable to one of the partitions. Default: true.
141 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800142
143 // Install symlinks to the installed file.
144 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800145
Wei Li59586252024-11-04 09:25:54 -0800146 // Install to partition oem when set to true.
147 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900148}
149
Inseob Kim27408bf2021-04-06 21:00:17 +0900150type prebuiltSubdirProperties struct {
151 // Optional subdirectory under which this file is installed into, cannot be specified with
152 // relative_install_path, prefer relative_install_path.
153 Sub_dir *string `android:"arch_variant"`
154
155 // Optional subdirectory under which this file is installed into, cannot be specified with
156 // sub_dir.
157 Relative_install_path *string `android:"arch_variant"`
158}
159
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900160type prebuiltRootProperties struct {
161 // Install this module to the root directory, without partition subdirs. When this module is
162 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
163 // then be copied to the root of system.img. When this module is packaged by other modules like
164 // android_filesystem, this module will be installed to the root ("/"), unlike normal
165 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
166 Install_in_root *bool
167}
168
Jooyung Han39edb6c2019-11-06 16:53:07 +0900169type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700170 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800171
172 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900173 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800174
175 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900176 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900177}
178
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900179type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700180 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000181 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900182
Jihoon Kang69725b32024-11-12 03:08:49 +0000183 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900184
185 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
186 // prebuilt_avb and prebuilt_root modules use this.
187 rootProperties prebuiltRootProperties
188
Inseob Kim27408bf2021-04-06 21:00:17 +0900189 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900190
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100191 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800192 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800193 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800194 installDirBase string
195 installDirBase64 string
196 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800197 // The base install location when soc_specific property is set to true, e.g. "firmware" for
198 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700199 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700200 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700201 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700202
Cole Faustfdec8722024-05-22 11:38:29 -0700203 usedSrcsProperty bool
204
Colin Crossf17e2b52023-10-30 15:17:25 -0700205 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900206}
207
Inseob Kim1e27a142021-05-06 11:46:11 +0000208type Defaults struct {
209 android.ModuleBase
210 android.DefaultsModuleBase
211}
212
Yifan Hong1b3348d2020-01-21 15:53:22 -0800213func (p *PrebuiltEtc) inRamdisk() bool {
214 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
215}
216
217func (p *PrebuiltEtc) onlyInRamdisk() bool {
218 return p.ModuleBase.InstallInRamdisk()
219}
220
221func (p *PrebuiltEtc) InstallInRamdisk() bool {
222 return p.inRamdisk()
223}
224
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700225func (p *PrebuiltEtc) inVendorRamdisk() bool {
226 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
227}
228
229func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
230 return p.ModuleBase.InstallInVendorRamdisk()
231}
232
233func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
234 return p.inVendorRamdisk()
235}
236
Inseob Kim08758f02021-04-08 21:13:22 +0900237func (p *PrebuiltEtc) inDebugRamdisk() bool {
238 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
239}
240
241func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
242 return p.ModuleBase.InstallInDebugRamdisk()
243}
244
245func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
246 return p.inDebugRamdisk()
247}
248
Kiyoung Kimae11c232021-07-19 11:38:04 +0900249func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800250 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700251}
252
253func (p *PrebuiltEtc) onlyInRecovery() bool {
254 return p.ModuleBase.InstallInRecovery()
255}
256
257func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900258 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700259}
260
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700261var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800262
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700263func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800264
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700265func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000266 return false
267}
268
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700269func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000270 return false
271}
272
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700273func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700274 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900275 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800276}
277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700279 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800280}
281
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700282func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700283 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
284}
285
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700286func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900287 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
288}
289
Nelson Li1fb94b22024-07-09 17:04:52 +0800290func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900291 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800292}
293
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700294func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700295 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800296}
297
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700298func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800299 return nil
300}
301
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700302func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800303}
304
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700305func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700306 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100307 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
308 }
Cole Faustfdec8722024-05-22 11:38:29 -0700309 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900310}
311
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700312func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700313 if len(p.installDirPaths) != 1 {
314 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
315 }
316 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900317}
318
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900319// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
320// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700321func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900322 p.additionalDependencies = &paths
323}
324
Cole Faust4e9f5922024-11-13 16:09:23 -0800325func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700326 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100327 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
328 }
329 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900330}
331
332func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900333 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700334 return subDir
335 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900336 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900337}
338
Jooyung Han0703fd82020-08-26 22:11:53 +0900339func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900340 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900341}
342
Jiyong Parkad9ce042018-10-31 22:49:57 +0900343func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800344 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900345}
346
Kiyoung Kimae11c232021-07-19 11:38:04 +0900347func (p *PrebuiltEtc) InVendor() bool {
348 return p.ModuleBase.InstallInVendor()
349}
350
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100351func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800352 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
353 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900354 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700355 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
356 installBaseDir = p.installDirBase64
357 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900358 if p.SocSpecific() && p.socInstallDirBase != "" {
359 installBaseDir = p.socInstallDirBase
360 }
Colin Cross2f634572023-11-13 12:12:06 -0800361 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
362 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
363 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100364 return installBaseDir
365}
Colin Cross2f634572023-11-13 12:12:06 -0800366
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100367func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
368 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900369
Cole Faustfdec8722024-05-22 11:38:29 -0700370 srcProperty := p.properties.Src.Get(ctx)
371 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
372 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100373 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000374 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700375 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
376 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
377 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
378 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100379
380 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
381 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
382 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
383 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700384 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800385 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000386 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800387 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
388 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100389
390 filename := proptools.String(p.properties.Filename)
391 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700392 if srcProperty.IsPresent() {
393 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100394 // If the source was not found, set a fake source path to
395 // support AllowMissingDependencies executions.
396 if len(p.sourceFilePaths) == 0 {
397 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
398 }
399
400 // Determine the output file basename.
401 // If Filename is set, use the name specified by the property.
402 // If Filename_from_src is set, use the source file name.
403 // Otherwise use the module name.
404 if filename != "" {
405 if filenameFromSrc {
406 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
407 return
408 }
409 } else if filenameFromSrc {
410 filename = p.sourceFilePaths[0].Base()
411 } else {
412 filename = ctx.ModuleName()
413 }
414 if strings.Contains(filename, "/") {
415 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
416 return
417 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800418 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100419
420 ip := installProperties{
421 filename: filename,
422 sourceFilePath: p.sourceFilePaths[0],
423 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700424 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100425 symlinks: p.properties.Symlinks,
426 }
427 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700428 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700429 } else if len(srcsProperty) > 0 {
430 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100431 if filename != "" {
432 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
433 }
434 if len(p.properties.Symlinks) > 0 {
435 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
436 }
437 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700438 if len(dstsProperty) > 0 {
439 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
440 } else {
441 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
442 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100443 }
Cole Faustfdec8722024-05-22 11:38:29 -0700444 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700445 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
446 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
447 }
448 for i, src := range p.sourceFilePaths {
449 var filename string
450 var installDirPath android.InstallPath
451
452 if len(dstsProperty) > 0 {
453 var dstdir string
454
455 dstdir, filename = filepath.Split(dstsProperty[i])
456 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
457 } else {
458 filename = src.Base()
459 installDirPath = baseInstallDirPath
460 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800461 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100462 ip := installProperties{
463 filename: filename,
464 sourceFilePath: src,
465 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700466 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100467 }
468 p.outputFilePaths = append(p.outputFilePaths, output)
469 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700470 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100471 }
472 } else if ctx.Config().AllowMissingDependencies() {
473 // If no srcs was set and AllowMissingDependencies is enabled then
474 // mark the module as missing dependencies and set a fake source path
475 // and file name.
476 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
477 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
478 if filename == "" {
479 filename = ctx.ModuleName()
480 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800481 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100482 ip := installProperties{
483 filename: filename,
484 sourceFilePath: p.sourceFilePaths[0],
485 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700486 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100487 }
488 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700489 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100490 } else {
491 ctx.PropertyErrorf("src", "missing prebuilt source file")
492 return
493 }
494
495 // Call InstallFile even when uninstallable to make the module included in the package.
496 if !p.Installable() {
497 p.SkipInstall()
498 }
499 for _, ip := range installs {
500 ip.addInstallRules(ctx)
501 }
mrziwang89371762024-06-11 12:42:24 -0700502
503 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000504}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900505
Spandan Das756d3402023-06-05 22:49:50 +0000506type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000507 filename string
508 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800509 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100510 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000511 symlinks []string
512}
513
514// utility function to add install rules to the build graph.
515// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100516func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000517 // Copy the file from src to a location in out/ with the correct `filename`
518 // This ensures that outputFilePath has the correct name for others to
519 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000520 ctx.Build(pctx, android.BuildParams{
521 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100522 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000523 Input: ip.sourceFilePath,
524 })
525
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100526 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000527 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100528 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900529 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900530}
531
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700532func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700533 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800534 if p.inRamdisk() && !p.onlyInRamdisk() {
535 nameSuffix = ".ramdisk"
536 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700537 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
538 nameSuffix = ".vendor_ramdisk"
539 }
Inseob Kim08758f02021-04-08 21:13:22 +0900540 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
541 nameSuffix = ".debug_ramdisk"
542 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900543 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700544 nameSuffix = ".recovery"
545 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700546
547 class := p.makeClass
548 if class == "" {
549 class = "ETC"
550 }
551
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100552 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700553 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700554 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100555 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700556 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700557 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700558 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700559 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100560 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800561 if len(p.properties.Symlinks) > 0 {
562 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
563 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800564 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700565 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800566 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900567 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700568 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900569 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900570 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900571}
572
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000573func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
574 return &p.ModuleBase
575}
576
Jooyung Hana0171822019-07-22 15:48:36 +0900577func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
578 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900579 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900580 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000581 p.AddProperties(&p.rootProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900582}
583
584func InitPrebuiltRootModule(p *PrebuiltEtc) {
585 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800586 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900587 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800588}
589
590func InitPrebuiltAvbModule(p *PrebuiltEtc) {
591 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900592 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900593 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900594}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900595
Patrice Arruda9e14b962019-03-11 15:58:50 -0700596// prebuilt_etc is for a prebuilt artifact that is installed in
597// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700598func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900599 module := &PrebuiltEtc{}
600 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900601 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700602 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000603 android.InitDefaultableModule(module)
604 return module
605}
606
607func defaultsFactory() android.Module {
608 return DefaultsFactory()
609}
610
611func DefaultsFactory(props ...interface{}) android.Module {
612 module := &Defaults{}
613
614 module.AddProperties(props...)
615 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000616 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000617 &prebuiltSubdirProperties{},
618 )
619
620 android.InitDefaultsModule(module)
621
Jiyong Parkc678ad32018-04-10 13:07:10 +0900622 return module
623}
Tao Bao0ba5c942018-08-14 22:20:22 -0700624
Patrice Arruda9e14b962019-03-11 15:58:50 -0700625// prebuilt_etc_host is for a host prebuilt artifact that is installed in
626// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700627func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900628 module := &PrebuiltEtc{}
629 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800630 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700631 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100632 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800633 return module
634}
635
Jihoon Kang3e149662025-03-12 22:14:39 +0000636// prebuilt_any is a special module where the module can define the subdirectory that the files
637// are installed to. This is only used for converting the PRODUCT_COPY_FILES entries to Soong
638// modules, and should never be defined in the bp files. If none of the existing prebuilt_*
639// modules allow installing the file at the desired location, introduce a new prebuilt_* module
640// type instead.
641func PrebuiltAnyFactory() android.Module {
642 module := &PrebuiltEtc{}
643 InitPrebuiltEtcModule(module, ".")
644 // This module is device-only
645 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
646 android.InitDefaultableModule(module)
647 return module
648}
649
Miguel32b02802022-12-01 18:38:26 +0000650// prebuilt_etc_host is for a host prebuilt artifact that is installed in
651// <partition>/etc/<sub_dir> directory.
652func PrebuiltEtcCaCertsFactory() android.Module {
653 module := &PrebuiltEtc{}
654 InitPrebuiltEtcModule(module, "cacerts")
655 // This module is device-only
656 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000657 return module
658}
659
Nelson Li1fb94b22024-07-09 17:04:52 +0800660// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
661// `prebuilt_avb` will not have a `system` subdirectory.
662// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
663// root directory of the partition: <partition_root>/avb.
664// prebuilt_avb does not allow adding any other subdirectories.
665func PrebuiltAvbFactory() android.Module {
666 module := &PrebuiltEtc{}
667 InitPrebuiltAvbModule(module)
668 // This module is device-only
669 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
670 android.InitDefaultableModule(module)
671 return module
672}
673
Inseob Kim27408bf2021-04-06 21:00:17 +0900674// prebuilt_root is for a prebuilt artifact that is installed in
675// <partition>/ directory. Can't have any sub directories.
676func PrebuiltRootFactory() android.Module {
677 module := &PrebuiltEtc{}
678 InitPrebuiltRootModule(module)
679 // This module is device-only
680 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100681 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900682 return module
683}
684
Liz Kammere9ecddc2022-01-04 17:27:52 -0500685// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
686// directory.
687func PrebuiltRootHostFactory() android.Module {
688 module := &PrebuiltEtc{}
689 InitPrebuiltEtcModule(module, ".")
690 // This module is host-only
691 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
692 android.InitDefaultableModule(module)
693 return module
694}
695
Patrice Arruda9e14b962019-03-11 15:58:50 -0700696// prebuilt_usr_share is for a prebuilt artifact that is installed in
697// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700698func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900699 module := &PrebuiltEtc{}
700 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800701 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700702 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100703 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800704 return module
705}
706
Patrice Arruda9e14b962019-03-11 15:58:50 -0700707// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
708// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700709func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900710 module := &PrebuiltEtc{}
711 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800712 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700713 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100714 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800715 return module
716}
717
yangbill63c5e192024-03-27 09:02:12 +0000718// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
719// <partition>/usr/hyphen-data/<sub_dir> directory.
720func PrebuiltUserHyphenDataFactory() android.Module {
721 module := &PrebuiltEtc{}
722 InitPrebuiltEtcModule(module, "usr/hyphen-data")
723 // This module is device-only
724 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
725 android.InitDefaultableModule(module)
726 return module
727}
728
yangbill85527e62024-04-30 08:24:50 +0000729// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
730// <partition>/usr/keylayout/<sub_dir> directory.
731func PrebuiltUserKeyLayoutFactory() android.Module {
732 module := &PrebuiltEtc{}
733 InitPrebuiltEtcModule(module, "usr/keylayout")
734 // This module is device-only
735 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
736 android.InitDefaultableModule(module)
737 return module
738}
739
740// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
741// <partition>/usr/keychars/<sub_dir> directory.
742func PrebuiltUserKeyCharsFactory() android.Module {
743 module := &PrebuiltEtc{}
744 InitPrebuiltEtcModule(module, "usr/keychars")
745 // This module is device-only
746 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
747 android.InitDefaultableModule(module)
748 return module
749}
750
751// prebuilt_usr_idc is for a prebuilt artifact that is installed in
752// <partition>/usr/idc/<sub_dir> directory.
753func PrebuiltUserIdcFactory() android.Module {
754 module := &PrebuiltEtc{}
755 InitPrebuiltEtcModule(module, "usr/idc")
756 // This module is device-only
757 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
758 android.InitDefaultableModule(module)
759 return module
760}
761
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000762// prebuilt_usr_srec is for a prebuilt artifact that is installed in
763// <partition>/usr/srec/<sub_dir> directory.
764func PrebuiltUserSrecFactory() android.Module {
765 module := &PrebuiltEtc{}
766 InitPrebuiltEtcModule(module, "usr/srec")
767 // This module is device-only
768 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
769 android.InitDefaultableModule(module)
770 return module
771}
772
Patrice Arruda61583eb2019-05-14 08:20:45 -0700773// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700774func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900775 module := &PrebuiltEtc{}
776 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700777 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700778 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100779 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700780 return module
781}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700782
Kevin93f7cd82024-05-02 12:37:59 +0200783// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
784func PrebuiltOverlayFactory() android.Module {
785 module := &PrebuiltEtc{}
786 InitPrebuiltEtcModule(module, "overlay")
787 // This module is device-only
788 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
789 return module
790}
791
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800792// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
793// image.
794// If soc_specific property is set to true, the firmware file is installed to the
795// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700796func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900797 module := &PrebuiltEtc{}
798 module.socInstallDirBase = "firmware"
799 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700800 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700801 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100802 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700803 return module
804}
Patrice Arruda0f688002020-06-08 21:40:25 +0000805
806// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800807// If soc_specific property is set to true, the DSP related file is installed to the
808// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000809func PrebuiltDSPFactory() android.Module {
810 module := &PrebuiltEtc{}
811 module.socInstallDirBase = "dsp"
812 InitPrebuiltEtcModule(module, "etc/dsp")
813 // This module is device-only
814 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100815 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000816 return module
817}
Colin Cross83ebf232021-04-09 09:41:23 -0700818
Colin Crossf17e2b52023-10-30 15:17:25 -0700819// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
820func PrebuiltRenderScriptBitcodeFactory() android.Module {
821 module := &PrebuiltEtc{}
822 module.makeClass = "RENDERSCRIPT_BITCODE"
823 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800824 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700825 InitPrebuiltEtcModule(module, "lib")
826 // This module is device-only
827 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
828 android.InitDefaultableModule(module)
829 return module
830}
831
Colin Cross83ebf232021-04-09 09:41:23 -0700832// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
833// to the <partition>/lib/rfsa directory.
834func PrebuiltRFSAFactory() android.Module {
835 module := &PrebuiltEtc{}
836 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
837 // many places outside of the application processor. They could be moved to /vendor/dsp once
838 // that is cleaned up.
839 InitPrebuiltEtcModule(module, "lib/rfsa")
840 // This module is device-only
841 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100842 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700843 return module
844}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000845
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000846// prebuilt_media installs media files in <partition>/media directory.
847func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000848 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000849 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000850 // This module is device-only
851 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
852 android.InitDefaultableModule(module)
853 return module
854}
Jihoon Kangec62d842024-10-25 20:27:18 +0000855
856// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
857func PrebuiltVoicepackFactory() android.Module {
858 module := &PrebuiltEtc{}
859 InitPrebuiltEtcModule(module, "tts")
860 // This module is device-only
861 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
862 android.InitDefaultableModule(module)
863 return module
864}
865
866// prebuilt_bin installs files in <partition>/bin directory.
867func PrebuiltBinaryFactory() android.Module {
868 module := &PrebuiltEtc{}
869 InitPrebuiltEtcModule(module, "bin")
870 // This module is device-only
871 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
872 android.InitDefaultableModule(module)
873 return module
874}
875
876// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
877func PrebuiltWallpaperFactory() android.Module {
878 module := &PrebuiltEtc{}
879 InitPrebuiltEtcModule(module, "wallpaper")
880 // This module is device-only
881 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
882 android.InitDefaultableModule(module)
883 return module
884}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000885
886// prebuilt_priv_app installs files in <partition>/priv-app directory.
887func PrebuiltPrivAppFactory() android.Module {
888 module := &PrebuiltEtc{}
889 InitPrebuiltEtcModule(module, "priv-app")
890 // This module is device-only
891 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
892 android.InitDefaultableModule(module)
893 return module
894}
895
896// prebuilt_rfs installs files in <partition>/rfs directory.
897func PrebuiltRfsFactory() android.Module {
898 module := &PrebuiltEtc{}
899 InitPrebuiltEtcModule(module, "rfs")
900 // This module is device-only
901 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
902 android.InitDefaultableModule(module)
903 return module
904}
905
906// prebuilt_framework installs files in <partition>/framework directory.
907func PrebuiltFrameworkFactory() android.Module {
908 module := &PrebuiltEtc{}
909 InitPrebuiltEtcModule(module, "framework")
910 // This module is device-only
911 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
912 android.InitDefaultableModule(module)
913 return module
914}
915
916// prebuilt_res installs files in <partition>/res directory.
917func PrebuiltResFactory() android.Module {
918 module := &PrebuiltEtc{}
919 InitPrebuiltEtcModule(module, "res")
920 // This module is device-only
921 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
922 android.InitDefaultableModule(module)
923 return module
924}
925
926// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
927func PrebuiltWlcUptFactory() android.Module {
928 module := &PrebuiltEtc{}
929 InitPrebuiltEtcModule(module, "wlc_upt")
930 // This module is device-only
931 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
932 android.InitDefaultableModule(module)
933 return module
934}
935
936// prebuilt_odm installs files in <partition>/odm directory.
937func PrebuiltOdmFactory() android.Module {
938 module := &PrebuiltEtc{}
939 InitPrebuiltEtcModule(module, "odm")
940 // This module is device-only
941 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
942 android.InitDefaultableModule(module)
943 return module
944}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000945
946// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
947func PrebuiltVendorDlkmFactory() android.Module {
948 module := &PrebuiltEtc{}
949 InitPrebuiltEtcModule(module, "vendor_dlkm")
950 // This module is device-only
951 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
952 android.InitDefaultableModule(module)
953 return module
954}
955
956// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
957func PrebuiltBtFirmwareFactory() android.Module {
958 module := &PrebuiltEtc{}
959 InitPrebuiltEtcModule(module, "bt_firmware")
960 // This module is device-only
961 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
962 android.InitDefaultableModule(module)
963 return module
964}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000965
966// prebuilt_tvservice installs files in <partition>/tvservice directory.
967func PrebuiltTvServiceFactory() android.Module {
968 module := &PrebuiltEtc{}
969 InitPrebuiltEtcModule(module, "tvservice")
970 // This module is device-only
971 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
972 android.InitDefaultableModule(module)
973 return module
974}
975
976// prebuilt_optee installs files in <partition>/optee directory.
977func PrebuiltOpteeFactory() android.Module {
978 module := &PrebuiltEtc{}
979 InitPrebuiltEtcModule(module, "optee")
980 // This module is device-only
981 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
982 android.InitDefaultableModule(module)
983 return module
984}
Jihoon Kangecf76dd2024-11-12 05:24:46 +0000985
986// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
987func PrebuiltTvConfigFactory() android.Module {
988 module := &PrebuiltEtc{}
989 InitPrebuiltEtcModule(module, "tvconfig")
990 // This module is device-only
991 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
992 android.InitDefaultableModule(module)
993 return module
994}
Jihoon Kang3ca07a12024-12-02 19:14:30 +0000995
996// prebuilt_vendor installs files in <partition>/vendor directory.
997func PrebuiltVendorFactory() android.Module {
998 module := &PrebuiltEtc{}
999 InitPrebuiltEtcModule(module, "vendor")
1000 // This module is device-only
1001 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1002 android.InitDefaultableModule(module)
1003 return module
1004}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001005
1006// prebuilt_sbin installs files in <partition>/sbin directory.
1007func PrebuiltSbinFactory() android.Module {
1008 module := &PrebuiltEtc{}
1009 InitPrebuiltEtcModule(module, "sbin")
1010 // This module is device-only
1011 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1012 android.InitDefaultableModule(module)
1013 return module
1014}
1015
1016// prebuilt_system installs files in <partition>/system directory.
1017func PrebuiltSystemFactory() android.Module {
1018 module := &PrebuiltEtc{}
1019 InitPrebuiltEtcModule(module, "system")
1020 // This module is device-only
1021 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1022 android.InitDefaultableModule(module)
1023 return module
1024}
1025
1026// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1027func PrebuiltFirstStageRamdiskFactory() android.Module {
1028 module := &PrebuiltEtc{}
1029 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1030 // This module is device-only
1031 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1032 android.InitDefaultableModule(module)
1033 return module
1034}