blob: dd274ad88089d622f597f32fc862f7a5e647ca4d [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)
Inseob Kim1e27a142021-05-06 11:46:11 +000085
86 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040087
Jiyong Parkc678ad32018-04-10 13:07:10 +090088}
89
Paul Duffin1172fed2021-03-08 11:28:18 +000090var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
91
Jihoon Kang69725b32024-11-12 03:08:49 +000092type PrebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080093 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110094 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070095 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090096
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110097 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070098 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
99 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -0700100 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100101
Douglas Anderson79688ff2024-09-27 15:08:33 -0700102 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
103 // set filename_from_src. This can be used to install each source file to a different directory
104 // and/or change filenames when files are installed. Must be exactly one entry per source file,
105 // which means care must be taken if srcs has globs.
106 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
107
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800108 // 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 +1100109 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900110 Filename *string `android:"arch_variant"`
111
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800112 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900113 // is the same as the file name of the source file.
114 Filename_from_src *bool `android:"arch_variant"`
115
Yifan Hong1b3348d2020-01-21 15:53:22 -0800116 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700117 // On device without a dedicated recovery partition, the module is only
118 // available after switching root into
119 // /first_stage_ramdisk. To expose the module before switching root, install
120 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800121 Ramdisk_available *bool
122
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700123 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700124 // On device without a dedicated recovery partition, the module is only
125 // available after switching root into
126 // /first_stage_ramdisk. To expose the module before switching root, install
127 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700128 Vendor_ramdisk_available *bool
129
Inseob Kim08758f02021-04-08 21:13:22 +0900130 // Make this module available when building for debug ramdisk.
131 Debug_ramdisk_available *bool
132
Tao Bao0ba5c942018-08-14 22:20:22 -0700133 // Make this module available when building for recovery.
134 Recovery_available *bool
135
Jiyong Parkad9ce042018-10-31 22:49:57 +0900136 // Whether this module is directly installable to one of the partitions. Default: true.
137 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800138
139 // Install symlinks to the installed file.
140 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800141
Wei Li59586252024-11-04 09:25:54 -0800142 // Install to partition oem when set to true.
143 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900144}
145
Inseob Kim27408bf2021-04-06 21:00:17 +0900146type prebuiltSubdirProperties struct {
147 // Optional subdirectory under which this file is installed into, cannot be specified with
148 // relative_install_path, prefer relative_install_path.
149 Sub_dir *string `android:"arch_variant"`
150
151 // Optional subdirectory under which this file is installed into, cannot be specified with
152 // sub_dir.
153 Relative_install_path *string `android:"arch_variant"`
154}
155
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900156type prebuiltRootProperties struct {
157 // Install this module to the root directory, without partition subdirs. When this module is
158 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
159 // then be copied to the root of system.img. When this module is packaged by other modules like
160 // android_filesystem, this module will be installed to the root ("/"), unlike normal
161 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
162 Install_in_root *bool
163}
164
Jooyung Han39edb6c2019-11-06 16:53:07 +0900165type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700166 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800167
168 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900169 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800170
171 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900172 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900173}
174
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900175type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700176 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000177 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900178
Jihoon Kang69725b32024-11-12 03:08:49 +0000179 properties PrebuiltEtcProperties
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900180
181 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
182 // prebuilt_avb and prebuilt_root modules use this.
183 rootProperties prebuiltRootProperties
184
Inseob Kim27408bf2021-04-06 21:00:17 +0900185 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900186
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100187 sourceFilePaths android.Paths
Cole Faust4e9f5922024-11-13 16:09:23 -0800188 outputFilePaths android.WritablePaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800189 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800190 installDirBase string
191 installDirBase64 string
192 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800193 // The base install location when soc_specific property is set to true, e.g. "firmware" for
194 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700195 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700196 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700197 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700198
Cole Faustfdec8722024-05-22 11:38:29 -0700199 usedSrcsProperty bool
200
Colin Crossf17e2b52023-10-30 15:17:25 -0700201 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900202}
203
Inseob Kim1e27a142021-05-06 11:46:11 +0000204type Defaults struct {
205 android.ModuleBase
206 android.DefaultsModuleBase
207}
208
Yifan Hong1b3348d2020-01-21 15:53:22 -0800209func (p *PrebuiltEtc) inRamdisk() bool {
210 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
211}
212
213func (p *PrebuiltEtc) onlyInRamdisk() bool {
214 return p.ModuleBase.InstallInRamdisk()
215}
216
217func (p *PrebuiltEtc) InstallInRamdisk() bool {
218 return p.inRamdisk()
219}
220
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700221func (p *PrebuiltEtc) inVendorRamdisk() bool {
222 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
223}
224
225func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
226 return p.ModuleBase.InstallInVendorRamdisk()
227}
228
229func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
230 return p.inVendorRamdisk()
231}
232
Inseob Kim08758f02021-04-08 21:13:22 +0900233func (p *PrebuiltEtc) inDebugRamdisk() bool {
234 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
235}
236
237func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
238 return p.ModuleBase.InstallInDebugRamdisk()
239}
240
241func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
242 return p.inDebugRamdisk()
243}
244
Kiyoung Kimae11c232021-07-19 11:38:04 +0900245func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800246 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700247}
248
249func (p *PrebuiltEtc) onlyInRecovery() bool {
250 return p.ModuleBase.InstallInRecovery()
251}
252
253func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900254 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700255}
256
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700257var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800258
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700259func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800260
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700261func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000262 return false
263}
264
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700265func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000266 return false
267}
268
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700269func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700270 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900271 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800272}
273
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700274func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700275 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800276}
277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700279 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
280}
281
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700282func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900283 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
284}
285
Nelson Li1fb94b22024-07-09 17:04:52 +0800286func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900287 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800288}
289
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700290func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700291 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800292}
293
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700294func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800295 return nil
296}
297
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700298func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800299}
300
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700301func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700302 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100303 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
304 }
Cole Faustfdec8722024-05-22 11:38:29 -0700305 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900306}
307
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700308func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700309 if len(p.installDirPaths) != 1 {
310 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
311 }
312 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900313}
314
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900315// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
316// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700317func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900318 p.additionalDependencies = &paths
319}
320
Cole Faust4e9f5922024-11-13 16:09:23 -0800321func (p *PrebuiltEtc) OutputFile() android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700322 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100323 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
324 }
325 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900326}
327
328func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900329 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700330 return subDir
331 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900332 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900333}
334
Jooyung Han0703fd82020-08-26 22:11:53 +0900335func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900336 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900337}
338
Jiyong Parkad9ce042018-10-31 22:49:57 +0900339func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800340 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900341}
342
Kiyoung Kimae11c232021-07-19 11:38:04 +0900343func (p *PrebuiltEtc) InVendor() bool {
344 return p.ModuleBase.InstallInVendor()
345}
346
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100347func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800348 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
349 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900350 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700351 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
352 installBaseDir = p.installDirBase64
353 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900354 if p.SocSpecific() && p.socInstallDirBase != "" {
355 installBaseDir = p.socInstallDirBase
356 }
Colin Cross2f634572023-11-13 12:12:06 -0800357 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
358 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
359 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100360 return installBaseDir
361}
Colin Cross2f634572023-11-13 12:12:06 -0800362
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100363func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
364 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900365
Cole Faustfdec8722024-05-22 11:38:29 -0700366 srcProperty := p.properties.Src.Get(ctx)
367 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
368 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100369 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000370 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700371 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
372 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
373 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
374 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100375
376 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
377 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
378 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
379 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700380 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800381 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000382 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800383 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
384 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100385
386 filename := proptools.String(p.properties.Filename)
387 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700388 if srcProperty.IsPresent() {
389 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100390 // If the source was not found, set a fake source path to
391 // support AllowMissingDependencies executions.
392 if len(p.sourceFilePaths) == 0 {
393 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
394 }
395
396 // Determine the output file basename.
397 // If Filename is set, use the name specified by the property.
398 // If Filename_from_src is set, use the source file name.
399 // Otherwise use the module name.
400 if filename != "" {
401 if filenameFromSrc {
402 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
403 return
404 }
405 } else if filenameFromSrc {
406 filename = p.sourceFilePaths[0].Base()
407 } else {
408 filename = ctx.ModuleName()
409 }
410 if strings.Contains(filename, "/") {
411 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
412 return
413 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800414 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100415
416 ip := installProperties{
417 filename: filename,
418 sourceFilePath: p.sourceFilePaths[0],
419 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700420 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100421 symlinks: p.properties.Symlinks,
422 }
423 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700424 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700425 } else if len(srcsProperty) > 0 {
426 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100427 if filename != "" {
428 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
429 }
430 if len(p.properties.Symlinks) > 0 {
431 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
432 }
433 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700434 if len(dstsProperty) > 0 {
435 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
436 } else {
437 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
438 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100439 }
Cole Faustfdec8722024-05-22 11:38:29 -0700440 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700441 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
442 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
443 }
444 for i, src := range p.sourceFilePaths {
445 var filename string
446 var installDirPath android.InstallPath
447
448 if len(dstsProperty) > 0 {
449 var dstdir string
450
451 dstdir, filename = filepath.Split(dstsProperty[i])
452 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
453 } else {
454 filename = src.Base()
455 installDirPath = baseInstallDirPath
456 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800457 output := android.PathForModuleOut(ctx, filename)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100458 ip := installProperties{
459 filename: filename,
460 sourceFilePath: src,
461 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700462 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100463 }
464 p.outputFilePaths = append(p.outputFilePaths, output)
465 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700466 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100467 }
468 } else if ctx.Config().AllowMissingDependencies() {
469 // If no srcs was set and AllowMissingDependencies is enabled then
470 // mark the module as missing dependencies and set a fake source path
471 // and file name.
472 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
473 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
474 if filename == "" {
475 filename = ctx.ModuleName()
476 }
Cole Faust4e9f5922024-11-13 16:09:23 -0800477 p.outputFilePaths = android.WritablePaths{android.PathForModuleOut(ctx, filename)}
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100478 ip := installProperties{
479 filename: filename,
480 sourceFilePath: p.sourceFilePaths[0],
481 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700482 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100483 }
484 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700485 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100486 } else {
487 ctx.PropertyErrorf("src", "missing prebuilt source file")
488 return
489 }
490
491 // Call InstallFile even when uninstallable to make the module included in the package.
492 if !p.Installable() {
493 p.SkipInstall()
494 }
495 for _, ip := range installs {
496 ip.addInstallRules(ctx)
497 }
mrziwang89371762024-06-11 12:42:24 -0700498
499 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000500}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900501
Spandan Das756d3402023-06-05 22:49:50 +0000502type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000503 filename string
504 sourceFilePath android.Path
Cole Faust4e9f5922024-11-13 16:09:23 -0800505 outputFilePath android.WritablePath
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100506 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000507 symlinks []string
508}
509
510// utility function to add install rules to the build graph.
511// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100512func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000513 // Copy the file from src to a location in out/ with the correct `filename`
514 // This ensures that outputFilePath has the correct name for others to
515 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000516 ctx.Build(pctx, android.BuildParams{
517 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100518 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000519 Input: ip.sourceFilePath,
520 })
521
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100522 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000523 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100524 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900525 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900526}
527
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700528func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700529 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800530 if p.inRamdisk() && !p.onlyInRamdisk() {
531 nameSuffix = ".ramdisk"
532 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700533 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
534 nameSuffix = ".vendor_ramdisk"
535 }
Inseob Kim08758f02021-04-08 21:13:22 +0900536 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
537 nameSuffix = ".debug_ramdisk"
538 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900539 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700540 nameSuffix = ".recovery"
541 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700542
543 class := p.makeClass
544 if class == "" {
545 class = "ETC"
546 }
547
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100548 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700549 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700550 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100551 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700552 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700553 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700554 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700555 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100556 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800557 if len(p.properties.Symlinks) > 0 {
558 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
559 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800560 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700561 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800562 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900563 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700564 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900565 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900566 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900567}
568
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000569func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
570 return &p.ModuleBase
571}
572
Jooyung Hana0171822019-07-22 15:48:36 +0900573func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
574 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900575 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900576 p.AddProperties(&p.subdirProperties)
577}
578
579func InitPrebuiltRootModule(p *PrebuiltEtc) {
580 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800581 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900582 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800583}
584
585func InitPrebuiltAvbModule(p *PrebuiltEtc) {
586 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900587 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900588 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900589}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900590
Patrice Arruda9e14b962019-03-11 15:58:50 -0700591// prebuilt_etc is for a prebuilt artifact that is installed in
592// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700593func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900594 module := &PrebuiltEtc{}
595 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900596 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700597 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000598 android.InitDefaultableModule(module)
599 return module
600}
601
602func defaultsFactory() android.Module {
603 return DefaultsFactory()
604}
605
606func DefaultsFactory(props ...interface{}) android.Module {
607 module := &Defaults{}
608
609 module.AddProperties(props...)
610 module.AddProperties(
Jihoon Kang69725b32024-11-12 03:08:49 +0000611 &PrebuiltEtcProperties{},
Inseob Kim1e27a142021-05-06 11:46:11 +0000612 &prebuiltSubdirProperties{},
613 )
614
615 android.InitDefaultsModule(module)
616
Jiyong Parkc678ad32018-04-10 13:07:10 +0900617 return module
618}
Tao Bao0ba5c942018-08-14 22:20:22 -0700619
Patrice Arruda9e14b962019-03-11 15:58:50 -0700620// prebuilt_etc_host is for a host prebuilt artifact that is installed in
621// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700622func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900623 module := &PrebuiltEtc{}
624 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800625 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700626 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100627 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800628 return module
629}
630
Miguel32b02802022-12-01 18:38:26 +0000631// prebuilt_etc_host is for a host prebuilt artifact that is installed in
632// <partition>/etc/<sub_dir> directory.
633func PrebuiltEtcCaCertsFactory() android.Module {
634 module := &PrebuiltEtc{}
635 InitPrebuiltEtcModule(module, "cacerts")
636 // This module is device-only
637 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000638 return module
639}
640
Nelson Li1fb94b22024-07-09 17:04:52 +0800641// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
642// `prebuilt_avb` will not have a `system` subdirectory.
643// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
644// root directory of the partition: <partition_root>/avb.
645// prebuilt_avb does not allow adding any other subdirectories.
646func PrebuiltAvbFactory() android.Module {
647 module := &PrebuiltEtc{}
648 InitPrebuiltAvbModule(module)
649 // This module is device-only
650 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
651 android.InitDefaultableModule(module)
652 return module
653}
654
Inseob Kim27408bf2021-04-06 21:00:17 +0900655// prebuilt_root is for a prebuilt artifact that is installed in
656// <partition>/ directory. Can't have any sub directories.
657func PrebuiltRootFactory() android.Module {
658 module := &PrebuiltEtc{}
659 InitPrebuiltRootModule(module)
660 // This module is device-only
661 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100662 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900663 return module
664}
665
Liz Kammere9ecddc2022-01-04 17:27:52 -0500666// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
667// directory.
668func PrebuiltRootHostFactory() android.Module {
669 module := &PrebuiltEtc{}
670 InitPrebuiltEtcModule(module, ".")
671 // This module is host-only
672 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
673 android.InitDefaultableModule(module)
674 return module
675}
676
Patrice Arruda9e14b962019-03-11 15:58:50 -0700677// prebuilt_usr_share is for a prebuilt artifact that is installed in
678// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700679func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900680 module := &PrebuiltEtc{}
681 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800682 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700683 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100684 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800685 return module
686}
687
Patrice Arruda9e14b962019-03-11 15:58:50 -0700688// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
689// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700690func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900691 module := &PrebuiltEtc{}
692 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800693 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700694 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100695 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800696 return module
697}
698
yangbill63c5e192024-03-27 09:02:12 +0000699// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
700// <partition>/usr/hyphen-data/<sub_dir> directory.
701func PrebuiltUserHyphenDataFactory() android.Module {
702 module := &PrebuiltEtc{}
703 InitPrebuiltEtcModule(module, "usr/hyphen-data")
704 // This module is device-only
705 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
706 android.InitDefaultableModule(module)
707 return module
708}
709
yangbill85527e62024-04-30 08:24:50 +0000710// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
711// <partition>/usr/keylayout/<sub_dir> directory.
712func PrebuiltUserKeyLayoutFactory() android.Module {
713 module := &PrebuiltEtc{}
714 InitPrebuiltEtcModule(module, "usr/keylayout")
715 // This module is device-only
716 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
717 android.InitDefaultableModule(module)
718 return module
719}
720
721// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
722// <partition>/usr/keychars/<sub_dir> directory.
723func PrebuiltUserKeyCharsFactory() android.Module {
724 module := &PrebuiltEtc{}
725 InitPrebuiltEtcModule(module, "usr/keychars")
726 // This module is device-only
727 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
728 android.InitDefaultableModule(module)
729 return module
730}
731
732// prebuilt_usr_idc is for a prebuilt artifact that is installed in
733// <partition>/usr/idc/<sub_dir> directory.
734func PrebuiltUserIdcFactory() android.Module {
735 module := &PrebuiltEtc{}
736 InitPrebuiltEtcModule(module, "usr/idc")
737 // This module is device-only
738 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
739 android.InitDefaultableModule(module)
740 return module
741}
742
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000743// prebuilt_usr_srec is for a prebuilt artifact that is installed in
744// <partition>/usr/srec/<sub_dir> directory.
745func PrebuiltUserSrecFactory() android.Module {
746 module := &PrebuiltEtc{}
747 InitPrebuiltEtcModule(module, "usr/srec")
748 // This module is device-only
749 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
750 android.InitDefaultableModule(module)
751 return module
752}
753
Patrice Arruda61583eb2019-05-14 08:20:45 -0700754// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700755func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900756 module := &PrebuiltEtc{}
757 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700758 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700759 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100760 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700761 return module
762}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700763
Kevin93f7cd82024-05-02 12:37:59 +0200764// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
765func PrebuiltOverlayFactory() android.Module {
766 module := &PrebuiltEtc{}
767 InitPrebuiltEtcModule(module, "overlay")
768 // This module is device-only
769 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
770 return module
771}
772
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800773// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
774// image.
775// If soc_specific property is set to true, the firmware file is installed to the
776// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700777func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900778 module := &PrebuiltEtc{}
779 module.socInstallDirBase = "firmware"
780 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700781 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700782 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100783 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700784 return module
785}
Patrice Arruda0f688002020-06-08 21:40:25 +0000786
787// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800788// If soc_specific property is set to true, the DSP related file is installed to the
789// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000790func PrebuiltDSPFactory() android.Module {
791 module := &PrebuiltEtc{}
792 module.socInstallDirBase = "dsp"
793 InitPrebuiltEtcModule(module, "etc/dsp")
794 // This module is device-only
795 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100796 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000797 return module
798}
Colin Cross83ebf232021-04-09 09:41:23 -0700799
Colin Crossf17e2b52023-10-30 15:17:25 -0700800// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
801func PrebuiltRenderScriptBitcodeFactory() android.Module {
802 module := &PrebuiltEtc{}
803 module.makeClass = "RENDERSCRIPT_BITCODE"
804 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800805 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700806 InitPrebuiltEtcModule(module, "lib")
807 // This module is device-only
808 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
809 android.InitDefaultableModule(module)
810 return module
811}
812
Colin Cross83ebf232021-04-09 09:41:23 -0700813// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
814// to the <partition>/lib/rfsa directory.
815func PrebuiltRFSAFactory() android.Module {
816 module := &PrebuiltEtc{}
817 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
818 // many places outside of the application processor. They could be moved to /vendor/dsp once
819 // that is cleaned up.
820 InitPrebuiltEtcModule(module, "lib/rfsa")
821 // This module is device-only
822 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100823 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700824 return module
825}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000826
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000827// prebuilt_media installs media files in <partition>/media directory.
828func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000829 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000830 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000831 // This module is device-only
832 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
833 android.InitDefaultableModule(module)
834 return module
835}
Jihoon Kangec62d842024-10-25 20:27:18 +0000836
837// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
838func PrebuiltVoicepackFactory() android.Module {
839 module := &PrebuiltEtc{}
840 InitPrebuiltEtcModule(module, "tts")
841 // This module is device-only
842 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
843 android.InitDefaultableModule(module)
844 return module
845}
846
847// prebuilt_bin installs files in <partition>/bin directory.
848func PrebuiltBinaryFactory() android.Module {
849 module := &PrebuiltEtc{}
850 InitPrebuiltEtcModule(module, "bin")
851 // This module is device-only
852 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
853 android.InitDefaultableModule(module)
854 return module
855}
856
857// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
858func PrebuiltWallpaperFactory() android.Module {
859 module := &PrebuiltEtc{}
860 InitPrebuiltEtcModule(module, "wallpaper")
861 // This module is device-only
862 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
863 android.InitDefaultableModule(module)
864 return module
865}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000866
867// prebuilt_priv_app installs files in <partition>/priv-app directory.
868func PrebuiltPrivAppFactory() android.Module {
869 module := &PrebuiltEtc{}
870 InitPrebuiltEtcModule(module, "priv-app")
871 // This module is device-only
872 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
873 android.InitDefaultableModule(module)
874 return module
875}
876
877// prebuilt_rfs installs files in <partition>/rfs directory.
878func PrebuiltRfsFactory() android.Module {
879 module := &PrebuiltEtc{}
880 InitPrebuiltEtcModule(module, "rfs")
881 // This module is device-only
882 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
883 android.InitDefaultableModule(module)
884 return module
885}
886
887// prebuilt_framework installs files in <partition>/framework directory.
888func PrebuiltFrameworkFactory() android.Module {
889 module := &PrebuiltEtc{}
890 InitPrebuiltEtcModule(module, "framework")
891 // This module is device-only
892 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
893 android.InitDefaultableModule(module)
894 return module
895}
896
897// prebuilt_res installs files in <partition>/res directory.
898func PrebuiltResFactory() android.Module {
899 module := &PrebuiltEtc{}
900 InitPrebuiltEtcModule(module, "res")
901 // This module is device-only
902 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
903 android.InitDefaultableModule(module)
904 return module
905}
906
907// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
908func PrebuiltWlcUptFactory() android.Module {
909 module := &PrebuiltEtc{}
910 InitPrebuiltEtcModule(module, "wlc_upt")
911 // This module is device-only
912 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
913 android.InitDefaultableModule(module)
914 return module
915}
916
917// prebuilt_odm installs files in <partition>/odm directory.
918func PrebuiltOdmFactory() android.Module {
919 module := &PrebuiltEtc{}
920 InitPrebuiltEtcModule(module, "odm")
921 // This module is device-only
922 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
923 android.InitDefaultableModule(module)
924 return module
925}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000926
927// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
928func PrebuiltVendorDlkmFactory() android.Module {
929 module := &PrebuiltEtc{}
930 InitPrebuiltEtcModule(module, "vendor_dlkm")
931 // This module is device-only
932 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
933 android.InitDefaultableModule(module)
934 return module
935}
936
937// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
938func PrebuiltBtFirmwareFactory() android.Module {
939 module := &PrebuiltEtc{}
940 InitPrebuiltEtcModule(module, "bt_firmware")
941 // This module is device-only
942 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
943 android.InitDefaultableModule(module)
944 return module
945}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000946
947// prebuilt_tvservice installs files in <partition>/tvservice directory.
948func PrebuiltTvServiceFactory() android.Module {
949 module := &PrebuiltEtc{}
950 InitPrebuiltEtcModule(module, "tvservice")
951 // This module is device-only
952 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
953 android.InitDefaultableModule(module)
954 return module
955}
956
957// prebuilt_optee installs files in <partition>/optee directory.
958func PrebuiltOpteeFactory() android.Module {
959 module := &PrebuiltEtc{}
960 InitPrebuiltEtcModule(module, "optee")
961 // This module is device-only
962 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
963 android.InitDefaultableModule(module)
964 return module
965}
Jihoon Kangecf76dd2024-11-12 05:24:46 +0000966
967// prebuilt_tvconfig installs files in <partition>/tvconfig directory.
968func PrebuiltTvConfigFactory() android.Module {
969 module := &PrebuiltEtc{}
970 InitPrebuiltEtcModule(module, "tvconfig")
971 // This module is device-only
972 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
973 android.InitDefaultableModule(module)
974 return module
975}
Jihoon Kang3ca07a12024-12-02 19:14:30 +0000976
977// prebuilt_vendor installs files in <partition>/vendor directory.
978func PrebuiltVendorFactory() android.Module {
979 module := &PrebuiltEtc{}
980 InitPrebuiltEtcModule(module, "vendor")
981 // This module is device-only
982 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
983 android.InitDefaultableModule(module)
984 return module
985}