blob: 6bb7ee3dc433afe7138907d9828d376649688f52 [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)
Inseob Kim1e27a142021-05-06 11:46:11 +000081
82 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040083
Jiyong Parkc678ad32018-04-10 13:07:10 +090084}
85
Paul Duffin1172fed2021-03-08 11:28:18 +000086var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
87
Jiyong Parkc678ad32018-04-10 13:07:10 +090088type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080089 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110090 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070091 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090092
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110093 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070094 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
95 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070096 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110097
Douglas Anderson79688ff2024-09-27 15:08:33 -070098 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
99 // set filename_from_src. This can be used to install each source file to a different directory
100 // and/or change filenames when files are installed. Must be exactly one entry per source file,
101 // which means care must be taken if srcs has globs.
102 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
103
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800104 // 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 +1100105 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900106 Filename *string `android:"arch_variant"`
107
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800108 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900109 // is the same as the file name of the source file.
110 Filename_from_src *bool `android:"arch_variant"`
111
Yifan Hong1b3348d2020-01-21 15:53:22 -0800112 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700113 // On device without a dedicated recovery partition, the module is only
114 // available after switching root into
115 // /first_stage_ramdisk. To expose the module before switching root, install
116 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800117 Ramdisk_available *bool
118
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700119 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700120 // On device without a dedicated recovery partition, the module is only
121 // available after switching root into
122 // /first_stage_ramdisk. To expose the module before switching root, install
123 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700124 Vendor_ramdisk_available *bool
125
Inseob Kim08758f02021-04-08 21:13:22 +0900126 // Make this module available when building for debug ramdisk.
127 Debug_ramdisk_available *bool
128
Tao Bao0ba5c942018-08-14 22:20:22 -0700129 // Make this module available when building for recovery.
130 Recovery_available *bool
131
Jiyong Parkad9ce042018-10-31 22:49:57 +0900132 // Whether this module is directly installable to one of the partitions. Default: true.
133 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800134
135 // Install symlinks to the installed file.
136 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800137
Wei Li59586252024-11-04 09:25:54 -0800138 // Install to partition oem when set to true.
139 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900140}
141
Inseob Kim27408bf2021-04-06 21:00:17 +0900142type prebuiltSubdirProperties struct {
143 // Optional subdirectory under which this file is installed into, cannot be specified with
144 // relative_install_path, prefer relative_install_path.
145 Sub_dir *string `android:"arch_variant"`
146
147 // Optional subdirectory under which this file is installed into, cannot be specified with
148 // sub_dir.
149 Relative_install_path *string `android:"arch_variant"`
150}
151
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900152type prebuiltRootProperties struct {
153 // Install this module to the root directory, without partition subdirs. When this module is
154 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
155 // then be copied to the root of system.img. When this module is packaged by other modules like
156 // android_filesystem, this module will be installed to the root ("/"), unlike normal
157 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
158 Install_in_root *bool
159}
160
Jooyung Han39edb6c2019-11-06 16:53:07 +0900161type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700162 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800163
164 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900165 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800166
167 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900168 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900169}
170
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900171type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700172 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000173 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900174
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900175 properties prebuiltEtcProperties
176
177 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
178 // prebuilt_avb and prebuilt_root modules use this.
179 rootProperties prebuiltRootProperties
180
Inseob Kim27408bf2021-04-06 21:00:17 +0900181 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900182
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100183 sourceFilePaths android.Paths
184 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800185 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800186 installDirBase string
187 installDirBase64 string
188 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800189 // The base install location when soc_specific property is set to true, e.g. "firmware" for
190 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700191 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700192 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700193 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700194
Cole Faustfdec8722024-05-22 11:38:29 -0700195 usedSrcsProperty bool
196
Colin Crossf17e2b52023-10-30 15:17:25 -0700197 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900198}
199
Inseob Kim1e27a142021-05-06 11:46:11 +0000200type Defaults struct {
201 android.ModuleBase
202 android.DefaultsModuleBase
203}
204
Yifan Hong1b3348d2020-01-21 15:53:22 -0800205func (p *PrebuiltEtc) inRamdisk() bool {
206 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
207}
208
209func (p *PrebuiltEtc) onlyInRamdisk() bool {
210 return p.ModuleBase.InstallInRamdisk()
211}
212
213func (p *PrebuiltEtc) InstallInRamdisk() bool {
214 return p.inRamdisk()
215}
216
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700217func (p *PrebuiltEtc) inVendorRamdisk() bool {
218 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
219}
220
221func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
222 return p.ModuleBase.InstallInVendorRamdisk()
223}
224
225func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
226 return p.inVendorRamdisk()
227}
228
Inseob Kim08758f02021-04-08 21:13:22 +0900229func (p *PrebuiltEtc) inDebugRamdisk() bool {
230 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
231}
232
233func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
234 return p.ModuleBase.InstallInDebugRamdisk()
235}
236
237func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
238 return p.inDebugRamdisk()
239}
240
Kiyoung Kimae11c232021-07-19 11:38:04 +0900241func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800242 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700243}
244
245func (p *PrebuiltEtc) onlyInRecovery() bool {
246 return p.ModuleBase.InstallInRecovery()
247}
248
249func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900250 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700251}
252
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700253var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800254
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700255func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800256
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700257func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000258 return false
259}
260
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700261func (p *PrebuiltEtc) ProductVariantNeeded(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) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700266 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900267 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800268}
269
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700270func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700271 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800272}
273
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700274func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700275 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
276}
277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900279 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
280}
281
Nelson Li1fb94b22024-07-09 17:04:52 +0800282func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900283 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800284}
285
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700286func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700287 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800288}
289
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700290func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800291 return nil
292}
293
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700294func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800295}
296
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700297func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700298 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100299 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
300 }
Cole Faustfdec8722024-05-22 11:38:29 -0700301 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900302}
303
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700304func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700305 if len(p.installDirPaths) != 1 {
306 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
307 }
308 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900309}
310
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900311// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
312// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700313func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900314 p.additionalDependencies = &paths
315}
316
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700317func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700318 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100319 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
320 }
321 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900322}
323
324func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900325 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700326 return subDir
327 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900328 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900329}
330
Jooyung Han0703fd82020-08-26 22:11:53 +0900331func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900332 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900333}
334
Jiyong Parkad9ce042018-10-31 22:49:57 +0900335func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800336 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900337}
338
Kiyoung Kimae11c232021-07-19 11:38:04 +0900339func (p *PrebuiltEtc) InVendor() bool {
340 return p.ModuleBase.InstallInVendor()
341}
342
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100343func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800344 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
345 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900346 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700347 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
348 installBaseDir = p.installDirBase64
349 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900350 if p.SocSpecific() && p.socInstallDirBase != "" {
351 installBaseDir = p.socInstallDirBase
352 }
Colin Cross2f634572023-11-13 12:12:06 -0800353 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
354 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
355 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100356 return installBaseDir
357}
Colin Cross2f634572023-11-13 12:12:06 -0800358
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100359func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
360 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900361
Cole Faustfdec8722024-05-22 11:38:29 -0700362 srcProperty := p.properties.Src.Get(ctx)
363 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
364 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100365 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000366 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700367 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
368 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
369 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
370 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100371
372 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
373 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
374 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
375 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700376 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800377 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000378 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800379 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
380 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100381
382 filename := proptools.String(p.properties.Filename)
383 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700384 if srcProperty.IsPresent() {
385 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100386 // If the source was not found, set a fake source path to
387 // support AllowMissingDependencies executions.
388 if len(p.sourceFilePaths) == 0 {
389 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
390 }
391
392 // Determine the output file basename.
393 // If Filename is set, use the name specified by the property.
394 // If Filename_from_src is set, use the source file name.
395 // Otherwise use the module name.
396 if filename != "" {
397 if filenameFromSrc {
398 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
399 return
400 }
401 } else if filenameFromSrc {
402 filename = p.sourceFilePaths[0].Base()
403 } else {
404 filename = ctx.ModuleName()
405 }
406 if strings.Contains(filename, "/") {
407 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
408 return
409 }
410 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
411
412 ip := installProperties{
413 filename: filename,
414 sourceFilePath: p.sourceFilePaths[0],
415 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700416 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100417 symlinks: p.properties.Symlinks,
418 }
419 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700420 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700421 } else if len(srcsProperty) > 0 {
422 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100423 if filename != "" {
424 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
425 }
426 if len(p.properties.Symlinks) > 0 {
427 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
428 }
429 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700430 if len(dstsProperty) > 0 {
431 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
432 } else {
433 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
434 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100435 }
Cole Faustfdec8722024-05-22 11:38:29 -0700436 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700437 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
438 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
439 }
440 for i, src := range p.sourceFilePaths {
441 var filename string
442 var installDirPath android.InstallPath
443
444 if len(dstsProperty) > 0 {
445 var dstdir string
446
447 dstdir, filename = filepath.Split(dstsProperty[i])
448 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
449 } else {
450 filename = src.Base()
451 installDirPath = baseInstallDirPath
452 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100453 output := android.PathForModuleOut(ctx, filename).OutputPath
454 ip := installProperties{
455 filename: filename,
456 sourceFilePath: src,
457 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700458 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100459 }
460 p.outputFilePaths = append(p.outputFilePaths, output)
461 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700462 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100463 }
464 } else if ctx.Config().AllowMissingDependencies() {
465 // If no srcs was set and AllowMissingDependencies is enabled then
466 // mark the module as missing dependencies and set a fake source path
467 // and file name.
468 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
469 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
470 if filename == "" {
471 filename = ctx.ModuleName()
472 }
473 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
474 ip := installProperties{
475 filename: filename,
476 sourceFilePath: p.sourceFilePaths[0],
477 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700478 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100479 }
480 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700481 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100482 } else {
483 ctx.PropertyErrorf("src", "missing prebuilt source file")
484 return
485 }
486
487 // Call InstallFile even when uninstallable to make the module included in the package.
488 if !p.Installable() {
489 p.SkipInstall()
490 }
491 for _, ip := range installs {
492 ip.addInstallRules(ctx)
493 }
mrziwang89371762024-06-11 12:42:24 -0700494
495 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000496}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900497
Spandan Das756d3402023-06-05 22:49:50 +0000498type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000499 filename string
500 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100501 outputFilePath android.OutputPath
502 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000503 symlinks []string
504}
505
506// utility function to add install rules to the build graph.
507// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100508func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000509 // Copy the file from src to a location in out/ with the correct `filename`
510 // This ensures that outputFilePath has the correct name for others to
511 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000512 ctx.Build(pctx, android.BuildParams{
513 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100514 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000515 Input: ip.sourceFilePath,
516 })
517
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100518 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000519 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100520 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900521 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900522}
523
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700524func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700525 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800526 if p.inRamdisk() && !p.onlyInRamdisk() {
527 nameSuffix = ".ramdisk"
528 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700529 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
530 nameSuffix = ".vendor_ramdisk"
531 }
Inseob Kim08758f02021-04-08 21:13:22 +0900532 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
533 nameSuffix = ".debug_ramdisk"
534 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900535 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700536 nameSuffix = ".recovery"
537 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700538
539 class := p.makeClass
540 if class == "" {
541 class = "ETC"
542 }
543
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100544 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700545 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700546 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100547 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700548 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700549 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700550 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700551 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100552 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800553 if len(p.properties.Symlinks) > 0 {
554 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
555 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800556 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700557 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800558 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900559 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700560 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900561 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900562 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900563}
564
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000565func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
566 return &p.ModuleBase
567}
568
Jooyung Hana0171822019-07-22 15:48:36 +0900569func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
570 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900571 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900572 p.AddProperties(&p.subdirProperties)
573}
574
575func InitPrebuiltRootModule(p *PrebuiltEtc) {
576 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800577 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900578 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800579}
580
581func InitPrebuiltAvbModule(p *PrebuiltEtc) {
582 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900583 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900584 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900585}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900586
Patrice Arruda9e14b962019-03-11 15:58:50 -0700587// prebuilt_etc is for a prebuilt artifact that is installed in
588// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700589func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900590 module := &PrebuiltEtc{}
591 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900592 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700593 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000594 android.InitDefaultableModule(module)
595 return module
596}
597
598func defaultsFactory() android.Module {
599 return DefaultsFactory()
600}
601
602func DefaultsFactory(props ...interface{}) android.Module {
603 module := &Defaults{}
604
605 module.AddProperties(props...)
606 module.AddProperties(
607 &prebuiltEtcProperties{},
608 &prebuiltSubdirProperties{},
609 )
610
611 android.InitDefaultsModule(module)
612
Jiyong Parkc678ad32018-04-10 13:07:10 +0900613 return module
614}
Tao Bao0ba5c942018-08-14 22:20:22 -0700615
Patrice Arruda9e14b962019-03-11 15:58:50 -0700616// prebuilt_etc_host is for a host prebuilt artifact that is installed in
617// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700618func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900619 module := &PrebuiltEtc{}
620 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800621 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700622 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100623 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800624 return module
625}
626
Miguel32b02802022-12-01 18:38:26 +0000627// prebuilt_etc_host is for a host prebuilt artifact that is installed in
628// <partition>/etc/<sub_dir> directory.
629func PrebuiltEtcCaCertsFactory() android.Module {
630 module := &PrebuiltEtc{}
631 InitPrebuiltEtcModule(module, "cacerts")
632 // This module is device-only
633 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000634 return module
635}
636
Nelson Li1fb94b22024-07-09 17:04:52 +0800637// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
638// `prebuilt_avb` will not have a `system` subdirectory.
639// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
640// root directory of the partition: <partition_root>/avb.
641// prebuilt_avb does not allow adding any other subdirectories.
642func PrebuiltAvbFactory() android.Module {
643 module := &PrebuiltEtc{}
644 InitPrebuiltAvbModule(module)
645 // This module is device-only
646 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
647 android.InitDefaultableModule(module)
648 return module
649}
650
Inseob Kim27408bf2021-04-06 21:00:17 +0900651// prebuilt_root is for a prebuilt artifact that is installed in
652// <partition>/ directory. Can't have any sub directories.
653func PrebuiltRootFactory() android.Module {
654 module := &PrebuiltEtc{}
655 InitPrebuiltRootModule(module)
656 // This module is device-only
657 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100658 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900659 return module
660}
661
Liz Kammere9ecddc2022-01-04 17:27:52 -0500662// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
663// directory.
664func PrebuiltRootHostFactory() android.Module {
665 module := &PrebuiltEtc{}
666 InitPrebuiltEtcModule(module, ".")
667 // This module is host-only
668 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
669 android.InitDefaultableModule(module)
670 return module
671}
672
Patrice Arruda9e14b962019-03-11 15:58:50 -0700673// prebuilt_usr_share is for a prebuilt artifact that is installed in
674// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700675func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900676 module := &PrebuiltEtc{}
677 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800678 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700679 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100680 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800681 return module
682}
683
Patrice Arruda9e14b962019-03-11 15:58:50 -0700684// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
685// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700686func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900687 module := &PrebuiltEtc{}
688 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800689 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700690 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100691 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800692 return module
693}
694
yangbill63c5e192024-03-27 09:02:12 +0000695// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
696// <partition>/usr/hyphen-data/<sub_dir> directory.
697func PrebuiltUserHyphenDataFactory() android.Module {
698 module := &PrebuiltEtc{}
699 InitPrebuiltEtcModule(module, "usr/hyphen-data")
700 // This module is device-only
701 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
702 android.InitDefaultableModule(module)
703 return module
704}
705
yangbill85527e62024-04-30 08:24:50 +0000706// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
707// <partition>/usr/keylayout/<sub_dir> directory.
708func PrebuiltUserKeyLayoutFactory() android.Module {
709 module := &PrebuiltEtc{}
710 InitPrebuiltEtcModule(module, "usr/keylayout")
711 // This module is device-only
712 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
713 android.InitDefaultableModule(module)
714 return module
715}
716
717// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
718// <partition>/usr/keychars/<sub_dir> directory.
719func PrebuiltUserKeyCharsFactory() android.Module {
720 module := &PrebuiltEtc{}
721 InitPrebuiltEtcModule(module, "usr/keychars")
722 // This module is device-only
723 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
724 android.InitDefaultableModule(module)
725 return module
726}
727
728// prebuilt_usr_idc is for a prebuilt artifact that is installed in
729// <partition>/usr/idc/<sub_dir> directory.
730func PrebuiltUserIdcFactory() android.Module {
731 module := &PrebuiltEtc{}
732 InitPrebuiltEtcModule(module, "usr/idc")
733 // This module is device-only
734 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
735 android.InitDefaultableModule(module)
736 return module
737}
738
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000739// prebuilt_usr_srec is for a prebuilt artifact that is installed in
740// <partition>/usr/srec/<sub_dir> directory.
741func PrebuiltUserSrecFactory() android.Module {
742 module := &PrebuiltEtc{}
743 InitPrebuiltEtcModule(module, "usr/srec")
744 // This module is device-only
745 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
746 android.InitDefaultableModule(module)
747 return module
748}
749
Patrice Arruda61583eb2019-05-14 08:20:45 -0700750// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700751func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900752 module := &PrebuiltEtc{}
753 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700754 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700755 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100756 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700757 return module
758}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700759
Kevin93f7cd82024-05-02 12:37:59 +0200760// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
761func PrebuiltOverlayFactory() android.Module {
762 module := &PrebuiltEtc{}
763 InitPrebuiltEtcModule(module, "overlay")
764 // This module is device-only
765 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
766 return module
767}
768
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800769// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
770// image.
771// If soc_specific property is set to true, the firmware file is installed to the
772// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700773func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900774 module := &PrebuiltEtc{}
775 module.socInstallDirBase = "firmware"
776 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700777 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700778 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100779 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700780 return module
781}
Patrice Arruda0f688002020-06-08 21:40:25 +0000782
783// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800784// If soc_specific property is set to true, the DSP related file is installed to the
785// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000786func PrebuiltDSPFactory() android.Module {
787 module := &PrebuiltEtc{}
788 module.socInstallDirBase = "dsp"
789 InitPrebuiltEtcModule(module, "etc/dsp")
790 // This module is device-only
791 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100792 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000793 return module
794}
Colin Cross83ebf232021-04-09 09:41:23 -0700795
Colin Crossf17e2b52023-10-30 15:17:25 -0700796// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
797func PrebuiltRenderScriptBitcodeFactory() android.Module {
798 module := &PrebuiltEtc{}
799 module.makeClass = "RENDERSCRIPT_BITCODE"
800 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800801 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700802 InitPrebuiltEtcModule(module, "lib")
803 // This module is device-only
804 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
805 android.InitDefaultableModule(module)
806 return module
807}
808
Colin Cross83ebf232021-04-09 09:41:23 -0700809// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
810// to the <partition>/lib/rfsa directory.
811func PrebuiltRFSAFactory() android.Module {
812 module := &PrebuiltEtc{}
813 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
814 // many places outside of the application processor. They could be moved to /vendor/dsp once
815 // that is cleaned up.
816 InitPrebuiltEtcModule(module, "lib/rfsa")
817 // This module is device-only
818 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100819 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700820 return module
821}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000822
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000823// prebuilt_media installs media files in <partition>/media directory.
824func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000825 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000826 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000827 // This module is device-only
828 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
829 android.InitDefaultableModule(module)
830 return module
831}
Jihoon Kangec62d842024-10-25 20:27:18 +0000832
833// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
834func PrebuiltVoicepackFactory() android.Module {
835 module := &PrebuiltEtc{}
836 InitPrebuiltEtcModule(module, "tts")
837 // This module is device-only
838 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
839 android.InitDefaultableModule(module)
840 return module
841}
842
843// prebuilt_bin installs files in <partition>/bin directory.
844func PrebuiltBinaryFactory() android.Module {
845 module := &PrebuiltEtc{}
846 InitPrebuiltEtcModule(module, "bin")
847 // This module is device-only
848 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
849 android.InitDefaultableModule(module)
850 return module
851}
852
853// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
854func PrebuiltWallpaperFactory() android.Module {
855 module := &PrebuiltEtc{}
856 InitPrebuiltEtcModule(module, "wallpaper")
857 // This module is device-only
858 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
859 android.InitDefaultableModule(module)
860 return module
861}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000862
863// prebuilt_priv_app installs files in <partition>/priv-app directory.
864func PrebuiltPrivAppFactory() android.Module {
865 module := &PrebuiltEtc{}
866 InitPrebuiltEtcModule(module, "priv-app")
867 // This module is device-only
868 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
869 android.InitDefaultableModule(module)
870 return module
871}
872
873// prebuilt_rfs installs files in <partition>/rfs directory.
874func PrebuiltRfsFactory() android.Module {
875 module := &PrebuiltEtc{}
876 InitPrebuiltEtcModule(module, "rfs")
877 // This module is device-only
878 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
879 android.InitDefaultableModule(module)
880 return module
881}
882
883// prebuilt_framework installs files in <partition>/framework directory.
884func PrebuiltFrameworkFactory() android.Module {
885 module := &PrebuiltEtc{}
886 InitPrebuiltEtcModule(module, "framework")
887 // This module is device-only
888 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
889 android.InitDefaultableModule(module)
890 return module
891}
892
893// prebuilt_res installs files in <partition>/res directory.
894func PrebuiltResFactory() android.Module {
895 module := &PrebuiltEtc{}
896 InitPrebuiltEtcModule(module, "res")
897 // This module is device-only
898 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
899 android.InitDefaultableModule(module)
900 return module
901}
902
903// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
904func PrebuiltWlcUptFactory() android.Module {
905 module := &PrebuiltEtc{}
906 InitPrebuiltEtcModule(module, "wlc_upt")
907 // This module is device-only
908 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
909 android.InitDefaultableModule(module)
910 return module
911}
912
913// prebuilt_odm installs files in <partition>/odm directory.
914func PrebuiltOdmFactory() android.Module {
915 module := &PrebuiltEtc{}
916 InitPrebuiltEtcModule(module, "odm")
917 // This module is device-only
918 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
919 android.InitDefaultableModule(module)
920 return module
921}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000922
923// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
924func PrebuiltVendorDlkmFactory() android.Module {
925 module := &PrebuiltEtc{}
926 InitPrebuiltEtcModule(module, "vendor_dlkm")
927 // This module is device-only
928 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
929 android.InitDefaultableModule(module)
930 return module
931}
932
933// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
934func PrebuiltBtFirmwareFactory() android.Module {
935 module := &PrebuiltEtc{}
936 InitPrebuiltEtcModule(module, "bt_firmware")
937 // This module is device-only
938 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
939 android.InitDefaultableModule(module)
940 return module
941}