blob: 3204e706e38999c06f59a3d79481942abe7a29f4 [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)
Jiyong Parkc678ad32018-04-10 13:07:10 +090057}
58
Paul Duffin1172fed2021-03-08 11:28:18 +000059var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
60
Jiyong Parkc678ad32018-04-10 13:07:10 +090061type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080062 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Colin Cross27b922f2019-03-04 22:35:41 -080063 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090064
Yo Chiangf0e19fe2020-11-18 15:28:42 +080065 // Optional name for the installed file. If unspecified, name of the module is used as the file
66 // name.
Jiyong Park139a2e62018-10-26 21:49:39 +090067 Filename *string `android:"arch_variant"`
68
Yo Chiangf0e19fe2020-11-18 15:28:42 +080069 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090070 // is the same as the file name of the source file.
71 Filename_from_src *bool `android:"arch_variant"`
72
Yifan Hong1b3348d2020-01-21 15:53:22 -080073 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070074 // On device without a dedicated recovery partition, the module is only
75 // available after switching root into
76 // /first_stage_ramdisk. To expose the module before switching root, install
77 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080078 Ramdisk_available *bool
79
Yifan Hong60e0cfb2020-10-21 15:17:56 -070080 // Make this module available when building for vendor 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 Hong60e0cfb2020-10-21 15:17:56 -070085 Vendor_ramdisk_available *bool
86
Florian Mayer836a8f32021-04-22 16:38:47 +000087 // Make this module available when building for debug ramdisk.
88 // 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.
92 Debug_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
Inseob Kim27408bf2021-04-06 21:00:17 +0900104type prebuiltSubdirProperties struct {
105 // Optional subdirectory under which this file is installed into, cannot be specified with
106 // relative_install_path, prefer relative_install_path.
107 Sub_dir *string `android:"arch_variant"`
108
109 // Optional subdirectory under which this file is installed into, cannot be specified with
110 // sub_dir.
111 Relative_install_path *string `android:"arch_variant"`
112}
113
Jooyung Han39edb6c2019-11-06 16:53:07 +0900114type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700115 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800116
117 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900118 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800119
120 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900121 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800122
123 // Returns an android.OutputPath to the intermeidate file, which is the renamed prebuilt source
124 // file.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700125 OutputFile() android.OutputPath
Jooyung Han39edb6c2019-11-06 16:53:07 +0900126}
127
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900128type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700129 android.ModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900130
Inseob Kim27408bf2021-04-06 21:00:17 +0900131 properties prebuiltEtcProperties
132 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900133
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700134 sourceFilePath android.Path
135 outputFilePath android.OutputPath
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800136 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700137 installDirBase string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800138 // The base install location when soc_specific property is set to true, e.g. "firmware" for
139 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700140 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700141 installDirPath android.InstallPath
142 additionalDependencies *android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900143}
144
Yifan Hong1b3348d2020-01-21 15:53:22 -0800145func (p *PrebuiltEtc) inRamdisk() bool {
146 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
147}
148
149func (p *PrebuiltEtc) onlyInRamdisk() bool {
150 return p.ModuleBase.InstallInRamdisk()
151}
152
153func (p *PrebuiltEtc) InstallInRamdisk() bool {
154 return p.inRamdisk()
155}
156
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700157func (p *PrebuiltEtc) inVendorRamdisk() bool {
158 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
159}
160
161func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
162 return p.ModuleBase.InstallInVendorRamdisk()
163}
164
165func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
166 return p.inVendorRamdisk()
167}
168
Florian Mayer836a8f32021-04-22 16:38:47 +0000169func (p *PrebuiltEtc) inDebugRamdisk() bool {
170 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
171}
172
173func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
174 return p.ModuleBase.InstallInDebugRamdisk()
175}
176
177func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
178 return p.inDebugRamdisk()
179}
180
Tao Bao0ba5c942018-08-14 22:20:22 -0700181func (p *PrebuiltEtc) inRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800182 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700183}
184
185func (p *PrebuiltEtc) onlyInRecovery() bool {
186 return p.ModuleBase.InstallInRecovery()
187}
188
189func (p *PrebuiltEtc) InstallInRecovery() bool {
190 return p.inRecovery()
191}
192
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700193var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800194
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700195func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800196
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700197func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700198 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Florian Mayer836a8f32021-04-22 16:38:47 +0000199 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800200}
201
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700202func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
203 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800204}
205
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700206func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
207 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
208}
209
Florian Mayer836a8f32021-04-22 16:38:47 +0000210func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
211 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
212}
213
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700214func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
215 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800216}
217
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700218func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800219 return nil
220}
221
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700222func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800223}
224
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700225func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800226 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900227}
228
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700229func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900230 return p.installDirPath
231}
232
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900233// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
234// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700235func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900236 p.additionalDependencies = &paths
237}
238
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700239func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900240 return p.outputFilePath
241}
242
Jiyong Park76a42f52021-02-16 06:50:37 +0900243var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
244
245func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
246 switch tag {
247 case "":
248 return android.Paths{p.outputFilePath}, nil
249 default:
250 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
251 }
252}
253
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900254func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900255 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700256 return subDir
257 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900258 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900259}
260
Jooyung Han0703fd82020-08-26 22:11:53 +0900261func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900262 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900263}
264
Jiyong Parkad9ce042018-10-31 22:49:57 +0900265func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800266 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900267}
268
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700269func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800270 if p.properties.Src == nil {
271 ctx.PropertyErrorf("src", "missing prebuilt source file")
272 return
273 }
274 p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Yo Chiang803c40d2020-11-16 20:32:51 +0800275
276 // Determine the output file basename.
277 // If Filename is set, use the name specified by the property.
278 // If Filename_from_src is set, use the source file name.
279 // Otherwise use the module name.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800280 filename := proptools.String(p.properties.Filename)
281 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
282 if filename != "" {
283 if filenameFromSrc {
284 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
285 return
Jiyong Park1a7cf082018-11-13 11:59:12 +0900286 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800287 } else if filenameFromSrc {
288 filename = p.sourceFilePath.Base()
289 } else {
290 filename = ctx.ModuleName()
Jiyong Park139a2e62018-10-26 21:49:39 +0900291 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700292 p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Patrice Arruda057a8b12019-06-03 15:29:27 -0700293
Inseob Kim27408bf2021-04-06 21:00:17 +0900294 if strings.Contains(filename, "/") {
295 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
296 return
297 }
298
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800299 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
Inseob Kim27408bf2021-04-06 21:00:17 +0900300 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
Liz Kammer0449a632020-06-26 10:12:36 -0700301 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
302 }
303
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800304 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
305 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900306 installBaseDir := p.installDirBase
307 if p.SocSpecific() && p.socInstallDirBase != "" {
308 installBaseDir = p.socInstallDirBase
309 }
310 p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900311
Dan Willemsenb0552672019-01-25 16:04:11 -0800312 // This ensures that outputFilePath has the correct name for others to
313 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700314 ctx.Build(pctx, android.BuildParams{
315 Rule: android.Cp,
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900316 Output: p.outputFilePath,
317 Input: p.sourceFilePath,
318 })
Jiyong Parkf9f68052020-09-29 20:15:08 +0900319
Inseob Kim916901e2021-02-17 15:48:53 +0900320 if !p.Installable() {
321 p.SkipInstall()
322 }
323
324 // Call InstallFile even when uninstallable to make the module included in the package
325 installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath)
326 for _, sl := range p.properties.Symlinks {
327 ctx.InstallSymlink(p.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900328 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900329}
330
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700331func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700332 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800333 if p.inRamdisk() && !p.onlyInRamdisk() {
334 nameSuffix = ".ramdisk"
335 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700336 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
337 nameSuffix = ".vendor_ramdisk"
338 }
Florian Mayer836a8f32021-04-22 16:38:47 +0000339 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
340 nameSuffix = ".debug_ramdisk"
341 }
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700342 if p.inRecovery() && !p.onlyInRecovery() {
343 nameSuffix = ".recovery"
344 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700345 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700346 Class: "ETC",
347 SubName: nameSuffix,
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700348 OutputFile: android.OptionalPathForPath(p.outputFilePath),
349 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700350 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700351 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossff6c33d2019-10-02 16:01:35 -0700352 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700353 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800354 if len(p.properties.Symlinks) > 0 {
355 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
356 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800357 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700358 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800359 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900360 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700361 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900362 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900363 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900364}
365
Jooyung Hana0171822019-07-22 15:48:36 +0900366func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
367 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900368 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900369 p.AddProperties(&p.subdirProperties)
370}
371
372func InitPrebuiltRootModule(p *PrebuiltEtc) {
373 p.installDirBase = "."
374 p.AddProperties(&p.properties)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900375}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900376
Patrice Arruda9e14b962019-03-11 15:58:50 -0700377// prebuilt_etc is for a prebuilt artifact that is installed in
378// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700379func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900380 module := &PrebuiltEtc{}
381 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900382 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700383 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900384 return module
385}
Tao Bao0ba5c942018-08-14 22:20:22 -0700386
Patrice Arruda9e14b962019-03-11 15:58:50 -0700387// prebuilt_etc_host is for a host prebuilt artifact that is installed in
388// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700389func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900390 module := &PrebuiltEtc{}
391 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800392 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700393 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Jaewoong Jung24788182019-02-04 14:34:10 -0800394 return module
395}
396
Inseob Kim27408bf2021-04-06 21:00:17 +0900397// prebuilt_root is for a prebuilt artifact that is installed in
398// <partition>/ directory. Can't have any sub directories.
399func PrebuiltRootFactory() android.Module {
400 module := &PrebuiltEtc{}
401 InitPrebuiltRootModule(module)
402 // This module is device-only
403 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
404 return module
405}
406
Patrice Arruda9e14b962019-03-11 15:58:50 -0700407// prebuilt_usr_share is for a prebuilt artifact that is installed in
408// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700409func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900410 module := &PrebuiltEtc{}
411 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800412 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700413 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800414 return module
415}
416
Patrice Arruda9e14b962019-03-11 15:58:50 -0700417// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
418// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700419func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900420 module := &PrebuiltEtc{}
421 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800422 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700423 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Patrice Arruda300cef92019-02-22 15:47:57 -0800424 return module
425}
426
Patrice Arruda61583eb2019-05-14 08:20:45 -0700427// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700428func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900429 module := &PrebuiltEtc{}
430 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700431 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700432 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700433 return module
434}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700435
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800436// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
437// image.
438// If soc_specific property is set to true, the firmware file is installed to the
439// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700440func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900441 module := &PrebuiltEtc{}
442 module.socInstallDirBase = "firmware"
443 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700444 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700445 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700446 return module
447}
Patrice Arruda0f688002020-06-08 21:40:25 +0000448
449// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800450// If soc_specific property is set to true, the DSP related file is installed to the
451// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000452func PrebuiltDSPFactory() android.Module {
453 module := &PrebuiltEtc{}
454 module.socInstallDirBase = "dsp"
455 InitPrebuiltEtcModule(module, "etc/dsp")
456 // This module is device-only
457 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
458 return module
459}