blob: de9dc452044647611cf14eafd1260d333153bd3f [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"
Inseob Kim27408bf2021-04-06 21:00:17 +090032 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090033
Jaewoong Jung4b79e982020-06-01 10:45:49 -070034 "github.com/google/blueprint/proptools"
35
36 "android/soong/android"
37)
38
39var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090040
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080041// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090042
43func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070044 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090045 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
46}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070047
Jooyung Han0703fd82020-08-26 22:11:53 +090048func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
49 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
50 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090051 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090052 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
53 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
54 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
55 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
56 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070057 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Jiyong Parkc678ad32018-04-10 13:07:10 +090058}
59
Paul Duffin1172fed2021-03-08 11:28:18 +000060var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
61
Jiyong Parkc678ad32018-04-10 13:07:10 +090062type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080063 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Colin Cross27b922f2019-03-04 22:35:41 -080064 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090065
Yo Chiangf0e19fe2020-11-18 15:28:42 +080066 // Optional name for the installed file. If unspecified, name of the module is used as the file
67 // name.
Jiyong Park139a2e62018-10-26 21:49:39 +090068 Filename *string `android:"arch_variant"`
69
Yo Chiangf0e19fe2020-11-18 15:28:42 +080070 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090071 // is the same as the file name of the source file.
72 Filename_from_src *bool `android:"arch_variant"`
73
Yifan Hong1b3348d2020-01-21 15:53:22 -080074 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070075 // On device without a dedicated recovery partition, the module is only
76 // available after switching root into
77 // /first_stage_ramdisk. To expose the module before switching root, install
78 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080079 Ramdisk_available *bool
80
Yifan Hong60e0cfb2020-10-21 15:17:56 -070081 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070082 // On device without a dedicated recovery partition, the module is only
83 // available after switching root into
84 // /first_stage_ramdisk. To expose the module before switching root, install
85 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -070086 Vendor_ramdisk_available *bool
87
Inseob Kim08758f02021-04-08 21:13:22 +090088 // Make this module available when building for debug ramdisk.
89 Debug_ramdisk_available *bool
90
Tao Bao0ba5c942018-08-14 22:20:22 -070091 // Make this module available when building for recovery.
92 Recovery_available *bool
93
Jiyong Parkad9ce042018-10-31 22:49:57 +090094 // Whether this module is directly installable to one of the partitions. Default: true.
95 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +080096
97 // Install symlinks to the installed file.
98 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090099}
100
Inseob Kim27408bf2021-04-06 21:00:17 +0900101type prebuiltSubdirProperties struct {
102 // Optional subdirectory under which this file is installed into, cannot be specified with
103 // relative_install_path, prefer relative_install_path.
104 Sub_dir *string `android:"arch_variant"`
105
106 // Optional subdirectory under which this file is installed into, cannot be specified with
107 // sub_dir.
108 Relative_install_path *string `android:"arch_variant"`
109}
110
Jooyung Han39edb6c2019-11-06 16:53:07 +0900111type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700112 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800113
114 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900115 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800116
117 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900118 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800119
120 // Returns an android.OutputPath to the intermeidate file, which is the renamed prebuilt source
121 // file.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700122 OutputFile() android.OutputPath
Jooyung Han39edb6c2019-11-06 16:53:07 +0900123}
124
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900125type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700126 android.ModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900127
Inseob Kim27408bf2021-04-06 21:00:17 +0900128 properties prebuiltEtcProperties
129 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900130
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700131 sourceFilePath android.Path
132 outputFilePath android.OutputPath
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800133 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700134 installDirBase string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800135 // The base install location when soc_specific property is set to true, e.g. "firmware" for
136 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700137 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700138 installDirPath android.InstallPath
139 additionalDependencies *android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900140}
141
Yifan Hong1b3348d2020-01-21 15:53:22 -0800142func (p *PrebuiltEtc) inRamdisk() bool {
143 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
144}
145
146func (p *PrebuiltEtc) onlyInRamdisk() bool {
147 return p.ModuleBase.InstallInRamdisk()
148}
149
150func (p *PrebuiltEtc) InstallInRamdisk() bool {
151 return p.inRamdisk()
152}
153
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700154func (p *PrebuiltEtc) inVendorRamdisk() bool {
155 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
156}
157
158func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
159 return p.ModuleBase.InstallInVendorRamdisk()
160}
161
162func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
163 return p.inVendorRamdisk()
164}
165
Inseob Kim08758f02021-04-08 21:13:22 +0900166func (p *PrebuiltEtc) inDebugRamdisk() bool {
167 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
168}
169
170func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
171 return p.ModuleBase.InstallInDebugRamdisk()
172}
173
174func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
175 return p.inDebugRamdisk()
176}
177
Tao Bao0ba5c942018-08-14 22:20:22 -0700178func (p *PrebuiltEtc) inRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800179 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700180}
181
182func (p *PrebuiltEtc) onlyInRecovery() bool {
183 return p.ModuleBase.InstallInRecovery()
184}
185
186func (p *PrebuiltEtc) InstallInRecovery() bool {
187 return p.inRecovery()
188}
189
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700190var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800191
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700192func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800193
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700194func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700195 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900196 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800197}
198
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700199func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
200 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800201}
202
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700203func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
204 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
205}
206
Inseob Kim08758f02021-04-08 21:13:22 +0900207func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
208 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
209}
210
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700211func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
212 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800213}
214
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700215func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800216 return nil
217}
218
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700219func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800220}
221
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700222func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800223 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900224}
225
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700226func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900227 return p.installDirPath
228}
229
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900230// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
231// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700232func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900233 p.additionalDependencies = &paths
234}
235
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700236func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900237 return p.outputFilePath
238}
239
Jiyong Park76a42f52021-02-16 06:50:37 +0900240var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
241
242func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
243 switch tag {
244 case "":
245 return android.Paths{p.outputFilePath}, nil
246 default:
247 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
248 }
249}
250
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900251func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900252 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700253 return subDir
254 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900255 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900256}
257
Jooyung Han0703fd82020-08-26 22:11:53 +0900258func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900259 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900260}
261
Jiyong Parkad9ce042018-10-31 22:49:57 +0900262func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800263 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900264}
265
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700266func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800267 if p.properties.Src == nil {
268 ctx.PropertyErrorf("src", "missing prebuilt source file")
269 return
270 }
271 p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Yo Chiang803c40d2020-11-16 20:32:51 +0800272
273 // Determine the output file basename.
274 // If Filename is set, use the name specified by the property.
275 // If Filename_from_src is set, use the source file name.
276 // Otherwise use the module name.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800277 filename := proptools.String(p.properties.Filename)
278 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
279 if filename != "" {
280 if filenameFromSrc {
281 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
282 return
Jiyong Park1a7cf082018-11-13 11:59:12 +0900283 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800284 } else if filenameFromSrc {
285 filename = p.sourceFilePath.Base()
286 } else {
287 filename = ctx.ModuleName()
Jiyong Park139a2e62018-10-26 21:49:39 +0900288 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700289 p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Patrice Arruda057a8b12019-06-03 15:29:27 -0700290
Inseob Kim27408bf2021-04-06 21:00:17 +0900291 if strings.Contains(filename, "/") {
292 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
293 return
294 }
295
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800296 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
Inseob Kim27408bf2021-04-06 21:00:17 +0900297 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
Liz Kammer0449a632020-06-26 10:12:36 -0700298 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
299 }
300
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800301 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
302 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900303 installBaseDir := p.installDirBase
304 if p.SocSpecific() && p.socInstallDirBase != "" {
305 installBaseDir = p.socInstallDirBase
306 }
307 p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900308
Dan Willemsenb0552672019-01-25 16:04:11 -0800309 // This ensures that outputFilePath has the correct name for others to
310 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700311 ctx.Build(pctx, android.BuildParams{
312 Rule: android.Cp,
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900313 Output: p.outputFilePath,
314 Input: p.sourceFilePath,
315 })
Jiyong Parkf9f68052020-09-29 20:15:08 +0900316
Inseob Kim916901e2021-02-17 15:48:53 +0900317 if !p.Installable() {
318 p.SkipInstall()
319 }
320
321 // Call InstallFile even when uninstallable to make the module included in the package
322 installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath)
323 for _, sl := range p.properties.Symlinks {
324 ctx.InstallSymlink(p.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900325 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900326}
327
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700328func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700329 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800330 if p.inRamdisk() && !p.onlyInRamdisk() {
331 nameSuffix = ".ramdisk"
332 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700333 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
334 nameSuffix = ".vendor_ramdisk"
335 }
Inseob Kim08758f02021-04-08 21:13:22 +0900336 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
337 nameSuffix = ".debug_ramdisk"
338 }
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700339 if p.inRecovery() && !p.onlyInRecovery() {
340 nameSuffix = ".recovery"
341 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700342 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700343 Class: "ETC",
344 SubName: nameSuffix,
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700345 OutputFile: android.OptionalPathForPath(p.outputFilePath),
346 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700347 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700348 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossff6c33d2019-10-02 16:01:35 -0700349 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700350 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800351 if len(p.properties.Symlinks) > 0 {
352 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
353 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800354 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700355 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800356 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900357 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700358 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900359 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900360 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900361}
362
Jooyung Hana0171822019-07-22 15:48:36 +0900363func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
364 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900365 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900366 p.AddProperties(&p.subdirProperties)
367}
368
369func InitPrebuiltRootModule(p *PrebuiltEtc) {
370 p.installDirBase = "."
371 p.AddProperties(&p.properties)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900372}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900373
Patrice Arruda9e14b962019-03-11 15:58:50 -0700374// prebuilt_etc is for a prebuilt artifact that is installed in
375// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700376func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900377 module := &PrebuiltEtc{}
378 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900379 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700380 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900381 return module
382}
Tao Bao0ba5c942018-08-14 22:20:22 -0700383
Patrice Arruda9e14b962019-03-11 15:58:50 -0700384// prebuilt_etc_host is for a host prebuilt artifact that is installed in
385// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700386func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900387 module := &PrebuiltEtc{}
388 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800389 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700390 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Jaewoong Jung24788182019-02-04 14:34:10 -0800391 return module
392}
393
Inseob Kim27408bf2021-04-06 21:00:17 +0900394// prebuilt_root is for a prebuilt artifact that is installed in
395// <partition>/ directory. Can't have any sub directories.
396func PrebuiltRootFactory() android.Module {
397 module := &PrebuiltEtc{}
398 InitPrebuiltRootModule(module)
399 // This module is device-only
400 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
401 return module
402}
403
Patrice Arruda9e14b962019-03-11 15:58:50 -0700404// prebuilt_usr_share is for a prebuilt artifact that is installed in
405// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700406func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900407 module := &PrebuiltEtc{}
408 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800409 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700410 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800411 return module
412}
413
Patrice Arruda9e14b962019-03-11 15:58:50 -0700414// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
415// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700416func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900417 module := &PrebuiltEtc{}
418 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800419 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700420 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Patrice Arruda300cef92019-02-22 15:47:57 -0800421 return module
422}
423
Patrice Arruda61583eb2019-05-14 08:20:45 -0700424// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700425func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900426 module := &PrebuiltEtc{}
427 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700428 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700429 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700430 return module
431}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700432
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800433// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
434// image.
435// If soc_specific property is set to true, the firmware file is installed to the
436// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700437func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900438 module := &PrebuiltEtc{}
439 module.socInstallDirBase = "firmware"
440 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700441 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700442 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700443 return module
444}
Patrice Arruda0f688002020-06-08 21:40:25 +0000445
446// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800447// If soc_specific property is set to true, the DSP related file is installed to the
448// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000449func PrebuiltDSPFactory() android.Module {
450 module := &PrebuiltEtc{}
451 module.socInstallDirBase = "dsp"
452 InitPrebuiltEtcModule(module, "etc/dsp")
453 // This module is device-only
454 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
455 return module
456}
Colin Cross83ebf232021-04-09 09:41:23 -0700457
458// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
459// to the <partition>/lib/rfsa directory.
460func PrebuiltRFSAFactory() android.Module {
461 module := &PrebuiltEtc{}
462 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
463 // many places outside of the application processor. They could be moved to /vendor/dsp once
464 // that is cleaned up.
465 InitPrebuiltEtcModule(module, "lib/rfsa")
466 // This module is device-only
467 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
468 return module
469}