blob: 47b391caad5244ed43475b6601a24fed8b2e55b5 [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)
Inseob Kim1e27a142021-05-06 11:46:11 +000084
85 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040086
Jiyong Parkc678ad32018-04-10 13:07:10 +090087}
88
Paul Duffin1172fed2021-03-08 11:28:18 +000089var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
90
Jiyong Parkc678ad32018-04-10 13:07:10 +090091type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080092 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110093 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070094 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090095
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110096 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070097 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
98 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070099 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100100
Douglas Anderson79688ff2024-09-27 15:08:33 -0700101 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
102 // set filename_from_src. This can be used to install each source file to a different directory
103 // and/or change filenames when files are installed. Must be exactly one entry per source file,
104 // which means care must be taken if srcs has globs.
105 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
106
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800107 // 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 +1100108 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900109 Filename *string `android:"arch_variant"`
110
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800111 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900112 // is the same as the file name of the source file.
113 Filename_from_src *bool `android:"arch_variant"`
114
Yifan Hong1b3348d2020-01-21 15:53:22 -0800115 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700116 // On device without a dedicated recovery partition, the module is only
117 // available after switching root into
118 // /first_stage_ramdisk. To expose the module before switching root, install
119 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800120 Ramdisk_available *bool
121
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700122 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700123 // On device without a dedicated recovery partition, the module is only
124 // available after switching root into
125 // /first_stage_ramdisk. To expose the module before switching root, install
126 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700127 Vendor_ramdisk_available *bool
128
Inseob Kim08758f02021-04-08 21:13:22 +0900129 // Make this module available when building for debug ramdisk.
130 Debug_ramdisk_available *bool
131
Tao Bao0ba5c942018-08-14 22:20:22 -0700132 // Make this module available when building for recovery.
133 Recovery_available *bool
134
Jiyong Parkad9ce042018-10-31 22:49:57 +0900135 // Whether this module is directly installable to one of the partitions. Default: true.
136 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800137
138 // Install symlinks to the installed file.
139 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800140
Wei Li59586252024-11-04 09:25:54 -0800141 // Install to partition oem when set to true.
142 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900143}
144
Inseob Kim27408bf2021-04-06 21:00:17 +0900145type prebuiltSubdirProperties struct {
146 // Optional subdirectory under which this file is installed into, cannot be specified with
147 // relative_install_path, prefer relative_install_path.
148 Sub_dir *string `android:"arch_variant"`
149
150 // Optional subdirectory under which this file is installed into, cannot be specified with
151 // sub_dir.
152 Relative_install_path *string `android:"arch_variant"`
153}
154
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900155type prebuiltRootProperties struct {
156 // Install this module to the root directory, without partition subdirs. When this module is
157 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
158 // then be copied to the root of system.img. When this module is packaged by other modules like
159 // android_filesystem, this module will be installed to the root ("/"), unlike normal
160 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
161 Install_in_root *bool
162}
163
Jooyung Han39edb6c2019-11-06 16:53:07 +0900164type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700165 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800166
167 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900168 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800169
170 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900171 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900172}
173
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900174type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700175 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000176 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900177
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900178 properties prebuiltEtcProperties
179
180 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
181 // prebuilt_avb and prebuilt_root modules use this.
182 rootProperties prebuiltRootProperties
183
Inseob Kim27408bf2021-04-06 21:00:17 +0900184 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900185
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100186 sourceFilePaths android.Paths
187 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800188 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800189 installDirBase string
190 installDirBase64 string
191 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800192 // The base install location when soc_specific property is set to true, e.g. "firmware" for
193 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700194 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700195 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700196 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700197
Cole Faustfdec8722024-05-22 11:38:29 -0700198 usedSrcsProperty bool
199
Colin Crossf17e2b52023-10-30 15:17:25 -0700200 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900201}
202
Inseob Kim1e27a142021-05-06 11:46:11 +0000203type Defaults struct {
204 android.ModuleBase
205 android.DefaultsModuleBase
206}
207
Yifan Hong1b3348d2020-01-21 15:53:22 -0800208func (p *PrebuiltEtc) inRamdisk() bool {
209 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
210}
211
212func (p *PrebuiltEtc) onlyInRamdisk() bool {
213 return p.ModuleBase.InstallInRamdisk()
214}
215
216func (p *PrebuiltEtc) InstallInRamdisk() bool {
217 return p.inRamdisk()
218}
219
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700220func (p *PrebuiltEtc) inVendorRamdisk() bool {
221 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
222}
223
224func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
225 return p.ModuleBase.InstallInVendorRamdisk()
226}
227
228func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
229 return p.inVendorRamdisk()
230}
231
Inseob Kim08758f02021-04-08 21:13:22 +0900232func (p *PrebuiltEtc) inDebugRamdisk() bool {
233 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
234}
235
236func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
237 return p.ModuleBase.InstallInDebugRamdisk()
238}
239
240func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
241 return p.inDebugRamdisk()
242}
243
Kiyoung Kimae11c232021-07-19 11:38:04 +0900244func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800245 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700246}
247
248func (p *PrebuiltEtc) onlyInRecovery() bool {
249 return p.ModuleBase.InstallInRecovery()
250}
251
252func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900253 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700254}
255
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700256var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800257
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700258func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800259
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700260func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000261 return false
262}
263
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700264func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000265 return false
266}
267
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700268func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700269 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900270 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800271}
272
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700273func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700274 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800275}
276
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700277func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700278 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
279}
280
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700281func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900282 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
283}
284
Nelson Li1fb94b22024-07-09 17:04:52 +0800285func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900286 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800287}
288
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700289func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700290 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800291}
292
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700293func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800294 return nil
295}
296
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700297func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800298}
299
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700300func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700301 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100302 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
303 }
Cole Faustfdec8722024-05-22 11:38:29 -0700304 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900305}
306
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700307func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700308 if len(p.installDirPaths) != 1 {
309 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
310 }
311 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900312}
313
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900314// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
315// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700316func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900317 p.additionalDependencies = &paths
318}
319
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700320func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700321 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100322 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
323 }
324 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900325}
326
327func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900328 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700329 return subDir
330 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900331 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900332}
333
Jooyung Han0703fd82020-08-26 22:11:53 +0900334func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900335 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900336}
337
Jiyong Parkad9ce042018-10-31 22:49:57 +0900338func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800339 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900340}
341
Kiyoung Kimae11c232021-07-19 11:38:04 +0900342func (p *PrebuiltEtc) InVendor() bool {
343 return p.ModuleBase.InstallInVendor()
344}
345
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100346func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800347 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
348 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900349 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700350 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
351 installBaseDir = p.installDirBase64
352 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900353 if p.SocSpecific() && p.socInstallDirBase != "" {
354 installBaseDir = p.socInstallDirBase
355 }
Colin Cross2f634572023-11-13 12:12:06 -0800356 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
357 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
358 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100359 return installBaseDir
360}
Colin Cross2f634572023-11-13 12:12:06 -0800361
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100362func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
363 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900364
Cole Faustfdec8722024-05-22 11:38:29 -0700365 srcProperty := p.properties.Src.Get(ctx)
366 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
367 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100368 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000369 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700370 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
371 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
372 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
373 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100374
375 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
376 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
377 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
378 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700379 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800380 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000381 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800382 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
383 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100384
385 filename := proptools.String(p.properties.Filename)
386 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700387 if srcProperty.IsPresent() {
388 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100389 // If the source was not found, set a fake source path to
390 // support AllowMissingDependencies executions.
391 if len(p.sourceFilePaths) == 0 {
392 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
393 }
394
395 // Determine the output file basename.
396 // If Filename is set, use the name specified by the property.
397 // If Filename_from_src is set, use the source file name.
398 // Otherwise use the module name.
399 if filename != "" {
400 if filenameFromSrc {
401 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
402 return
403 }
404 } else if filenameFromSrc {
405 filename = p.sourceFilePaths[0].Base()
406 } else {
407 filename = ctx.ModuleName()
408 }
409 if strings.Contains(filename, "/") {
410 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
411 return
412 }
413 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
414
415 ip := installProperties{
416 filename: filename,
417 sourceFilePath: p.sourceFilePaths[0],
418 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700419 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100420 symlinks: p.properties.Symlinks,
421 }
422 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700423 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700424 } else if len(srcsProperty) > 0 {
425 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100426 if filename != "" {
427 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
428 }
429 if len(p.properties.Symlinks) > 0 {
430 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
431 }
432 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700433 if len(dstsProperty) > 0 {
434 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
435 } else {
436 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
437 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100438 }
Cole Faustfdec8722024-05-22 11:38:29 -0700439 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700440 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
441 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
442 }
443 for i, src := range p.sourceFilePaths {
444 var filename string
445 var installDirPath android.InstallPath
446
447 if len(dstsProperty) > 0 {
448 var dstdir string
449
450 dstdir, filename = filepath.Split(dstsProperty[i])
451 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
452 } else {
453 filename = src.Base()
454 installDirPath = baseInstallDirPath
455 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100456 output := android.PathForModuleOut(ctx, filename).OutputPath
457 ip := installProperties{
458 filename: filename,
459 sourceFilePath: src,
460 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700461 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100462 }
463 p.outputFilePaths = append(p.outputFilePaths, output)
464 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700465 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100466 }
467 } else if ctx.Config().AllowMissingDependencies() {
468 // If no srcs was set and AllowMissingDependencies is enabled then
469 // mark the module as missing dependencies and set a fake source path
470 // and file name.
471 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
472 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
473 if filename == "" {
474 filename = ctx.ModuleName()
475 }
476 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
477 ip := installProperties{
478 filename: filename,
479 sourceFilePath: p.sourceFilePaths[0],
480 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700481 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100482 }
483 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700484 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100485 } else {
486 ctx.PropertyErrorf("src", "missing prebuilt source file")
487 return
488 }
489
490 // Call InstallFile even when uninstallable to make the module included in the package.
491 if !p.Installable() {
492 p.SkipInstall()
493 }
494 for _, ip := range installs {
495 ip.addInstallRules(ctx)
496 }
mrziwang89371762024-06-11 12:42:24 -0700497
498 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000499}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900500
Spandan Das756d3402023-06-05 22:49:50 +0000501type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000502 filename string
503 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100504 outputFilePath android.OutputPath
505 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000506 symlinks []string
507}
508
509// utility function to add install rules to the build graph.
510// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100511func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000512 // Copy the file from src to a location in out/ with the correct `filename`
513 // This ensures that outputFilePath has the correct name for others to
514 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000515 ctx.Build(pctx, android.BuildParams{
516 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100517 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000518 Input: ip.sourceFilePath,
519 })
520
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100521 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000522 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100523 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900524 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900525}
526
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700527func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700528 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800529 if p.inRamdisk() && !p.onlyInRamdisk() {
530 nameSuffix = ".ramdisk"
531 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700532 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
533 nameSuffix = ".vendor_ramdisk"
534 }
Inseob Kim08758f02021-04-08 21:13:22 +0900535 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
536 nameSuffix = ".debug_ramdisk"
537 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900538 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700539 nameSuffix = ".recovery"
540 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700541
542 class := p.makeClass
543 if class == "" {
544 class = "ETC"
545 }
546
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100547 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700548 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700549 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100550 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700551 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700552 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700553 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700554 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100555 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800556 if len(p.properties.Symlinks) > 0 {
557 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
558 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800559 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700560 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800561 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900562 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700563 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900564 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900565 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900566}
567
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000568func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
569 return &p.ModuleBase
570}
571
Jooyung Hana0171822019-07-22 15:48:36 +0900572func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
573 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900574 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900575 p.AddProperties(&p.subdirProperties)
576}
577
578func InitPrebuiltRootModule(p *PrebuiltEtc) {
579 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800580 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900581 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800582}
583
584func InitPrebuiltAvbModule(p *PrebuiltEtc) {
585 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900586 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900587 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900588}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900589
Patrice Arruda9e14b962019-03-11 15:58:50 -0700590// prebuilt_etc is for a prebuilt artifact that is installed in
591// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700592func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900593 module := &PrebuiltEtc{}
594 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900595 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700596 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000597 android.InitDefaultableModule(module)
598 return module
599}
600
601func defaultsFactory() android.Module {
602 return DefaultsFactory()
603}
604
605func DefaultsFactory(props ...interface{}) android.Module {
606 module := &Defaults{}
607
608 module.AddProperties(props...)
609 module.AddProperties(
610 &prebuiltEtcProperties{},
611 &prebuiltSubdirProperties{},
612 )
613
614 android.InitDefaultsModule(module)
615
Jiyong Parkc678ad32018-04-10 13:07:10 +0900616 return module
617}
Tao Bao0ba5c942018-08-14 22:20:22 -0700618
Patrice Arruda9e14b962019-03-11 15:58:50 -0700619// prebuilt_etc_host is for a host prebuilt artifact that is installed in
620// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700621func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900622 module := &PrebuiltEtc{}
623 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800624 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700625 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100626 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800627 return module
628}
629
Miguel32b02802022-12-01 18:38:26 +0000630// prebuilt_etc_host is for a host prebuilt artifact that is installed in
631// <partition>/etc/<sub_dir> directory.
632func PrebuiltEtcCaCertsFactory() android.Module {
633 module := &PrebuiltEtc{}
634 InitPrebuiltEtcModule(module, "cacerts")
635 // This module is device-only
636 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000637 return module
638}
639
Nelson Li1fb94b22024-07-09 17:04:52 +0800640// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
641// `prebuilt_avb` will not have a `system` subdirectory.
642// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
643// root directory of the partition: <partition_root>/avb.
644// prebuilt_avb does not allow adding any other subdirectories.
645func PrebuiltAvbFactory() android.Module {
646 module := &PrebuiltEtc{}
647 InitPrebuiltAvbModule(module)
648 // This module is device-only
649 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
650 android.InitDefaultableModule(module)
651 return module
652}
653
Inseob Kim27408bf2021-04-06 21:00:17 +0900654// prebuilt_root is for a prebuilt artifact that is installed in
655// <partition>/ directory. Can't have any sub directories.
656func PrebuiltRootFactory() android.Module {
657 module := &PrebuiltEtc{}
658 InitPrebuiltRootModule(module)
659 // This module is device-only
660 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100661 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900662 return module
663}
664
Liz Kammere9ecddc2022-01-04 17:27:52 -0500665// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
666// directory.
667func PrebuiltRootHostFactory() android.Module {
668 module := &PrebuiltEtc{}
669 InitPrebuiltEtcModule(module, ".")
670 // This module is host-only
671 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
672 android.InitDefaultableModule(module)
673 return module
674}
675
Patrice Arruda9e14b962019-03-11 15:58:50 -0700676// prebuilt_usr_share is for a prebuilt artifact that is installed in
677// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700678func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900679 module := &PrebuiltEtc{}
680 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800681 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700682 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100683 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800684 return module
685}
686
Patrice Arruda9e14b962019-03-11 15:58:50 -0700687// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
688// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700689func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900690 module := &PrebuiltEtc{}
691 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800692 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700693 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100694 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800695 return module
696}
697
yangbill63c5e192024-03-27 09:02:12 +0000698// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
699// <partition>/usr/hyphen-data/<sub_dir> directory.
700func PrebuiltUserHyphenDataFactory() android.Module {
701 module := &PrebuiltEtc{}
702 InitPrebuiltEtcModule(module, "usr/hyphen-data")
703 // This module is device-only
704 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
705 android.InitDefaultableModule(module)
706 return module
707}
708
yangbill85527e62024-04-30 08:24:50 +0000709// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
710// <partition>/usr/keylayout/<sub_dir> directory.
711func PrebuiltUserKeyLayoutFactory() android.Module {
712 module := &PrebuiltEtc{}
713 InitPrebuiltEtcModule(module, "usr/keylayout")
714 // This module is device-only
715 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
716 android.InitDefaultableModule(module)
717 return module
718}
719
720// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
721// <partition>/usr/keychars/<sub_dir> directory.
722func PrebuiltUserKeyCharsFactory() android.Module {
723 module := &PrebuiltEtc{}
724 InitPrebuiltEtcModule(module, "usr/keychars")
725 // This module is device-only
726 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
727 android.InitDefaultableModule(module)
728 return module
729}
730
731// prebuilt_usr_idc is for a prebuilt artifact that is installed in
732// <partition>/usr/idc/<sub_dir> directory.
733func PrebuiltUserIdcFactory() android.Module {
734 module := &PrebuiltEtc{}
735 InitPrebuiltEtcModule(module, "usr/idc")
736 // This module is device-only
737 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
738 android.InitDefaultableModule(module)
739 return module
740}
741
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000742// prebuilt_usr_srec is for a prebuilt artifact that is installed in
743// <partition>/usr/srec/<sub_dir> directory.
744func PrebuiltUserSrecFactory() android.Module {
745 module := &PrebuiltEtc{}
746 InitPrebuiltEtcModule(module, "usr/srec")
747 // This module is device-only
748 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
749 android.InitDefaultableModule(module)
750 return module
751}
752
Patrice Arruda61583eb2019-05-14 08:20:45 -0700753// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700754func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900755 module := &PrebuiltEtc{}
756 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700757 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700758 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100759 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700760 return module
761}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700762
Kevin93f7cd82024-05-02 12:37:59 +0200763// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
764func PrebuiltOverlayFactory() android.Module {
765 module := &PrebuiltEtc{}
766 InitPrebuiltEtcModule(module, "overlay")
767 // This module is device-only
768 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
769 return module
770}
771
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800772// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
773// image.
774// If soc_specific property is set to true, the firmware file is installed to the
775// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700776func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900777 module := &PrebuiltEtc{}
778 module.socInstallDirBase = "firmware"
779 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700780 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700781 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100782 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700783 return module
784}
Patrice Arruda0f688002020-06-08 21:40:25 +0000785
786// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800787// If soc_specific property is set to true, the DSP related file is installed to the
788// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000789func PrebuiltDSPFactory() android.Module {
790 module := &PrebuiltEtc{}
791 module.socInstallDirBase = "dsp"
792 InitPrebuiltEtcModule(module, "etc/dsp")
793 // This module is device-only
794 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100795 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000796 return module
797}
Colin Cross83ebf232021-04-09 09:41:23 -0700798
Colin Crossf17e2b52023-10-30 15:17:25 -0700799// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
800func PrebuiltRenderScriptBitcodeFactory() android.Module {
801 module := &PrebuiltEtc{}
802 module.makeClass = "RENDERSCRIPT_BITCODE"
803 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800804 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700805 InitPrebuiltEtcModule(module, "lib")
806 // This module is device-only
807 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
808 android.InitDefaultableModule(module)
809 return module
810}
811
Colin Cross83ebf232021-04-09 09:41:23 -0700812// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
813// to the <partition>/lib/rfsa directory.
814func PrebuiltRFSAFactory() android.Module {
815 module := &PrebuiltEtc{}
816 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
817 // many places outside of the application processor. They could be moved to /vendor/dsp once
818 // that is cleaned up.
819 InitPrebuiltEtcModule(module, "lib/rfsa")
820 // This module is device-only
821 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100822 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700823 return module
824}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000825
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000826// prebuilt_media installs media files in <partition>/media directory.
827func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000828 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000829 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000830 // This module is device-only
831 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
832 android.InitDefaultableModule(module)
833 return module
834}
Jihoon Kangec62d842024-10-25 20:27:18 +0000835
836// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
837func PrebuiltVoicepackFactory() android.Module {
838 module := &PrebuiltEtc{}
839 InitPrebuiltEtcModule(module, "tts")
840 // This module is device-only
841 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
842 android.InitDefaultableModule(module)
843 return module
844}
845
846// prebuilt_bin installs files in <partition>/bin directory.
847func PrebuiltBinaryFactory() android.Module {
848 module := &PrebuiltEtc{}
849 InitPrebuiltEtcModule(module, "bin")
850 // This module is device-only
851 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
852 android.InitDefaultableModule(module)
853 return module
854}
855
856// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
857func PrebuiltWallpaperFactory() android.Module {
858 module := &PrebuiltEtc{}
859 InitPrebuiltEtcModule(module, "wallpaper")
860 // This module is device-only
861 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
862 android.InitDefaultableModule(module)
863 return module
864}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000865
866// prebuilt_priv_app installs files in <partition>/priv-app directory.
867func PrebuiltPrivAppFactory() android.Module {
868 module := &PrebuiltEtc{}
869 InitPrebuiltEtcModule(module, "priv-app")
870 // This module is device-only
871 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
872 android.InitDefaultableModule(module)
873 return module
874}
875
876// prebuilt_rfs installs files in <partition>/rfs directory.
877func PrebuiltRfsFactory() android.Module {
878 module := &PrebuiltEtc{}
879 InitPrebuiltEtcModule(module, "rfs")
880 // This module is device-only
881 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
882 android.InitDefaultableModule(module)
883 return module
884}
885
886// prebuilt_framework installs files in <partition>/framework directory.
887func PrebuiltFrameworkFactory() android.Module {
888 module := &PrebuiltEtc{}
889 InitPrebuiltEtcModule(module, "framework")
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_res installs files in <partition>/res directory.
897func PrebuiltResFactory() android.Module {
898 module := &PrebuiltEtc{}
899 InitPrebuiltEtcModule(module, "res")
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_wlc_upt installs files in <partition>/wlc_upt directory.
907func PrebuiltWlcUptFactory() android.Module {
908 module := &PrebuiltEtc{}
909 InitPrebuiltEtcModule(module, "wlc_upt")
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_odm installs files in <partition>/odm directory.
917func PrebuiltOdmFactory() android.Module {
918 module := &PrebuiltEtc{}
919 InitPrebuiltEtcModule(module, "odm")
920 // This module is device-only
921 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
922 android.InitDefaultableModule(module)
923 return module
924}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000925
926// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
927func PrebuiltVendorDlkmFactory() android.Module {
928 module := &PrebuiltEtc{}
929 InitPrebuiltEtcModule(module, "vendor_dlkm")
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_bt_firmware installs files in <partition>/bt_firmware directory.
937func PrebuiltBtFirmwareFactory() android.Module {
938 module := &PrebuiltEtc{}
939 InitPrebuiltEtcModule(module, "bt_firmware")
940 // This module is device-only
941 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
942 android.InitDefaultableModule(module)
943 return module
944}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000945
946// prebuilt_tvservice installs files in <partition>/tvservice directory.
947func PrebuiltTvServiceFactory() android.Module {
948 module := &PrebuiltEtc{}
949 InitPrebuiltEtcModule(module, "tvservice")
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_optee installs files in <partition>/optee directory.
957func PrebuiltOpteeFactory() android.Module {
958 module := &PrebuiltEtc{}
959 InitPrebuiltEtcModule(module, "optee")
960 // This module is device-only
961 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
962 android.InitDefaultableModule(module)
963 return module
964}
Jihoon Kangecf76dd2024-11-12 05:24:46 +0000965
966// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
967func PrebuiltTvConfigFactory() android.Module {
968 module := &PrebuiltEtc{}
969 InitPrebuiltEtcModule(module, "tvconfig")
970 // This module is device-only
971 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
972 android.InitDefaultableModule(module)
973 return module
974}