blob: 6291325f4b70f199ddf261035c9371bcb6b167e1 [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"
32
Jaewoong Jung4b79e982020-06-01 10:45:49 -070033 "github.com/google/blueprint/proptools"
34
35 "android/soong/android"
36)
37
38var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090039
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080040// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090041
42func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070043 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090044 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
45}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070046
Jooyung Han0703fd82020-08-26 22:11:53 +090047func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
48 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
49 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
50 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
51 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
52 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
53 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
54 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Jiyong Parkc678ad32018-04-10 13:07:10 +090055}
56
Paul Duffin1172fed2021-03-08 11:28:18 +000057var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
58
Jiyong Parkc678ad32018-04-10 13:07:10 +090059type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080060 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Colin Cross27b922f2019-03-04 22:35:41 -080061 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090062
Yo Chiangf0e19fe2020-11-18 15:28:42 +080063 // Optional subdirectory under which this file is installed into, cannot be specified with
64 // relative_install_path, prefer relative_install_path.
Jiyong Parkc678ad32018-04-10 13:07:10 +090065 Sub_dir *string `android:"arch_variant"`
Tao Bao0ba5c942018-08-14 22:20:22 -070066
Yo Chiangf0e19fe2020-11-18 15:28:42 +080067 // Optional subdirectory under which this file is installed into, cannot be specified with
68 // sub_dir.
Liz Kammer0449a632020-06-26 10:12:36 -070069 Relative_install_path *string `android:"arch_variant"`
70
Yo Chiangf0e19fe2020-11-18 15:28:42 +080071 // Optional name for the installed file. If unspecified, name of the module is used as the file
72 // name.
Jiyong Park139a2e62018-10-26 21:49:39 +090073 Filename *string `android:"arch_variant"`
74
Yo Chiangf0e19fe2020-11-18 15:28:42 +080075 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090076 // is the same as the file name of the source file.
77 Filename_from_src *bool `android:"arch_variant"`
78
Yifan Hong1b3348d2020-01-21 15:53:22 -080079 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070080 // On device without a dedicated recovery partition, the module is only
81 // available after switching root into
82 // /first_stage_ramdisk. To expose the module before switching root, install
83 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080084 Ramdisk_available *bool
85
Yifan Hong60e0cfb2020-10-21 15:17:56 -070086 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070087 // On device without a dedicated recovery partition, the module is only
88 // available after switching root into
89 // /first_stage_ramdisk. To expose the module before switching root, install
90 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -070091 Vendor_ramdisk_available *bool
92
Tao Bao0ba5c942018-08-14 22:20:22 -070093 // Make this module available when building for recovery.
94 Recovery_available *bool
95
Jiyong Parkad9ce042018-10-31 22:49:57 +090096 // Whether this module is directly installable to one of the partitions. Default: true.
97 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +080098
99 // Install symlinks to the installed file.
100 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900101}
102
Jooyung Han39edb6c2019-11-06 16:53:07 +0900103type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700104 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800105
106 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900107 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800108
109 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900110 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800111
112 // Returns an android.OutputPath to the intermeidate file, which is the renamed prebuilt source
113 // file.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700114 OutputFile() android.OutputPath
Jooyung Han39edb6c2019-11-06 16:53:07 +0900115}
116
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900117type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700118 android.ModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900119
120 properties prebuiltEtcProperties
121
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700122 sourceFilePath android.Path
123 outputFilePath android.OutputPath
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800124 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700125 installDirBase string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800126 // The base install location when soc_specific property is set to true, e.g. "firmware" for
127 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700128 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700129 installDirPath android.InstallPath
130 additionalDependencies *android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900131}
132
Yifan Hong1b3348d2020-01-21 15:53:22 -0800133func (p *PrebuiltEtc) inRamdisk() bool {
134 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
135}
136
137func (p *PrebuiltEtc) onlyInRamdisk() bool {
138 return p.ModuleBase.InstallInRamdisk()
139}
140
141func (p *PrebuiltEtc) InstallInRamdisk() bool {
142 return p.inRamdisk()
143}
144
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700145func (p *PrebuiltEtc) inVendorRamdisk() bool {
146 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
147}
148
149func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
150 return p.ModuleBase.InstallInVendorRamdisk()
151}
152
153func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
154 return p.inVendorRamdisk()
155}
156
Tao Bao0ba5c942018-08-14 22:20:22 -0700157func (p *PrebuiltEtc) inRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800158 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700159}
160
161func (p *PrebuiltEtc) onlyInRecovery() bool {
162 return p.ModuleBase.InstallInRecovery()
163}
164
165func (p *PrebuiltEtc) InstallInRecovery() bool {
166 return p.inRecovery()
167}
168
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700169var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800170
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700171func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800172
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700173func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700174 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
175 !p.ModuleBase.InstallInVendorRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800176}
177
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700178func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
179 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800180}
181
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700182func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
183 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
184}
185
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700186func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
187 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800188}
189
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700190func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800191 return nil
192}
193
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700194func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800195}
196
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700197func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800198 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900199}
200
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700201func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900202 return p.installDirPath
203}
204
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900205// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
206// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700207func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900208 p.additionalDependencies = &paths
209}
210
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700211func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900212 return p.outputFilePath
213}
214
Jiyong Park76a42f52021-02-16 06:50:37 +0900215var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
216
217func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
218 switch tag {
219 case "":
220 return android.Paths{p.outputFilePath}, nil
221 default:
222 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
223 }
224}
225
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900226func (p *PrebuiltEtc) SubDir() string {
Liz Kammer0449a632020-06-26 10:12:36 -0700227 if subDir := proptools.String(p.properties.Sub_dir); subDir != "" {
228 return subDir
229 }
230 return proptools.String(p.properties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900231}
232
Jooyung Han0703fd82020-08-26 22:11:53 +0900233func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900234 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900235}
236
Jiyong Parkad9ce042018-10-31 22:49:57 +0900237func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800238 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900239}
240
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700241func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800242 if p.properties.Src == nil {
243 ctx.PropertyErrorf("src", "missing prebuilt source file")
244 return
245 }
246 p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Yo Chiang803c40d2020-11-16 20:32:51 +0800247
248 // Determine the output file basename.
249 // If Filename is set, use the name specified by the property.
250 // If Filename_from_src is set, use the source file name.
251 // Otherwise use the module name.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800252 filename := proptools.String(p.properties.Filename)
253 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
254 if filename != "" {
255 if filenameFromSrc {
256 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
257 return
Jiyong Park1a7cf082018-11-13 11:59:12 +0900258 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800259 } else if filenameFromSrc {
260 filename = p.sourceFilePath.Base()
261 } else {
262 filename = ctx.ModuleName()
Jiyong Park139a2e62018-10-26 21:49:39 +0900263 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700264 p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Patrice Arruda057a8b12019-06-03 15:29:27 -0700265
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800266 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
Liz Kammer0449a632020-06-26 10:12:36 -0700267 if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil {
268 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
269 }
270
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800271 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
272 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900273 installBaseDir := p.installDirBase
274 if p.SocSpecific() && p.socInstallDirBase != "" {
275 installBaseDir = p.socInstallDirBase
276 }
277 p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900278
Dan Willemsenb0552672019-01-25 16:04:11 -0800279 // This ensures that outputFilePath has the correct name for others to
280 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700281 ctx.Build(pctx, android.BuildParams{
282 Rule: android.Cp,
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900283 Output: p.outputFilePath,
284 Input: p.sourceFilePath,
285 })
Jiyong Parkf9f68052020-09-29 20:15:08 +0900286
Inseob Kim916901e2021-02-17 15:48:53 +0900287 if !p.Installable() {
288 p.SkipInstall()
289 }
290
291 // Call InstallFile even when uninstallable to make the module included in the package
292 installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath)
293 for _, sl := range p.properties.Symlinks {
294 ctx.InstallSymlink(p.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900295 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900296}
297
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700298func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700299 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800300 if p.inRamdisk() && !p.onlyInRamdisk() {
301 nameSuffix = ".ramdisk"
302 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700303 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
304 nameSuffix = ".vendor_ramdisk"
305 }
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700306 if p.inRecovery() && !p.onlyInRecovery() {
307 nameSuffix = ".recovery"
308 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700309 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700310 Class: "ETC",
311 SubName: nameSuffix,
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700312 OutputFile: android.OptionalPathForPath(p.outputFilePath),
313 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700314 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700315 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossff6c33d2019-10-02 16:01:35 -0700316 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700317 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800318 if len(p.properties.Symlinks) > 0 {
319 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
320 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800321 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700322 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800323 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900324 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700325 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900326 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900327 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900328}
329
Jooyung Hana0171822019-07-22 15:48:36 +0900330func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
331 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900332 p.AddProperties(&p.properties)
333}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900334
Patrice Arruda9e14b962019-03-11 15:58:50 -0700335// prebuilt_etc is for a prebuilt artifact that is installed in
336// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700337func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900338 module := &PrebuiltEtc{}
339 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900340 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700341 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900342 return module
343}
Tao Bao0ba5c942018-08-14 22:20:22 -0700344
Patrice Arruda9e14b962019-03-11 15:58:50 -0700345// prebuilt_etc_host is for a host prebuilt artifact that is installed in
346// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700347func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900348 module := &PrebuiltEtc{}
349 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800350 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700351 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Jaewoong Jung24788182019-02-04 14:34:10 -0800352 return module
353}
354
Patrice Arruda9e14b962019-03-11 15:58:50 -0700355// prebuilt_usr_share is for a prebuilt artifact that is installed in
356// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700357func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900358 module := &PrebuiltEtc{}
359 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800360 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700361 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800362 return module
363}
364
Patrice Arruda9e14b962019-03-11 15:58:50 -0700365// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
366// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700367func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900368 module := &PrebuiltEtc{}
369 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800370 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700371 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Patrice Arruda300cef92019-02-22 15:47:57 -0800372 return module
373}
374
Patrice Arruda61583eb2019-05-14 08:20:45 -0700375// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700376func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900377 module := &PrebuiltEtc{}
378 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700379 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700380 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700381 return module
382}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700383
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800384// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
385// image.
386// If soc_specific property is set to true, the firmware file is installed to the
387// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700388func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900389 module := &PrebuiltEtc{}
390 module.socInstallDirBase = "firmware"
391 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700392 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700393 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700394 return module
395}
Patrice Arruda0f688002020-06-08 21:40:25 +0000396
397// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800398// If soc_specific property is set to true, the DSP related file is installed to the
399// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000400func PrebuiltDSPFactory() android.Module {
401 module := &PrebuiltEtc{}
402 module.socInstallDirBase = "dsp"
403 InitPrebuiltEtcModule(module, "etc/dsp")
404 // This module is device-only
405 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
406 return module
407}