blob: dcd7fdcb9edf6dadee5792d7cb20351ac9289db6 [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 (
Kiyoung Kimae11c232021-07-19 11:38:04 +090031 "encoding/json"
Jiyong Park76a42f52021-02-16 06:50:37 +090032 "fmt"
Kiyoung Kimae11c232021-07-19 11:38:04 +090033 "path/filepath"
Alixbbfd5382022-06-09 18:52:05 +000034 "reflect"
Inseob Kim27408bf2021-04-06 21:00:17 +090035 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090036
Jaewoong Jung4b79e982020-06-01 10:45:49 -070037 "github.com/google/blueprint/proptools"
38
39 "android/soong/android"
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040040 "android/soong/bazel"
Kiyoung Kimae11c232021-07-19 11:38:04 +090041 "android/soong/snapshot"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070042)
43
44var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090045
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080046// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090047
48func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070049 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090050 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
Kiyoung Kimae11c232021-07-19 11:38:04 +090051 snapshot.RegisterSnapshotAction(generatePrebuiltSnapshot)
Jooyung Han0703fd82020-08-26 22:11:53 +090052}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070053
Jooyung Han0703fd82020-08-26 22:11:53 +090054func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
55 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
56 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000057 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090058 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050059 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090060 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
61 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
62 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
63 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
64 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070065 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000066
67 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040068
Jiyong Parkc678ad32018-04-10 13:07:10 +090069}
70
Paul Duffin1172fed2021-03-08 11:28:18 +000071var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
72
Jiyong Parkc678ad32018-04-10 13:07:10 +090073type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080074 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Colin Cross27b922f2019-03-04 22:35:41 -080075 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090076
Yo Chiangf0e19fe2020-11-18 15:28:42 +080077 // Optional name for the installed file. If unspecified, name of the module is used as the file
78 // name.
Jiyong Park139a2e62018-10-26 21:49:39 +090079 Filename *string `android:"arch_variant"`
80
Yo Chiangf0e19fe2020-11-18 15:28:42 +080081 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090082 // is the same as the file name of the source file.
83 Filename_from_src *bool `android:"arch_variant"`
84
Yifan Hong1b3348d2020-01-21 15:53:22 -080085 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070086 // On device without a dedicated recovery partition, the module is only
87 // available after switching root into
88 // /first_stage_ramdisk. To expose the module before switching root, install
89 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080090 Ramdisk_available *bool
91
Yifan Hong60e0cfb2020-10-21 15:17:56 -070092 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070093 // On device without a dedicated recovery partition, the module is only
94 // available after switching root into
95 // /first_stage_ramdisk. To expose the module before switching root, install
96 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -070097 Vendor_ramdisk_available *bool
98
Inseob Kim08758f02021-04-08 21:13:22 +090099 // Make this module available when building for debug ramdisk.
100 Debug_ramdisk_available *bool
101
Tao Bao0ba5c942018-08-14 22:20:22 -0700102 // Make this module available when building for recovery.
103 Recovery_available *bool
104
Jiyong Parkad9ce042018-10-31 22:49:57 +0900105 // Whether this module is directly installable to one of the partitions. Default: true.
106 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800107
108 // Install symlinks to the installed file.
109 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900110}
111
Inseob Kim27408bf2021-04-06 21:00:17 +0900112type prebuiltSubdirProperties struct {
113 // Optional subdirectory under which this file is installed into, cannot be specified with
114 // relative_install_path, prefer relative_install_path.
115 Sub_dir *string `android:"arch_variant"`
116
117 // Optional subdirectory under which this file is installed into, cannot be specified with
118 // sub_dir.
119 Relative_install_path *string `android:"arch_variant"`
120}
121
Jooyung Han39edb6c2019-11-06 16:53:07 +0900122type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700123 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800124
125 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900126 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800127
128 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900129 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800130
131 // Returns an android.OutputPath to the intermeidate file, which is the renamed prebuilt source
132 // file.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700133 OutputFile() android.OutputPath
Jooyung Han39edb6c2019-11-06 16:53:07 +0900134}
135
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900136type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700137 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000138 android.DefaultableModuleBase
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400139 android.BazelModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900140
Kiyoung Kimae11c232021-07-19 11:38:04 +0900141 snapshot.VendorSnapshotModuleInterface
142 snapshot.RecoverySnapshotModuleInterface
143
Inseob Kim27408bf2021-04-06 21:00:17 +0900144 properties prebuiltEtcProperties
145 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900146
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700147 sourceFilePath android.Path
148 outputFilePath android.OutputPath
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800149 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700150 installDirBase string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800151 // The base install location when soc_specific property is set to true, e.g. "firmware" for
152 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700153 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700154 installDirPath android.InstallPath
155 additionalDependencies *android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900156}
157
Inseob Kim1e27a142021-05-06 11:46:11 +0000158type Defaults struct {
159 android.ModuleBase
160 android.DefaultsModuleBase
161}
162
Yifan Hong1b3348d2020-01-21 15:53:22 -0800163func (p *PrebuiltEtc) inRamdisk() bool {
164 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
165}
166
167func (p *PrebuiltEtc) onlyInRamdisk() bool {
168 return p.ModuleBase.InstallInRamdisk()
169}
170
171func (p *PrebuiltEtc) InstallInRamdisk() bool {
172 return p.inRamdisk()
173}
174
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700175func (p *PrebuiltEtc) inVendorRamdisk() bool {
176 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
177}
178
179func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
180 return p.ModuleBase.InstallInVendorRamdisk()
181}
182
183func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
184 return p.inVendorRamdisk()
185}
186
Inseob Kim08758f02021-04-08 21:13:22 +0900187func (p *PrebuiltEtc) inDebugRamdisk() bool {
188 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
189}
190
191func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
192 return p.ModuleBase.InstallInDebugRamdisk()
193}
194
195func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
196 return p.inDebugRamdisk()
197}
198
Kiyoung Kimae11c232021-07-19 11:38:04 +0900199func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800200 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700201}
202
203func (p *PrebuiltEtc) onlyInRecovery() bool {
204 return p.ModuleBase.InstallInRecovery()
205}
206
207func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900208 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700209}
210
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700211var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800212
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700213func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800214
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700215func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700216 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900217 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800218}
219
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700220func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
221 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800222}
223
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700224func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
225 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
226}
227
Inseob Kim08758f02021-04-08 21:13:22 +0900228func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
229 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
230}
231
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700232func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
233 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800234}
235
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700236func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800237 return nil
238}
239
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700240func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800241}
242
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700243func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800244 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900245}
246
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700247func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900248 return p.installDirPath
249}
250
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900251// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
252// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700253func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900254 p.additionalDependencies = &paths
255}
256
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700257func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900258 return p.outputFilePath
259}
260
Jiyong Park76a42f52021-02-16 06:50:37 +0900261var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
262
263func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
264 switch tag {
265 case "":
266 return android.Paths{p.outputFilePath}, nil
267 default:
268 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
269 }
270}
271
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900272func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900273 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700274 return subDir
275 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900276 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900277}
278
Jooyung Han0703fd82020-08-26 22:11:53 +0900279func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900280 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900281}
282
Jiyong Parkad9ce042018-10-31 22:49:57 +0900283func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800284 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900285}
286
Kiyoung Kimae11c232021-07-19 11:38:04 +0900287func (p *PrebuiltEtc) InVendor() bool {
288 return p.ModuleBase.InstallInVendor()
289}
290
291func (p *PrebuiltEtc) ExcludeFromVendorSnapshot() bool {
292 return false
293}
294
295func (p *PrebuiltEtc) ExcludeFromRecoverySnapshot() bool {
296 return false
297}
298
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700299func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800300 filename := proptools.String(p.properties.Filename)
301 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
Colin Cross725eac62022-10-03 15:31:29 -0700302 if p.properties.Src != nil {
303 p.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
304
305 // Determine the output file basename.
306 // If Filename is set, use the name specified by the property.
307 // If Filename_from_src is set, use the source file name.
308 // Otherwise use the module name.
309 if filename != "" {
310 if filenameFromSrc {
311 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
312 return
313 }
314 } else if filenameFromSrc {
315 filename = p.sourceFilePath.Base()
316 } else {
317 filename = ctx.ModuleName()
Jiyong Park1a7cf082018-11-13 11:59:12 +0900318 }
Colin Cross725eac62022-10-03 15:31:29 -0700319 } else if ctx.Config().AllowMissingDependencies() {
320 // If no srcs was set and AllowMissingDependencies is enabled then
321 // mark the module as missing dependencies and set a fake source path
322 // and file name.
323 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
324 p.sourceFilePath = android.PathForModuleSrc(ctx)
325 if filename == "" {
326 filename = ctx.ModuleName()
327 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800328 } else {
Colin Cross725eac62022-10-03 15:31:29 -0700329 ctx.PropertyErrorf("src", "missing prebuilt source file")
330 return
Jiyong Park139a2e62018-10-26 21:49:39 +0900331 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700332 p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Patrice Arruda057a8b12019-06-03 15:29:27 -0700333
Inseob Kim27408bf2021-04-06 21:00:17 +0900334 if strings.Contains(filename, "/") {
335 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
336 return
337 }
338
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800339 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
Inseob Kim27408bf2021-04-06 21:00:17 +0900340 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
Liz Kammer0449a632020-06-26 10:12:36 -0700341 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
342 }
343
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800344 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
345 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900346 installBaseDir := p.installDirBase
347 if p.SocSpecific() && p.socInstallDirBase != "" {
348 installBaseDir = p.socInstallDirBase
349 }
350 p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir())
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900351
Dan Willemsenb0552672019-01-25 16:04:11 -0800352 // This ensures that outputFilePath has the correct name for others to
353 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700354 ctx.Build(pctx, android.BuildParams{
355 Rule: android.Cp,
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900356 Output: p.outputFilePath,
357 Input: p.sourceFilePath,
358 })
Jiyong Parkf9f68052020-09-29 20:15:08 +0900359
Inseob Kim916901e2021-02-17 15:48:53 +0900360 if !p.Installable() {
361 p.SkipInstall()
362 }
363
364 // Call InstallFile even when uninstallable to make the module included in the package
365 installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath)
366 for _, sl := range p.properties.Symlinks {
367 ctx.InstallSymlink(p.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900368 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900369}
370
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700371func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700372 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800373 if p.inRamdisk() && !p.onlyInRamdisk() {
374 nameSuffix = ".ramdisk"
375 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700376 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
377 nameSuffix = ".vendor_ramdisk"
378 }
Inseob Kim08758f02021-04-08 21:13:22 +0900379 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
380 nameSuffix = ".debug_ramdisk"
381 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900382 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700383 nameSuffix = ".recovery"
384 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700385 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700386 Class: "ETC",
387 SubName: nameSuffix,
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700388 OutputFile: android.OptionalPathForPath(p.outputFilePath),
389 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700390 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700391 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossc68db4b2021-11-11 18:59:15 -0800392 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.String())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700393 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800394 if len(p.properties.Symlinks) > 0 {
395 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
396 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800397 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700398 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800399 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900400 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700401 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900402 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900403 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900404}
405
Jooyung Hana0171822019-07-22 15:48:36 +0900406func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
407 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900408 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900409 p.AddProperties(&p.subdirProperties)
410}
411
412func InitPrebuiltRootModule(p *PrebuiltEtc) {
413 p.installDirBase = "."
414 p.AddProperties(&p.properties)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900415}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900416
Patrice Arruda9e14b962019-03-11 15:58:50 -0700417// prebuilt_etc is for a prebuilt artifact that is installed in
418// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700419func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900420 module := &PrebuiltEtc{}
421 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900422 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700423 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000424 android.InitDefaultableModule(module)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400425 android.InitBazelModule(module)
Inseob Kim1e27a142021-05-06 11:46:11 +0000426 return module
427}
428
429func defaultsFactory() android.Module {
430 return DefaultsFactory()
431}
432
433func DefaultsFactory(props ...interface{}) android.Module {
434 module := &Defaults{}
435
436 module.AddProperties(props...)
437 module.AddProperties(
438 &prebuiltEtcProperties{},
439 &prebuiltSubdirProperties{},
440 )
441
442 android.InitDefaultsModule(module)
443
Jiyong Parkc678ad32018-04-10 13:07:10 +0900444 return module
445}
Tao Bao0ba5c942018-08-14 22:20:22 -0700446
Patrice Arruda9e14b962019-03-11 15:58:50 -0700447// prebuilt_etc_host is for a host prebuilt artifact that is installed in
448// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700449func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900450 module := &PrebuiltEtc{}
451 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800452 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700453 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100454 android.InitDefaultableModule(module)
Liz Kammera9234422021-12-22 15:32:18 -0500455 android.InitBazelModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800456 return module
457}
458
Miguel32b02802022-12-01 18:38:26 +0000459// prebuilt_etc_host is for a host prebuilt artifact that is installed in
460// <partition>/etc/<sub_dir> directory.
461func PrebuiltEtcCaCertsFactory() android.Module {
462 module := &PrebuiltEtc{}
463 InitPrebuiltEtcModule(module, "cacerts")
464 // This module is device-only
465 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
466 android.InitBazelModule(module)
467 return module
468}
469
Inseob Kim27408bf2021-04-06 21:00:17 +0900470// prebuilt_root is for a prebuilt artifact that is installed in
471// <partition>/ directory. Can't have any sub directories.
472func PrebuiltRootFactory() android.Module {
473 module := &PrebuiltEtc{}
474 InitPrebuiltRootModule(module)
475 // This module is device-only
476 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100477 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900478 return module
479}
480
Liz Kammere9ecddc2022-01-04 17:27:52 -0500481// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
482// directory.
483func PrebuiltRootHostFactory() android.Module {
484 module := &PrebuiltEtc{}
485 InitPrebuiltEtcModule(module, ".")
486 // This module is host-only
487 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
488 android.InitDefaultableModule(module)
489 return module
490}
491
Patrice Arruda9e14b962019-03-11 15:58:50 -0700492// prebuilt_usr_share is for a prebuilt artifact that is installed in
493// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700494func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900495 module := &PrebuiltEtc{}
496 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800497 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700498 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100499 android.InitDefaultableModule(module)
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500500 android.InitBazelModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800501 return module
502}
503
Patrice Arruda9e14b962019-03-11 15:58:50 -0700504// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
505// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700506func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900507 module := &PrebuiltEtc{}
508 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800509 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700510 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100511 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800512 return module
513}
514
Patrice Arruda61583eb2019-05-14 08:20:45 -0700515// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700516func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900517 module := &PrebuiltEtc{}
518 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700519 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700520 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100521 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700522 return module
523}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700524
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800525// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
526// image.
527// If soc_specific property is set to true, the firmware file is installed to the
528// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700529func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900530 module := &PrebuiltEtc{}
531 module.socInstallDirBase = "firmware"
532 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700533 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700534 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100535 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700536 return module
537}
Patrice Arruda0f688002020-06-08 21:40:25 +0000538
539// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800540// If soc_specific property is set to true, the DSP related file is installed to the
541// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000542func PrebuiltDSPFactory() android.Module {
543 module := &PrebuiltEtc{}
544 module.socInstallDirBase = "dsp"
545 InitPrebuiltEtcModule(module, "etc/dsp")
546 // This module is device-only
547 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100548 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000549 return module
550}
Colin Cross83ebf232021-04-09 09:41:23 -0700551
552// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
553// to the <partition>/lib/rfsa directory.
554func PrebuiltRFSAFactory() android.Module {
555 module := &PrebuiltEtc{}
556 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
557 // many places outside of the application processor. They could be moved to /vendor/dsp once
558 // that is cleaned up.
559 InitPrebuiltEtcModule(module, "lib/rfsa")
560 // This module is device-only
561 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100562 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700563 return module
564}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900565
Kiyoung Kimae11c232021-07-19 11:38:04 +0900566// Copy file into the snapshot
567func copyFile(ctx android.SingletonContext, path android.Path, out string, fake bool) android.OutputPath {
568 if fake {
569 // Create empty file instead for the fake snapshot
570 return snapshot.WriteStringToFileRule(ctx, "", out)
571 } else {
572 return snapshot.CopyFileRule(pctx, ctx, path, out)
573 }
574}
575
576// Check if the module is target of the snapshot
577func isSnapshotAware(ctx android.SingletonContext, m *PrebuiltEtc, image snapshot.SnapshotImage) bool {
578 if !m.Enabled() {
579 return false
580 }
581
582 // Skip if the module is not included in the image
583 if !image.InImage(m)() {
584 return false
585 }
586
587 // When android/prebuilt.go selects between source and prebuilt, it sets
588 // HideFromMake on the other one to avoid duplicate install rules in make.
589 if m.IsHideFromMake() {
590 return false
591 }
592
593 // There are some prebuilt_etc module with multiple definition of same name.
594 // Check if the target would be included from the build
595 if !m.ExportedToMake() {
596 return false
597 }
598
599 // Skip if the module is in the predefined path list to skip
600 if image.IsProprietaryPath(ctx.ModuleDir(m), ctx.DeviceConfig()) {
601 return false
602 }
603
604 // Skip if the module should be excluded
605 if image.ExcludeFromSnapshot(m) || image.ExcludeFromDirectedSnapshot(ctx.DeviceConfig(), m.BaseModuleName()) {
606 return false
607 }
608
609 // Skip from other exceptional cases
610 if m.Target().Os.Class != android.Device {
611 return false
612 }
613 if m.Target().NativeBridge == android.NativeBridgeEnabled {
614 return false
615 }
616
617 return true
618}
619
620func generatePrebuiltSnapshot(s snapshot.SnapshotSingleton, ctx android.SingletonContext, snapshotArchDir string) android.Paths {
621 /*
622 Snapshot zipped artifacts directory structure for etc modules:
623 {SNAPSHOT_ARCH}/
624 arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
625 etc/
626 (prebuilt etc files)
627 arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
628 etc/
629 (prebuilt etc files)
630 NOTICE_FILES/
631 (notice files)
632 */
633 var snapshotOutputs android.Paths
634 noticeDir := filepath.Join(snapshotArchDir, "NOTICE_FILES")
635 installedNotices := make(map[string]bool)
636
637 ctx.VisitAllModules(func(module android.Module) {
638 m, ok := module.(*PrebuiltEtc)
639 if !ok {
640 return
641 }
642
643 if !isSnapshotAware(ctx, m, s.Image) {
644 return
645 }
646
647 targetArch := "arch-" + m.Target().Arch.ArchType.String()
648
649 snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "etc", m.BaseModuleName())
650 snapshotOutputs = append(snapshotOutputs, copyFile(ctx, m.OutputFile(), snapshotLibOut, s.Fake))
651
Rob Seymour925aa092021-08-10 20:42:03 +0000652 prop := snapshot.SnapshotJsonFlags{}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900653 propOut := snapshotLibOut + ".json"
654 prop.ModuleName = m.BaseModuleName()
655 if m.subdirProperties.Relative_install_path != nil {
656 prop.RelativeInstallPath = *m.subdirProperties.Relative_install_path
657 }
658
659 if m.properties.Filename != nil {
660 prop.Filename = *m.properties.Filename
661 }
662
663 j, err := json.Marshal(prop)
664 if err != nil {
665 ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
666 return
667 }
668 snapshotOutputs = append(snapshotOutputs, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
669
670 if len(m.EffectiveLicenseFiles()) > 0 {
671 noticeName := ctx.ModuleName(m) + ".txt"
672 noticeOut := filepath.Join(noticeDir, noticeName)
673 // skip already copied notice file
674 if !installedNotices[noticeOut] {
675 installedNotices[noticeOut] = true
676
677 noticeOutPath := android.PathForOutput(ctx, noticeOut)
678 ctx.Build(pctx, android.BuildParams{
679 Rule: android.Cat,
680 Inputs: m.EffectiveLicenseFiles(),
681 Output: noticeOutPath,
682 Description: "combine notices for " + noticeOut,
683 })
684 snapshotOutputs = append(snapshotOutputs, noticeOutPath)
685 }
686 }
687
688 })
689
690 return snapshotOutputs
691}
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400692
693// For Bazel / bp2build
694
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500695type bazelPrebuiltFileAttributes struct {
Alix993872a2022-06-15 17:42:14 +0000696 Src bazel.LabelAttribute
697 Filename bazel.LabelAttribute
698 Dir string
699 Installable bazel.BoolAttribute
700 Filename_from_src bazel.BoolAttribute
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400701}
702
Alix5918d642022-06-27 20:57:44 +0000703// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
704// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
705// used by both prebuilt_etc_xml and other prebuilt_* moodules
706func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *bazelPrebuiltFileAttributes {
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500707 var src bazel.LabelAttribute
Liz Kammerdff00ea2021-10-04 13:44:34 -0400708 for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
709 for config, p := range configToProps {
710 props, ok := p.(*prebuiltEtcProperties)
711 if !ok {
712 continue
713 }
714 if props.Src != nil {
Chris Parsons58852a02021-12-09 18:10:18 -0500715 label := android.BazelLabelForModuleSrcSingle(ctx, *props.Src)
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500716 src.SetSelectValue(axis, config, label)
Liz Kammerdff00ea2021-10-04 13:44:34 -0400717 }
718 }
Alixbbfd5382022-06-09 18:52:05 +0000719
Cole Faust912bc882023-03-08 12:29:50 -0800720 for propName, productConfigProps := range android.ProductVariableProperties(ctx, ctx.Module()) {
Alixbbfd5382022-06-09 18:52:05 +0000721 for configProp, propVal := range productConfigProps {
722 if propName == "Src" {
723 props, ok := propVal.(*string)
724 if !ok {
725 ctx.PropertyErrorf(" Expected Property to have type string, but was %s\n", reflect.TypeOf(propVal).String())
726 continue
727 }
728 if props != nil {
729 label := android.BazelLabelForModuleSrcSingle(ctx, *props)
730 src.SetSelectValue(configProp.ConfigurationAxis(), configProp.SelectKey(), label)
731 }
732 }
733 }
734 }
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400735 }
736
737 var filename string
Alix993872a2022-06-15 17:42:14 +0000738 var filenameFromSrc bool
739 moduleProps := module.properties
740
741 if moduleProps.Filename != nil && *moduleProps.Filename != "" {
742 filename = *moduleProps.Filename
743 } else if moduleProps.Filename_from_src != nil && *moduleProps.Filename_from_src {
744 if moduleProps.Src != nil {
745 filename = *moduleProps.Src
746 }
747 filenameFromSrc = true
748 } else {
749 filename = ctx.ModuleName()
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400750 }
751
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500752 var dir = module.installDirBase
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500753 if subDir := module.subdirProperties.Sub_dir; subDir != nil {
754 dir = dir + "/" + *subDir
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400755 }
756
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500757 var installable bazel.BoolAttribute
758 if install := module.properties.Installable; install != nil {
759 installable.Value = install
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400760 }
761
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500762 attrs := &bazelPrebuiltFileAttributes{
763 Src: src,
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc78604e2022-02-28 18:22:59 -0500764 Dir: dir,
765 Installable: installable,
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400766 }
767
Alix993872a2022-06-15 17:42:14 +0000768 if filename != "" {
769 attrs.Filename = bazel.LabelAttribute{Value: &bazel.Label{Label: filename}}
770 } else if filenameFromSrc {
771 attrs.Filename_from_src = bazel.BoolAttribute{Value: moduleProps.Filename_from_src}
772 }
773
Alix5918d642022-06-27 20:57:44 +0000774 return attrs
775
776}
777
778// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
779// prebuilt_* modules (except prebuilt_etc_xml) are PrebuiltEtc,
780// which we treat as *PrebuiltFile*
781func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
782 var dir = module.installDirBase
783 // prebuilt_file supports only `etc` or `usr/share`
784 if !(dir == "etc" || dir == "usr/share") {
785 return
786 }
787
788 attrs := module.Bp2buildHelper(ctx)
789
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400790 props := bazel.BazelTargetModuleProperties{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxb81f77e2022-02-28 17:38:34 -0500791 Rule_class: "prebuilt_file",
792 Bzl_load_location: "//build/bazel/rules:prebuilt_file.bzl",
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400793 }
794
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +0000795 ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -0400796}