blob: 5d1d5e288903ebe8889c59465a006eafd8df17f0 [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)
Inseob Kim1e27a142021-05-06 11:46:11 +000083
84 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040085
Jiyong Parkc678ad32018-04-10 13:07:10 +090086}
87
Paul Duffin1172fed2021-03-08 11:28:18 +000088var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
89
Jiyong Parkc678ad32018-04-10 13:07:10 +090090type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080091 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110092 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070093 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090094
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110095 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070096 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
97 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070098 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110099
Douglas Anderson79688ff2024-09-27 15:08:33 -0700100 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
101 // set filename_from_src. This can be used to install each source file to a different directory
102 // and/or change filenames when files are installed. Must be exactly one entry per source file,
103 // which means care must be taken if srcs has globs.
104 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
105
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800106 // 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 +1100107 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900108 Filename *string `android:"arch_variant"`
109
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800110 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900111 // is the same as the file name of the source file.
112 Filename_from_src *bool `android:"arch_variant"`
113
Yifan Hong1b3348d2020-01-21 15:53:22 -0800114 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700115 // On device without a dedicated recovery partition, the module is only
116 // available after switching root into
117 // /first_stage_ramdisk. To expose the module before switching root, install
118 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800119 Ramdisk_available *bool
120
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700121 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700122 // On device without a dedicated recovery partition, the module is only
123 // available after switching root into
124 // /first_stage_ramdisk. To expose the module before switching root, install
125 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700126 Vendor_ramdisk_available *bool
127
Inseob Kim08758f02021-04-08 21:13:22 +0900128 // Make this module available when building for debug ramdisk.
129 Debug_ramdisk_available *bool
130
Tao Bao0ba5c942018-08-14 22:20:22 -0700131 // Make this module available when building for recovery.
132 Recovery_available *bool
133
Jiyong Parkad9ce042018-10-31 22:49:57 +0900134 // Whether this module is directly installable to one of the partitions. Default: true.
135 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800136
137 // Install symlinks to the installed file.
138 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800139
140 // Install to partition system_dlkm when set to true.
141 System_dlkm_specific *bool `android:"arch_variant"`
142
143 // Install to partition vendor_dlkm when set to true.
144 Vendor_dlkm_specific *bool `android:"arch_variant"`
145
146 // Install to partition odm_dlkm when set to true.
147 Odm_dlkm_specific *bool `android:"arch_variant"`
148
149 // Install to partition oem when set to true.
150 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900151}
152
Inseob Kim27408bf2021-04-06 21:00:17 +0900153type prebuiltSubdirProperties struct {
154 // Optional subdirectory under which this file is installed into, cannot be specified with
155 // relative_install_path, prefer relative_install_path.
156 Sub_dir *string `android:"arch_variant"`
157
158 // Optional subdirectory under which this file is installed into, cannot be specified with
159 // sub_dir.
160 Relative_install_path *string `android:"arch_variant"`
161}
162
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900163type prebuiltRootProperties struct {
164 // Install this module to the root directory, without partition subdirs. When this module is
165 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
166 // then be copied to the root of system.img. When this module is packaged by other modules like
167 // android_filesystem, this module will be installed to the root ("/"), unlike normal
168 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
169 Install_in_root *bool
170}
171
Jooyung Han39edb6c2019-11-06 16:53:07 +0900172type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700173 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800174
175 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900176 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800177
178 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900179 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900180}
181
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900182type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700183 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000184 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900185
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900186 properties prebuiltEtcProperties
187
188 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
189 // prebuilt_avb and prebuilt_root modules use this.
190 rootProperties prebuiltRootProperties
191
Inseob Kim27408bf2021-04-06 21:00:17 +0900192 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900193
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100194 sourceFilePaths android.Paths
195 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800196 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800197 installDirBase string
198 installDirBase64 string
199 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800200 // The base install location when soc_specific property is set to true, e.g. "firmware" for
201 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700202 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700203 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700204 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700205
Cole Faustfdec8722024-05-22 11:38:29 -0700206 usedSrcsProperty bool
207
Colin Crossf17e2b52023-10-30 15:17:25 -0700208 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900209}
210
Inseob Kim1e27a142021-05-06 11:46:11 +0000211type Defaults struct {
212 android.ModuleBase
213 android.DefaultsModuleBase
214}
215
Yifan Hong1b3348d2020-01-21 15:53:22 -0800216func (p *PrebuiltEtc) inRamdisk() bool {
217 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
218}
219
220func (p *PrebuiltEtc) onlyInRamdisk() bool {
221 return p.ModuleBase.InstallInRamdisk()
222}
223
224func (p *PrebuiltEtc) InstallInRamdisk() bool {
225 return p.inRamdisk()
226}
227
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700228func (p *PrebuiltEtc) inVendorRamdisk() bool {
229 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
230}
231
232func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
233 return p.ModuleBase.InstallInVendorRamdisk()
234}
235
236func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
237 return p.inVendorRamdisk()
238}
239
Inseob Kim08758f02021-04-08 21:13:22 +0900240func (p *PrebuiltEtc) inDebugRamdisk() bool {
241 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
242}
243
244func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
245 return p.ModuleBase.InstallInDebugRamdisk()
246}
247
248func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
249 return p.inDebugRamdisk()
250}
251
Kiyoung Kimae11c232021-07-19 11:38:04 +0900252func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800253 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700254}
255
256func (p *PrebuiltEtc) onlyInRecovery() bool {
257 return p.ModuleBase.InstallInRecovery()
258}
259
260func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900261 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700262}
263
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700264var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800265
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700266func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800267
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700268func (p *PrebuiltEtc) VendorVariantNeeded(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) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000273 return false
274}
275
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700276func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700277 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900278 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800279}
280
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700281func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700282 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800283}
284
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700285func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700286 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
287}
288
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700289func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900290 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
291}
292
Nelson Li1fb94b22024-07-09 17:04:52 +0800293func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900294 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800295}
296
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700297func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700298 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800299}
300
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700301func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800302 return nil
303}
304
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700305func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800306}
307
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700308func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700309 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100310 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
311 }
Cole Faustfdec8722024-05-22 11:38:29 -0700312 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900313}
314
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700315func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700316 if len(p.installDirPaths) != 1 {
317 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
318 }
319 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900320}
321
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900322// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
323// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700324func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900325 p.additionalDependencies = &paths
326}
327
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700328func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700329 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100330 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
331 }
332 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900333}
334
335func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900336 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700337 return subDir
338 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900339 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900340}
341
Jooyung Han0703fd82020-08-26 22:11:53 +0900342func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900343 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900344}
345
Jiyong Parkad9ce042018-10-31 22:49:57 +0900346func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800347 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900348}
349
Kiyoung Kimae11c232021-07-19 11:38:04 +0900350func (p *PrebuiltEtc) InVendor() bool {
351 return p.ModuleBase.InstallInVendor()
352}
353
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100354func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800355 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
356 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900357 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700358 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
359 installBaseDir = p.installDirBase64
360 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900361 if p.SocSpecific() && p.socInstallDirBase != "" {
362 installBaseDir = p.socInstallDirBase
363 }
Colin Cross2f634572023-11-13 12:12:06 -0800364 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
365 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
366 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100367 return installBaseDir
368}
Colin Cross2f634572023-11-13 12:12:06 -0800369
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100370func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
371 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900372
Cole Faustfdec8722024-05-22 11:38:29 -0700373 srcProperty := p.properties.Src.Get(ctx)
374 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
375 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100376 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000377 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700378 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
379 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
380 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
381 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100382
383 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
384 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
385 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
386 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700387 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800388 // TODO(b/377304441)
389 if android.Bool(p.properties.System_dlkm_specific) {
390 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().SystemDlkmPath(), p.installBaseDir(ctx), p.SubDir())
391 } else if android.Bool(p.properties.Vendor_dlkm_specific) {
392 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().VendorDlkmPath(), p.installBaseDir(ctx), p.SubDir())
393 } else if android.Bool(p.properties.Odm_dlkm_specific) {
394 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OdmDlkmPath(), p.installBaseDir(ctx), p.SubDir())
395 } else if android.Bool(p.properties.Oem_specific) {
396 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
397 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100398
399 filename := proptools.String(p.properties.Filename)
400 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700401 if srcProperty.IsPresent() {
402 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100403 // If the source was not found, set a fake source path to
404 // support AllowMissingDependencies executions.
405 if len(p.sourceFilePaths) == 0 {
406 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
407 }
408
409 // Determine the output file basename.
410 // If Filename is set, use the name specified by the property.
411 // If Filename_from_src is set, use the source file name.
412 // Otherwise use the module name.
413 if filename != "" {
414 if filenameFromSrc {
415 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
416 return
417 }
418 } else if filenameFromSrc {
419 filename = p.sourceFilePaths[0].Base()
420 } else {
421 filename = ctx.ModuleName()
422 }
423 if strings.Contains(filename, "/") {
424 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
425 return
426 }
427 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
428
429 ip := installProperties{
430 filename: filename,
431 sourceFilePath: p.sourceFilePaths[0],
432 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700433 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100434 symlinks: p.properties.Symlinks,
435 }
436 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700437 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700438 } else if len(srcsProperty) > 0 {
439 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100440 if filename != "" {
441 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
442 }
443 if len(p.properties.Symlinks) > 0 {
444 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
445 }
446 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700447 if len(dstsProperty) > 0 {
448 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
449 } else {
450 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
451 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100452 }
Cole Faustfdec8722024-05-22 11:38:29 -0700453 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700454 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
455 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
456 }
457 for i, src := range p.sourceFilePaths {
458 var filename string
459 var installDirPath android.InstallPath
460
461 if len(dstsProperty) > 0 {
462 var dstdir string
463
464 dstdir, filename = filepath.Split(dstsProperty[i])
465 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
466 } else {
467 filename = src.Base()
468 installDirPath = baseInstallDirPath
469 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100470 output := android.PathForModuleOut(ctx, filename).OutputPath
471 ip := installProperties{
472 filename: filename,
473 sourceFilePath: src,
474 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700475 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100476 }
477 p.outputFilePaths = append(p.outputFilePaths, output)
478 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700479 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100480 }
481 } else if ctx.Config().AllowMissingDependencies() {
482 // If no srcs was set and AllowMissingDependencies is enabled then
483 // mark the module as missing dependencies and set a fake source path
484 // and file name.
485 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
486 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
487 if filename == "" {
488 filename = ctx.ModuleName()
489 }
490 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
491 ip := installProperties{
492 filename: filename,
493 sourceFilePath: p.sourceFilePaths[0],
494 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700495 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100496 }
497 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700498 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100499 } else {
500 ctx.PropertyErrorf("src", "missing prebuilt source file")
501 return
502 }
503
504 // Call InstallFile even when uninstallable to make the module included in the package.
505 if !p.Installable() {
506 p.SkipInstall()
507 }
508 for _, ip := range installs {
509 ip.addInstallRules(ctx)
510 }
mrziwang89371762024-06-11 12:42:24 -0700511
512 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000513}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900514
Spandan Das756d3402023-06-05 22:49:50 +0000515type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000516 filename string
517 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100518 outputFilePath android.OutputPath
519 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000520 symlinks []string
521}
522
523// utility function to add install rules to the build graph.
524// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100525func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000526 // Copy the file from src to a location in out/ with the correct `filename`
527 // This ensures that outputFilePath has the correct name for others to
528 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000529 ctx.Build(pctx, android.BuildParams{
530 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100531 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000532 Input: ip.sourceFilePath,
533 })
534
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100535 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000536 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100537 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900538 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900539}
540
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700541func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700542 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800543 if p.inRamdisk() && !p.onlyInRamdisk() {
544 nameSuffix = ".ramdisk"
545 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700546 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
547 nameSuffix = ".vendor_ramdisk"
548 }
Inseob Kim08758f02021-04-08 21:13:22 +0900549 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
550 nameSuffix = ".debug_ramdisk"
551 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900552 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700553 nameSuffix = ".recovery"
554 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700555
556 class := p.makeClass
557 if class == "" {
558 class = "ETC"
559 }
560
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100561 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700562 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700563 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100564 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700565 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700566 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700567 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700568 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100569 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800570 if len(p.properties.Symlinks) > 0 {
571 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
572 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800573 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700574 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800575 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900576 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700577 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900578 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900579 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900580}
581
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000582func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
583 return &p.ModuleBase
584}
585
Jooyung Hana0171822019-07-22 15:48:36 +0900586func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
587 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900588 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900589 p.AddProperties(&p.subdirProperties)
590}
591
592func InitPrebuiltRootModule(p *PrebuiltEtc) {
593 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800594 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900595 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800596}
597
598func InitPrebuiltAvbModule(p *PrebuiltEtc) {
599 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900600 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900601 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900602}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900603
Patrice Arruda9e14b962019-03-11 15:58:50 -0700604// prebuilt_etc is for a prebuilt artifact that is installed in
605// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700606func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900607 module := &PrebuiltEtc{}
608 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900609 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700610 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000611 android.InitDefaultableModule(module)
612 return module
613}
614
615func defaultsFactory() android.Module {
616 return DefaultsFactory()
617}
618
619func DefaultsFactory(props ...interface{}) android.Module {
620 module := &Defaults{}
621
622 module.AddProperties(props...)
623 module.AddProperties(
624 &prebuiltEtcProperties{},
625 &prebuiltSubdirProperties{},
626 )
627
628 android.InitDefaultsModule(module)
629
Jiyong Parkc678ad32018-04-10 13:07:10 +0900630 return module
631}
Tao Bao0ba5c942018-08-14 22:20:22 -0700632
Patrice Arruda9e14b962019-03-11 15:58:50 -0700633// prebuilt_etc_host is for a host prebuilt artifact that is installed in
634// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700635func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900636 module := &PrebuiltEtc{}
637 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800638 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700639 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100640 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800641 return module
642}
643
Miguel32b02802022-12-01 18:38:26 +0000644// prebuilt_etc_host is for a host prebuilt artifact that is installed in
645// <partition>/etc/<sub_dir> directory.
646func PrebuiltEtcCaCertsFactory() android.Module {
647 module := &PrebuiltEtc{}
648 InitPrebuiltEtcModule(module, "cacerts")
649 // This module is device-only
650 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000651 return module
652}
653
Nelson Li1fb94b22024-07-09 17:04:52 +0800654// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
655// `prebuilt_avb` will not have a `system` subdirectory.
656// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
657// root directory of the partition: <partition_root>/avb.
658// prebuilt_avb does not allow adding any other subdirectories.
659func PrebuiltAvbFactory() android.Module {
660 module := &PrebuiltEtc{}
661 InitPrebuiltAvbModule(module)
662 // This module is device-only
663 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
664 android.InitDefaultableModule(module)
665 return module
666}
667
Inseob Kim27408bf2021-04-06 21:00:17 +0900668// prebuilt_root is for a prebuilt artifact that is installed in
669// <partition>/ directory. Can't have any sub directories.
670func PrebuiltRootFactory() android.Module {
671 module := &PrebuiltEtc{}
672 InitPrebuiltRootModule(module)
673 // This module is device-only
674 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100675 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900676 return module
677}
678
Liz Kammere9ecddc2022-01-04 17:27:52 -0500679// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
680// directory.
681func PrebuiltRootHostFactory() android.Module {
682 module := &PrebuiltEtc{}
683 InitPrebuiltEtcModule(module, ".")
684 // This module is host-only
685 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
686 android.InitDefaultableModule(module)
687 return module
688}
689
Patrice Arruda9e14b962019-03-11 15:58:50 -0700690// prebuilt_usr_share is for a prebuilt artifact that is installed in
691// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700692func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900693 module := &PrebuiltEtc{}
694 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800695 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700696 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100697 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800698 return module
699}
700
Patrice Arruda9e14b962019-03-11 15:58:50 -0700701// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
702// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700703func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900704 module := &PrebuiltEtc{}
705 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800706 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700707 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100708 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800709 return module
710}
711
yangbill63c5e192024-03-27 09:02:12 +0000712// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
713// <partition>/usr/hyphen-data/<sub_dir> directory.
714func PrebuiltUserHyphenDataFactory() android.Module {
715 module := &PrebuiltEtc{}
716 InitPrebuiltEtcModule(module, "usr/hyphen-data")
717 // This module is device-only
718 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
719 android.InitDefaultableModule(module)
720 return module
721}
722
yangbill85527e62024-04-30 08:24:50 +0000723// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
724// <partition>/usr/keylayout/<sub_dir> directory.
725func PrebuiltUserKeyLayoutFactory() android.Module {
726 module := &PrebuiltEtc{}
727 InitPrebuiltEtcModule(module, "usr/keylayout")
728 // This module is device-only
729 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
730 android.InitDefaultableModule(module)
731 return module
732}
733
734// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
735// <partition>/usr/keychars/<sub_dir> directory.
736func PrebuiltUserKeyCharsFactory() android.Module {
737 module := &PrebuiltEtc{}
738 InitPrebuiltEtcModule(module, "usr/keychars")
739 // This module is device-only
740 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
741 android.InitDefaultableModule(module)
742 return module
743}
744
745// prebuilt_usr_idc is for a prebuilt artifact that is installed in
746// <partition>/usr/idc/<sub_dir> directory.
747func PrebuiltUserIdcFactory() android.Module {
748 module := &PrebuiltEtc{}
749 InitPrebuiltEtcModule(module, "usr/idc")
750 // This module is device-only
751 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
752 android.InitDefaultableModule(module)
753 return module
754}
755
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000756// prebuilt_usr_srec is for a prebuilt artifact that is installed in
757// <partition>/usr/srec/<sub_dir> directory.
758func PrebuiltUserSrecFactory() android.Module {
759 module := &PrebuiltEtc{}
760 InitPrebuiltEtcModule(module, "usr/srec")
761 // This module is device-only
762 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
763 android.InitDefaultableModule(module)
764 return module
765}
766
Patrice Arruda61583eb2019-05-14 08:20:45 -0700767// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700768func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900769 module := &PrebuiltEtc{}
770 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700771 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700772 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100773 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700774 return module
775}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700776
Kevin93f7cd82024-05-02 12:37:59 +0200777// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
778func PrebuiltOverlayFactory() android.Module {
779 module := &PrebuiltEtc{}
780 InitPrebuiltEtcModule(module, "overlay")
781 // This module is device-only
782 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
783 return module
784}
785
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800786// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
787// image.
788// If soc_specific property is set to true, the firmware file is installed to the
789// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700790func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900791 module := &PrebuiltEtc{}
792 module.socInstallDirBase = "firmware"
793 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700794 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700795 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100796 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700797 return module
798}
Patrice Arruda0f688002020-06-08 21:40:25 +0000799
800// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800801// If soc_specific property is set to true, the DSP related file is installed to the
802// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000803func PrebuiltDSPFactory() android.Module {
804 module := &PrebuiltEtc{}
805 module.socInstallDirBase = "dsp"
806 InitPrebuiltEtcModule(module, "etc/dsp")
807 // This module is device-only
808 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100809 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000810 return module
811}
Colin Cross83ebf232021-04-09 09:41:23 -0700812
Colin Crossf17e2b52023-10-30 15:17:25 -0700813// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
814func PrebuiltRenderScriptBitcodeFactory() android.Module {
815 module := &PrebuiltEtc{}
816 module.makeClass = "RENDERSCRIPT_BITCODE"
817 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800818 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700819 InitPrebuiltEtcModule(module, "lib")
820 // This module is device-only
821 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
822 android.InitDefaultableModule(module)
823 return module
824}
825
Colin Cross83ebf232021-04-09 09:41:23 -0700826// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
827// to the <partition>/lib/rfsa directory.
828func PrebuiltRFSAFactory() android.Module {
829 module := &PrebuiltEtc{}
830 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
831 // many places outside of the application processor. They could be moved to /vendor/dsp once
832 // that is cleaned up.
833 InitPrebuiltEtcModule(module, "lib/rfsa")
834 // This module is device-only
835 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100836 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700837 return module
838}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000839
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000840// prebuilt_media installs media files in <partition>/media directory.
841func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000842 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000843 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000844 // This module is device-only
845 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
846 android.InitDefaultableModule(module)
847 return module
848}
Jihoon Kangec62d842024-10-25 20:27:18 +0000849
850// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
851func PrebuiltVoicepackFactory() android.Module {
852 module := &PrebuiltEtc{}
853 InitPrebuiltEtcModule(module, "tts")
854 // This module is device-only
855 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
856 android.InitDefaultableModule(module)
857 return module
858}
859
860// prebuilt_bin installs files in <partition>/bin directory.
861func PrebuiltBinaryFactory() android.Module {
862 module := &PrebuiltEtc{}
863 InitPrebuiltEtcModule(module, "bin")
864 // This module is device-only
865 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
866 android.InitDefaultableModule(module)
867 return module
868}
869
870// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
871func PrebuiltWallpaperFactory() android.Module {
872 module := &PrebuiltEtc{}
873 InitPrebuiltEtcModule(module, "wallpaper")
874 // This module is device-only
875 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
876 android.InitDefaultableModule(module)
877 return module
878}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000879
880// prebuilt_priv_app installs files in <partition>/priv-app directory.
881func PrebuiltPrivAppFactory() android.Module {
882 module := &PrebuiltEtc{}
883 InitPrebuiltEtcModule(module, "priv-app")
884 // This module is device-only
885 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
886 android.InitDefaultableModule(module)
887 return module
888}
889
890// prebuilt_rfs installs files in <partition>/rfs directory.
891func PrebuiltRfsFactory() android.Module {
892 module := &PrebuiltEtc{}
893 InitPrebuiltEtcModule(module, "rfs")
894 // This module is device-only
895 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
896 android.InitDefaultableModule(module)
897 return module
898}
899
900// prebuilt_framework installs files in <partition>/framework directory.
901func PrebuiltFrameworkFactory() android.Module {
902 module := &PrebuiltEtc{}
903 InitPrebuiltEtcModule(module, "framework")
904 // This module is device-only
905 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
906 android.InitDefaultableModule(module)
907 return module
908}
909
910// prebuilt_res installs files in <partition>/res directory.
911func PrebuiltResFactory() android.Module {
912 module := &PrebuiltEtc{}
913 InitPrebuiltEtcModule(module, "res")
914 // This module is device-only
915 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
916 android.InitDefaultableModule(module)
917 return module
918}
919
920// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
921func PrebuiltWlcUptFactory() android.Module {
922 module := &PrebuiltEtc{}
923 InitPrebuiltEtcModule(module, "wlc_upt")
924 // This module is device-only
925 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
926 android.InitDefaultableModule(module)
927 return module
928}
929
930// prebuilt_odm installs files in <partition>/odm directory.
931func PrebuiltOdmFactory() android.Module {
932 module := &PrebuiltEtc{}
933 InitPrebuiltEtcModule(module, "odm")
934 // This module is device-only
935 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
936 android.InitDefaultableModule(module)
937 return module
938}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000939
940// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
941func PrebuiltVendorDlkmFactory() android.Module {
942 module := &PrebuiltEtc{}
943 InitPrebuiltEtcModule(module, "vendor_dlkm")
944 // This module is device-only
945 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
946 android.InitDefaultableModule(module)
947 return module
948}
949
950// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
951func PrebuiltBtFirmwareFactory() android.Module {
952 module := &PrebuiltEtc{}
953 InitPrebuiltEtcModule(module, "bt_firmware")
954 // This module is device-only
955 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
956 android.InitDefaultableModule(module)
957 return module
958}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000959
960// prebuilt_tvservice installs files in <partition>/tvservice directory.
961func PrebuiltTvServiceFactory() android.Module {
962 module := &PrebuiltEtc{}
963 InitPrebuiltEtcModule(module, "tvservice")
964 // This module is device-only
965 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
966 android.InitDefaultableModule(module)
967 return module
968}
969
970// prebuilt_optee installs files in <partition>/optee directory.
971func PrebuiltOpteeFactory() android.Module {
972 module := &PrebuiltEtc{}
973 InitPrebuiltEtcModule(module, "optee")
974 // This module is device-only
975 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
976 android.InitDefaultableModule(module)
977 return module
978}