blob: f17a5ded9d0d6273aa2bca94162b4cc3637a7c04 [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)
Jihoon Kang2ecf8622024-10-23 21:20:30 +000068 ctx.RegisterModuleType("prebuilt_media_audio", PrebuiltMediaAudioFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000069
70 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040071
Jiyong Parkc678ad32018-04-10 13:07:10 +090072}
73
Paul Duffin1172fed2021-03-08 11:28:18 +000074var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
75
Jiyong Parkc678ad32018-04-10 13:07:10 +090076type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080077 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110078 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070079 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090080
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110081 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070082 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
83 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070084 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110085
Douglas Anderson79688ff2024-09-27 15:08:33 -070086 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
87 // set filename_from_src. This can be used to install each source file to a different directory
88 // and/or change filenames when files are installed. Must be exactly one entry per source file,
89 // which means care must be taken if srcs has globs.
90 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
91
Yo Chiangf0e19fe2020-11-18 15:28:42 +080092 // 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 +110093 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +090094 Filename *string `android:"arch_variant"`
95
Yo Chiangf0e19fe2020-11-18 15:28:42 +080096 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090097 // is the same as the file name of the source file.
98 Filename_from_src *bool `android:"arch_variant"`
99
Yifan Hong1b3348d2020-01-21 15:53:22 -0800100 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700101 // On device without a dedicated recovery partition, the module is only
102 // available after switching root into
103 // /first_stage_ramdisk. To expose the module before switching root, install
104 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800105 Ramdisk_available *bool
106
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700107 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700108 // On device without a dedicated recovery partition, the module is only
109 // available after switching root into
110 // /first_stage_ramdisk. To expose the module before switching root, install
111 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700112 Vendor_ramdisk_available *bool
113
Inseob Kim08758f02021-04-08 21:13:22 +0900114 // Make this module available when building for debug ramdisk.
115 Debug_ramdisk_available *bool
116
Tao Bao0ba5c942018-08-14 22:20:22 -0700117 // Make this module available when building for recovery.
118 Recovery_available *bool
119
Jiyong Parkad9ce042018-10-31 22:49:57 +0900120 // Whether this module is directly installable to one of the partitions. Default: true.
121 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800122
123 // Install symlinks to the installed file.
124 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900125}
126
Inseob Kim27408bf2021-04-06 21:00:17 +0900127type prebuiltSubdirProperties struct {
128 // Optional subdirectory under which this file is installed into, cannot be specified with
129 // relative_install_path, prefer relative_install_path.
130 Sub_dir *string `android:"arch_variant"`
131
132 // Optional subdirectory under which this file is installed into, cannot be specified with
133 // sub_dir.
134 Relative_install_path *string `android:"arch_variant"`
135}
136
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900137type prebuiltRootProperties struct {
138 // Install this module to the root directory, without partition subdirs. When this module is
139 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
140 // then be copied to the root of system.img. When this module is packaged by other modules like
141 // android_filesystem, this module will be installed to the root ("/"), unlike normal
142 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
143 Install_in_root *bool
144}
145
Jooyung Han39edb6c2019-11-06 16:53:07 +0900146type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700147 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800148
149 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900150 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800151
152 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900153 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900154}
155
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900156type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700157 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000158 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900159
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900160 properties prebuiltEtcProperties
161
162 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
163 // prebuilt_avb and prebuilt_root modules use this.
164 rootProperties prebuiltRootProperties
165
Inseob Kim27408bf2021-04-06 21:00:17 +0900166 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900167
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100168 sourceFilePaths android.Paths
169 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800170 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800171 installDirBase string
172 installDirBase64 string
173 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800174 // The base install location when soc_specific property is set to true, e.g. "firmware" for
175 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700176 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700177 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700178 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700179
Cole Faustfdec8722024-05-22 11:38:29 -0700180 usedSrcsProperty bool
181
Colin Crossf17e2b52023-10-30 15:17:25 -0700182 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900183}
184
Inseob Kim1e27a142021-05-06 11:46:11 +0000185type Defaults struct {
186 android.ModuleBase
187 android.DefaultsModuleBase
188}
189
Yifan Hong1b3348d2020-01-21 15:53:22 -0800190func (p *PrebuiltEtc) inRamdisk() bool {
191 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
192}
193
194func (p *PrebuiltEtc) onlyInRamdisk() bool {
195 return p.ModuleBase.InstallInRamdisk()
196}
197
198func (p *PrebuiltEtc) InstallInRamdisk() bool {
199 return p.inRamdisk()
200}
201
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700202func (p *PrebuiltEtc) inVendorRamdisk() bool {
203 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
204}
205
206func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
207 return p.ModuleBase.InstallInVendorRamdisk()
208}
209
210func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
211 return p.inVendorRamdisk()
212}
213
Inseob Kim08758f02021-04-08 21:13:22 +0900214func (p *PrebuiltEtc) inDebugRamdisk() bool {
215 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
216}
217
218func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
219 return p.ModuleBase.InstallInDebugRamdisk()
220}
221
222func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
223 return p.inDebugRamdisk()
224}
225
Kiyoung Kimae11c232021-07-19 11:38:04 +0900226func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800227 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700228}
229
230func (p *PrebuiltEtc) onlyInRecovery() bool {
231 return p.ModuleBase.InstallInRecovery()
232}
233
234func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900235 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700236}
237
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700238var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800239
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700240func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800241
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700242func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000243 return false
244}
245
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700246func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000247 return false
248}
249
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700250func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700251 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900252 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800253}
254
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700255func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700256 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800257}
258
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700259func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700260 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
261}
262
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700263func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900264 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
265}
266
Nelson Li1fb94b22024-07-09 17:04:52 +0800267func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900268 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800269}
270
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700271func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700272 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800273}
274
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700275func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800276 return nil
277}
278
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700279func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800280}
281
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700282func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700283 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100284 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
285 }
Cole Faustfdec8722024-05-22 11:38:29 -0700286 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900287}
288
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700289func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700290 if len(p.installDirPaths) != 1 {
291 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
292 }
293 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900294}
295
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900296// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
297// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700298func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900299 p.additionalDependencies = &paths
300}
301
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700302func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700303 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100304 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
305 }
306 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900307}
308
309func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900310 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700311 return subDir
312 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900313 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900314}
315
Jooyung Han0703fd82020-08-26 22:11:53 +0900316func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900317 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900318}
319
Jiyong Parkad9ce042018-10-31 22:49:57 +0900320func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800321 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900322}
323
Kiyoung Kimae11c232021-07-19 11:38:04 +0900324func (p *PrebuiltEtc) InVendor() bool {
325 return p.ModuleBase.InstallInVendor()
326}
327
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100328func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800329 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
330 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900331 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700332 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
333 installBaseDir = p.installDirBase64
334 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900335 if p.SocSpecific() && p.socInstallDirBase != "" {
336 installBaseDir = p.socInstallDirBase
337 }
Colin Cross2f634572023-11-13 12:12:06 -0800338 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
339 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
340 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100341 return installBaseDir
342}
Colin Cross2f634572023-11-13 12:12:06 -0800343
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100344func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
345 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900346
Cole Faustfdec8722024-05-22 11:38:29 -0700347 srcProperty := p.properties.Src.Get(ctx)
348 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
349 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100350 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000351 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700352 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
353 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
354 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
355 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100356
357 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
358 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
359 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
360 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700361 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100362
363 filename := proptools.String(p.properties.Filename)
364 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700365 if srcProperty.IsPresent() {
366 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100367 // If the source was not found, set a fake source path to
368 // support AllowMissingDependencies executions.
369 if len(p.sourceFilePaths) == 0 {
370 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
371 }
372
373 // Determine the output file basename.
374 // If Filename is set, use the name specified by the property.
375 // If Filename_from_src is set, use the source file name.
376 // Otherwise use the module name.
377 if filename != "" {
378 if filenameFromSrc {
379 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
380 return
381 }
382 } else if filenameFromSrc {
383 filename = p.sourceFilePaths[0].Base()
384 } else {
385 filename = ctx.ModuleName()
386 }
387 if strings.Contains(filename, "/") {
388 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
389 return
390 }
391 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
392
393 ip := installProperties{
394 filename: filename,
395 sourceFilePath: p.sourceFilePaths[0],
396 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700397 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100398 symlinks: p.properties.Symlinks,
399 }
400 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700401 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700402 } else if len(srcsProperty) > 0 {
403 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100404 if filename != "" {
405 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
406 }
407 if len(p.properties.Symlinks) > 0 {
408 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
409 }
410 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700411 if len(dstsProperty) > 0 {
412 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
413 } else {
414 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
415 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100416 }
Cole Faustfdec8722024-05-22 11:38:29 -0700417 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700418 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
419 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
420 }
421 for i, src := range p.sourceFilePaths {
422 var filename string
423 var installDirPath android.InstallPath
424
425 if len(dstsProperty) > 0 {
426 var dstdir string
427
428 dstdir, filename = filepath.Split(dstsProperty[i])
429 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
430 } else {
431 filename = src.Base()
432 installDirPath = baseInstallDirPath
433 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100434 output := android.PathForModuleOut(ctx, filename).OutputPath
435 ip := installProperties{
436 filename: filename,
437 sourceFilePath: src,
438 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700439 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100440 }
441 p.outputFilePaths = append(p.outputFilePaths, output)
442 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700443 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100444 }
445 } else if ctx.Config().AllowMissingDependencies() {
446 // If no srcs was set and AllowMissingDependencies is enabled then
447 // mark the module as missing dependencies and set a fake source path
448 // and file name.
449 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
450 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
451 if filename == "" {
452 filename = ctx.ModuleName()
453 }
454 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
455 ip := installProperties{
456 filename: filename,
457 sourceFilePath: p.sourceFilePaths[0],
458 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700459 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100460 }
461 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700462 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100463 } else {
464 ctx.PropertyErrorf("src", "missing prebuilt source file")
465 return
466 }
467
468 // Call InstallFile even when uninstallable to make the module included in the package.
469 if !p.Installable() {
470 p.SkipInstall()
471 }
472 for _, ip := range installs {
473 ip.addInstallRules(ctx)
474 }
mrziwang89371762024-06-11 12:42:24 -0700475
476 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000477}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900478
Spandan Das756d3402023-06-05 22:49:50 +0000479type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000480 filename string
481 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100482 outputFilePath android.OutputPath
483 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000484 symlinks []string
485}
486
487// utility function to add install rules to the build graph.
488// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100489func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000490 // Copy the file from src to a location in out/ with the correct `filename`
491 // This ensures that outputFilePath has the correct name for others to
492 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000493 ctx.Build(pctx, android.BuildParams{
494 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100495 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000496 Input: ip.sourceFilePath,
497 })
498
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100499 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000500 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100501 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900502 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900503}
504
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700505func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700506 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800507 if p.inRamdisk() && !p.onlyInRamdisk() {
508 nameSuffix = ".ramdisk"
509 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700510 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
511 nameSuffix = ".vendor_ramdisk"
512 }
Inseob Kim08758f02021-04-08 21:13:22 +0900513 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
514 nameSuffix = ".debug_ramdisk"
515 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900516 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700517 nameSuffix = ".recovery"
518 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700519
520 class := p.makeClass
521 if class == "" {
522 class = "ETC"
523 }
524
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100525 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700526 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700527 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100528 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700529 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700530 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700531 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700532 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100533 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800534 if len(p.properties.Symlinks) > 0 {
535 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
536 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800537 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700538 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800539 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900540 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700541 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900542 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900543 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900544}
545
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000546func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
547 return &p.ModuleBase
548}
549
Jooyung Hana0171822019-07-22 15:48:36 +0900550func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
551 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900552 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900553 p.AddProperties(&p.subdirProperties)
554}
555
556func InitPrebuiltRootModule(p *PrebuiltEtc) {
557 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800558 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900559 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800560}
561
562func InitPrebuiltAvbModule(p *PrebuiltEtc) {
563 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900564 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900565 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900566}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900567
Patrice Arruda9e14b962019-03-11 15:58:50 -0700568// prebuilt_etc is for a prebuilt artifact that is installed in
569// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700570func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900571 module := &PrebuiltEtc{}
572 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900573 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700574 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000575 android.InitDefaultableModule(module)
576 return module
577}
578
579func defaultsFactory() android.Module {
580 return DefaultsFactory()
581}
582
583func DefaultsFactory(props ...interface{}) android.Module {
584 module := &Defaults{}
585
586 module.AddProperties(props...)
587 module.AddProperties(
588 &prebuiltEtcProperties{},
589 &prebuiltSubdirProperties{},
590 )
591
592 android.InitDefaultsModule(module)
593
Jiyong Parkc678ad32018-04-10 13:07:10 +0900594 return module
595}
Tao Bao0ba5c942018-08-14 22:20:22 -0700596
Patrice Arruda9e14b962019-03-11 15:58:50 -0700597// prebuilt_etc_host is for a host prebuilt artifact that is installed in
598// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700599func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900600 module := &PrebuiltEtc{}
601 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800602 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700603 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100604 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800605 return module
606}
607
Miguel32b02802022-12-01 18:38:26 +0000608// prebuilt_etc_host is for a host prebuilt artifact that is installed in
609// <partition>/etc/<sub_dir> directory.
610func PrebuiltEtcCaCertsFactory() android.Module {
611 module := &PrebuiltEtc{}
612 InitPrebuiltEtcModule(module, "cacerts")
613 // This module is device-only
614 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000615 return module
616}
617
Nelson Li1fb94b22024-07-09 17:04:52 +0800618// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
619// `prebuilt_avb` will not have a `system` subdirectory.
620// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
621// root directory of the partition: <partition_root>/avb.
622// prebuilt_avb does not allow adding any other subdirectories.
623func PrebuiltAvbFactory() android.Module {
624 module := &PrebuiltEtc{}
625 InitPrebuiltAvbModule(module)
626 // This module is device-only
627 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
628 android.InitDefaultableModule(module)
629 return module
630}
631
Inseob Kim27408bf2021-04-06 21:00:17 +0900632// prebuilt_root is for a prebuilt artifact that is installed in
633// <partition>/ directory. Can't have any sub directories.
634func PrebuiltRootFactory() android.Module {
635 module := &PrebuiltEtc{}
636 InitPrebuiltRootModule(module)
637 // This module is device-only
638 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100639 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900640 return module
641}
642
Liz Kammere9ecddc2022-01-04 17:27:52 -0500643// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
644// directory.
645func PrebuiltRootHostFactory() android.Module {
646 module := &PrebuiltEtc{}
647 InitPrebuiltEtcModule(module, ".")
648 // This module is host-only
649 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
650 android.InitDefaultableModule(module)
651 return module
652}
653
Patrice Arruda9e14b962019-03-11 15:58:50 -0700654// prebuilt_usr_share is for a prebuilt artifact that is installed in
655// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700656func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900657 module := &PrebuiltEtc{}
658 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800659 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700660 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100661 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800662 return module
663}
664
Patrice Arruda9e14b962019-03-11 15:58:50 -0700665// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
666// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700667func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900668 module := &PrebuiltEtc{}
669 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800670 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700671 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100672 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800673 return module
674}
675
yangbill63c5e192024-03-27 09:02:12 +0000676// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
677// <partition>/usr/hyphen-data/<sub_dir> directory.
678func PrebuiltUserHyphenDataFactory() android.Module {
679 module := &PrebuiltEtc{}
680 InitPrebuiltEtcModule(module, "usr/hyphen-data")
681 // This module is device-only
682 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
683 android.InitDefaultableModule(module)
684 return module
685}
686
yangbill85527e62024-04-30 08:24:50 +0000687// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
688// <partition>/usr/keylayout/<sub_dir> directory.
689func PrebuiltUserKeyLayoutFactory() android.Module {
690 module := &PrebuiltEtc{}
691 InitPrebuiltEtcModule(module, "usr/keylayout")
692 // This module is device-only
693 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
694 android.InitDefaultableModule(module)
695 return module
696}
697
698// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
699// <partition>/usr/keychars/<sub_dir> directory.
700func PrebuiltUserKeyCharsFactory() android.Module {
701 module := &PrebuiltEtc{}
702 InitPrebuiltEtcModule(module, "usr/keychars")
703 // This module is device-only
704 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
705 android.InitDefaultableModule(module)
706 return module
707}
708
709// prebuilt_usr_idc is for a prebuilt artifact that is installed in
710// <partition>/usr/idc/<sub_dir> directory.
711func PrebuiltUserIdcFactory() android.Module {
712 module := &PrebuiltEtc{}
713 InitPrebuiltEtcModule(module, "usr/idc")
714 // This module is device-only
715 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
716 android.InitDefaultableModule(module)
717 return module
718}
719
Patrice Arruda61583eb2019-05-14 08:20:45 -0700720// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700721func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900722 module := &PrebuiltEtc{}
723 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700724 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700725 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100726 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700727 return module
728}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700729
Kevin93f7cd82024-05-02 12:37:59 +0200730// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
731func PrebuiltOverlayFactory() android.Module {
732 module := &PrebuiltEtc{}
733 InitPrebuiltEtcModule(module, "overlay")
734 // This module is device-only
735 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
736 return module
737}
738
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800739// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
740// image.
741// If soc_specific property is set to true, the firmware file is installed to the
742// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700743func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900744 module := &PrebuiltEtc{}
745 module.socInstallDirBase = "firmware"
746 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700747 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700748 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100749 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700750 return module
751}
Patrice Arruda0f688002020-06-08 21:40:25 +0000752
753// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800754// If soc_specific property is set to true, the DSP related file is installed to the
755// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000756func PrebuiltDSPFactory() android.Module {
757 module := &PrebuiltEtc{}
758 module.socInstallDirBase = "dsp"
759 InitPrebuiltEtcModule(module, "etc/dsp")
760 // This module is device-only
761 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100762 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000763 return module
764}
Colin Cross83ebf232021-04-09 09:41:23 -0700765
Colin Crossf17e2b52023-10-30 15:17:25 -0700766// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
767func PrebuiltRenderScriptBitcodeFactory() android.Module {
768 module := &PrebuiltEtc{}
769 module.makeClass = "RENDERSCRIPT_BITCODE"
770 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800771 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700772 InitPrebuiltEtcModule(module, "lib")
773 // This module is device-only
774 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
775 android.InitDefaultableModule(module)
776 return module
777}
778
Colin Cross83ebf232021-04-09 09:41:23 -0700779// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
780// to the <partition>/lib/rfsa directory.
781func PrebuiltRFSAFactory() android.Module {
782 module := &PrebuiltEtc{}
783 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
784 // many places outside of the application processor. They could be moved to /vendor/dsp once
785 // that is cleaned up.
786 InitPrebuiltEtcModule(module, "lib/rfsa")
787 // This module is device-only
788 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100789 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700790 return module
791}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000792
793// prebuilt_media_audio installs audio files in <partition>/media/audio directory.
794func PrebuiltMediaAudioFactory() android.Module {
795 module := &PrebuiltEtc{}
796 InitPrebuiltEtcModule(module, "media/audio")
797 // This module is device-only
798 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
799 android.InitDefaultableModule(module)
800 return module
801}