blob: be943a3ca99a1508ce26c062602d750ec8edbebb [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)
Jihoon Kangdca2f2b2024-11-06 18:43:19 +000081 ctx.RegisterModuleType("prebuilt_tvservice", PrebuiltTvServiceFactory)
82 ctx.RegisterModuleType("prebuilt_optee", PrebuiltOpteeFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000083
84 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040085
Jiyong Parkc678ad32018-04-10 13:07:10 +090086}
87
Paul Duffin1172fed2021-03-08 11:28:18 +000088var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
89
Jiyong Parkc678ad32018-04-10 13:07:10 +090090type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080091 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110092 // Mutually exclusive with srcs.
Cole Faustfdec8722024-05-22 11:38:29 -070093 Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090094
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110095 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Douglas Anderson79688ff2024-09-27 15:08:33 -070096 // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
97 // set. May use globs in filenames.
Cole Faustfdec8722024-05-22 11:38:29 -070098 Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110099
Douglas Anderson79688ff2024-09-27 15:08:33 -0700100 // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
101 // set filename_from_src. This can be used to install each source file to a different directory
102 // and/or change filenames when files are installed. Must be exactly one entry per source file,
103 // which means care must be taken if srcs has globs.
104 Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
105
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800106 // 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 +1100107 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +0900108 Filename *string `android:"arch_variant"`
109
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800110 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +0900111 // is the same as the file name of the source file.
112 Filename_from_src *bool `android:"arch_variant"`
113
Yifan Hong1b3348d2020-01-21 15:53:22 -0800114 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700115 // On device without a dedicated recovery partition, the module is only
116 // available after switching root into
117 // /first_stage_ramdisk. To expose the module before switching root, install
118 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -0800119 Ramdisk_available *bool
120
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700121 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -0700122 // On device without a dedicated recovery partition, the module is only
123 // available after switching root into
124 // /first_stage_ramdisk. To expose the module before switching root, install
125 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700126 Vendor_ramdisk_available *bool
127
Inseob Kim08758f02021-04-08 21:13:22 +0900128 // Make this module available when building for debug ramdisk.
129 Debug_ramdisk_available *bool
130
Tao Bao0ba5c942018-08-14 22:20:22 -0700131 // Make this module available when building for recovery.
132 Recovery_available *bool
133
Jiyong Parkad9ce042018-10-31 22:49:57 +0900134 // Whether this module is directly installable to one of the partitions. Default: true.
135 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800136
137 // Install symlinks to the installed file.
138 Symlinks []string `android:"arch_variant"`
Wei Li59586252024-11-04 09:25:54 -0800139
Wei Li59586252024-11-04 09:25:54 -0800140 // Install to partition oem when set to true.
141 Oem_specific *bool `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900142}
143
Inseob Kim27408bf2021-04-06 21:00:17 +0900144type prebuiltSubdirProperties struct {
145 // Optional subdirectory under which this file is installed into, cannot be specified with
146 // relative_install_path, prefer relative_install_path.
147 Sub_dir *string `android:"arch_variant"`
148
149 // Optional subdirectory under which this file is installed into, cannot be specified with
150 // sub_dir.
151 Relative_install_path *string `android:"arch_variant"`
152}
153
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900154type prebuiltRootProperties struct {
155 // Install this module to the root directory, without partition subdirs. When this module is
156 // added to PRODUCT_PACKAGES, this module will be installed to $PRODUCT_OUT/root, which will
157 // then be copied to the root of system.img. When this module is packaged by other modules like
158 // android_filesystem, this module will be installed to the root ("/"), unlike normal
159 // prebuilt_root modules which are installed to the partition subdir (e.g. "/system/").
160 Install_in_root *bool
161}
162
Jooyung Han39edb6c2019-11-06 16:53:07 +0900163type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700164 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800165
166 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900167 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800168
169 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900170 SubDir() string
Jooyung Han39edb6c2019-11-06 16:53:07 +0900171}
172
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900173type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700174 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000175 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900176
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900177 properties prebuiltEtcProperties
178
179 // rootProperties is used to return the value of the InstallInRoot() method. Currently, only
180 // prebuilt_avb and prebuilt_root modules use this.
181 rootProperties prebuiltRootProperties
182
Inseob Kim27408bf2021-04-06 21:00:17 +0900183 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900184
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100185 sourceFilePaths android.Paths
186 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800187 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800188 installDirBase string
189 installDirBase64 string
190 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800191 // The base install location when soc_specific property is set to true, e.g. "firmware" for
192 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700193 socInstallDirBase string
Douglas Anderson79688ff2024-09-27 15:08:33 -0700194 installDirPaths []android.InstallPath
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700195 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700196
Cole Faustfdec8722024-05-22 11:38:29 -0700197 usedSrcsProperty bool
198
Colin Crossf17e2b52023-10-30 15:17:25 -0700199 makeClass string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900200}
201
Inseob Kim1e27a142021-05-06 11:46:11 +0000202type Defaults struct {
203 android.ModuleBase
204 android.DefaultsModuleBase
205}
206
Yifan Hong1b3348d2020-01-21 15:53:22 -0800207func (p *PrebuiltEtc) inRamdisk() bool {
208 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
209}
210
211func (p *PrebuiltEtc) onlyInRamdisk() bool {
212 return p.ModuleBase.InstallInRamdisk()
213}
214
215func (p *PrebuiltEtc) InstallInRamdisk() bool {
216 return p.inRamdisk()
217}
218
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700219func (p *PrebuiltEtc) inVendorRamdisk() bool {
220 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
221}
222
223func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
224 return p.ModuleBase.InstallInVendorRamdisk()
225}
226
227func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
228 return p.inVendorRamdisk()
229}
230
Inseob Kim08758f02021-04-08 21:13:22 +0900231func (p *PrebuiltEtc) inDebugRamdisk() bool {
232 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
233}
234
235func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
236 return p.ModuleBase.InstallInDebugRamdisk()
237}
238
239func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
240 return p.inDebugRamdisk()
241}
242
Kiyoung Kimae11c232021-07-19 11:38:04 +0900243func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800244 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700245}
246
247func (p *PrebuiltEtc) onlyInRecovery() bool {
248 return p.ModuleBase.InstallInRecovery()
249}
250
251func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900252 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700253}
254
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700255var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800256
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700257func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.ImageInterfaceContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800258
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700259func (p *PrebuiltEtc) VendorVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000260 return false
261}
262
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700263func (p *PrebuiltEtc) ProductVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jihoon Kang47e91842024-06-19 00:51:16 +0000264 return false
265}
266
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700267func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700268 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900269 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800270}
271
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700272func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700273 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800274}
275
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700276func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700277 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
278}
279
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700280func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.ImageInterfaceContext) bool {
Inseob Kim08758f02021-04-08 21:13:22 +0900281 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
282}
283
Nelson Li1fb94b22024-07-09 17:04:52 +0800284func (p *PrebuiltEtc) InstallInRoot() bool {
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900285 return proptools.Bool(p.rootProperties.Install_in_root)
Nelson Li1fb94b22024-07-09 17:04:52 +0800286}
287
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700288func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.ImageInterfaceContext) bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700289 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800290}
291
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700292func (p *PrebuiltEtc) ExtraImageVariations(ctx android.ImageInterfaceContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800293 return nil
294}
295
Cole Faustfa6e0fd2024-10-15 15:22:57 -0700296func (p *PrebuiltEtc) SetImageVariation(ctx android.ImageInterfaceContext, variation string) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800297}
298
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700299func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Cole Faustfdec8722024-05-22 11:38:29 -0700300 if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100301 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
302 }
Cole Faustfdec8722024-05-22 11:38:29 -0700303 return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, ""))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900304}
305
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700306func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700307 if len(p.installDirPaths) != 1 {
308 panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
309 }
310 return p.installDirPaths[0]
Jooyung Hana0171822019-07-22 15:48:36 +0900311}
312
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900313// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
314// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700315func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900316 p.additionalDependencies = &paths
317}
318
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700319func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Cole Faustfdec8722024-05-22 11:38:29 -0700320 if p.usedSrcsProperty {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100321 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
322 }
323 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900324}
325
326func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900327 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700328 return subDir
329 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900330 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900331}
332
Jooyung Han0703fd82020-08-26 22:11:53 +0900333func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900334 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900335}
336
Jiyong Parkad9ce042018-10-31 22:49:57 +0900337func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800338 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900339}
340
Kiyoung Kimae11c232021-07-19 11:38:04 +0900341func (p *PrebuiltEtc) InVendor() bool {
342 return p.ModuleBase.InstallInVendor()
343}
344
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100345func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800346 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
347 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900348 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700349 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
350 installBaseDir = p.installDirBase64
351 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900352 if p.SocSpecific() && p.socInstallDirBase != "" {
353 installBaseDir = p.socInstallDirBase
354 }
Colin Cross2f634572023-11-13 12:12:06 -0800355 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
356 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
357 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100358 return installBaseDir
359}
Colin Cross2f634572023-11-13 12:12:06 -0800360
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100361func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
362 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900363
Cole Faustfdec8722024-05-22 11:38:29 -0700364 srcProperty := p.properties.Src.Get(ctx)
365 srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil)
366 if srcProperty.IsPresent() && len(srcsProperty) > 0 {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100367 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000368 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700369 dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
370 if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
371 ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
372 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100373
374 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
375 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
376 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
377 }
Douglas Anderson79688ff2024-09-27 15:08:33 -0700378 baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
Wei Li59586252024-11-04 09:25:54 -0800379 // TODO(b/377304441)
Spandan Das27ff7672024-11-06 19:23:57 +0000380 if android.Bool(p.properties.Oem_specific) {
Wei Li59586252024-11-04 09:25:54 -0800381 baseInstallDirPath = android.PathForModuleInPartitionInstall(ctx, ctx.DeviceConfig().OemPath(), p.installBaseDir(ctx), p.SubDir())
382 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100383
384 filename := proptools.String(p.properties.Filename)
385 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Cole Faustfdec8722024-05-22 11:38:29 -0700386 if srcProperty.IsPresent() {
387 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()})
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100388 // If the source was not found, set a fake source path to
389 // support AllowMissingDependencies executions.
390 if len(p.sourceFilePaths) == 0 {
391 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
392 }
393
394 // Determine the output file basename.
395 // If Filename is set, use the name specified by the property.
396 // If Filename_from_src is set, use the source file name.
397 // Otherwise use the module name.
398 if filename != "" {
399 if filenameFromSrc {
400 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
401 return
402 }
403 } else if filenameFromSrc {
404 filename = p.sourceFilePaths[0].Base()
405 } else {
406 filename = ctx.ModuleName()
407 }
408 if strings.Contains(filename, "/") {
409 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
410 return
411 }
412 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
413
414 ip := installProperties{
415 filename: filename,
416 sourceFilePath: p.sourceFilePaths[0],
417 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700418 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100419 symlinks: p.properties.Symlinks,
420 }
421 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700422 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Cole Faustfdec8722024-05-22 11:38:29 -0700423 } else if len(srcsProperty) > 0 {
424 p.usedSrcsProperty = true
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100425 if filename != "" {
426 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
427 }
428 if len(p.properties.Symlinks) > 0 {
429 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
430 }
431 if p.properties.Filename_from_src != nil {
Douglas Anderson79688ff2024-09-27 15:08:33 -0700432 if len(dstsProperty) > 0 {
433 ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
434 } else {
435 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
436 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100437 }
Cole Faustfdec8722024-05-22 11:38:29 -0700438 p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700439 if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
440 ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
441 }
442 for i, src := range p.sourceFilePaths {
443 var filename string
444 var installDirPath android.InstallPath
445
446 if len(dstsProperty) > 0 {
447 var dstdir string
448
449 dstdir, filename = filepath.Split(dstsProperty[i])
450 installDirPath = baseInstallDirPath.Join(ctx, dstdir)
451 } else {
452 filename = src.Base()
453 installDirPath = baseInstallDirPath
454 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100455 output := android.PathForModuleOut(ctx, filename).OutputPath
456 ip := installProperties{
457 filename: filename,
458 sourceFilePath: src,
459 outputFilePath: output,
Douglas Anderson79688ff2024-09-27 15:08:33 -0700460 installDirPath: installDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100461 }
462 p.outputFilePaths = append(p.outputFilePaths, output)
463 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700464 p.installDirPaths = append(p.installDirPaths, installDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100465 }
466 } else if ctx.Config().AllowMissingDependencies() {
467 // If no srcs was set and AllowMissingDependencies is enabled then
468 // mark the module as missing dependencies and set a fake source path
469 // and file name.
470 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
471 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
472 if filename == "" {
473 filename = ctx.ModuleName()
474 }
475 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
476 ip := installProperties{
477 filename: filename,
478 sourceFilePath: p.sourceFilePaths[0],
479 outputFilePath: p.outputFilePaths[0],
Douglas Anderson79688ff2024-09-27 15:08:33 -0700480 installDirPath: baseInstallDirPath,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100481 }
482 installs = append(installs, ip)
Douglas Anderson79688ff2024-09-27 15:08:33 -0700483 p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100484 } else {
485 ctx.PropertyErrorf("src", "missing prebuilt source file")
486 return
487 }
488
489 // Call InstallFile even when uninstallable to make the module included in the package.
490 if !p.Installable() {
491 p.SkipInstall()
492 }
493 for _, ip := range installs {
494 ip.addInstallRules(ctx)
495 }
mrziwang89371762024-06-11 12:42:24 -0700496
497 ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
Spandan Das756d3402023-06-05 22:49:50 +0000498}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900499
Spandan Das756d3402023-06-05 22:49:50 +0000500type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000501 filename string
502 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100503 outputFilePath android.OutputPath
504 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000505 symlinks []string
506}
507
508// utility function to add install rules to the build graph.
509// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100510func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000511 // Copy the file from src to a location in out/ with the correct `filename`
512 // This ensures that outputFilePath has the correct name for others to
513 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000514 ctx.Build(pctx, android.BuildParams{
515 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100516 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000517 Input: ip.sourceFilePath,
518 })
519
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100520 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000521 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100522 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900523 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900524}
525
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700526func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700527 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800528 if p.inRamdisk() && !p.onlyInRamdisk() {
529 nameSuffix = ".ramdisk"
530 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700531 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
532 nameSuffix = ".vendor_ramdisk"
533 }
Inseob Kim08758f02021-04-08 21:13:22 +0900534 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
535 nameSuffix = ".debug_ramdisk"
536 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900537 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700538 nameSuffix = ".recovery"
539 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700540
541 class := p.makeClass
542 if class == "" {
543 class = "ETC"
544 }
545
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100546 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700547 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700548 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100549 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700550 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700551 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700552 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Douglas Anderson79688ff2024-09-27 15:08:33 -0700553 entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100554 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800555 if len(p.properties.Symlinks) > 0 {
556 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
557 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800558 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700559 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800560 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900561 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700562 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900563 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900564 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900565}
566
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000567func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
568 return &p.ModuleBase
569}
570
Jooyung Hana0171822019-07-22 15:48:36 +0900571func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
572 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900573 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900574 p.AddProperties(&p.subdirProperties)
575}
576
577func InitPrebuiltRootModule(p *PrebuiltEtc) {
578 p.installDirBase = "."
Nelson Li1fb94b22024-07-09 17:04:52 +0800579 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900580 p.AddProperties(&p.rootProperties)
Nelson Li1fb94b22024-07-09 17:04:52 +0800581}
582
583func InitPrebuiltAvbModule(p *PrebuiltEtc) {
584 p.installDirBase = "avb"
Inseob Kim27408bf2021-04-06 21:00:17 +0900585 p.AddProperties(&p.properties)
Inseob Kimbe6a66d2024-07-11 15:43:44 +0900586 p.rootProperties.Install_in_root = proptools.BoolPtr(true)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900587}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900588
Patrice Arruda9e14b962019-03-11 15:58:50 -0700589// prebuilt_etc is for a prebuilt artifact that is installed in
590// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700591func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900592 module := &PrebuiltEtc{}
593 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900594 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700595 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000596 android.InitDefaultableModule(module)
597 return module
598}
599
600func defaultsFactory() android.Module {
601 return DefaultsFactory()
602}
603
604func DefaultsFactory(props ...interface{}) android.Module {
605 module := &Defaults{}
606
607 module.AddProperties(props...)
608 module.AddProperties(
609 &prebuiltEtcProperties{},
610 &prebuiltSubdirProperties{},
611 )
612
613 android.InitDefaultsModule(module)
614
Jiyong Parkc678ad32018-04-10 13:07:10 +0900615 return module
616}
Tao Bao0ba5c942018-08-14 22:20:22 -0700617
Patrice Arruda9e14b962019-03-11 15:58:50 -0700618// prebuilt_etc_host is for a host prebuilt artifact that is installed in
619// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700620func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900621 module := &PrebuiltEtc{}
622 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800623 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700624 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100625 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800626 return module
627}
628
Miguel32b02802022-12-01 18:38:26 +0000629// prebuilt_etc_host is for a host prebuilt artifact that is installed in
630// <partition>/etc/<sub_dir> directory.
631func PrebuiltEtcCaCertsFactory() android.Module {
632 module := &PrebuiltEtc{}
633 InitPrebuiltEtcModule(module, "cacerts")
634 // This module is device-only
635 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000636 return module
637}
638
Nelson Li1fb94b22024-07-09 17:04:52 +0800639// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
640// `prebuilt_avb` will not have a `system` subdirectory.
641// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
642// root directory of the partition: <partition_root>/avb.
643// prebuilt_avb does not allow adding any other subdirectories.
644func PrebuiltAvbFactory() android.Module {
645 module := &PrebuiltEtc{}
646 InitPrebuiltAvbModule(module)
647 // This module is device-only
648 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
649 android.InitDefaultableModule(module)
650 return module
651}
652
Inseob Kim27408bf2021-04-06 21:00:17 +0900653// prebuilt_root is for a prebuilt artifact that is installed in
654// <partition>/ directory. Can't have any sub directories.
655func PrebuiltRootFactory() android.Module {
656 module := &PrebuiltEtc{}
657 InitPrebuiltRootModule(module)
658 // This module is device-only
659 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100660 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900661 return module
662}
663
Liz Kammere9ecddc2022-01-04 17:27:52 -0500664// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
665// directory.
666func PrebuiltRootHostFactory() android.Module {
667 module := &PrebuiltEtc{}
668 InitPrebuiltEtcModule(module, ".")
669 // This module is host-only
670 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
671 android.InitDefaultableModule(module)
672 return module
673}
674
Patrice Arruda9e14b962019-03-11 15:58:50 -0700675// prebuilt_usr_share is for a prebuilt artifact that is installed in
676// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700677func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900678 module := &PrebuiltEtc{}
679 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800680 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700681 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100682 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800683 return module
684}
685
Patrice Arruda9e14b962019-03-11 15:58:50 -0700686// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
687// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700688func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900689 module := &PrebuiltEtc{}
690 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800691 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700692 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100693 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800694 return module
695}
696
yangbill63c5e192024-03-27 09:02:12 +0000697// prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in
698// <partition>/usr/hyphen-data/<sub_dir> directory.
699func PrebuiltUserHyphenDataFactory() android.Module {
700 module := &PrebuiltEtc{}
701 InitPrebuiltEtcModule(module, "usr/hyphen-data")
702 // This module is device-only
703 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
704 android.InitDefaultableModule(module)
705 return module
706}
707
yangbill85527e62024-04-30 08:24:50 +0000708// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in
709// <partition>/usr/keylayout/<sub_dir> directory.
710func PrebuiltUserKeyLayoutFactory() android.Module {
711 module := &PrebuiltEtc{}
712 InitPrebuiltEtcModule(module, "usr/keylayout")
713 // This module is device-only
714 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
715 android.InitDefaultableModule(module)
716 return module
717}
718
719// prebuilt_usr_keychars is for a prebuilt artifact that is installed in
720// <partition>/usr/keychars/<sub_dir> directory.
721func PrebuiltUserKeyCharsFactory() android.Module {
722 module := &PrebuiltEtc{}
723 InitPrebuiltEtcModule(module, "usr/keychars")
724 // This module is device-only
725 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
726 android.InitDefaultableModule(module)
727 return module
728}
729
730// prebuilt_usr_idc is for a prebuilt artifact that is installed in
731// <partition>/usr/idc/<sub_dir> directory.
732func PrebuiltUserIdcFactory() android.Module {
733 module := &PrebuiltEtc{}
734 InitPrebuiltEtcModule(module, "usr/idc")
735 // This module is device-only
736 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
737 android.InitDefaultableModule(module)
738 return module
739}
740
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000741// prebuilt_usr_srec is for a prebuilt artifact that is installed in
742// <partition>/usr/srec/<sub_dir> directory.
743func PrebuiltUserSrecFactory() android.Module {
744 module := &PrebuiltEtc{}
745 InitPrebuiltEtcModule(module, "usr/srec")
746 // This module is device-only
747 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
748 android.InitDefaultableModule(module)
749 return module
750}
751
Patrice Arruda61583eb2019-05-14 08:20:45 -0700752// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700753func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900754 module := &PrebuiltEtc{}
755 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700756 // This module is device-only
Cole Faustc49443e2024-10-29 11:15:34 -0700757 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100758 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700759 return module
760}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700761
Kevin93f7cd82024-05-02 12:37:59 +0200762// prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory.
763func PrebuiltOverlayFactory() android.Module {
764 module := &PrebuiltEtc{}
765 InitPrebuiltEtcModule(module, "overlay")
766 // This module is device-only
767 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
768 return module
769}
770
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800771// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
772// image.
773// If soc_specific property is set to true, the firmware file is installed to the
774// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700775func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900776 module := &PrebuiltEtc{}
777 module.socInstallDirBase = "firmware"
778 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700779 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700780 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100781 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700782 return module
783}
Patrice Arruda0f688002020-06-08 21:40:25 +0000784
785// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800786// If soc_specific property is set to true, the DSP related file is installed to the
787// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000788func PrebuiltDSPFactory() android.Module {
789 module := &PrebuiltEtc{}
790 module.socInstallDirBase = "dsp"
791 InitPrebuiltEtcModule(module, "etc/dsp")
792 // This module is device-only
793 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100794 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000795 return module
796}
Colin Cross83ebf232021-04-09 09:41:23 -0700797
Colin Crossf17e2b52023-10-30 15:17:25 -0700798// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
799func PrebuiltRenderScriptBitcodeFactory() android.Module {
800 module := &PrebuiltEtc{}
801 module.makeClass = "RENDERSCRIPT_BITCODE"
802 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800803 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700804 InitPrebuiltEtcModule(module, "lib")
805 // This module is device-only
806 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
807 android.InitDefaultableModule(module)
808 return module
809}
810
Colin Cross83ebf232021-04-09 09:41:23 -0700811// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
812// to the <partition>/lib/rfsa directory.
813func PrebuiltRFSAFactory() android.Module {
814 module := &PrebuiltEtc{}
815 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
816 // many places outside of the application processor. They could be moved to /vendor/dsp once
817 // that is cleaned up.
818 InitPrebuiltEtcModule(module, "lib/rfsa")
819 // This module is device-only
820 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100821 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700822 return module
823}
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000824
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000825// prebuilt_media installs media files in <partition>/media directory.
826func PrebuiltMediaFactory() android.Module {
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000827 module := &PrebuiltEtc{}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000828 InitPrebuiltEtcModule(module, "media")
Jihoon Kang2ecf8622024-10-23 21:20:30 +0000829 // This module is device-only
830 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
831 android.InitDefaultableModule(module)
832 return module
833}
Jihoon Kangec62d842024-10-25 20:27:18 +0000834
835// prebuilt_voicepack installs voice pack files in <partition>/tts directory.
836func PrebuiltVoicepackFactory() android.Module {
837 module := &PrebuiltEtc{}
838 InitPrebuiltEtcModule(module, "tts")
839 // This module is device-only
840 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
841 android.InitDefaultableModule(module)
842 return module
843}
844
845// prebuilt_bin installs files in <partition>/bin directory.
846func PrebuiltBinaryFactory() android.Module {
847 module := &PrebuiltEtc{}
848 InitPrebuiltEtcModule(module, "bin")
849 // This module is device-only
850 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
851 android.InitDefaultableModule(module)
852 return module
853}
854
855// prebuilt_wallpaper installs image files in <partition>/wallpaper directory.
856func PrebuiltWallpaperFactory() android.Module {
857 module := &PrebuiltEtc{}
858 InitPrebuiltEtcModule(module, "wallpaper")
859 // This module is device-only
860 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
861 android.InitDefaultableModule(module)
862 return module
863}
Jihoon Kang0da5ae92024-10-29 23:24:17 +0000864
865// prebuilt_priv_app installs files in <partition>/priv-app directory.
866func PrebuiltPrivAppFactory() android.Module {
867 module := &PrebuiltEtc{}
868 InitPrebuiltEtcModule(module, "priv-app")
869 // This module is device-only
870 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
871 android.InitDefaultableModule(module)
872 return module
873}
874
875// prebuilt_rfs installs files in <partition>/rfs directory.
876func PrebuiltRfsFactory() android.Module {
877 module := &PrebuiltEtc{}
878 InitPrebuiltEtcModule(module, "rfs")
879 // This module is device-only
880 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
881 android.InitDefaultableModule(module)
882 return module
883}
884
885// prebuilt_framework installs files in <partition>/framework directory.
886func PrebuiltFrameworkFactory() android.Module {
887 module := &PrebuiltEtc{}
888 InitPrebuiltEtcModule(module, "framework")
889 // This module is device-only
890 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
891 android.InitDefaultableModule(module)
892 return module
893}
894
895// prebuilt_res installs files in <partition>/res directory.
896func PrebuiltResFactory() android.Module {
897 module := &PrebuiltEtc{}
898 InitPrebuiltEtcModule(module, "res")
899 // This module is device-only
900 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
901 android.InitDefaultableModule(module)
902 return module
903}
904
905// prebuilt_wlc_upt installs files in <partition>/wlc_upt directory.
906func PrebuiltWlcUptFactory() android.Module {
907 module := &PrebuiltEtc{}
908 InitPrebuiltEtcModule(module, "wlc_upt")
909 // This module is device-only
910 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
911 android.InitDefaultableModule(module)
912 return module
913}
914
915// prebuilt_odm installs files in <partition>/odm directory.
916func PrebuiltOdmFactory() android.Module {
917 module := &PrebuiltEtc{}
918 InitPrebuiltEtcModule(module, "odm")
919 // This module is device-only
920 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
921 android.InitDefaultableModule(module)
922 return module
923}
Jihoon Kang2e2b7442024-11-05 00:26:20 +0000924
925// prebuilt_vendor_dlkm installs files in <partition>/vendor_dlkm directory.
926func PrebuiltVendorDlkmFactory() android.Module {
927 module := &PrebuiltEtc{}
928 InitPrebuiltEtcModule(module, "vendor_dlkm")
929 // This module is device-only
930 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
931 android.InitDefaultableModule(module)
932 return module
933}
934
935// prebuilt_bt_firmware installs files in <partition>/bt_firmware directory.
936func PrebuiltBtFirmwareFactory() android.Module {
937 module := &PrebuiltEtc{}
938 InitPrebuiltEtcModule(module, "bt_firmware")
939 // This module is device-only
940 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
941 android.InitDefaultableModule(module)
942 return module
943}
Jihoon Kangdca2f2b2024-11-06 18:43:19 +0000944
945// prebuilt_tvservice installs files in <partition>/tvservice directory.
946func PrebuiltTvServiceFactory() android.Module {
947 module := &PrebuiltEtc{}
948 InitPrebuiltEtcModule(module, "tvservice")
949 // This module is device-only
950 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
951 android.InitDefaultableModule(module)
952 return module
953}
954
955// prebuilt_optee installs files in <partition>/optee directory.
956func PrebuiltOpteeFactory() android.Module {
957 module := &PrebuiltEtc{}
958 InitPrebuiltEtcModule(module, "optee")
959 // This module is device-only
960 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
961 android.InitDefaultableModule(module)
962 return module
963}