blob: fbe24d1daee4f41f178470a57ea263c3853ca3ba [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)
Jooyung Han0703fd82020-08-26 22:11:53 +090062 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020063 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090064 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
65 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070066 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070067 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000068
69 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040070
Jiyong Parkc678ad32018-04-10 13:07:10 +090071}
72
Paul Duffin1172fed2021-03-08 11:28:18 +000073var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
74
Jiyong Parkc678ad32018-04-10 13:07:10 +090075type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080076 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110077 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070078 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090079
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110080 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070081 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
82 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070083 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110084
Douglas Anderson79688ff2024-09-27 15:08:33 -070085 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
86 // set filename_from_src. This can be used to install each source file to a different directory
87 // and/or change filenames when files are installed. Must be exactly one entry per source file,
88 // which means care must be taken if srcs has globs.
89 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
90
Yo Chiangf0e19fe2020-11-18 15:28:42 +080091 // 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 +110092 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +090093 Filename *string `android:"arch_variant"`
94
Yo Chiangf0e19fe2020-11-18 15:28:42 +080095 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090096 // is the same as the file name of the source file.
97 Filename_from_src *bool `android:"arch_variant"`
98
Yifan Hong1b3348d2020-01-21 15:53:22 -080099 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700100 // On device without a dedicated recovery partition, the module is only
101 // available after switching root into
102 // /first_stage_ramdisk. To expose the module before switching root, install
103 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800104 Ramdisk_available *bool
105
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700106 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700107 // On device without a dedicated recovery partition, the module is only
108 // available after switching root into
109 // /first_stage_ramdisk. To expose the module before switching root, install
110 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700111 Vendor_ramdisk_available *bool
112
Inseob Kim08758f02021-04-08 21:13:22 +0900113 // Make this module available when building for debug ramdisk.
114 Debug_ramdisk_available *bool
115
Tao Bao0ba5c942018-08-14 22:20:22 -0700116 // Make this module available when building for recovery.
117 Recovery_available *bool
118
Jiyong Parkad9ce042018-10-31 22:49:57 +0900119 // Whether this module is directly installable to one of the partitions. Default: true.
120 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800121
122 // Install symlinks to the installed file.
123 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900124}
125
Inseob Kim27408bf2021-04-06 21:00:17 +0900126type prebuiltSubdirProperties struct {
127 // Optional subdirectory under which this file is installed into, cannot be specified with
128 // relative_install_path, prefer relative_install_path.
129 Sub_dir *string `android:"arch_variant"`
130
131 // Optional subdirectory under which this file is installed into, cannot be specified with
132 // sub_dir.
133 Relative_install_path *string `android:"arch_variant"`
134}
135
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900136type prebuiltRootProperties struct {
137 // Install this module to the root directory, without partition subdirs. When this module is
138 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
139 // then be copied to the root of system.img. When this module is packaged by other modules like
140 // android_filesystem, this module will be installed to the root ("/"), unlike normal
141 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
142 Install_in_root *bool
143}
144
Jooyung Han39edb6c2019-11-06 16:53:07 +0900145type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700146 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800147
148 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900149 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800150
151 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900152 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900153}
154
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900155type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700156 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000157 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900158
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900159 properties prebuiltEtcProperties
160
161 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
162 // prebuilt_avb and prebuilt_root modules use this.
163 rootProperties prebuiltRootProperties
164
Inseob Kim27408bf2021-04-06 21:00:17 +0900165 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900166
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100167 sourceFilePaths android.Paths
168 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800169 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800170 installDirBase string
171 installDirBase64 string
172 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800173 // The base install location when soc_specific property is set to true, e.g. "firmware" for
174 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700175 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700176 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700177 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700178
Cole Faustfdec8722024-05-22 11:38:29 -0700179 usedSrcsProperty bool
180
Colin Crossf17e2b52023-10-30 15:17:25 -0700181 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900182}
183
Inseob Kim1e27a142021-05-06 11:46:11 +0000184type Defaults struct {
185 android.ModuleBase
186 android.DefaultsModuleBase
187}
188
Yifan Hong1b3348d2020-01-21 15:53:22 -0800189func (p *PrebuiltEtc) inRamdisk() bool {
190 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
191}
192
193func (p *PrebuiltEtc) onlyInRamdisk() bool {
194 return p.ModuleBase.InstallInRamdisk()
195}
196
197func (p *PrebuiltEtc) InstallInRamdisk() bool {
198 return p.inRamdisk()
199}
200
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700201func (p *PrebuiltEtc) inVendorRamdisk() bool {
202 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
203}
204
205func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
206 return p.ModuleBase.InstallInVendorRamdisk()
207}
208
209func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
210 return p.inVendorRamdisk()
211}
212
Inseob Kim08758f02021-04-08 21:13:22 +0900213func (p *PrebuiltEtc) inDebugRamdisk() bool {
214 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
215}
216
217func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
218 return p.ModuleBase.InstallInDebugRamdisk()
219}
220
221func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
222 return p.inDebugRamdisk()
223}
224
Kiyoung Kimae11c232021-07-19 11:38:04 +0900225func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800226 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700227}
228
229func (p *PrebuiltEtc) onlyInRecovery() bool {
230 return p.ModuleBase.InstallInRecovery()
231}
232
233func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900234 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700235}
236
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700237var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800238
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700239func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800240
Jihoon Kang47e91842024-06-19 00:51:16 +0000241func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.BaseModuleContext) bool {
242 return false
243}
244
245func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.BaseModuleContext) bool {
246 return false
247}
248
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700249func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700250 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900251 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800252}
253
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700254func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
255 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800256}
257
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700258func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
259 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
260}
261
Inseob Kim08758f02021-04-08 21:13:22 +0900262func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
263 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
264}
265
Nelson Li1fb94b22024-07-09 17:04:52 +0800266func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900267 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800268}
269
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700270func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
271 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800272}
273
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700274func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800275 return nil
276}
277
Jihoon Kang7583e832024-06-13 21:25:45 +0000278func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800279}
280
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700281func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700282 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100283 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
284 }
Cole Faustfdec8722024-05-22 11:38:29 -0700285 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900286}
287
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700288func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700289 if len(p.installDirPaths) != 1 {
290 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
291 }
292 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900293}
294
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900295// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
296// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700297func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900298 p.additionalDependencies = &paths
299}
300
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700301func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700302 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100303 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
304 }
305 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900306}
307
308func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900309 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700310 return subDir
311 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900312 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900313}
314
Jooyung Han0703fd82020-08-26 22:11:53 +0900315func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900316 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900317}
318
Jiyong Parkad9ce042018-10-31 22:49:57 +0900319func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800320 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900321}
322
Kiyoung Kimae11c232021-07-19 11:38:04 +0900323func (p *PrebuiltEtc) InVendor() bool {
324 return p.ModuleBase.InstallInVendor()
325}
326
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100327func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800328 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
329 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900330 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700331 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
332 installBaseDir = p.installDirBase64
333 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900334 if p.SocSpecific() && p.socInstallDirBase != "" {
335 installBaseDir = p.socInstallDirBase
336 }
Colin Cross2f634572023-11-13 12:12:06 -0800337 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
338 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
339 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100340 return installBaseDir
341}
Colin Cross2f634572023-11-13 12:12:06 -0800342
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100343func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
344 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900345
Cole Faustfdec8722024-05-22 11:38:29 -0700346 srcProperty := p.properties.Src.Get(ctx)
347 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
348 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100349 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000350 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700351 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
352 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
353 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
354 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100355
356 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
357 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
358 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
359 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700360 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100361
362 filename := proptools.String(p.properties.Filename)
363 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700364 if srcProperty.IsPresent() {
365 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100366 // If the source was not found, set a fake source path to
367 // support AllowMissingDependencies executions.
368 if len(p.sourceFilePaths) == 0 {
369 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
370 }
371
372 // Determine the output file basename.
373 // If Filename is set, use the name specified by the property.
374 // If Filename_from_src is set, use the source file name.
375 // Otherwise use the module name.
376 if filename != "" {
377 if filenameFromSrc {
378 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
379 return
380 }
381 } else if filenameFromSrc {
382 filename = p.sourceFilePaths[0].Base()
383 } else {
384 filename = ctx.ModuleName()
385 }
386 if strings.Contains(filename, "/") {
387 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
388 return
389 }
390 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
391
392 ip := installProperties{
393 filename: filename,
394 sourceFilePath: p.sourceFilePaths[0],
395 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700396 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100397 symlinks: p.properties.Symlinks,
398 }
399 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700400 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700401 } else if len(srcsProperty) > 0 {
402 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100403 if filename != "" {
404 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
405 }
406 if len(p.properties.Symlinks) > 0 {
407 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
408 }
409 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700410 if len(dstsProperty) > 0 {
411 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
412 } else {
413 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
414 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100415 }
Cole Faustfdec8722024-05-22 11:38:29 -0700416 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700417 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
418 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
419 }
420 for i, src := range p.sourceFilePaths {
421 var filename string
422 var installDirPath android.InstallPath
423
424 if len(dstsProperty) > 0 {
425 var dstdir string
426
427 dstdir, filename = filepath.Split(dstsProperty[i])
428 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
429 } else {
430 filename = src.Base()
431 installDirPath = baseInstallDirPath
432 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100433 output := android.PathForModuleOut(ctx, filename).OutputPath
434 ip := installProperties{
435 filename: filename,
436 sourceFilePath: src,
437 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700438 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100439 }
440 p.outputFilePaths = append(p.outputFilePaths, output)
441 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700442 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100443 }
444 } else if ctx.Config().AllowMissingDependencies() {
445 // If no srcs was set and AllowMissingDependencies is enabled then
446 // mark the module as missing dependencies and set a fake source path
447 // and file name.
448 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
449 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
450 if filename == "" {
451 filename = ctx.ModuleName()
452 }
453 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
454 ip := installProperties{
455 filename: filename,
456 sourceFilePath: p.sourceFilePaths[0],
457 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700458 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100459 }
460 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700461 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100462 } else {
463 ctx.PropertyErrorf("src", "missing prebuilt source file")
464 return
465 }
466
467 // Call InstallFile even when uninstallable to make the module included in the package.
468 if !p.Installable() {
469 p.SkipInstall()
470 }
471 for _, ip := range installs {
472 ip.addInstallRules(ctx)
473 }
mrziwang89371762024-06-11 12:42:24 -0700474
475 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000476}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900477
Spandan Das756d3402023-06-05 22:49:50 +0000478type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000479 filename string
480 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100481 outputFilePath android.OutputPath
482 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000483 symlinks []string
484}
485
486// utility function to add install rules to the build graph.
487// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100488func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000489 // Copy the file from src to a location in out/ with the correct `filename`
490 // This ensures that outputFilePath has the correct name for others to
491 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000492 ctx.Build(pctx, android.BuildParams{
493 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100494 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000495 Input: ip.sourceFilePath,
496 })
497
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100498 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000499 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100500 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900501 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900502}
503
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700504func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700505 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800506 if p.inRamdisk() && !p.onlyInRamdisk() {
507 nameSuffix = ".ramdisk"
508 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700509 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
510 nameSuffix = ".vendor_ramdisk"
511 }
Inseob Kim08758f02021-04-08 21:13:22 +0900512 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
513 nameSuffix = ".debug_ramdisk"
514 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900515 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700516 nameSuffix = ".recovery"
517 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700518
519 class := p.makeClass
520 if class == "" {
521 class = "ETC"
522 }
523
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100524 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700525 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700526 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100527 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700528 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700529 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700530 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700531 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100532 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800533 if len(p.properties.Symlinks) > 0 {
534 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
535 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800536 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700537 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800538 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900539 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700540 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900541 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900542 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900543}
544
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000545func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
546 return &p.ModuleBase
547}
548
Jooyung Hana0171822019-07-22 15:48:36 +0900549func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
550 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900551 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900552 p.AddProperties(&p.subdirProperties)
553}
554
555func InitPrebuiltRootModule(p *PrebuiltEtc) {
556 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800557 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900558 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800559}
560
561func InitPrebuiltAvbModule(p *PrebuiltEtc) {
562 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900563 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900564 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900565}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900566
Patrice Arruda9e14b962019-03-11 15:58:50 -0700567// prebuilt_etc is for a prebuilt artifact that is installed in
568// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700569func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900570 module := &PrebuiltEtc{}
571 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900572 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700573 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000574 android.InitDefaultableModule(module)
575 return module
576}
577
578func defaultsFactory() android.Module {
579 return DefaultsFactory()
580}
581
582func DefaultsFactory(props ...interface{}) android.Module {
583 module := &Defaults{}
584
585 module.AddProperties(props...)
586 module.AddProperties(
587 &prebuiltEtcProperties{},
588 &prebuiltSubdirProperties{},
589 )
590
591 android.InitDefaultsModule(module)
592
Jiyong Parkc678ad32018-04-10 13:07:10 +0900593 return module
594}
Tao Bao0ba5c942018-08-14 22:20:22 -0700595
Patrice Arruda9e14b962019-03-11 15:58:50 -0700596// prebuilt_etc_host is for a host prebuilt artifact that is installed in
597// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700598func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900599 module := &PrebuiltEtc{}
600 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800601 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700602 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100603 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800604 return module
605}
606
Miguel32b02802022-12-01 18:38:26 +0000607// prebuilt_etc_host is for a host prebuilt artifact that is installed in
608// <partition>/etc/<sub_dir> directory.
609func PrebuiltEtcCaCertsFactory() android.Module {
610 module := &PrebuiltEtc{}
611 InitPrebuiltEtcModule(module, "cacerts")
612 // This module is device-only
613 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000614 return module
615}
616
Nelson Li1fb94b22024-07-09 17:04:52 +0800617// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
618// `prebuilt_avb` will not have a `system` subdirectory.
619// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
620// root directory of the partition: <partition_root>/avb.
621// prebuilt_avb does not allow adding any other subdirectories.
622func PrebuiltAvbFactory() android.Module {
623 module := &PrebuiltEtc{}
624 InitPrebuiltAvbModule(module)
625 // This module is device-only
626 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
627 android.InitDefaultableModule(module)
628 return module
629}
630
Inseob Kim27408bf2021-04-06 21:00:17 +0900631// prebuilt_root is for a prebuilt artifact that is installed in
632// <partition>/ directory. Can't have any sub directories.
633func PrebuiltRootFactory() android.Module {
634 module := &PrebuiltEtc{}
635 InitPrebuiltRootModule(module)
636 // This module is device-only
637 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100638 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900639 return module
640}
641
Liz Kammere9ecddc2022-01-04 17:27:52 -0500642// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
643// directory.
644func PrebuiltRootHostFactory() android.Module {
645 module := &PrebuiltEtc{}
646 InitPrebuiltEtcModule(module, ".")
647 // This module is host-only
648 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
649 android.InitDefaultableModule(module)
650 return module
651}
652
Patrice Arruda9e14b962019-03-11 15:58:50 -0700653// prebuilt_usr_share is for a prebuilt artifact that is installed in
654// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700655func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900656 module := &PrebuiltEtc{}
657 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800658 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700659 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100660 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800661 return module
662}
663
Patrice Arruda9e14b962019-03-11 15:58:50 -0700664// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
665// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700666func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900667 module := &PrebuiltEtc{}
668 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800669 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700670 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100671 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800672 return module
673}
674
yangbill63c5e192024-03-27 09:02:12 +0000675// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
676// <partition>/usr/hyphen-data/<sub_dir> directory.
677func PrebuiltUserHyphenDataFactory() android.Module {
678 module := &PrebuiltEtc{}
679 InitPrebuiltEtcModule(module, "usr/hyphen-data")
680 // This module is device-only
681 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
682 android.InitDefaultableModule(module)
683 return module
684}
685
yangbill85527e62024-04-30 08:24:50 +0000686// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
687// <partition>/usr/keylayout/<sub_dir> directory.
688func PrebuiltUserKeyLayoutFactory() android.Module {
689 module := &PrebuiltEtc{}
690 InitPrebuiltEtcModule(module, "usr/keylayout")
691 // This module is device-only
692 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
693 android.InitDefaultableModule(module)
694 return module
695}
696
697// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
698// <partition>/usr/keychars/<sub_dir> directory.
699func PrebuiltUserKeyCharsFactory() android.Module {
700 module := &PrebuiltEtc{}
701 InitPrebuiltEtcModule(module, "usr/keychars")
702 // This module is device-only
703 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
704 android.InitDefaultableModule(module)
705 return module
706}
707
708// prebuilt_usr_idc is for a prebuilt artifact that is installed in
709// <partition>/usr/idc/<sub_dir> directory.
710func PrebuiltUserIdcFactory() android.Module {
711 module := &PrebuiltEtc{}
712 InitPrebuiltEtcModule(module, "usr/idc")
713 // This module is device-only
714 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
715 android.InitDefaultableModule(module)
716 return module
717}
718
Patrice Arruda61583eb2019-05-14 08:20:45 -0700719// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700720func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900721 module := &PrebuiltEtc{}
722 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700723 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700724 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100725 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700726 return module
727}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700728
Kevin93f7cd82024-05-02 12:37:59 +0200729// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
730func PrebuiltOverlayFactory() android.Module {
731 module := &PrebuiltEtc{}
732 InitPrebuiltEtcModule(module, "overlay")
733 // This module is device-only
734 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
735 return module
736}
737
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800738// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
739// image.
740// If soc_specific property is set to true, the firmware file is installed to the
741// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700742func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900743 module := &PrebuiltEtc{}
744 module.socInstallDirBase = "firmware"
745 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700746 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700747 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100748 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700749 return module
750}
Patrice Arruda0f688002020-06-08 21:40:25 +0000751
752// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800753// If soc_specific property is set to true, the DSP related file is installed to the
754// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000755func PrebuiltDSPFactory() android.Module {
756 module := &PrebuiltEtc{}
757 module.socInstallDirBase = "dsp"
758 InitPrebuiltEtcModule(module, "etc/dsp")
759 // This module is device-only
760 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100761 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000762 return module
763}
Colin Cross83ebf232021-04-09 09:41:23 -0700764
Colin Crossf17e2b52023-10-30 15:17:25 -0700765// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
766func PrebuiltRenderScriptBitcodeFactory() android.Module {
767 module := &PrebuiltEtc{}
768 module.makeClass = "RENDERSCRIPT_BITCODE"
769 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800770 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700771 InitPrebuiltEtcModule(module, "lib")
772 // This module is device-only
773 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
774 android.InitDefaultableModule(module)
775 return module
776}
777
Colin Cross83ebf232021-04-09 09:41:23 -0700778// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
779// to the <partition>/lib/rfsa directory.
780func PrebuiltRFSAFactory() android.Module {
781 module := &PrebuiltEtc{}
782 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
783 // many places outside of the application processor. They could be moved to /vendor/dsp once
784 // that is cleaned up.
785 InitPrebuiltEtcModule(module, "lib/rfsa")
786 // This module is device-only
787 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100788 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700789 return module
790}