blob: 861ca3c80de066fee7d8a13dbbb2b7808918fdca [file] [log] [blame]
Jiyong Parkc678ad32018-04-10 13:07:10 +09001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Jaewoong Jung4b79e982020-06-01 10:45:49 -070015package etc
Jiyong Parkc678ad32018-04-10 13:07:10 +090016
Yo Chiang803c40d2020-11-16 20:32:51 +080017// This file implements module types that install prebuilt artifacts.
18//
19// There exist two classes of prebuilt modules in the Android tree. The first class are the ones
20// based on `android.Prebuilt`, such as `cc_prebuilt_library` and `java_import`. This kind of
21// modules may exist both as prebuilts and source at the same time, though only one would be
22// installed and the other would be marked disabled. The `prebuilt_postdeps` mutator would select
23// the actual modules to be installed. More details in android/prebuilt.go.
24//
25// The second class is described in this file. Unlike `android.Prebuilt` based module types,
26// `prebuilt_etc` exist only as prebuilts and cannot have a same-named source module counterpart.
27// This makes the logic of `prebuilt_etc` to be much simpler as they don't need to go through the
28// various `prebuilt_*` mutators.
Jaewoong Jung4b79e982020-06-01 10:45:49 -070029
Yo Chiang803c40d2020-11-16 20:32:51 +080030import (
Jiyong Park76a42f52021-02-16 06:50:37 +090031 "fmt"
Kiyoung Kimae11c232021-07-19 11:38:04 +090032 "path/filepath"
Inseob Kim27408bf2021-04-06 21:00:17 +090033 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090034
Jaewoong Jung4b79e982020-06-01 10:45:49 -070035 "github.com/google/blueprint/proptools"
36
37 "android/soong/android"
38)
39
40var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090041
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080042// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090043
44func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070045 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090046 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
47}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070048
Jooyung Han0703fd82020-08-26 22:11:53 +090049func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
50 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
51 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000052 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Nelson Li1fb94b22024-07-09 17:04:52 +080053 ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090054 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050055 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090056 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
57 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
yangbill63c5e192024-03-27 09:02:12 +000058 ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory)
yangbill85527e62024-04-30 08:24:50 +000059 ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory)
60 ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory)
61 ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000062 ctx.RegisterModuleType("prebuilt_usr_srec", PrebuiltUserSrecFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090063 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
Kevin93f7cd82024-05-02 12:37:59 +020064 ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090065 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
66 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070067 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070068 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000069 ctx.RegisterModuleType("prebuilt_media", PrebuiltMediaFactory)
Jihoon Kangec62d842024-10-25 20:27:18 +000070 ctx.RegisterModuleType("prebuilt_voicepack", PrebuiltVoicepackFactory)
71 ctx.RegisterModuleType("prebuilt_bin", PrebuiltBinaryFactory)
72 ctx.RegisterModuleType("prebuilt_wallpaper", PrebuiltWallpaperFactory)
Jihoon Kang0da5ae92024-10-29 23:24:17 +000073 ctx.RegisterModuleType("prebuilt_priv_app", PrebuiltPrivAppFactory)
74 ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
75 ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
76 ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
77 ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
78 ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
Jihoon Kang2e2b7442024-11-05 00:26:20 +000079 ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
80 ctx.RegisterModuleType("prebuilt_bt_firmware", PrebuiltBtFirmwareFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000081
82 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040083
Jiyong Parkc678ad32018-04-10 13:07:10 +090084}
85
Paul Duffin1172fed2021-03-08 11:28:18 +000086var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
87
Jiyong Parkc678ad32018-04-10 13:07:10 +090088type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080089 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110090 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070091 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090092
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110093 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070094 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
95 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070096 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110097
Douglas Anderson79688ff2024-09-27 15:08:33 -070098 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
99 // set filename_from_src. This can be used to install each source file to a different directory
100 // and/or change filenames when files are installed. Must be exactly one entry per source file,
101 // which means care must be taken if srcs has globs.
102 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
103
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800104 // Optional name for the installed file. If unspecified, name of the module is used as the file
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100105 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900106 Filename *string `android:"arch_variant"`
107
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800108 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900109 // is the same as the file name of the source file.
110 Filename_from_src *bool `android:"arch_variant"`
111
Yifan Hong1b3348d2020-01-21 15:53:22 -0800112 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700113 // On device without a dedicated recovery partition, the module is only
114 // available after switching root into
115 // /first_stage_ramdisk. To expose the module before switching root, install
116 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800117 Ramdisk_available *bool
118
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700119 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700120 // On device without a dedicated recovery partition, the module is only
121 // available after switching root into
122 // /first_stage_ramdisk. To expose the module before switching root, install
123 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700124 Vendor_ramdisk_available *bool
125
Inseob Kim08758f02021-04-08 21:13:22 +0900126 // Make this module available when building for debug ramdisk.
127 Debug_ramdisk_available *bool
128
Tao Bao0ba5c942018-08-14 22:20:22 -0700129 // Make this module available when building for recovery.
130 Recovery_available *bool
131
Jiyong Parkad9ce042018-10-31 22:49:57 +0900132 // Whether this module is directly installable to one of the partitions. Default: true.
133 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800134
135 // Install symlinks to the installed file.
136 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900137}
138
Inseob Kim27408bf2021-04-06 21:00:17 +0900139type prebuiltSubdirProperties struct {
140 // Optional subdirectory under which this file is installed into, cannot be specified with
141 // relative_install_path, prefer relative_install_path.
142 Sub_dir *string `android:"arch_variant"`
143
144 // Optional subdirectory under which this file is installed into, cannot be specified with
145 // sub_dir.
146 Relative_install_path *string `android:"arch_variant"`
147}
148
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900149type prebuiltRootProperties struct {
150 // Install this module to the root directory, without partition subdirs. When this module is
151 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
152 // then be copied to the root of system.img. When this module is packaged by other modules like
153 // android_filesystem, this module will be installed to the root ("/"), unlike normal
154 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
155 Install_in_root *bool
156}
157
Jooyung Han39edb6c2019-11-06 16:53:07 +0900158type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700159 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800160
161 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900162 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800163
164 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900165 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900166}
167
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900168type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700169 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000170 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900171
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900172 properties prebuiltEtcProperties
173
174 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
175 // prebuilt_avb and prebuilt_root modules use this.
176 rootProperties prebuiltRootProperties
177
Inseob Kim27408bf2021-04-06 21:00:17 +0900178 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900179
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100180 sourceFilePaths android.Paths
181 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800182 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800183 installDirBase string
184 installDirBase64 string
185 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800186 // The base install location when soc_specific property is set to true, e.g. "firmware" for
187 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700188 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700189 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700190 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700191
Cole Faustfdec8722024-05-22 11:38:29 -0700192 usedSrcsProperty bool
193
Colin Crossf17e2b52023-10-30 15:17:25 -0700194 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900195}
196
Inseob Kim1e27a142021-05-06 11:46:11 +0000197type Defaults struct {
198 android.ModuleBase
199 android.DefaultsModuleBase
200}
201
Yifan Hong1b3348d2020-01-21 15:53:22 -0800202func (p *PrebuiltEtc) inRamdisk() bool {
203 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
204}
205
206func (p *PrebuiltEtc) onlyInRamdisk() bool {
207 return p.ModuleBase.InstallInRamdisk()
208}
209
210func (p *PrebuiltEtc) InstallInRamdisk() bool {
211 return p.inRamdisk()
212}
213
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700214func (p *PrebuiltEtc) inVendorRamdisk() bool {
215 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
216}
217
218func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
219 return p.ModuleBase.InstallInVendorRamdisk()
220}
221
222func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
223 return p.inVendorRamdisk()
224}
225
Inseob Kim08758f02021-04-08 21:13:22 +0900226func (p *PrebuiltEtc) inDebugRamdisk() bool {
227 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
228}
229
230func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
231 return p.ModuleBase.InstallInDebugRamdisk()
232}
233
234func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
235 return p.inDebugRamdisk()
236}
237
Kiyoung Kimae11c232021-07-19 11:38:04 +0900238func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800239 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700240}
241
242func (p *PrebuiltEtc) onlyInRecovery() bool {
243 return p.ModuleBase.InstallInRecovery()
244}
245
246func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900247 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700248}
249
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700250var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800251
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700252func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800253
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700254func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000255 return false
256}
257
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700258func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000259 return false
260}
261
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700262func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700263 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900264 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800265}
266
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700267func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700268 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800269}
270
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700271func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700272 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
273}
274
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700275func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900276 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
277}
278
Nelson Li1fb94b22024-07-09 17:04:52 +0800279func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900280 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800281}
282
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700283func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700284 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800285}
286
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700287func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800288 return nil
289}
290
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700291func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800292}
293
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700294func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700295 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100296 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
297 }
Cole Faustfdec8722024-05-22 11:38:29 -0700298 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900299}
300
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700301func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700302 if len(p.installDirPaths) != 1 {
303 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
304 }
305 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900306}
307
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900308// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
309// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700310func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900311 p.additionalDependencies = &paths
312}
313
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700314func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700315 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100316 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
317 }
318 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900319}
320
321func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900322 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700323 return subDir
324 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900325 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900326}
327
Jooyung Han0703fd82020-08-26 22:11:53 +0900328func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900329 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900330}
331
Jiyong Parkad9ce042018-10-31 22:49:57 +0900332func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800333 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900334}
335
Kiyoung Kimae11c232021-07-19 11:38:04 +0900336func (p *PrebuiltEtc) InVendor() bool {
337 return p.ModuleBase.InstallInVendor()
338}
339
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100340func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800341 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
342 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900343 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700344 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
345 installBaseDir = p.installDirBase64
346 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900347 if p.SocSpecific() && p.socInstallDirBase != "" {
348 installBaseDir = p.socInstallDirBase
349 }
Colin Cross2f634572023-11-13 12:12:06 -0800350 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
351 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
352 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100353 return installBaseDir
354}
Colin Cross2f634572023-11-13 12:12:06 -0800355
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100356func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
357 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900358
Cole Faustfdec8722024-05-22 11:38:29 -0700359 srcProperty := p.properties.Src.Get(ctx)
360 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
361 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100362 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000363 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700364 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
365 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
366 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
367 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100368
369 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
370 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
371 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
372 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700373 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100374
375 filename := proptools.String(p.properties.Filename)
376 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700377 if srcProperty.IsPresent() {
378 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100379 // If the source was not found, set a fake source path to
380 // support AllowMissingDependencies executions.
381 if len(p.sourceFilePaths) == 0 {
382 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
383 }
384
385 // Determine the output file basename.
386 // If Filename is set, use the name specified by the property.
387 // If Filename_from_src is set, use the source file name.
388 // Otherwise use the module name.
389 if filename != "" {
390 if filenameFromSrc {
391 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
392 return
393 }
394 } else if filenameFromSrc {
395 filename = p.sourceFilePaths[0].Base()
396 } else {
397 filename = ctx.ModuleName()
398 }
399 if strings.Contains(filename, "/") {
400 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
401 return
402 }
403 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
404
405 ip := installProperties{
406 filename: filename,
407 sourceFilePath: p.sourceFilePaths[0],
408 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700409 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100410 symlinks: p.properties.Symlinks,
411 }
412 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700413 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700414 } else if len(srcsProperty) > 0 {
415 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100416 if filename != "" {
417 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
418 }
419 if len(p.properties.Symlinks) > 0 {
420 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
421 }
422 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700423 if len(dstsProperty) > 0 {
424 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
425 } else {
426 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
427 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100428 }
Cole Faustfdec8722024-05-22 11:38:29 -0700429 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700430 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
431 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
432 }
433 for i, src := range p.sourceFilePaths {
434 var filename string
435 var installDirPath android.InstallPath
436
437 if len(dstsProperty) > 0 {
438 var dstdir string
439
440 dstdir, filename = filepath.Split(dstsProperty[i])
441 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
442 } else {
443 filename = src.Base()
444 installDirPath = baseInstallDirPath
445 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100446 output := android.PathForModuleOut(ctx, filename).OutputPath
447 ip := installProperties{
448 filename: filename,
449 sourceFilePath: src,
450 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700451 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100452 }
453 p.outputFilePaths = append(p.outputFilePaths, output)
454 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700455 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100456 }
457 } else if ctx.Config().AllowMissingDependencies() {
458 // If no srcs was set and AllowMissingDependencies is enabled then
459 // mark the module as missing dependencies and set a fake source path
460 // and file name.
461 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
462 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
463 if filename == "" {
464 filename = ctx.ModuleName()
465 }
466 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
467 ip := installProperties{
468 filename: filename,
469 sourceFilePath: p.sourceFilePaths[0],
470 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700471 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100472 }
473 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700474 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100475 } else {
476 ctx.PropertyErrorf("src", "missing prebuilt source file")
477 return
478 }
479
480 // Call InstallFile even when uninstallable to make the module included in the package.
481 if !p.Installable() {
482 p.SkipInstall()
483 }
484 for _, ip := range installs {
485 ip.addInstallRules(ctx)
486 }
mrziwang89371762024-06-11 12:42:24 -0700487
488 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000489}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900490
Spandan Das756d3402023-06-05 22:49:50 +0000491type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000492 filename string
493 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100494 outputFilePath android.OutputPath
495 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000496 symlinks []string
497}
498
499// utility function to add install rules to the build graph.
500// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100501func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000502 // Copy the file from src to a location in out/ with the correct `filename`
503 // This ensures that outputFilePath has the correct name for others to
504 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000505 ctx.Build(pctx, android.BuildParams{
506 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100507 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000508 Input: ip.sourceFilePath,
509 })
510
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100511 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000512 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100513 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900514 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900515}
516
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700517func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700518 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800519 if p.inRamdisk() && !p.onlyInRamdisk() {
520 nameSuffix = ".ramdisk"
521 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700522 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
523 nameSuffix = ".vendor_ramdisk"
524 }
Inseob Kim08758f02021-04-08 21:13:22 +0900525 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
526 nameSuffix = ".debug_ramdisk"
527 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900528 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700529 nameSuffix = ".recovery"
530 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700531
532 class := p.makeClass
533 if class == "" {
534 class = "ETC"
535 }
536
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100537 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700538 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700539 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100540 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700541 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700542 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700543 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700544 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100545 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800546 if len(p.properties.Symlinks) > 0 {
547 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
548 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800549 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700550 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800551 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900552 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700553 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900554 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900555 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900556}
557
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000558func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
559 return &p.ModuleBase
560}
561
Jooyung Hana0171822019-07-22 15:48:36 +0900562func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
563 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900564 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900565 p.AddProperties(&p.subdirProperties)
566}
567
568func InitPrebuiltRootModule(p *PrebuiltEtc) {
569 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800570 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900571 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800572}
573
574func InitPrebuiltAvbModule(p *PrebuiltEtc) {
575 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900576 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900577 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900578}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900579
Patrice Arruda9e14b962019-03-11 15:58:50 -0700580// prebuilt_etc is for a prebuilt artifact that is installed in
581// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700582func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900583 module := &PrebuiltEtc{}
584 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900585 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700586 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000587 android.InitDefaultableModule(module)
588 return module
589}
590
591func defaultsFactory() android.Module {
592 return DefaultsFactory()
593}
594
595func DefaultsFactory(props ...interface{}) android.Module {
596 module := &Defaults{}
597
598 module.AddProperties(props...)
599 module.AddProperties(
600 &prebuiltEtcProperties{},
601 &prebuiltSubdirProperties{},
602 )
603
604 android.InitDefaultsModule(module)
605
Jiyong Parkc678ad32018-04-10 13:07:10 +0900606 return module
607}
Tao Bao0ba5c942018-08-14 22:20:22 -0700608
Patrice Arruda9e14b962019-03-11 15:58:50 -0700609// prebuilt_etc_host is for a host prebuilt artifact that is installed in
610// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700611func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900612 module := &PrebuiltEtc{}
613 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800614 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700615 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100616 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800617 return module
618}
619
Miguel32b02802022-12-01 18:38:26 +0000620// prebuilt_etc_host is for a host prebuilt artifact that is installed in
621// <partition>/etc/<sub_dir> directory.
622func PrebuiltEtcCaCertsFactory() android.Module {
623 module := &PrebuiltEtc{}
624 InitPrebuiltEtcModule(module, "cacerts")
625 // This module is device-only
626 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000627 return module
628}
629
Nelson Li1fb94b22024-07-09 17:04:52 +0800630// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
631// `prebuilt_avb` will not have a `system` subdirectory.
632// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
633// root directory of the partition: <partition_root>/avb.
634// prebuilt_avb does not allow adding any other subdirectories.
635func PrebuiltAvbFactory() android.Module {
636 module := &PrebuiltEtc{}
637 InitPrebuiltAvbModule(module)
638 // This module is device-only
639 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
640 android.InitDefaultableModule(module)
641 return module
642}
643
Inseob Kim27408bf2021-04-06 21:00:17 +0900644// prebuilt_root is for a prebuilt artifact that is installed in
645// <partition>/ directory. Can't have any sub directories.
646func PrebuiltRootFactory() android.Module {
647 module := &PrebuiltEtc{}
648 InitPrebuiltRootModule(module)
649 // This module is device-only
650 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100651 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900652 return module
653}
654
Liz Kammere9ecddc2022-01-04 17:27:52 -0500655// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
656// directory.
657func PrebuiltRootHostFactory() android.Module {
658 module := &PrebuiltEtc{}
659 InitPrebuiltEtcModule(module, ".")
660 // This module is host-only
661 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
662 android.InitDefaultableModule(module)
663 return module
664}
665
Patrice Arruda9e14b962019-03-11 15:58:50 -0700666// prebuilt_usr_share is for a prebuilt artifact that is installed in
667// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700668func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900669 module := &PrebuiltEtc{}
670 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800671 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700672 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100673 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800674 return module
675}
676
Patrice Arruda9e14b962019-03-11 15:58:50 -0700677// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
678// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700679func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900680 module := &PrebuiltEtc{}
681 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800682 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700683 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100684 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800685 return module
686}
687
yangbill63c5e192024-03-27 09:02:12 +0000688// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
689// <partition>/usr/hyphen-data/<sub_dir> directory.
690func PrebuiltUserHyphenDataFactory() android.Module {
691 module := &PrebuiltEtc{}
692 InitPrebuiltEtcModule(module, "usr/hyphen-data")
693 // This module is device-only
694 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
695 android.InitDefaultableModule(module)
696 return module
697}
698
yangbill85527e62024-04-30 08:24:50 +0000699// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
700// <partition>/usr/keylayout/<sub_dir> directory.
701func PrebuiltUserKeyLayoutFactory() android.Module {
702 module := &PrebuiltEtc{}
703 InitPrebuiltEtcModule(module, "usr/keylayout")
704 // This module is device-only
705 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
706 android.InitDefaultableModule(module)
707 return module
708}
709
710// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
711// <partition>/usr/keychars/<sub_dir> directory.
712func PrebuiltUserKeyCharsFactory() android.Module {
713 module := &PrebuiltEtc{}
714 InitPrebuiltEtcModule(module, "usr/keychars")
715 // This module is device-only
716 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
717 android.InitDefaultableModule(module)
718 return module
719}
720
721// prebuilt_usr_idc is for a prebuilt artifact that is installed in
722// <partition>/usr/idc/<sub_dir> directory.
723func PrebuiltUserIdcFactory() android.Module {
724 module := &PrebuiltEtc{}
725 InitPrebuiltEtcModule(module, "usr/idc")
726 // This module is device-only
727 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
728 android.InitDefaultableModule(module)
729 return module
730}
731
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000732// prebuilt_usr_srec is for a prebuilt artifact that is installed in
733// <partition>/usr/srec/<sub_dir> directory.
734func PrebuiltUserSrecFactory() android.Module {
735 module := &PrebuiltEtc{}
736 InitPrebuiltEtcModule(module, "usr/srec")
737 // This module is device-only
738 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
739 android.InitDefaultableModule(module)
740 return module
741}
742
Patrice Arruda61583eb2019-05-14 08:20:45 -0700743// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700744func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900745 module := &PrebuiltEtc{}
746 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700747 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700748 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100749 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700750 return module
751}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700752
Kevin93f7cd82024-05-02 12:37:59 +0200753// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
754func PrebuiltOverlayFactory() android.Module {
755 module := &PrebuiltEtc{}
756 InitPrebuiltEtcModule(module, "overlay")
757 // This module is device-only
758 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
759 return module
760}
761
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800762// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
763// image.
764// If soc_specific property is set to true, the firmware file is installed to the
765// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700766func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900767 module := &PrebuiltEtc{}
768 module.socInstallDirBase = "firmware"
769 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700770 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700771 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100772 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700773 return module
774}
Patrice Arruda0f688002020-06-08 21:40:25 +0000775
776// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800777// If soc_specific property is set to true, the DSP related file is installed to the
778// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000779func PrebuiltDSPFactory() android.Module {
780 module := &PrebuiltEtc{}
781 module.socInstallDirBase = "dsp"
782 InitPrebuiltEtcModule(module, "etc/dsp")
783 // This module is device-only
784 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100785 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000786 return module
787}
Colin Cross83ebf232021-04-09 09:41:23 -0700788
Colin Crossf17e2b52023-10-30 15:17:25 -0700789// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
790func PrebuiltRenderScriptBitcodeFactory() android.Module {
791 module := &PrebuiltEtc{}
792 module.makeClass = "RENDERSCRIPT_BITCODE"
793 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800794 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700795 InitPrebuiltEtcModule(module, "lib")
796 // This module is device-only
797 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
798 android.InitDefaultableModule(module)
799 return module
800}
801
Colin Cross83ebf232021-04-09 09:41:23 -0700802// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
803// to the <partition>/lib/rfsa directory.
804func PrebuiltRFSAFactory() android.Module {
805 module := &PrebuiltEtc{}
806 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
807 // many places outside of the application processor. They could be moved to /vendor/dsp once
808 // that is cleaned up.
809 InitPrebuiltEtcModule(module, "lib/rfsa")
810 // This module is device-only
811 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100812 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700813 return module
814}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000815
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000816// prebuilt_media installs media files in <partition>/media directory.
817func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000818 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000819 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000820 // This module is device-only
821 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
822 android.InitDefaultableModule(module)
823 return module
824}
Jihoon Kangec62d842024-10-25 20:27:18 +0000825
826// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
827func PrebuiltVoicepackFactory() android.Module {
828 module := &PrebuiltEtc{}
829 InitPrebuiltEtcModule(module, "tts")
830 // This module is device-only
831 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
832 android.InitDefaultableModule(module)
833 return module
834}
835
836// prebuilt_bin installs files in <partition>/bin directory.
837func PrebuiltBinaryFactory() android.Module {
838 module := &PrebuiltEtc{}
839 InitPrebuiltEtcModule(module, "bin")
840 // This module is device-only
841 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
842 android.InitDefaultableModule(module)
843 return module
844}
845
846// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
847func PrebuiltWallpaperFactory() android.Module {
848 module := &PrebuiltEtc{}
849 InitPrebuiltEtcModule(module, "wallpaper")
850 // This module is device-only
851 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
852 android.InitDefaultableModule(module)
853 return module
854}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000855
856// prebuilt_priv_app installs files in <partition>/priv-app directory.
857func PrebuiltPrivAppFactory() android.Module {
858 module := &PrebuiltEtc{}
859 InitPrebuiltEtcModule(module, "priv-app")
860 // This module is device-only
861 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
862 android.InitDefaultableModule(module)
863 return module
864}
865
866// prebuilt_rfs installs files in <partition>/rfs directory.
867func PrebuiltRfsFactory() android.Module {
868 module := &PrebuiltEtc{}
869 InitPrebuiltEtcModule(module, "rfs")
870 // This module is device-only
871 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
872 android.InitDefaultableModule(module)
873 return module
874}
875
876// prebuilt_framework installs files in <partition>/framework directory.
877func PrebuiltFrameworkFactory() android.Module {
878 module := &PrebuiltEtc{}
879 InitPrebuiltEtcModule(module, "framework")
880 // This module is device-only
881 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
882 android.InitDefaultableModule(module)
883 return module
884}
885
886// prebuilt_res installs files in <partition>/res directory.
887func PrebuiltResFactory() android.Module {
888 module := &PrebuiltEtc{}
889 InitPrebuiltEtcModule(module, "res")
890 // This module is device-only
891 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
892 android.InitDefaultableModule(module)
893 return module
894}
895
896// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
897func PrebuiltWlcUptFactory() android.Module {
898 module := &PrebuiltEtc{}
899 InitPrebuiltEtcModule(module, "wlc_upt")
900 // This module is device-only
901 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
902 android.InitDefaultableModule(module)
903 return module
904}
905
906// prebuilt_odm installs files in <partition>/odm directory.
907func PrebuiltOdmFactory() android.Module {
908 module := &PrebuiltEtc{}
909 InitPrebuiltEtcModule(module, "odm")
910 // This module is device-only
911 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
912 android.InitDefaultableModule(module)
913 return module
914}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000915
916// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
917func PrebuiltVendorDlkmFactory() android.Module {
918 module := &PrebuiltEtc{}
919 InitPrebuiltEtcModule(module, "vendor_dlkm")
920 // This module is device-only
921 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
922 android.InitDefaultableModule(module)
923 return module
924}
925
926// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
927func PrebuiltBtFirmwareFactory() android.Module {
928 module := &PrebuiltEtc{}
929 InitPrebuiltEtcModule(module, "bt_firmware")
930 // This module is device-only
931 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
932 android.InitDefaultableModule(module)
933 return module
934}