blob: a42c576d5d826a5c6c963524ac99ea03b996ce79 [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"
Inseob Kim27408bf2021-04-06 21:00:17 +090034 "strings"
Jiyong Park76a42f52021-02-16 06:50:37 +090035
Jaewoong Jung4b79e982020-06-01 10:45:49 -070036 "github.com/google/blueprint/proptools"
37
38 "android/soong/android"
Kiyoung Kimae11c232021-07-19 11:38:04 +090039 "android/soong/snapshot"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070040)
41
42var pctx = android.NewPackageContext("android/soong/etc")
Jiyong Parkc678ad32018-04-10 13:07:10 +090043
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -080044// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
Jiyong Parkc678ad32018-04-10 13:07:10 +090045
46func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070047 pctx.Import("android/soong/android")
Jooyung Han0703fd82020-08-26 22:11:53 +090048 RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext)
Kiyoung Kimae11c232021-07-19 11:38:04 +090049 snapshot.RegisterSnapshotAction(generatePrebuiltSnapshot)
Jooyung Han0703fd82020-08-26 22:11:53 +090050}
Jaewoong Jung4b79e982020-06-01 10:45:49 -070051
Jooyung Han0703fd82020-08-26 22:11:53 +090052func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
53 ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
54 ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
Miguel32b02802022-12-01 18:38:26 +000055 ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
Inseob Kim27408bf2021-04-06 21:00:17 +090056 ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
Liz Kammere9ecddc2022-01-04 17:27:52 -050057 ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
Jooyung Han0703fd82020-08-26 22:11:53 +090058 ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
59 ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
60 ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
61 ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
62 ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
Colin Cross83ebf232021-04-09 09:41:23 -070063 ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
Colin Crossf17e2b52023-10-30 15:17:25 -070064 ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory)
Inseob Kim1e27a142021-05-06 11:46:11 +000065
66 ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
Rupert Shuttleworth378fc1b2021-07-28 08:03:16 -040067
Jiyong Parkc678ad32018-04-10 13:07:10 +090068}
69
Paul Duffin1172fed2021-03-08 11:28:18 +000070var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
71
Jiyong Parkc678ad32018-04-10 13:07:10 +090072type prebuiltEtcProperties struct {
Yo Chiang803c40d2020-11-16 20:32:51 +080073 // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110074 // Mutually exclusive with srcs.
Colin Cross27b922f2019-03-04 22:35:41 -080075 Src *string `android:"path,arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +090076
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110077 // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
78 // Mutually exclusive with src. When used, filename_from_src is set to true.
79 Srcs []string `android:"path,arch_variant"`
80
Yo Chiangf0e19fe2020-11-18 15:28:42 +080081 // Optional name for the installed file. If unspecified, name of the module is used as the file
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +110082 // name. Only available when using a single source (src).
Jiyong Park139a2e62018-10-26 21:49:39 +090083 Filename *string `android:"arch_variant"`
84
Yo Chiangf0e19fe2020-11-18 15:28:42 +080085 // When set to true, and filename property is not set, the name for the installed file
Jiyong Park1a7cf082018-11-13 11:59:12 +090086 // is the same as the file name of the source file.
87 Filename_from_src *bool `android:"arch_variant"`
88
Yifan Hong1b3348d2020-01-21 15:53:22 -080089 // Make this module available when building for ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070090 // On device without a dedicated recovery partition, the module is only
91 // available after switching root into
92 // /first_stage_ramdisk. To expose the module before switching root, install
93 // the recovery variant instead.
Yifan Hong1b3348d2020-01-21 15:53:22 -080094 Ramdisk_available *bool
95
Yifan Hong60e0cfb2020-10-21 15:17:56 -070096 // Make this module available when building for vendor ramdisk.
Yifan Hong39143a92020-10-26 12:43:12 -070097 // On device without a dedicated recovery partition, the module is only
98 // available after switching root into
99 // /first_stage_ramdisk. To expose the module before switching root, install
100 // the recovery variant instead.
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700101 Vendor_ramdisk_available *bool
102
Inseob Kim08758f02021-04-08 21:13:22 +0900103 // Make this module available when building for debug ramdisk.
104 Debug_ramdisk_available *bool
105
Tao Bao0ba5c942018-08-14 22:20:22 -0700106 // Make this module available when building for recovery.
107 Recovery_available *bool
108
Jiyong Parkad9ce042018-10-31 22:49:57 +0900109 // Whether this module is directly installable to one of the partitions. Default: true.
110 Installable *bool
Yo Chiang3d64d492020-05-27 17:56:39 +0800111
112 // Install symlinks to the installed file.
113 Symlinks []string `android:"arch_variant"`
Jiyong Parkc678ad32018-04-10 13:07:10 +0900114}
115
Inseob Kim27408bf2021-04-06 21:00:17 +0900116type prebuiltSubdirProperties struct {
117 // Optional subdirectory under which this file is installed into, cannot be specified with
118 // relative_install_path, prefer relative_install_path.
119 Sub_dir *string `android:"arch_variant"`
120
121 // Optional subdirectory under which this file is installed into, cannot be specified with
122 // sub_dir.
123 Relative_install_path *string `android:"arch_variant"`
124}
125
Jooyung Han39edb6c2019-11-06 16:53:07 +0900126type PrebuiltEtcModule interface {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700127 android.Module
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800128
129 // Returns the base install directory, such as "etc", "usr/share".
Jooyung Han0703fd82020-08-26 22:11:53 +0900130 BaseDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800131
132 // Returns the sub install directory relative to BaseDir().
Jooyung Han39edb6c2019-11-06 16:53:07 +0900133 SubDir() string
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800134
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100135 // Returns an android.OutputPath to the intermediate file, which is the renamed prebuilt source
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800136 // file.
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100137 OutputFiles(tag string) (android.Paths, error)
Jooyung Han39edb6c2019-11-06 16:53:07 +0900138}
139
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900140type PrebuiltEtc struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700141 android.ModuleBase
Inseob Kim1e27a142021-05-06 11:46:11 +0000142 android.DefaultableModuleBase
Jiyong Parkc678ad32018-04-10 13:07:10 +0900143
Kiyoung Kimae11c232021-07-19 11:38:04 +0900144 snapshot.VendorSnapshotModuleInterface
145 snapshot.RecoverySnapshotModuleInterface
146
Inseob Kim27408bf2021-04-06 21:00:17 +0900147 properties prebuiltEtcProperties
148 subdirProperties prebuiltSubdirProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900149
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100150 sourceFilePaths android.Paths
151 outputFilePaths android.OutputPaths
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800152 // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
Colin Cross2f634572023-11-13 12:12:06 -0800153 installDirBase string
154 installDirBase64 string
155 installAvoidMultilibConflict bool
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800156 // The base install location when soc_specific property is set to true, e.g. "firmware" for
157 // prebuilt_firmware.
Patrice Arruda057a8b12019-06-03 15:29:27 -0700158 socInstallDirBase string
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700159 installDirPath android.InstallPath
160 additionalDependencies *android.Paths
Colin Crossf17e2b52023-10-30 15:17:25 -0700161
162 makeClass string
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000163
164 // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
165 mergedAconfigFiles map[string]android.Paths
Jiyong Parkc678ad32018-04-10 13:07:10 +0900166}
167
Inseob Kim1e27a142021-05-06 11:46:11 +0000168type Defaults struct {
169 android.ModuleBase
170 android.DefaultsModuleBase
171}
172
Yifan Hong1b3348d2020-01-21 15:53:22 -0800173func (p *PrebuiltEtc) inRamdisk() bool {
174 return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
175}
176
177func (p *PrebuiltEtc) onlyInRamdisk() bool {
178 return p.ModuleBase.InstallInRamdisk()
179}
180
181func (p *PrebuiltEtc) InstallInRamdisk() bool {
182 return p.inRamdisk()
183}
184
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700185func (p *PrebuiltEtc) inVendorRamdisk() bool {
186 return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk()
187}
188
189func (p *PrebuiltEtc) onlyInVendorRamdisk() bool {
190 return p.ModuleBase.InstallInVendorRamdisk()
191}
192
193func (p *PrebuiltEtc) InstallInVendorRamdisk() bool {
194 return p.inVendorRamdisk()
195}
196
Inseob Kim08758f02021-04-08 21:13:22 +0900197func (p *PrebuiltEtc) inDebugRamdisk() bool {
198 return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk()
199}
200
201func (p *PrebuiltEtc) onlyInDebugRamdisk() bool {
202 return p.ModuleBase.InstallInDebugRamdisk()
203}
204
205func (p *PrebuiltEtc) InstallInDebugRamdisk() bool {
206 return p.inDebugRamdisk()
207}
208
Kiyoung Kimae11c232021-07-19 11:38:04 +0900209func (p *PrebuiltEtc) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800210 return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700211}
212
213func (p *PrebuiltEtc) onlyInRecovery() bool {
214 return p.ModuleBase.InstallInRecovery()
215}
216
217func (p *PrebuiltEtc) InstallInRecovery() bool {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900218 return p.InRecovery()
Tao Bao0ba5c942018-08-14 22:20:22 -0700219}
220
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700221var _ android.ImageInterface = (*PrebuiltEtc)(nil)
Colin Cross7228ecd2019-11-18 16:00:16 -0800222
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700223func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
Colin Cross7228ecd2019-11-18 16:00:16 -0800224
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700225func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700226 return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() &&
Inseob Kim08758f02021-04-08 21:13:22 +0900227 !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk()
Yifan Hong1b3348d2020-01-21 15:53:22 -0800228}
229
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700230func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
231 return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
Colin Cross7228ecd2019-11-18 16:00:16 -0800232}
233
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700234func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
235 return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk()
236}
237
Inseob Kim08758f02021-04-08 21:13:22 +0900238func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
239 return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
240}
241
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700242func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
243 return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
Colin Cross7228ecd2019-11-18 16:00:16 -0800244}
245
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700246func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Colin Cross7228ecd2019-11-18 16:00:16 -0800247 return nil
248}
249
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700250func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
Colin Cross7228ecd2019-11-18 16:00:16 -0800251}
252
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700253func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100254 if len(p.properties.Srcs) > 0 {
255 panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name()))
256 }
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800257 return android.PathForModuleSrc(ctx, proptools.String(p.properties.Src))
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900258}
259
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700260func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
Jooyung Hana0171822019-07-22 15:48:36 +0900261 return p.installDirPath
262}
263
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900264// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
265// additional steps (like validating the src) before the file is installed.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700266func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900267 p.additionalDependencies = &paths
268}
269
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700270func (p *PrebuiltEtc) OutputFile() android.OutputPath {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100271 if len(p.properties.Srcs) > 0 {
272 panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name()))
273 }
274 return p.outputFilePaths[0]
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900275}
276
Jiyong Park76a42f52021-02-16 06:50:37 +0900277var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
278
279func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
280 switch tag {
281 case "":
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100282 return p.outputFilePaths.Paths(), nil
Jiyong Park76a42f52021-02-16 06:50:37 +0900283 default:
284 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
285 }
286}
287
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900288func (p *PrebuiltEtc) SubDir() string {
Inseob Kim27408bf2021-04-06 21:00:17 +0900289 if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
Liz Kammer0449a632020-06-26 10:12:36 -0700290 return subDir
291 }
Inseob Kim27408bf2021-04-06 21:00:17 +0900292 return proptools.String(p.subdirProperties.Relative_install_path)
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900293}
294
Jooyung Han0703fd82020-08-26 22:11:53 +0900295func (p *PrebuiltEtc) BaseDir() string {
Jooyung Han8e5685d2020-09-21 11:02:57 +0900296 return p.installDirBase
Jooyung Han0703fd82020-08-26 22:11:53 +0900297}
298
Jiyong Parkad9ce042018-10-31 22:49:57 +0900299func (p *PrebuiltEtc) Installable() bool {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800300 return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
Jiyong Parkad9ce042018-10-31 22:49:57 +0900301}
302
Kiyoung Kimae11c232021-07-19 11:38:04 +0900303func (p *PrebuiltEtc) InVendor() bool {
304 return p.ModuleBase.InstallInVendor()
305}
306
307func (p *PrebuiltEtc) ExcludeFromVendorSnapshot() bool {
308 return false
309}
310
311func (p *PrebuiltEtc) ExcludeFromRecoverySnapshot() bool {
312 return false
313}
314
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100315func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string {
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800316 // If soc install dir was specified and SOC specific is set, set the installDirPath to the
317 // specified socInstallDirBase.
Jooyung Han8e5685d2020-09-21 11:02:57 +0900318 installBaseDir := p.installDirBase
Colin Crossf17e2b52023-10-30 15:17:25 -0700319 if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" {
320 installBaseDir = p.installDirBase64
321 }
Jooyung Han8e5685d2020-09-21 11:02:57 +0900322 if p.SocSpecific() && p.socInstallDirBase != "" {
323 installBaseDir = p.socInstallDirBase
324 }
Colin Cross2f634572023-11-13 12:12:06 -0800325 if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
326 installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String())
327 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100328 return installBaseDir
329}
Colin Cross2f634572023-11-13 12:12:06 -0800330
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100331func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
332 var installs []installProperties
Jiyong Parkc43e0ac2018-10-04 20:27:15 +0900333
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100334 if p.properties.Src != nil && len(p.properties.Srcs) > 0 {
335 ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
Spandan Das756d3402023-06-05 22:49:50 +0000336 }
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100337
338 // Check that `sub_dir` and `relative_install_path` are not set at the same time.
339 if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
340 ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
341 }
342 p.installDirPath = android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
343
344 filename := proptools.String(p.properties.Filename)
345 filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
346 if p.properties.Src != nil {
347 p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{proptools.String(p.properties.Src)})
348 // If the source was not found, set a fake source path to
349 // support AllowMissingDependencies executions.
350 if len(p.sourceFilePaths) == 0 {
351 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
352 }
353
354 // Determine the output file basename.
355 // If Filename is set, use the name specified by the property.
356 // If Filename_from_src is set, use the source file name.
357 // Otherwise use the module name.
358 if filename != "" {
359 if filenameFromSrc {
360 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
361 return
362 }
363 } else if filenameFromSrc {
364 filename = p.sourceFilePaths[0].Base()
365 } else {
366 filename = ctx.ModuleName()
367 }
368 if strings.Contains(filename, "/") {
369 ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
370 return
371 }
372 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
373
374 ip := installProperties{
375 filename: filename,
376 sourceFilePath: p.sourceFilePaths[0],
377 outputFilePath: p.outputFilePaths[0],
378 installDirPath: p.installDirPath,
379 symlinks: p.properties.Symlinks,
380 }
381 installs = append(installs, ip)
382 } else if len(p.properties.Srcs) > 0 {
383 if filename != "" {
384 ctx.PropertyErrorf("filename", "filename cannot be set when using srcs")
385 }
386 if len(p.properties.Symlinks) > 0 {
387 ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
388 }
389 if p.properties.Filename_from_src != nil {
390 ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
391 }
392 p.sourceFilePaths = android.PathsForModuleSrc(ctx, p.properties.Srcs)
393 for _, src := range p.sourceFilePaths {
394 filename := src.Base()
395 output := android.PathForModuleOut(ctx, filename).OutputPath
396 ip := installProperties{
397 filename: filename,
398 sourceFilePath: src,
399 outputFilePath: output,
400 installDirPath: p.installDirPath,
401 }
402 p.outputFilePaths = append(p.outputFilePaths, output)
403 installs = append(installs, ip)
404 }
405 } else if ctx.Config().AllowMissingDependencies() {
406 // If no srcs was set and AllowMissingDependencies is enabled then
407 // mark the module as missing dependencies and set a fake source path
408 // and file name.
409 ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"})
410 p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)}
411 if filename == "" {
412 filename = ctx.ModuleName()
413 }
414 p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath}
415 ip := installProperties{
416 filename: filename,
417 sourceFilePath: p.sourceFilePaths[0],
418 outputFilePath: p.outputFilePaths[0],
419 installDirPath: p.installDirPath,
420 }
421 installs = append(installs, ip)
422 } else {
423 ctx.PropertyErrorf("src", "missing prebuilt source file")
424 return
425 }
426
427 // Call InstallFile even when uninstallable to make the module included in the package.
428 if !p.Installable() {
429 p.SkipInstall()
430 }
431 for _, ip := range installs {
432 ip.addInstallRules(ctx)
433 }
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000434 android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
Spandan Das756d3402023-06-05 22:49:50 +0000435}
Jiyong Parkf9f68052020-09-29 20:15:08 +0900436
Spandan Das756d3402023-06-05 22:49:50 +0000437type installProperties struct {
Spandan Das756d3402023-06-05 22:49:50 +0000438 filename string
439 sourceFilePath android.Path
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100440 outputFilePath android.OutputPath
441 installDirPath android.InstallPath
Spandan Das756d3402023-06-05 22:49:50 +0000442 symlinks []string
443}
444
445// utility function to add install rules to the build graph.
446// Reduces code duplication between Soong and Mixed build analysis
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100447func (ip *installProperties) addInstallRules(ctx android.ModuleContext) {
Spandan Das756d3402023-06-05 22:49:50 +0000448 // Copy the file from src to a location in out/ with the correct `filename`
449 // This ensures that outputFilePath has the correct name for others to
450 // use, as the source file may have a different name.
Spandan Das756d3402023-06-05 22:49:50 +0000451 ctx.Build(pctx, android.BuildParams{
452 Rule: android.Cp,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100453 Output: ip.outputFilePath,
Spandan Das756d3402023-06-05 22:49:50 +0000454 Input: ip.sourceFilePath,
455 })
456
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100457 installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath)
Spandan Das756d3402023-06-05 22:49:50 +0000458 for _, sl := range ip.symlinks {
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100459 ctx.InstallSymlink(ip.installDirPath, sl, installPath)
Jiyong Parkf9f68052020-09-29 20:15:08 +0900460 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900461}
462
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700463func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700464 nameSuffix := ""
Yifan Hong1b3348d2020-01-21 15:53:22 -0800465 if p.inRamdisk() && !p.onlyInRamdisk() {
466 nameSuffix = ".ramdisk"
467 }
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700468 if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() {
469 nameSuffix = ".vendor_ramdisk"
470 }
Inseob Kim08758f02021-04-08 21:13:22 +0900471 if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() {
472 nameSuffix = ".debug_ramdisk"
473 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900474 if p.InRecovery() && !p.onlyInRecovery() {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700475 nameSuffix = ".recovery"
476 }
Colin Crossf17e2b52023-10-30 15:17:25 -0700477
478 class := p.makeClass
479 if class == "" {
480 class = "ETC"
481 }
482
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100483 return []android.AndroidMkEntries{{
Colin Crossf17e2b52023-10-30 15:17:25 -0700484 Class: class,
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700485 SubName: nameSuffix,
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100486 OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]),
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700487 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700488 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700489 entries.SetString("LOCAL_MODULE_TAGS", "optional")
Colin Crossc68db4b2021-11-11 18:59:15 -0800490 entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.String())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100491 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
Yo Chiang3d64d492020-05-27 17:56:39 +0800492 if len(p.properties.Symlinks) > 0 {
493 entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
494 }
Yo Chiang803c40d2020-11-16 20:32:51 +0800495 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700496 if p.additionalDependencies != nil {
Yo Chiang803c40d2020-11-16 20:32:51 +0800497 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900498 }
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000499 android.SetAconfigFileMkEntries(p.AndroidModuleBase(), entries, p.mergedAconfigFiles)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700500 },
Jiyong Parkc678ad32018-04-10 13:07:10 +0900501 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900502 }}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900503}
504
LaMont Jonesafe7baf2024-01-09 22:47:39 +0000505func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
506 return &p.ModuleBase
507}
508
Jooyung Hana0171822019-07-22 15:48:36 +0900509func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
510 p.installDirBase = dirBase
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900511 p.AddProperties(&p.properties)
Inseob Kim27408bf2021-04-06 21:00:17 +0900512 p.AddProperties(&p.subdirProperties)
513}
514
515func InitPrebuiltRootModule(p *PrebuiltEtc) {
516 p.installDirBase = "."
517 p.AddProperties(&p.properties)
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900518}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900519
Patrice Arruda9e14b962019-03-11 15:58:50 -0700520// prebuilt_etc is for a prebuilt artifact that is installed in
521// <partition>/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700522func PrebuiltEtcFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900523 module := &PrebuiltEtc{}
524 InitPrebuiltEtcModule(module, "etc")
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900525 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700526 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Inseob Kim1e27a142021-05-06 11:46:11 +0000527 android.InitDefaultableModule(module)
528 return module
529}
530
531func defaultsFactory() android.Module {
532 return DefaultsFactory()
533}
534
535func DefaultsFactory(props ...interface{}) android.Module {
536 module := &Defaults{}
537
538 module.AddProperties(props...)
539 module.AddProperties(
540 &prebuiltEtcProperties{},
541 &prebuiltSubdirProperties{},
542 )
543
544 android.InitDefaultsModule(module)
545
Jiyong Parkc678ad32018-04-10 13:07:10 +0900546 return module
547}
Tao Bao0ba5c942018-08-14 22:20:22 -0700548
Patrice Arruda9e14b962019-03-11 15:58:50 -0700549// prebuilt_etc_host is for a host prebuilt artifact that is installed in
550// $(HOST_OUT)/etc/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700551func PrebuiltEtcHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900552 module := &PrebuiltEtc{}
553 InitPrebuiltEtcModule(module, "etc")
Jaewoong Jung24788182019-02-04 14:34:10 -0800554 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700555 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100556 android.InitDefaultableModule(module)
Jaewoong Jung24788182019-02-04 14:34:10 -0800557 return module
558}
559
Miguel32b02802022-12-01 18:38:26 +0000560// prebuilt_etc_host is for a host prebuilt artifact that is installed in
561// <partition>/etc/<sub_dir> directory.
562func PrebuiltEtcCaCertsFactory() android.Module {
563 module := &PrebuiltEtc{}
564 InitPrebuiltEtcModule(module, "cacerts")
565 // This module is device-only
566 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Miguel32b02802022-12-01 18:38:26 +0000567 return module
568}
569
Inseob Kim27408bf2021-04-06 21:00:17 +0900570// prebuilt_root is for a prebuilt artifact that is installed in
571// <partition>/ directory. Can't have any sub directories.
572func PrebuiltRootFactory() android.Module {
573 module := &PrebuiltEtc{}
574 InitPrebuiltRootModule(module)
575 // This module is device-only
576 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100577 android.InitDefaultableModule(module)
Inseob Kim27408bf2021-04-06 21:00:17 +0900578 return module
579}
580
Liz Kammere9ecddc2022-01-04 17:27:52 -0500581// prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir>
582// directory.
583func PrebuiltRootHostFactory() android.Module {
584 module := &PrebuiltEtc{}
585 InitPrebuiltEtcModule(module, ".")
586 // This module is host-only
587 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
588 android.InitDefaultableModule(module)
589 return module
590}
591
Patrice Arruda9e14b962019-03-11 15:58:50 -0700592// prebuilt_usr_share is for a prebuilt artifact that is installed in
593// <partition>/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700594func PrebuiltUserShareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900595 module := &PrebuiltEtc{}
596 InitPrebuiltEtcModule(module, "usr/share")
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800597 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700598 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100599 android.InitDefaultableModule(module)
Jaewoong Jungc3fcdb42019-02-13 05:50:33 -0800600 return module
601}
602
Patrice Arruda9e14b962019-03-11 15:58:50 -0700603// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
604// $(HOST_OUT)/usr/share/<sub_dir> directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700605func PrebuiltUserShareHostFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900606 module := &PrebuiltEtc{}
607 InitPrebuiltEtcModule(module, "usr/share")
Patrice Arruda300cef92019-02-22 15:47:57 -0800608 // This module is host-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700609 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100610 android.InitDefaultableModule(module)
Patrice Arruda300cef92019-02-22 15:47:57 -0800611 return module
612}
613
Patrice Arruda61583eb2019-05-14 08:20:45 -0700614// prebuilt_font installs a font in <partition>/fonts directory.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700615func PrebuiltFontFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900616 module := &PrebuiltEtc{}
617 InitPrebuiltEtcModule(module, "fonts")
Patrice Arruda61583eb2019-05-14 08:20:45 -0700618 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700619 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100620 android.InitDefaultableModule(module)
Patrice Arruda61583eb2019-05-14 08:20:45 -0700621 return module
622}
Patrice Arruda057a8b12019-06-03 15:29:27 -0700623
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800624// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system
625// image.
626// If soc_specific property is set to true, the firmware file is installed to the
627// vendor <partition>/firmware directory for vendor image.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700628func PrebuiltFirmwareFactory() android.Module {
Jooyung Hana0171822019-07-22 15:48:36 +0900629 module := &PrebuiltEtc{}
630 module.socInstallDirBase = "firmware"
631 InitPrebuiltEtcModule(module, "etc/firmware")
Patrice Arruda057a8b12019-06-03 15:29:27 -0700632 // This module is device-only
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700633 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100634 android.InitDefaultableModule(module)
Patrice Arruda057a8b12019-06-03 15:29:27 -0700635 return module
636}
Patrice Arruda0f688002020-06-08 21:40:25 +0000637
638// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
Yo Chiangf0e19fe2020-11-18 15:28:42 +0800639// If soc_specific property is set to true, the DSP related file is installed to the
640// vendor <partition>/dsp directory for vendor image.
Patrice Arruda0f688002020-06-08 21:40:25 +0000641func PrebuiltDSPFactory() android.Module {
642 module := &PrebuiltEtc{}
643 module.socInstallDirBase = "dsp"
644 InitPrebuiltEtcModule(module, "etc/dsp")
645 // This module is device-only
646 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100647 android.InitDefaultableModule(module)
Patrice Arruda0f688002020-06-08 21:40:25 +0000648 return module
649}
Colin Cross83ebf232021-04-09 09:41:23 -0700650
Colin Crossf17e2b52023-10-30 15:17:25 -0700651// prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64.
652func PrebuiltRenderScriptBitcodeFactory() android.Module {
653 module := &PrebuiltEtc{}
654 module.makeClass = "RENDERSCRIPT_BITCODE"
655 module.installDirBase64 = "lib64"
Colin Cross2f634572023-11-13 12:12:06 -0800656 module.installAvoidMultilibConflict = true
Colin Crossf17e2b52023-10-30 15:17:25 -0700657 InitPrebuiltEtcModule(module, "lib")
658 // This module is device-only
659 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
660 android.InitDefaultableModule(module)
661 return module
662}
663
Colin Cross83ebf232021-04-09 09:41:23 -0700664// prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA
665// to the <partition>/lib/rfsa directory.
666func PrebuiltRFSAFactory() android.Module {
667 module := &PrebuiltEtc{}
668 // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too
669 // many places outside of the application processor. They could be moved to /vendor/dsp once
670 // that is cleaned up.
671 InitPrebuiltEtcModule(module, "lib/rfsa")
672 // This module is device-only
673 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
Martin Stjernholmdc6525e2021-10-14 00:42:59 +0100674 android.InitDefaultableModule(module)
Colin Cross83ebf232021-04-09 09:41:23 -0700675 return module
676}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900677
Kiyoung Kimae11c232021-07-19 11:38:04 +0900678// Copy file into the snapshot
679func copyFile(ctx android.SingletonContext, path android.Path, out string, fake bool) android.OutputPath {
680 if fake {
681 // Create empty file instead for the fake snapshot
682 return snapshot.WriteStringToFileRule(ctx, "", out)
683 } else {
684 return snapshot.CopyFileRule(pctx, ctx, path, out)
685 }
686}
687
688// Check if the module is target of the snapshot
689func isSnapshotAware(ctx android.SingletonContext, m *PrebuiltEtc, image snapshot.SnapshotImage) bool {
690 if !m.Enabled() {
691 return false
692 }
693
694 // Skip if the module is not included in the image
695 if !image.InImage(m)() {
696 return false
697 }
698
699 // When android/prebuilt.go selects between source and prebuilt, it sets
700 // HideFromMake on the other one to avoid duplicate install rules in make.
701 if m.IsHideFromMake() {
702 return false
703 }
704
705 // There are some prebuilt_etc module with multiple definition of same name.
706 // Check if the target would be included from the build
707 if !m.ExportedToMake() {
708 return false
709 }
710
711 // Skip if the module is in the predefined path list to skip
712 if image.IsProprietaryPath(ctx.ModuleDir(m), ctx.DeviceConfig()) {
713 return false
714 }
715
716 // Skip if the module should be excluded
717 if image.ExcludeFromSnapshot(m) || image.ExcludeFromDirectedSnapshot(ctx.DeviceConfig(), m.BaseModuleName()) {
718 return false
719 }
720
721 // Skip from other exceptional cases
722 if m.Target().Os.Class != android.Device {
723 return false
724 }
725 if m.Target().NativeBridge == android.NativeBridgeEnabled {
726 return false
727 }
728
729 return true
730}
731
Justin Yun1db97482023-04-11 18:20:07 +0900732func generatePrebuiltSnapshot(s snapshot.SnapshotSingleton, ctx android.SingletonContext, snapshotArchDir string) snapshot.SnapshotPaths {
Kiyoung Kimae11c232021-07-19 11:38:04 +0900733 /*
734 Snapshot zipped artifacts directory structure for etc modules:
735 {SNAPSHOT_ARCH}/
736 arch-{TARGET_ARCH}-{TARGET_ARCH_VARIANT}/
737 etc/
738 (prebuilt etc files)
739 arch-{TARGET_2ND_ARCH}-{TARGET_2ND_ARCH_VARIANT}/
740 etc/
741 (prebuilt etc files)
742 NOTICE_FILES/
743 (notice files)
744 */
745 var snapshotOutputs android.Paths
Justin Yun1db97482023-04-11 18:20:07 +0900746 var snapshotNotices android.Paths
Kiyoung Kimae11c232021-07-19 11:38:04 +0900747 installedNotices := make(map[string]bool)
748
749 ctx.VisitAllModules(func(module android.Module) {
750 m, ok := module.(*PrebuiltEtc)
751 if !ok {
752 return
753 }
754
755 if !isSnapshotAware(ctx, m, s.Image) {
756 return
757 }
758
759 targetArch := "arch-" + m.Target().Arch.ArchType.String()
760
761 snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "etc", m.BaseModuleName())
Thiébaud Weksteen00e8b312024-03-18 14:06:00 +1100762 outputs, _ := m.OutputFiles("")
763 for _, output := range outputs {
764 cp := copyFile(ctx, output, snapshotLibOut, s.Fake)
765 snapshotOutputs = append(snapshotOutputs, cp)
766 }
Kiyoung Kimae11c232021-07-19 11:38:04 +0900767
Rob Seymour925aa092021-08-10 20:42:03 +0000768 prop := snapshot.SnapshotJsonFlags{}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900769 propOut := snapshotLibOut + ".json"
Justin Yun1db97482023-04-11 18:20:07 +0900770 prop.InitBaseSnapshotProps(m)
Justin Yun8bd3afe2023-05-12 15:53:06 +0900771 prop.RelativeInstallPath = m.SubDir()
Kiyoung Kimae11c232021-07-19 11:38:04 +0900772
773 if m.properties.Filename != nil {
774 prop.Filename = *m.properties.Filename
775 }
776
777 j, err := json.Marshal(prop)
778 if err != nil {
779 ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
780 return
781 }
782 snapshotOutputs = append(snapshotOutputs, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
783
Justin Yun1db97482023-04-11 18:20:07 +0900784 for _, notice := range m.EffectiveLicenseFiles() {
785 if _, ok := installedNotices[notice.String()]; !ok {
786 installedNotices[notice.String()] = true
787 snapshotNotices = append(snapshotNotices, notice)
Kiyoung Kimae11c232021-07-19 11:38:04 +0900788 }
789 }
790
791 })
792
Justin Yun1db97482023-04-11 18:20:07 +0900793 return snapshot.SnapshotPaths{OutputFiles: snapshotOutputs, NoticeFiles: snapshotNotices}
Kiyoung Kimae11c232021-07-19 11:38:04 +0900794}