blob: 6d0ee6f69602357de6bad46624510a90e49e0f11 [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)
Colin Cross83ebf232021-04-09 09:41:23 -070055 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Jiyong Parkc678ad32018-04-10 13:07:10 +090056}
57
Paul Duffin1172fed2021-03-08 11:28:18 +000058var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
59
Jiyong Parkc678ad32018-04-10 13:07:10 +090060type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080061 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Colin Cross27b922f2019-03-04 22:35:41 -080062 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090063
Yo Chiangf0e19fe2020-11-18 15:28:42 +080064 // Optional subdirectory under which this file is installed into, cannot be specified with
65 // relative_install_path, prefer relative_install_path.
Jiyong Parkc678ad32018-04-10 13:07:10 +090066 Sub_dir *string `android:"arch_variant"`
Tao Bao0ba5c942018-08-14 22:20:22 -070067
Yo Chiangf0e19fe2020-11-18 15:28:42 +080068 // Optional subdirectory under which this file is installed into, cannot be specified with
69 // sub_dir.
Liz Kammer0449a632020-06-26 10:12:36 -070070 Relative_install_path *string `android:"arch_variant"`
71
Yo Chiangf0e19fe2020-11-18 15:28:42 +080072 // Optional name for the installed file. If unspecified, name of the module is used as the file
73 // name.
Jiyong Park139a2e62018-10-26 21:49:39 +090074 Filename *string `android:"arch_variant"`
75
Yo Chiangf0e19fe2020-11-18 15:28:42 +080076 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090077 // is the same as the file name of the source file.
78 Filename_from_src *bool `android:"arch_variant"`
79
Yifan Hong1b3348d2020-01-21 15:53:22 -080080 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070081 // On device without a dedicated recovery partition, the module is only
82 // available after switching root into
83 // /first_stage_ramdisk. To expose the module before switching root, install
84 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080085 Ramdisk_available *bool
86
Yifan Hong60e0cfb2020-10-21 15:17:56 -070087 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070088 // On device without a dedicated recovery partition, the module is only
89 // available after switching root into
90 // /first_stage_ramdisk. To expose the module before switching root, install
91 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -070092 Vendor_ramdisk_available *bool
93
Tao Bao0ba5c942018-08-14 22:20:22 -070094 // Make this module available when building for recovery.
95 Recovery_available *bool
96
Jiyong Parkad9ce042018-10-31 22:49:57 +090097 // Whether this module is directly installable to one of the partitions. Default: true.
98 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +080099
100 // Install symlinks to the installed file.
101 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900102}
103
Jooyung Han39edb6c2019-11-06 16:53:07 +0900104type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700105 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800106
107 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900108 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800109
110 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900111 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800112
113 // Returns an android.OutputPath to the intermeidate file, which is the renamed prebuilt source
114 // file.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700115 OutputFile() android.OutputPath
Jooyung Han39edb6c2019-11-06 16:53:07 +0900116}
117
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900118type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700119 android.ModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900120
121 properties prebuiltEtcProperties
122
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700123 sourceFilePath android.Path
124 outputFilePath android.OutputPath
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800125 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700126 installDirBase string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800127 // The base install location when soc_specific property is set to true, e.g. "firmware" for
128 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700129 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700130 installDirPath android.InstallPath
131 additionalDependencies *android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900132}
133
Yifan Hong1b3348d2020-01-21 15:53:22 -0800134func (p *PrebuiltEtc) inRamdisk() bool {
135 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
136}
137
138func (p *PrebuiltEtc) onlyInRamdisk() bool {
139 return p.ModuleBase.InstallInRamdisk()
140}
141
142func (p *PrebuiltEtc) InstallInRamdisk() bool {
143 return p.inRamdisk()
144}
145
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700146func (p *PrebuiltEtc) inVendorRamdisk() bool {
147 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
148}
149
150func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
151 return p.ModuleBase.InstallInVendorRamdisk()
152}
153
154func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
155 return p.inVendorRamdisk()
156}
157
Tao Bao0ba5c942018-08-14 22:20:22 -0700158func (p *PrebuiltEtc) inRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800159 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700160}
161
162func (p *PrebuiltEtc) onlyInRecovery() bool {
163 return p.ModuleBase.InstallInRecovery()
164}
165
166func (p *PrebuiltEtc) InstallInRecovery() bool {
167 return p.inRecovery()
168}
169
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700170var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800171
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700172func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800173
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700174func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700175 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
176 !p.ModuleBase.InstallInVendorRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800177}
178
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700179func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
180 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800181}
182
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700183func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
184 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
185}
186
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700187func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
188 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800189}
190
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700191func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800192 return nil
193}
194
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700195func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800196}
197
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700198func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800199 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900200}
201
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700202func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900203 return p.installDirPath
204}
205
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900206// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
207// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700208func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900209 p.additionalDependencies = &paths
210}
211
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700212func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900213 return p.outputFilePath
214}
215
Jiyong Park76a42f52021-02-16 06:50:37 +0900216var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
217
218func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
219 switch tag {
220 case "":
221 return android.Paths{p.outputFilePath}, nil
222 default:
223 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
224 }
225}
226
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900227func (p *PrebuiltEtc) SubDir() string {
Liz Kammer0449a632020-06-26 10:12:36 -0700228 if subDir := proptools.String(p.properties.Sub_dir); subDir != "" {
229 return subDir
230 }
231 return proptools.String(p.properties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900232}
233
Jooyung Han0703fd82020-08-26 22:11:53 +0900234func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900235 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900236}
237
Jiyong Parkad9ce042018-10-31 22:49:57 +0900238func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800239 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900240}
241
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700242func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800243 if p.properties.Src == nil {
244 ctx.PropertyErrorf("src", "missing prebuilt source file")
245 return
246 }
247 p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Yo Chiang803c40d2020-11-16 20:32:51 +0800248
249 // Determine the output file basename.
250 // If Filename is set, use the name specified by the property.
251 // If Filename_from_src is set, use the source file name.
252 // Otherwise use the module name.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800253 filename := proptools.String(p.properties.Filename)
254 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
255 if filename != "" {
256 if filenameFromSrc {
257 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
258 return
Jiyong Park1a7cf082018-11-13 11:59:12 +0900259 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800260 } else if filenameFromSrc {
261 filename = p.sourceFilePath.Base()
262 } else {
263 filename = ctx.ModuleName()
Jiyong Park139a2e62018-10-26 21:49:39 +0900264 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700265 p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Patrice Arruda057a8b12019-06-03 15:29:27 -0700266
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800267 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
Liz Kammer0449a632020-06-26 10:12:36 -0700268 if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil {
269 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
270 }
271
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800272 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
273 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900274 installBaseDir := p.installDirBase
275 if p.SocSpecific() && p.socInstallDirBase != "" {
276 installBaseDir = p.socInstallDirBase
277 }
278 p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900279
Dan Willemsenb0552672019-01-25 16:04:11 -0800280 // This ensures that outputFilePath has the correct name for others to
281 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700282 ctx.Build(pctx, android.BuildParams{
283 Rule: android.Cp,
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900284 Output: p.outputFilePath,
285 Input: p.sourceFilePath,
286 })
Jiyong Parkf9f68052020-09-29 20:15:08 +0900287
Inseob Kim916901e2021-02-17 15:48:53 +0900288 if !p.Installable() {
289 p.SkipInstall()
290 }
291
292 // Call InstallFile even when uninstallable to make the module included in the package
293 installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath)
294 for _, sl := range p.properties.Symlinks {
295 ctx.InstallSymlink(p.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900296 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900297}
298
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700299func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700300 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800301 if p.inRamdisk() && !p.onlyInRamdisk() {
302 nameSuffix = ".ramdisk"
303 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700304 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
305 nameSuffix = ".vendor_ramdisk"
306 }
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700307 if p.inRecovery() && !p.onlyInRecovery() {
308 nameSuffix = ".recovery"
309 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700310 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700311 Class: "ETC",
312 SubName: nameSuffix,
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700313 OutputFile: android.OptionalPathForPath(p.outputFilePath),
314 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700315 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700316 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossff6c33d2019-10-02 16:01:35 -0700317 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700318 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800319 if len(p.properties.Symlinks) > 0 {
320 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
321 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800322 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700323 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800324 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900325 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700326 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900327 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900328 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900329}
330
Jooyung Hana0171822019-07-22 15:48:36 +0900331func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
332 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900333 p.AddProperties(&p.properties)
334}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900335
Patrice Arruda9e14b962019-03-11 15:58:50 -0700336// prebuilt_etc is for a prebuilt artifact that is installed in
337// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700338func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900339 module := &PrebuiltEtc{}
340 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900341 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700342 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900343 return module
344}
Tao Bao0ba5c942018-08-14 22:20:22 -0700345
Patrice Arruda9e14b962019-03-11 15:58:50 -0700346// prebuilt_etc_host is for a host prebuilt artifact that is installed in
347// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700348func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900349 module := &PrebuiltEtc{}
350 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800351 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700352 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Jaewoong Jung24788182019-02-04 14:34:10 -0800353 return module
354}
355
Patrice Arruda9e14b962019-03-11 15:58:50 -0700356// prebuilt_usr_share is for a prebuilt artifact that is installed in
357// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700358func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900359 module := &PrebuiltEtc{}
360 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800361 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700362 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800363 return module
364}
365
Patrice Arruda9e14b962019-03-11 15:58:50 -0700366// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
367// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700368func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900369 module := &PrebuiltEtc{}
370 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800371 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700372 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Patrice Arruda300cef92019-02-22 15:47:57 -0800373 return module
374}
375
Patrice Arruda61583eb2019-05-14 08:20:45 -0700376// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700377func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900378 module := &PrebuiltEtc{}
379 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700380 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700381 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700382 return module
383}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700384
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800385// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
386// image.
387// If soc_specific property is set to true, the firmware file is installed to the
388// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700389func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900390 module := &PrebuiltEtc{}
391 module.socInstallDirBase = "firmware"
392 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700393 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700394 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700395 return module
396}
Patrice Arruda0f688002020-06-08 21:40:25 +0000397
398// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800399// If soc_specific property is set to true, the DSP related file is installed to the
400// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000401func PrebuiltDSPFactory() android.Module {
402 module := &PrebuiltEtc{}
403 module.socInstallDirBase = "dsp"
404 InitPrebuiltEtcModule(module, "etc/dsp")
405 // This module is device-only
406 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
407 return module
408}
Colin Cross83ebf232021-04-09 09:41:23 -0700409
410// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
411// to the <partition>/lib/rfsa directory.
412func PrebuiltRFSAFactory() android.Module {
413 module := &PrebuiltEtc{}
414 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
415 // many places outside of the application processor. They could be moved to /vendor/dsp once
416 // that is cleaned up.
417 InitPrebuiltEtcModule(module, "lib/rfsa")
418 // This module is device-only
419 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
420 return module
421}