blob: bf54c094123f5ca780cf41505c5b8176ff908f47 [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)
Inseob Kim1e27a142021-05-06 11:46:11 +000088
89 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040090
Jiyong Parkc678ad32018-04-10 13:07:10 +090091}
92
Paul Duffin1172fed2021-03-08 11:28:18 +000093var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
94
Jihoon Kang69725b32024-11-12 03:08:49 +000095type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080096 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110097 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070098 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090099
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100100 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -0700101 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
102 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700103 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100104
Douglas Anderson79688ff2024-09-27 15:08:33 -0700105 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
106 // set filename_from_src. This can be used to install each source file to a different directory
107 // and/or change filenames when files are installed. Must be exactly one entry per source file,
108 // which means care must be taken if srcs has globs.
109 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
110
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800111 // 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 +1100112 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900113 Filename *string `android:"arch_variant"`
114
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800115 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900116 // is the same as the file name of the source file.
117 Filename_from_src *bool `android:"arch_variant"`
118
Yifan Hong1b3348d2020-01-21 15:53:22 -0800119 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700120 // On device without a dedicated recovery partition, the module is only
121 // available after switching root into
122 // /first_stage_ramdisk. To expose the module before switching root, install
123 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800124 Ramdisk_available *bool
125
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700126 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700127 // On device without a dedicated recovery partition, the module is only
128 // available after switching root into
129 // /first_stage_ramdisk. To expose the module before switching root, install
130 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700131 Vendor_ramdisk_available *bool
132
Inseob Kim08758f02021-04-08 21:13:22 +0900133 // Make this module available when building for debug ramdisk.
134 Debug_ramdisk_available *bool
135
Tao Bao0ba5c942018-08-14 22:20:22 -0700136 // Make this module available when building for recovery.
137 Recovery_available *bool
138
Jiyong Parkad9ce042018-10-31 22:49:57 +0900139 // Whether this module is directly installable to one of the partitions. Default: true.
140 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800141
142 // Install symlinks to the installed file.
143 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800144
Wei Li59586252024-11-04 09:25:54 -0800145 // Install to partition oem when set to true.
146 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900147}
148
Inseob Kim27408bf2021-04-06 21:00:17 +0900149type prebuiltSubdirProperties struct {
150 // Optional subdirectory under which this file is installed into, cannot be specified with
151 // relative_install_path, prefer relative_install_path.
152 Sub_dir *string `android:"arch_variant"`
153
154 // Optional subdirectory under which this file is installed into, cannot be specified with
155 // sub_dir.
156 Relative_install_path *string `android:"arch_variant"`
157}
158
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900159type prebuiltRootProperties struct {
160 // Install this module to the root directory, without partition subdirs. When this module is
161 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
162 // then be copied to the root of system.img. When this module is packaged by other modules like
163 // android_filesystem, this module will be installed to the root ("/"), unlike normal
164 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
165 Install_in_root *bool
166}
167
Jooyung Han39edb6c2019-11-06 16:53:07 +0900168type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700169 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800170
171 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900172 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800173
174 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900175 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900176}
177
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900178type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700179 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000180 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900181
Jihoon Kang69725b32024-11-12 03:08:49 +0000182 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900183
184 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
185 // prebuilt_avb and prebuilt_root modules use this.
186 rootProperties prebuiltRootProperties
187
Inseob Kim27408bf2021-04-06 21:00:17 +0900188 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900189
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100190 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800191 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800192 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800193 installDirBase string
194 installDirBase64 string
195 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800196 // The base install location when soc_specific property is set to true, e.g. "firmware" for
197 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700198 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700199 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700200 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700201
Cole Faustfdec8722024-05-22 11:38:29 -0700202 usedSrcsProperty bool
203
Colin Crossf17e2b52023-10-30 15:17:25 -0700204 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900205}
206
Inseob Kim1e27a142021-05-06 11:46:11 +0000207type Defaults struct {
208 android.ModuleBase
209 android.DefaultsModuleBase
210}
211
Yifan Hong1b3348d2020-01-21 15:53:22 -0800212func (p *PrebuiltEtc) inRamdisk() bool {
213 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
214}
215
216func (p *PrebuiltEtc) onlyInRamdisk() bool {
217 return p.ModuleBase.InstallInRamdisk()
218}
219
220func (p *PrebuiltEtc) InstallInRamdisk() bool {
221 return p.inRamdisk()
222}
223
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700224func (p *PrebuiltEtc) inVendorRamdisk() bool {
225 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
226}
227
228func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
229 return p.ModuleBase.InstallInVendorRamdisk()
230}
231
232func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
233 return p.inVendorRamdisk()
234}
235
Inseob Kim08758f02021-04-08 21:13:22 +0900236func (p *PrebuiltEtc) inDebugRamdisk() bool {
237 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
238}
239
240func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
241 return p.ModuleBase.InstallInDebugRamdisk()
242}
243
244func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
245 return p.inDebugRamdisk()
246}
247
Kiyoung Kimae11c232021-07-19 11:38:04 +0900248func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800249 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700250}
251
252func (p *PrebuiltEtc) onlyInRecovery() bool {
253 return p.ModuleBase.InstallInRecovery()
254}
255
256func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900257 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700258}
259
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700260var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800261
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700262func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800263
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700264func (p *PrebuiltEtc) VendorVariantNeeded(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) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000269 return false
270}
271
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700272func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700273 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900274 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800275}
276
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700277func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700278 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800279}
280
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700281func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700282 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
283}
284
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700285func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900286 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
287}
288
Nelson Li1fb94b22024-07-09 17:04:52 +0800289func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900290 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800291}
292
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700293func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700294 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800295}
296
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700297func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800298 return nil
299}
300
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700301func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800302}
303
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700304func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700305 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100306 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
307 }
Cole Faustfdec8722024-05-22 11:38:29 -0700308 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900309}
310
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700311func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700312 if len(p.installDirPaths) != 1 {
313 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
314 }
315 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900316}
317
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900318// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
319// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700320func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900321 p.additionalDependencies = &paths
322}
323
Cole Faust4e9f5922024-11-13 16:09:23 -0800324func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700325 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100326 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
327 }
328 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900329}
330
331func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900332 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700333 return subDir
334 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900335 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900336}
337
Jooyung Han0703fd82020-08-26 22:11:53 +0900338func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900339 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900340}
341
Jiyong Parkad9ce042018-10-31 22:49:57 +0900342func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800343 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900344}
345
Kiyoung Kimae11c232021-07-19 11:38:04 +0900346func (p *PrebuiltEtc) InVendor() bool {
347 return p.ModuleBase.InstallInVendor()
348}
349
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100350func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800351 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
352 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900353 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700354 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
355 installBaseDir = p.installDirBase64
356 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900357 if p.SocSpecific() && p.socInstallDirBase != "" {
358 installBaseDir = p.socInstallDirBase
359 }
Colin Cross2f634572023-11-13 12:12:06 -0800360 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
361 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
362 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100363 return installBaseDir
364}
Colin Cross2f634572023-11-13 12:12:06 -0800365
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100366func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
367 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900368
Cole Faustfdec8722024-05-22 11:38:29 -0700369 srcProperty := p.properties.Src.Get(ctx)
370 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
371 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100372 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000373 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700374 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
375 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
376 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
377 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100378
379 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
380 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
381 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
382 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700383 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800384 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000385 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800386 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
387 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100388
389 filename := proptools.String(p.properties.Filename)
390 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700391 if srcProperty.IsPresent() {
392 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100393 // If the source was not found, set a fake source path to
394 // support AllowMissingDependencies executions.
395 if len(p.sourceFilePaths) == 0 {
396 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
397 }
398
399 // Determine the output file basename.
400 // If Filename is set, use the name specified by the property.
401 // If Filename_from_src is set, use the source file name.
402 // Otherwise use the module name.
403 if filename != "" {
404 if filenameFromSrc {
405 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
406 return
407 }
408 } else if filenameFromSrc {
409 filename = p.sourceFilePaths[0].Base()
410 } else {
411 filename = ctx.ModuleName()
412 }
413 if strings.Contains(filename, "/") {
414 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
415 return
416 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800417 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100418
419 ip := installProperties{
420 filename: filename,
421 sourceFilePath: p.sourceFilePaths[0],
422 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700423 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100424 symlinks: p.properties.Symlinks,
425 }
426 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700427 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700428 } else if len(srcsProperty) > 0 {
429 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100430 if filename != "" {
431 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
432 }
433 if len(p.properties.Symlinks) > 0 {
434 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
435 }
436 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700437 if len(dstsProperty) > 0 {
438 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
439 } else {
440 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
441 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100442 }
Cole Faustfdec8722024-05-22 11:38:29 -0700443 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700444 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
445 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
446 }
447 for i, src := range p.sourceFilePaths {
448 var filename string
449 var installDirPath android.InstallPath
450
451 if len(dstsProperty) > 0 {
452 var dstdir string
453
454 dstdir, filename = filepath.Split(dstsProperty[i])
455 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
456 } else {
457 filename = src.Base()
458 installDirPath = baseInstallDirPath
459 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800460 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100461 ip := installProperties{
462 filename: filename,
463 sourceFilePath: src,
464 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700465 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100466 }
467 p.outputFilePaths = append(p.outputFilePaths, output)
468 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700469 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100470 }
471 } else if ctx.Config().AllowMissingDependencies() {
472 // If no srcs was set and AllowMissingDependencies is enabled then
473 // mark the module as missing dependencies and set a fake source path
474 // and file name.
475 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
476 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
477 if filename == "" {
478 filename = ctx.ModuleName()
479 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800480 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100481 ip := installProperties{
482 filename: filename,
483 sourceFilePath: p.sourceFilePaths[0],
484 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700485 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100486 }
487 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700488 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100489 } else {
490 ctx.PropertyErrorf("src", "missing prebuilt source file")
491 return
492 }
493
494 // Call InstallFile even when uninstallable to make the module included in the package.
495 if !p.Installable() {
496 p.SkipInstall()
497 }
498 for _, ip := range installs {
499 ip.addInstallRules(ctx)
500 }
mrziwang89371762024-06-11 12:42:24 -0700501
mrziwanga25adf32025-02-05 23:50:55 +0000502 p.updateModuleInfoJSON(ctx)
503
mrziwang89371762024-06-11 12:42:24 -0700504 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000505}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900506
mrziwanga25adf32025-02-05 23:50:55 +0000507func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
508 moduleInfoJSON := ctx.ModuleInfoJSON()
509 moduleInfoJSON.Class = []string{"ETC"}
510 if p.makeClass != "" {
511 moduleInfoJSON.Class = []string{p.makeClass}
512 }
513 moduleInfoJSON.SystemSharedLibs = []string{"none"}
514 moduleInfoJSON.Tags = []string{"optional"}
515}
516
Spandan Das756d3402023-06-05 22:49:50 +0000517type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000518 filename string
519 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800520 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100521 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000522 symlinks []string
523}
524
525// utility function to add install rules to the build graph.
526// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100527func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000528 // Copy the file from src to a location in out/ with the correct `filename`
529 // This ensures that outputFilePath has the correct name for others to
530 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000531 ctx.Build(pctx, android.BuildParams{
532 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100533 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000534 Input: ip.sourceFilePath,
535 })
536
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100537 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000538 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100539 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900540 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900541}
542
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700543func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700544 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800545 if p.inRamdisk() && !p.onlyInRamdisk() {
546 nameSuffix = ".ramdisk"
547 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700548 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
549 nameSuffix = ".vendor_ramdisk"
550 }
Inseob Kim08758f02021-04-08 21:13:22 +0900551 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
552 nameSuffix = ".debug_ramdisk"
553 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900554 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700555 nameSuffix = ".recovery"
556 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700557
558 class := p.makeClass
559 if class == "" {
560 class = "ETC"
561 }
562
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100563 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700564 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700565 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100566 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700567 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700568 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700569 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700570 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100571 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800572 if len(p.properties.Symlinks) > 0 {
573 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
574 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800575 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700576 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800577 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900578 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700579 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900580 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900581 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900582}
583
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000584func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
585 return &p.ModuleBase
586}
587
Jooyung Hana0171822019-07-22 15:48:36 +0900588func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
589 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900590 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900591 p.AddProperties(&p.subdirProperties)
Jihoon Kang320ca7c2024-12-03 18:14:50 +0000592 p.AddProperties(&p.rootProperties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900593}
594
595func InitPrebuiltRootModule(p *PrebuiltEtc) {
596 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800597 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900598 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800599}
600
601func InitPrebuiltAvbModule(p *PrebuiltEtc) {
602 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900603 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900604 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900605}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900606
Patrice Arruda9e14b962019-03-11 15:58:50 -0700607// prebuilt_etc is for a prebuilt artifact that is installed in
608// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700609func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900610 module := &PrebuiltEtc{}
611 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900612 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700613 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000614 android.InitDefaultableModule(module)
615 return module
616}
617
618func defaultsFactory() android.Module {
619 return DefaultsFactory()
620}
621
622func DefaultsFactory(props ...interface{}) android.Module {
623 module := &Defaults{}
624
625 module.AddProperties(props...)
626 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000627 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000628 &prebuiltSubdirProperties{},
629 )
630
631 android.InitDefaultsModule(module)
632
Jiyong Parkc678ad32018-04-10 13:07:10 +0900633 return module
634}
Tao Bao0ba5c942018-08-14 22:20:22 -0700635
Patrice Arruda9e14b962019-03-11 15:58:50 -0700636// prebuilt_etc_host is for a host prebuilt artifact that is installed in
637// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700638func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900639 module := &PrebuiltEtc{}
640 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800641 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700642 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100643 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800644 return module
645}
646
Miguel32b02802022-12-01 18:38:26 +0000647// prebuilt_etc_host is for a host prebuilt artifact that is installed in
648// <partition>/etc/<sub_dir> directory.
649func PrebuiltEtcCaCertsFactory() android.Module {
650 module := &PrebuiltEtc{}
651 InitPrebuiltEtcModule(module, "cacerts")
652 // This module is device-only
653 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000654 return module
655}
656
Nelson Li1fb94b22024-07-09 17:04:52 +0800657// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
658// `prebuilt_avb` will not have a `system` subdirectory.
659// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
660// root directory of the partition: <partition_root>/avb.
661// prebuilt_avb does not allow adding any other subdirectories.
662func PrebuiltAvbFactory() android.Module {
663 module := &PrebuiltEtc{}
664 InitPrebuiltAvbModule(module)
665 // This module is device-only
666 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
667 android.InitDefaultableModule(module)
668 return module
669}
670
Inseob Kim27408bf2021-04-06 21:00:17 +0900671// prebuilt_root is for a prebuilt artifact that is installed in
672// <partition>/ directory. Can't have any sub directories.
673func PrebuiltRootFactory() android.Module {
674 module := &PrebuiltEtc{}
675 InitPrebuiltRootModule(module)
676 // This module is device-only
677 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100678 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900679 return module
680}
681
Liz Kammere9ecddc2022-01-04 17:27:52 -0500682// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
683// directory.
684func PrebuiltRootHostFactory() android.Module {
685 module := &PrebuiltEtc{}
686 InitPrebuiltEtcModule(module, ".")
687 // This module is host-only
688 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
689 android.InitDefaultableModule(module)
690 return module
691}
692
Patrice Arruda9e14b962019-03-11 15:58:50 -0700693// prebuilt_usr_share is for a prebuilt artifact that is installed in
694// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700695func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900696 module := &PrebuiltEtc{}
697 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800698 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700699 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100700 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800701 return module
702}
703
Patrice Arruda9e14b962019-03-11 15:58:50 -0700704// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
705// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700706func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900707 module := &PrebuiltEtc{}
708 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800709 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700710 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100711 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800712 return module
713}
714
yangbill63c5e192024-03-27 09:02:12 +0000715// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
716// <partition>/usr/hyphen-data/<sub_dir> directory.
717func PrebuiltUserHyphenDataFactory() android.Module {
718 module := &PrebuiltEtc{}
719 InitPrebuiltEtcModule(module, "usr/hyphen-data")
720 // This module is device-only
721 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
722 android.InitDefaultableModule(module)
723 return module
724}
725
yangbill85527e62024-04-30 08:24:50 +0000726// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
727// <partition>/usr/keylayout/<sub_dir> directory.
728func PrebuiltUserKeyLayoutFactory() android.Module {
729 module := &PrebuiltEtc{}
730 InitPrebuiltEtcModule(module, "usr/keylayout")
731 // This module is device-only
732 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
733 android.InitDefaultableModule(module)
734 return module
735}
736
737// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
738// <partition>/usr/keychars/<sub_dir> directory.
739func PrebuiltUserKeyCharsFactory() android.Module {
740 module := &PrebuiltEtc{}
741 InitPrebuiltEtcModule(module, "usr/keychars")
742 // This module is device-only
743 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
744 android.InitDefaultableModule(module)
745 return module
746}
747
748// prebuilt_usr_idc is for a prebuilt artifact that is installed in
749// <partition>/usr/idc/<sub_dir> directory.
750func PrebuiltUserIdcFactory() android.Module {
751 module := &PrebuiltEtc{}
752 InitPrebuiltEtcModule(module, "usr/idc")
753 // This module is device-only
754 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
755 android.InitDefaultableModule(module)
756 return module
757}
758
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000759// prebuilt_usr_srec is for a prebuilt artifact that is installed in
760// <partition>/usr/srec/<sub_dir> directory.
761func PrebuiltUserSrecFactory() android.Module {
762 module := &PrebuiltEtc{}
763 InitPrebuiltEtcModule(module, "usr/srec")
764 // This module is device-only
765 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
766 android.InitDefaultableModule(module)
767 return module
768}
769
Patrice Arruda61583eb2019-05-14 08:20:45 -0700770// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700771func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900772 module := &PrebuiltEtc{}
773 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700774 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700775 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100776 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700777 return module
778}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700779
Kevin93f7cd82024-05-02 12:37:59 +0200780// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
781func PrebuiltOverlayFactory() android.Module {
782 module := &PrebuiltEtc{}
783 InitPrebuiltEtcModule(module, "overlay")
784 // This module is device-only
785 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
786 return module
787}
788
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800789// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
790// image.
791// If soc_specific property is set to true, the firmware file is installed to the
792// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700793func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900794 module := &PrebuiltEtc{}
795 module.socInstallDirBase = "firmware"
796 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700797 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700798 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100799 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700800 return module
801}
Patrice Arruda0f688002020-06-08 21:40:25 +0000802
803// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800804// If soc_specific property is set to true, the DSP related file is installed to the
805// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000806func PrebuiltDSPFactory() android.Module {
807 module := &PrebuiltEtc{}
808 module.socInstallDirBase = "dsp"
809 InitPrebuiltEtcModule(module, "etc/dsp")
810 // This module is device-only
811 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100812 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000813 return module
814}
Colin Cross83ebf232021-04-09 09:41:23 -0700815
Colin Crossf17e2b52023-10-30 15:17:25 -0700816// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
817func PrebuiltRenderScriptBitcodeFactory() android.Module {
818 module := &PrebuiltEtc{}
819 module.makeClass = "RENDERSCRIPT_BITCODE"
820 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800821 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700822 InitPrebuiltEtcModule(module, "lib")
823 // This module is device-only
824 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
825 android.InitDefaultableModule(module)
826 return module
827}
828
Colin Cross83ebf232021-04-09 09:41:23 -0700829// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
830// to the <partition>/lib/rfsa directory.
831func PrebuiltRFSAFactory() android.Module {
832 module := &PrebuiltEtc{}
833 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
834 // many places outside of the application processor. They could be moved to /vendor/dsp once
835 // that is cleaned up.
836 InitPrebuiltEtcModule(module, "lib/rfsa")
837 // This module is device-only
838 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100839 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700840 return module
841}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000842
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000843// prebuilt_media installs media files in <partition>/media directory.
844func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000845 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000846 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000847 // This module is device-only
848 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
849 android.InitDefaultableModule(module)
850 return module
851}
Jihoon Kangec62d842024-10-25 20:27:18 +0000852
853// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
854func PrebuiltVoicepackFactory() android.Module {
855 module := &PrebuiltEtc{}
856 InitPrebuiltEtcModule(module, "tts")
857 // This module is device-only
858 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
859 android.InitDefaultableModule(module)
860 return module
861}
862
863// prebuilt_bin installs files in <partition>/bin directory.
864func PrebuiltBinaryFactory() android.Module {
865 module := &PrebuiltEtc{}
866 InitPrebuiltEtcModule(module, "bin")
867 // This module is device-only
868 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
869 android.InitDefaultableModule(module)
870 return module
871}
872
873// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
874func PrebuiltWallpaperFactory() android.Module {
875 module := &PrebuiltEtc{}
876 InitPrebuiltEtcModule(module, "wallpaper")
877 // This module is device-only
878 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
879 android.InitDefaultableModule(module)
880 return module
881}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000882
883// prebuilt_priv_app installs files in <partition>/priv-app directory.
884func PrebuiltPrivAppFactory() android.Module {
885 module := &PrebuiltEtc{}
886 InitPrebuiltEtcModule(module, "priv-app")
887 // This module is device-only
888 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
889 android.InitDefaultableModule(module)
890 return module
891}
892
893// prebuilt_rfs installs files in <partition>/rfs directory.
894func PrebuiltRfsFactory() android.Module {
895 module := &PrebuiltEtc{}
896 InitPrebuiltEtcModule(module, "rfs")
897 // This module is device-only
898 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
899 android.InitDefaultableModule(module)
900 return module
901}
902
903// prebuilt_framework installs files in <partition>/framework directory.
904func PrebuiltFrameworkFactory() android.Module {
905 module := &PrebuiltEtc{}
906 InitPrebuiltEtcModule(module, "framework")
907 // This module is device-only
908 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
909 android.InitDefaultableModule(module)
910 return module
911}
912
913// prebuilt_res installs files in <partition>/res directory.
914func PrebuiltResFactory() android.Module {
915 module := &PrebuiltEtc{}
916 InitPrebuiltEtcModule(module, "res")
917 // This module is device-only
918 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
919 android.InitDefaultableModule(module)
920 return module
921}
922
923// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
924func PrebuiltWlcUptFactory() android.Module {
925 module := &PrebuiltEtc{}
926 InitPrebuiltEtcModule(module, "wlc_upt")
927 // This module is device-only
928 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
929 android.InitDefaultableModule(module)
930 return module
931}
932
933// prebuilt_odm installs files in <partition>/odm directory.
934func PrebuiltOdmFactory() android.Module {
935 module := &PrebuiltEtc{}
936 InitPrebuiltEtcModule(module, "odm")
937 // This module is device-only
938 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
939 android.InitDefaultableModule(module)
940 return module
941}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000942
943// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
944func PrebuiltVendorDlkmFactory() android.Module {
945 module := &PrebuiltEtc{}
946 InitPrebuiltEtcModule(module, "vendor_dlkm")
947 // This module is device-only
948 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
949 android.InitDefaultableModule(module)
950 return module
951}
952
953// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
954func PrebuiltBtFirmwareFactory() android.Module {
955 module := &PrebuiltEtc{}
956 InitPrebuiltEtcModule(module, "bt_firmware")
957 // This module is device-only
958 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
959 android.InitDefaultableModule(module)
960 return module
961}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000962
963// prebuilt_tvservice installs files in <partition>/tvservice directory.
964func PrebuiltTvServiceFactory() android.Module {
965 module := &PrebuiltEtc{}
966 InitPrebuiltEtcModule(module, "tvservice")
967 // This module is device-only
968 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
969 android.InitDefaultableModule(module)
970 return module
971}
972
973// prebuilt_optee installs files in <partition>/optee directory.
974func PrebuiltOpteeFactory() android.Module {
975 module := &PrebuiltEtc{}
976 InitPrebuiltEtcModule(module, "optee")
977 // This module is device-only
978 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
979 android.InitDefaultableModule(module)
980 return module
981}
Jihoon Kangecf76dd2024-11-12 05:24:46 +0000982
983// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
984func PrebuiltTvConfigFactory() android.Module {
985 module := &PrebuiltEtc{}
986 InitPrebuiltEtcModule(module, "tvconfig")
987 // This module is device-only
988 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
989 android.InitDefaultableModule(module)
990 return module
991}
Jihoon Kang3ca07a12024-12-02 19:14:30 +0000992
993// prebuilt_vendor installs files in <partition>/vendor directory.
994func PrebuiltVendorFactory() android.Module {
995 module := &PrebuiltEtc{}
996 InitPrebuiltEtcModule(module, "vendor")
997 // This module is device-only
998 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
999 android.InitDefaultableModule(module)
1000 return module
1001}
Jihoon Kang320ca7c2024-12-03 18:14:50 +00001002
1003// prebuilt_sbin installs files in <partition>/sbin directory.
1004func PrebuiltSbinFactory() android.Module {
1005 module := &PrebuiltEtc{}
1006 InitPrebuiltEtcModule(module, "sbin")
1007 // This module is device-only
1008 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1009 android.InitDefaultableModule(module)
1010 return module
1011}
1012
1013// prebuilt_system installs files in <partition>/system directory.
1014func PrebuiltSystemFactory() android.Module {
1015 module := &PrebuiltEtc{}
1016 InitPrebuiltEtcModule(module, "system")
1017 // This module is device-only
1018 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1019 android.InitDefaultableModule(module)
1020 return module
1021}
1022
1023// prebuilt_first_stage_ramdisk installs files in <partition>/first_stage_ramdisk directory.
1024func PrebuiltFirstStageRamdiskFactory() android.Module {
1025 module := &PrebuiltEtc{}
1026 InitPrebuiltEtcModule(module, "first_stage_ramdisk")
1027 // This module is device-only
1028 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1029 android.InitDefaultableModule(module)
1030 return module
1031}