Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 1 | // 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 Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 15 | package etc |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 16 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 17 | import ( |
| 18 | "strconv" |
| 19 | |
| 20 | "github.com/google/blueprint/proptools" |
| 21 | |
| 22 | "android/soong/android" |
| 23 | ) |
| 24 | |
| 25 | var pctx = android.NewPackageContext("android/soong/etc") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 26 | |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 27 | // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file. |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 28 | |
| 29 | func init() { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 30 | pctx.Import("android/soong/android") |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 31 | RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext) |
| 32 | } |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 33 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 34 | func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { |
| 35 | ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) |
| 36 | ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) |
| 37 | ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) |
| 38 | ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory) |
| 39 | ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory) |
| 40 | ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) |
| 41 | ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | type prebuiltEtcProperties struct { |
| 45 | // Source file of this prebuilt. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 46 | Src *string `android:"path,arch_variant"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 47 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 48 | // optional subdirectory under which this file is installed into, cannot be specified with relative_install_path, prefer relative_install_path |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 49 | Sub_dir *string `android:"arch_variant"` |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 50 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 51 | // optional subdirectory under which this file is installed into, cannot be specified with sub_dir |
| 52 | Relative_install_path *string `android:"arch_variant"` |
| 53 | |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 54 | // optional name for the installed file. If unspecified, name of the module is used as the file name |
| 55 | Filename *string `android:"arch_variant"` |
| 56 | |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 57 | // when set to true, and filename property is not set, the name for the installed file |
| 58 | // is the same as the file name of the source file. |
| 59 | Filename_from_src *bool `android:"arch_variant"` |
| 60 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 61 | // Make this module available when building for ramdisk. |
| 62 | Ramdisk_available *bool |
| 63 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 64 | // Make this module available when building for vendor ramdisk. |
| 65 | Vendor_ramdisk_available *bool |
| 66 | |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 67 | // Make this module available when building for recovery. |
| 68 | Recovery_available *bool |
| 69 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 70 | // Whether this module is directly installable to one of the partitions. Default: true. |
| 71 | Installable *bool |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 72 | |
| 73 | // Install symlinks to the installed file. |
| 74 | Symlinks []string `android:"arch_variant"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 75 | } |
| 76 | |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 77 | type PrebuiltEtcModule interface { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 78 | android.Module |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 79 | BaseDir() string |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 80 | SubDir() string |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 81 | OutputFile() android.OutputPath |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 82 | } |
| 83 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 84 | type PrebuiltEtc struct { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 85 | android.ModuleBase |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 86 | |
| 87 | properties prebuiltEtcProperties |
| 88 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 89 | sourceFilePath android.Path |
| 90 | outputFilePath android.OutputPath |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 91 | // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share. |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 92 | installDirBase string |
| 93 | // The base install location when soc_specific property is set to true, e.g. "firmware" for prebuilt_firmware. |
| 94 | socInstallDirBase string |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 95 | installDirPath android.InstallPath |
| 96 | additionalDependencies *android.Paths |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 97 | } |
| 98 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 99 | func (p *PrebuiltEtc) inRamdisk() bool { |
| 100 | return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk() |
| 101 | } |
| 102 | |
| 103 | func (p *PrebuiltEtc) onlyInRamdisk() bool { |
| 104 | return p.ModuleBase.InstallInRamdisk() |
| 105 | } |
| 106 | |
| 107 | func (p *PrebuiltEtc) InstallInRamdisk() bool { |
| 108 | return p.inRamdisk() |
| 109 | } |
| 110 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 111 | func (p *PrebuiltEtc) inVendorRamdisk() bool { |
| 112 | return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk() |
| 113 | } |
| 114 | |
| 115 | func (p *PrebuiltEtc) onlyInVendorRamdisk() bool { |
| 116 | return p.ModuleBase.InstallInVendorRamdisk() |
| 117 | } |
| 118 | |
| 119 | func (p *PrebuiltEtc) InstallInVendorRamdisk() bool { |
| 120 | return p.inVendorRamdisk() |
| 121 | } |
| 122 | |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 123 | func (p *PrebuiltEtc) inRecovery() bool { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 124 | return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery() |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | func (p *PrebuiltEtc) onlyInRecovery() bool { |
| 128 | return p.ModuleBase.InstallInRecovery() |
| 129 | } |
| 130 | |
| 131 | func (p *PrebuiltEtc) InstallInRecovery() bool { |
| 132 | return p.inRecovery() |
| 133 | } |
| 134 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 135 | var _ android.ImageInterface = (*PrebuiltEtc)(nil) |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 136 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 137 | func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {} |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 138 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 139 | func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 140 | return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() && |
| 141 | !p.ModuleBase.InstallInVendorRamdisk() |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 142 | } |
| 143 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 144 | func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 145 | return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 148 | func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 149 | return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk() |
| 150 | } |
| 151 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 152 | func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { |
| 153 | return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 156 | func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 157 | return nil |
| 158 | } |
| 159 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 160 | func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 161 | } |
| 162 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 163 | func (p *PrebuiltEtc) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 164 | if p.properties.Src == nil { |
| 165 | ctx.PropertyErrorf("src", "missing prebuilt source file") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 166 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 167 | } |
| 168 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 169 | func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path { |
| 170 | return android.PathForModuleSrc(ctx, android.String(p.properties.Src)) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 171 | } |
| 172 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 173 | func (p *PrebuiltEtc) InstallDirPath() android.InstallPath { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 174 | return p.installDirPath |
| 175 | } |
| 176 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 177 | // This allows other derivative modules (e.g. prebuilt_etc_xml) to perform |
| 178 | // additional steps (like validating the src) before the file is installed. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 179 | func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) { |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 180 | p.additionalDependencies = &paths |
| 181 | } |
| 182 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 183 | func (p *PrebuiltEtc) OutputFile() android.OutputPath { |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 184 | return p.outputFilePath |
| 185 | } |
| 186 | |
| 187 | func (p *PrebuiltEtc) SubDir() string { |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 188 | if subDir := proptools.String(p.properties.Sub_dir); subDir != "" { |
| 189 | return subDir |
| 190 | } |
| 191 | return proptools.String(p.properties.Relative_install_path) |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 192 | } |
| 193 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 194 | func (p *PrebuiltEtc) BaseDir() string { |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 195 | return p.installDirBase |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 196 | } |
| 197 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 198 | func (p *PrebuiltEtc) Installable() bool { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 199 | return p.properties.Installable == nil || android.Bool(p.properties.Installable) |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 200 | } |
| 201 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 202 | func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 203 | p.sourceFilePath = android.PathForModuleSrc(ctx, android.String(p.properties.Src)) |
| 204 | filename := android.String(p.properties.Filename) |
| 205 | filename_from_src := android.Bool(p.properties.Filename_from_src) |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 206 | if filename == "" { |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 207 | if filename_from_src { |
| 208 | filename = p.sourceFilePath.Base() |
| 209 | } else { |
| 210 | filename = ctx.ModuleName() |
| 211 | } |
| 212 | } else if filename_from_src { |
| 213 | ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true") |
| 214 | return |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 215 | } |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 216 | p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 217 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 218 | if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil { |
| 219 | ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") |
| 220 | } |
| 221 | |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 222 | // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified |
| 223 | // socInstallDirBase. |
| 224 | installBaseDir := p.installDirBase |
| 225 | if p.SocSpecific() && p.socInstallDirBase != "" { |
| 226 | installBaseDir = p.socInstallDirBase |
| 227 | } |
| 228 | p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir()) |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 229 | |
Dan Willemsen | b055267 | 2019-01-25 16:04:11 -0800 | [diff] [blame] | 230 | // This ensures that outputFilePath has the correct name for others to |
| 231 | // use, as the source file may have a different name. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 232 | ctx.Build(pctx, android.BuildParams{ |
| 233 | Rule: android.Cp, |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 234 | Output: p.outputFilePath, |
| 235 | Input: p.sourceFilePath, |
| 236 | }) |
Jiyong Park | f9f6805 | 2020-09-29 20:15:08 +0900 | [diff] [blame] | 237 | |
| 238 | if p.Installable() { |
| 239 | installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath) |
| 240 | for _, sl := range p.properties.Symlinks { |
| 241 | ctx.InstallSymlink(p.installDirPath, sl, installPath) |
| 242 | } |
| 243 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 244 | } |
| 245 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 246 | func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 247 | nameSuffix := "" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 248 | if p.inRamdisk() && !p.onlyInRamdisk() { |
| 249 | nameSuffix = ".ramdisk" |
| 250 | } |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 251 | if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() { |
| 252 | nameSuffix = ".vendor_ramdisk" |
| 253 | } |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 254 | if p.inRecovery() && !p.onlyInRecovery() { |
| 255 | nameSuffix = ".recovery" |
| 256 | } |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 257 | return []android.AndroidMkEntries{android.AndroidMkEntries{ |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 258 | Class: "ETC", |
| 259 | SubName: nameSuffix, |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 260 | OutputFile: android.OptionalPathForPath(p.outputFilePath), |
| 261 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 262 | func(entries *android.AndroidMkEntries) { |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 263 | entries.SetString("LOCAL_MODULE_TAGS", "optional") |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 264 | entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 265 | entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 266 | if len(p.properties.Symlinks) > 0 { |
| 267 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...) |
| 268 | } |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 269 | entries.SetString("LOCAL_UNINSTALLABLE_MODULE", strconv.FormatBool(!p.Installable())) |
| 270 | if p.additionalDependencies != nil { |
| 271 | for _, path := range *p.additionalDependencies { |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 272 | entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", path.String()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 273 | } |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 274 | } |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 275 | }, |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 276 | }, |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 277 | }} |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 278 | } |
| 279 | |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 280 | func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { |
| 281 | p.installDirBase = dirBase |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 282 | p.AddProperties(&p.properties) |
| 283 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 284 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 285 | // prebuilt_etc is for a prebuilt artifact that is installed in |
| 286 | // <partition>/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 287 | func PrebuiltEtcFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 288 | module := &PrebuiltEtc{} |
| 289 | InitPrebuiltEtcModule(module, "etc") |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 290 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 291 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 292 | return module |
| 293 | } |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 294 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 295 | // prebuilt_etc_host is for a host prebuilt artifact that is installed in |
| 296 | // $(HOST_OUT)/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 297 | func PrebuiltEtcHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 298 | module := &PrebuiltEtc{} |
| 299 | InitPrebuiltEtcModule(module, "etc") |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 300 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 301 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 302 | return module |
| 303 | } |
| 304 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 305 | // prebuilt_usr_share is for a prebuilt artifact that is installed in |
| 306 | // <partition>/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 307 | func PrebuiltUserShareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 308 | module := &PrebuiltEtc{} |
| 309 | InitPrebuiltEtcModule(module, "usr/share") |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 310 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 311 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 312 | return module |
| 313 | } |
| 314 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 315 | // prebuild_usr_share_host is for a host prebuilt artifact that is installed in |
| 316 | // $(HOST_OUT)/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 317 | func PrebuiltUserShareHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 318 | module := &PrebuiltEtc{} |
| 319 | InitPrebuiltEtcModule(module, "usr/share") |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 320 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 321 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 322 | return module |
| 323 | } |
| 324 | |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 325 | // prebuilt_font installs a font in <partition>/fonts directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 326 | func PrebuiltFontFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 327 | module := &PrebuiltEtc{} |
| 328 | InitPrebuiltEtcModule(module, "fonts") |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 329 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 330 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 331 | return module |
| 332 | } |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 333 | |
| 334 | // prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system image. |
| 335 | // If soc_specific property is set to true, the firmware file is installed to the vendor <partition>/firmware |
| 336 | // directory for vendor image. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 337 | func PrebuiltFirmwareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 338 | module := &PrebuiltEtc{} |
| 339 | module.socInstallDirBase = "firmware" |
| 340 | InitPrebuiltEtcModule(module, "etc/firmware") |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 341 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 342 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 343 | return module |
| 344 | } |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 345 | |
| 346 | // prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image. |
| 347 | // If soc_specific property is set to true, the DSP related file is installed to the vendor <partition>/dsp |
| 348 | // directory for vendor image. |
| 349 | func PrebuiltDSPFactory() android.Module { |
| 350 | module := &PrebuiltEtc{} |
| 351 | module.socInstallDirBase = "dsp" |
| 352 | InitPrebuiltEtcModule(module, "etc/dsp") |
| 353 | // This module is device-only |
| 354 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 355 | return module |
| 356 | } |