blob: ce72fed18e418b3c79416a9c2955ef02d4fae252 [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)
Jihoon Kangec62d842024-10-25 20:27:18 +000069 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
70 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
71 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000072
73 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040074
Jiyong Parkc678ad32018-04-10 13:07:10 +090075}
76
Paul Duffin1172fed2021-03-08 11:28:18 +000077var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
78
Jiyong Parkc678ad32018-04-10 13:07:10 +090079type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080080 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110081 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070082 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090083
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110084 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070085 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
86 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070087 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110088
Douglas Anderson79688ff2024-09-27 15:08:33 -070089 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
90 // set filename_from_src. This can be used to install each source file to a different directory
91 // and/or change filenames when files are installed. Must be exactly one entry per source file,
92 // which means care must be taken if srcs has globs.
93 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
94
Yo Chiangf0e19fe2020-11-18 15:28:42 +080095 // 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 +110096 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +090097 Filename *string `android:"arch_variant"`
98
Yo Chiangf0e19fe2020-11-18 15:28:42 +080099 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900100 // is the same as the file name of the source file.
101 Filename_from_src *bool `android:"arch_variant"`
102
Yifan Hong1b3348d2020-01-21 15:53:22 -0800103 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700104 // On device without a dedicated recovery partition, the module is only
105 // available after switching root into
106 // /first_stage_ramdisk. To expose the module before switching root, install
107 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800108 Ramdisk_available *bool
109
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700110 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700111 // On device without a dedicated recovery partition, the module is only
112 // available after switching root into
113 // /first_stage_ramdisk. To expose the module before switching root, install
114 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700115 Vendor_ramdisk_available *bool
116
Inseob Kim08758f02021-04-08 21:13:22 +0900117 // Make this module available when building for debug ramdisk.
118 Debug_ramdisk_available *bool
119
Tao Bao0ba5c942018-08-14 22:20:22 -0700120 // Make this module available when building for recovery.
121 Recovery_available *bool
122
Jiyong Parkad9ce042018-10-31 22:49:57 +0900123 // Whether this module is directly installable to one of the partitions. Default: true.
124 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800125
126 // Install symlinks to the installed file.
127 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900128}
129
Inseob Kim27408bf2021-04-06 21:00:17 +0900130type prebuiltSubdirProperties struct {
131 // Optional subdirectory under which this file is installed into, cannot be specified with
132 // relative_install_path, prefer relative_install_path.
133 Sub_dir *string `android:"arch_variant"`
134
135 // Optional subdirectory under which this file is installed into, cannot be specified with
136 // sub_dir.
137 Relative_install_path *string `android:"arch_variant"`
138}
139
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900140type prebuiltRootProperties struct {
141 // Install this module to the root directory, without partition subdirs. When this module is
142 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
143 // then be copied to the root of system.img. When this module is packaged by other modules like
144 // android_filesystem, this module will be installed to the root ("/"), unlike normal
145 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
146 Install_in_root *bool
147}
148
Jooyung Han39edb6c2019-11-06 16:53:07 +0900149type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700150 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800151
152 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900153 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800154
155 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900156 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900157}
158
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900159type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700160 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000161 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900162
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900163 properties prebuiltEtcProperties
164
165 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
166 // prebuilt_avb and prebuilt_root modules use this.
167 rootProperties prebuiltRootProperties
168
Inseob Kim27408bf2021-04-06 21:00:17 +0900169 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900170
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100171 sourceFilePaths android.Paths
172 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800173 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800174 installDirBase string
175 installDirBase64 string
176 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800177 // The base install location when soc_specific property is set to true, e.g. "firmware" for
178 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700179 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700180 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700181 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700182
Cole Faustfdec8722024-05-22 11:38:29 -0700183 usedSrcsProperty bool
184
Colin Crossf17e2b52023-10-30 15:17:25 -0700185 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900186}
187
Inseob Kim1e27a142021-05-06 11:46:11 +0000188type Defaults struct {
189 android.ModuleBase
190 android.DefaultsModuleBase
191}
192
Yifan Hong1b3348d2020-01-21 15:53:22 -0800193func (p *PrebuiltEtc) inRamdisk() bool {
194 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
195}
196
197func (p *PrebuiltEtc) onlyInRamdisk() bool {
198 return p.ModuleBase.InstallInRamdisk()
199}
200
201func (p *PrebuiltEtc) InstallInRamdisk() bool {
202 return p.inRamdisk()
203}
204
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700205func (p *PrebuiltEtc) inVendorRamdisk() bool {
206 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
207}
208
209func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
210 return p.ModuleBase.InstallInVendorRamdisk()
211}
212
213func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
214 return p.inVendorRamdisk()
215}
216
Inseob Kim08758f02021-04-08 21:13:22 +0900217func (p *PrebuiltEtc) inDebugRamdisk() bool {
218 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
219}
220
221func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
222 return p.ModuleBase.InstallInDebugRamdisk()
223}
224
225func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
226 return p.inDebugRamdisk()
227}
228
Kiyoung Kimae11c232021-07-19 11:38:04 +0900229func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800230 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700231}
232
233func (p *PrebuiltEtc) onlyInRecovery() bool {
234 return p.ModuleBase.InstallInRecovery()
235}
236
237func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900238 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700239}
240
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700241var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800242
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700243func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800244
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700245func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000246 return false
247}
248
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700249func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000250 return false
251}
252
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700253func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700254 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900255 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800256}
257
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700258func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700259 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800260}
261
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700262func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700263 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
264}
265
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700266func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900267 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
268}
269
Nelson Li1fb94b22024-07-09 17:04:52 +0800270func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900271 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800272}
273
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700274func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700275 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800276}
277
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700278func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800279 return nil
280}
281
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700282func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800283}
284
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700285func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700286 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100287 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
288 }
Cole Faustfdec8722024-05-22 11:38:29 -0700289 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900290}
291
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700292func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700293 if len(p.installDirPaths) != 1 {
294 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
295 }
296 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900297}
298
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900299// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
300// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700301func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900302 p.additionalDependencies = &paths
303}
304
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700305func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700306 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100307 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
308 }
309 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900310}
311
312func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900313 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700314 return subDir
315 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900316 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900317}
318
Jooyung Han0703fd82020-08-26 22:11:53 +0900319func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900320 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900321}
322
Jiyong Parkad9ce042018-10-31 22:49:57 +0900323func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800324 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900325}
326
Kiyoung Kimae11c232021-07-19 11:38:04 +0900327func (p *PrebuiltEtc) InVendor() bool {
328 return p.ModuleBase.InstallInVendor()
329}
330
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100331func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800332 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
333 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900334 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700335 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
336 installBaseDir = p.installDirBase64
337 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900338 if p.SocSpecific() && p.socInstallDirBase != "" {
339 installBaseDir = p.socInstallDirBase
340 }
Colin Cross2f634572023-11-13 12:12:06 -0800341 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
342 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
343 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100344 return installBaseDir
345}
Colin Cross2f634572023-11-13 12:12:06 -0800346
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100347func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
348 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900349
Cole Faustfdec8722024-05-22 11:38:29 -0700350 srcProperty := p.properties.Src.Get(ctx)
351 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
352 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100353 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000354 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700355 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
356 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
357 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
358 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100359
360 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
361 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
362 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
363 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700364 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100365
366 filename := proptools.String(p.properties.Filename)
367 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700368 if srcProperty.IsPresent() {
369 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100370 // If the source was not found, set a fake source path to
371 // support AllowMissingDependencies executions.
372 if len(p.sourceFilePaths) == 0 {
373 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
374 }
375
376 // Determine the output file basename.
377 // If Filename is set, use the name specified by the property.
378 // If Filename_from_src is set, use the source file name.
379 // Otherwise use the module name.
380 if filename != "" {
381 if filenameFromSrc {
382 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
383 return
384 }
385 } else if filenameFromSrc {
386 filename = p.sourceFilePaths[0].Base()
387 } else {
388 filename = ctx.ModuleName()
389 }
390 if strings.Contains(filename, "/") {
391 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
392 return
393 }
394 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
395
396 ip := installProperties{
397 filename: filename,
398 sourceFilePath: p.sourceFilePaths[0],
399 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700400 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100401 symlinks: p.properties.Symlinks,
402 }
403 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700404 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700405 } else if len(srcsProperty) > 0 {
406 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100407 if filename != "" {
408 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
409 }
410 if len(p.properties.Symlinks) > 0 {
411 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
412 }
413 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700414 if len(dstsProperty) > 0 {
415 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
416 } else {
417 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
418 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100419 }
Cole Faustfdec8722024-05-22 11:38:29 -0700420 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700421 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
422 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
423 }
424 for i, src := range p.sourceFilePaths {
425 var filename string
426 var installDirPath android.InstallPath
427
428 if len(dstsProperty) > 0 {
429 var dstdir string
430
431 dstdir, filename = filepath.Split(dstsProperty[i])
432 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
433 } else {
434 filename = src.Base()
435 installDirPath = baseInstallDirPath
436 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100437 output := android.PathForModuleOut(ctx, filename).OutputPath
438 ip := installProperties{
439 filename: filename,
440 sourceFilePath: src,
441 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700442 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100443 }
444 p.outputFilePaths = append(p.outputFilePaths, output)
445 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700446 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100447 }
448 } else if ctx.Config().AllowMissingDependencies() {
449 // If no srcs was set and AllowMissingDependencies is enabled then
450 // mark the module as missing dependencies and set a fake source path
451 // and file name.
452 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
453 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
454 if filename == "" {
455 filename = ctx.ModuleName()
456 }
457 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
458 ip := installProperties{
459 filename: filename,
460 sourceFilePath: p.sourceFilePaths[0],
461 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700462 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100463 }
464 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700465 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100466 } else {
467 ctx.PropertyErrorf("src", "missing prebuilt source file")
468 return
469 }
470
471 // Call InstallFile even when uninstallable to make the module included in the package.
472 if !p.Installable() {
473 p.SkipInstall()
474 }
475 for _, ip := range installs {
476 ip.addInstallRules(ctx)
477 }
mrziwang89371762024-06-11 12:42:24 -0700478
479 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000480}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900481
Spandan Das756d3402023-06-05 22:49:50 +0000482type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000483 filename string
484 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100485 outputFilePath android.OutputPath
486 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000487 symlinks []string
488}
489
490// utility function to add install rules to the build graph.
491// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100492func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000493 // Copy the file from src to a location in out/ with the correct `filename`
494 // This ensures that outputFilePath has the correct name for others to
495 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000496 ctx.Build(pctx, android.BuildParams{
497 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100498 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000499 Input: ip.sourceFilePath,
500 })
501
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100502 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000503 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100504 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900505 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900506}
507
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700508func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700509 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800510 if p.inRamdisk() && !p.onlyInRamdisk() {
511 nameSuffix = ".ramdisk"
512 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700513 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
514 nameSuffix = ".vendor_ramdisk"
515 }
Inseob Kim08758f02021-04-08 21:13:22 +0900516 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
517 nameSuffix = ".debug_ramdisk"
518 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900519 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700520 nameSuffix = ".recovery"
521 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700522
523 class := p.makeClass
524 if class == "" {
525 class = "ETC"
526 }
527
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100528 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700529 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700530 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100531 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700532 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700533 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700534 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700535 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100536 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800537 if len(p.properties.Symlinks) > 0 {
538 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
539 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800540 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700541 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800542 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900543 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700544 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900545 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900546 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900547}
548
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000549func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
550 return &p.ModuleBase
551}
552
Jooyung Hana0171822019-07-22 15:48:36 +0900553func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
554 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900555 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900556 p.AddProperties(&p.subdirProperties)
557}
558
559func InitPrebuiltRootModule(p *PrebuiltEtc) {
560 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800561 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900562 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800563}
564
565func InitPrebuiltAvbModule(p *PrebuiltEtc) {
566 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900567 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900568 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900569}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900570
Patrice Arruda9e14b962019-03-11 15:58:50 -0700571// prebuilt_etc is for a prebuilt artifact that is installed in
572// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700573func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900574 module := &PrebuiltEtc{}
575 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900576 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700577 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000578 android.InitDefaultableModule(module)
579 return module
580}
581
582func defaultsFactory() android.Module {
583 return DefaultsFactory()
584}
585
586func DefaultsFactory(props ...interface{}) android.Module {
587 module := &Defaults{}
588
589 module.AddProperties(props...)
590 module.AddProperties(
591 &prebuiltEtcProperties{},
592 &prebuiltSubdirProperties{},
593 )
594
595 android.InitDefaultsModule(module)
596
Jiyong Parkc678ad32018-04-10 13:07:10 +0900597 return module
598}
Tao Bao0ba5c942018-08-14 22:20:22 -0700599
Patrice Arruda9e14b962019-03-11 15:58:50 -0700600// prebuilt_etc_host is for a host prebuilt artifact that is installed in
601// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700602func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900603 module := &PrebuiltEtc{}
604 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800605 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700606 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100607 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800608 return module
609}
610
Miguel32b02802022-12-01 18:38:26 +0000611// prebuilt_etc_host is for a host prebuilt artifact that is installed in
612// <partition>/etc/<sub_dir> directory.
613func PrebuiltEtcCaCertsFactory() android.Module {
614 module := &PrebuiltEtc{}
615 InitPrebuiltEtcModule(module, "cacerts")
616 // This module is device-only
617 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000618 return module
619}
620
Nelson Li1fb94b22024-07-09 17:04:52 +0800621// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
622// `prebuilt_avb` will not have a `system` subdirectory.
623// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
624// root directory of the partition: <partition_root>/avb.
625// prebuilt_avb does not allow adding any other subdirectories.
626func PrebuiltAvbFactory() android.Module {
627 module := &PrebuiltEtc{}
628 InitPrebuiltAvbModule(module)
629 // This module is device-only
630 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
631 android.InitDefaultableModule(module)
632 return module
633}
634
Inseob Kim27408bf2021-04-06 21:00:17 +0900635// prebuilt_root is for a prebuilt artifact that is installed in
636// <partition>/ directory. Can't have any sub directories.
637func PrebuiltRootFactory() android.Module {
638 module := &PrebuiltEtc{}
639 InitPrebuiltRootModule(module)
640 // This module is device-only
641 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100642 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900643 return module
644}
645
Liz Kammere9ecddc2022-01-04 17:27:52 -0500646// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
647// directory.
648func PrebuiltRootHostFactory() android.Module {
649 module := &PrebuiltEtc{}
650 InitPrebuiltEtcModule(module, ".")
651 // This module is host-only
652 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
653 android.InitDefaultableModule(module)
654 return module
655}
656
Patrice Arruda9e14b962019-03-11 15:58:50 -0700657// prebuilt_usr_share is for a prebuilt artifact that is installed in
658// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700659func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900660 module := &PrebuiltEtc{}
661 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800662 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700663 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100664 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800665 return module
666}
667
Patrice Arruda9e14b962019-03-11 15:58:50 -0700668// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
669// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700670func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900671 module := &PrebuiltEtc{}
672 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800673 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700674 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100675 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800676 return module
677}
678
yangbill63c5e192024-03-27 09:02:12 +0000679// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
680// <partition>/usr/hyphen-data/<sub_dir> directory.
681func PrebuiltUserHyphenDataFactory() android.Module {
682 module := &PrebuiltEtc{}
683 InitPrebuiltEtcModule(module, "usr/hyphen-data")
684 // This module is device-only
685 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
686 android.InitDefaultableModule(module)
687 return module
688}
689
yangbill85527e62024-04-30 08:24:50 +0000690// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
691// <partition>/usr/keylayout/<sub_dir> directory.
692func PrebuiltUserKeyLayoutFactory() android.Module {
693 module := &PrebuiltEtc{}
694 InitPrebuiltEtcModule(module, "usr/keylayout")
695 // This module is device-only
696 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
697 android.InitDefaultableModule(module)
698 return module
699}
700
701// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
702// <partition>/usr/keychars/<sub_dir> directory.
703func PrebuiltUserKeyCharsFactory() android.Module {
704 module := &PrebuiltEtc{}
705 InitPrebuiltEtcModule(module, "usr/keychars")
706 // This module is device-only
707 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
708 android.InitDefaultableModule(module)
709 return module
710}
711
712// prebuilt_usr_idc is for a prebuilt artifact that is installed in
713// <partition>/usr/idc/<sub_dir> directory.
714func PrebuiltUserIdcFactory() android.Module {
715 module := &PrebuiltEtc{}
716 InitPrebuiltEtcModule(module, "usr/idc")
717 // This module is device-only
718 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
719 android.InitDefaultableModule(module)
720 return module
721}
722
Patrice Arruda61583eb2019-05-14 08:20:45 -0700723// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700724func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900725 module := &PrebuiltEtc{}
726 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700727 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700728 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100729 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700730 return module
731}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700732
Kevin93f7cd82024-05-02 12:37:59 +0200733// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
734func PrebuiltOverlayFactory() android.Module {
735 module := &PrebuiltEtc{}
736 InitPrebuiltEtcModule(module, "overlay")
737 // This module is device-only
738 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
739 return module
740}
741
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800742// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
743// image.
744// If soc_specific property is set to true, the firmware file is installed to the
745// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700746func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900747 module := &PrebuiltEtc{}
748 module.socInstallDirBase = "firmware"
749 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700750 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700751 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100752 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700753 return module
754}
Patrice Arruda0f688002020-06-08 21:40:25 +0000755
756// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800757// If soc_specific property is set to true, the DSP related file is installed to the
758// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000759func PrebuiltDSPFactory() android.Module {
760 module := &PrebuiltEtc{}
761 module.socInstallDirBase = "dsp"
762 InitPrebuiltEtcModule(module, "etc/dsp")
763 // This module is device-only
764 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100765 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000766 return module
767}
Colin Cross83ebf232021-04-09 09:41:23 -0700768
Colin Crossf17e2b52023-10-30 15:17:25 -0700769// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
770func PrebuiltRenderScriptBitcodeFactory() android.Module {
771 module := &PrebuiltEtc{}
772 module.makeClass = "RENDERSCRIPT_BITCODE"
773 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800774 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700775 InitPrebuiltEtcModule(module, "lib")
776 // This module is device-only
777 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
778 android.InitDefaultableModule(module)
779 return module
780}
781
Colin Cross83ebf232021-04-09 09:41:23 -0700782// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
783// to the <partition>/lib/rfsa directory.
784func PrebuiltRFSAFactory() android.Module {
785 module := &PrebuiltEtc{}
786 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
787 // many places outside of the application processor. They could be moved to /vendor/dsp once
788 // that is cleaned up.
789 InitPrebuiltEtcModule(module, "lib/rfsa")
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)
Colin Cross83ebf232021-04-09 09:41:23 -0700793 return module
794}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000795
796// prebuilt_media_audio installs audio files in <partition>/media/audio directory.
797func PrebuiltMediaAudioFactory() android.Module {
798 module := &PrebuiltEtc{}
799 InitPrebuiltEtcModule(module, "media/audio")
800 // This module is device-only
801 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
802 android.InitDefaultableModule(module)
803 return module
804}
Jihoon Kangec62d842024-10-25 20:27:18 +0000805
806// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
807func PrebuiltVoicepackFactory() android.Module {
808 module := &PrebuiltEtc{}
809 InitPrebuiltEtcModule(module, "tts")
810 // This module is device-only
811 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
812 android.InitDefaultableModule(module)
813 return module
814}
815
816// prebuilt_bin installs files in <partition>/bin directory.
817func PrebuiltBinaryFactory() android.Module {
818 module := &PrebuiltEtc{}
819 InitPrebuiltEtcModule(module, "bin")
820 // This module is device-only
821 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
822 android.InitDefaultableModule(module)
823 return module
824}
825
826// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
827func PrebuiltWallpaperFactory() android.Module {
828 module := &PrebuiltEtc{}
829 InitPrebuiltEtcModule(module, "wallpaper")
830 // This module is device-only
831 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
832 android.InitDefaultableModule(module)
833 return module
834}