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 | |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 17 | // 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 Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 29 | |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 30 | import ( |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 31 | "fmt" |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 32 | "path/filepath" |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 33 | "strings" |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 34 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 35 | "github.com/google/blueprint/proptools" |
| 36 | |
| 37 | "android/soong/android" |
| 38 | ) |
| 39 | |
| 40 | var pctx = android.NewPackageContext("android/soong/etc") |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 41 | |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 42 | // 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] | 43 | |
| 44 | func init() { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 45 | pctx.Import("android/soong/android") |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 46 | RegisterPrebuiltEtcBuildComponents(android.InitRegistrationContext) |
| 47 | } |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 48 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 49 | func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { |
| 50 | ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) |
| 51 | ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 52 | ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 53 | ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory) |
Liz Kammer | e9ecddc | 2022-01-04 17:27:52 -0500 | [diff] [blame] | 54 | ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 55 | ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) |
| 56 | ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory) |
yangbill | 63c5e19 | 2024-03-27 09:02:12 +0000 | [diff] [blame] | 57 | ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory) |
yangbill | 85527e6 | 2024-04-30 08:24:50 +0000 | [diff] [blame] | 58 | ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory) |
| 59 | ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory) |
| 60 | ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 61 | ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory) |
Kevin | 93f7cd8 | 2024-05-02 12:37:59 +0200 | [diff] [blame] | 62 | ctx.RegisterModuleType("prebuilt_overlay", PrebuiltOverlayFactory) |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 63 | ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) |
| 64 | ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 65 | ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory) |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 66 | ctx.RegisterModuleType("prebuilt_renderscript_bitcode", PrebuiltRenderScriptBitcodeFactory) |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 67 | |
| 68 | ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory) |
Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 69 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 70 | } |
| 71 | |
Paul Duffin | 1172fed | 2021-03-08 11:28:18 +0000 | [diff] [blame] | 72 | var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents) |
| 73 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 74 | type prebuiltEtcProperties struct { |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 75 | // Source file of this prebuilt. Can reference a genrule type module with the ":module" syntax. |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 76 | // Mutually exclusive with srcs. |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 77 | Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 78 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 79 | // Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax. |
| 80 | // Mutually exclusive with src. When used, filename_from_src is set to true. |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 81 | Srcs proptools.Configurable[[]string] `android:"path,arch_variant"` |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 82 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 83 | // Optional name for the installed file. If unspecified, name of the module is used as the file |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 84 | // name. Only available when using a single source (src). |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 85 | Filename *string `android:"arch_variant"` |
| 86 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 87 | // When set to true, and filename property is not set, the name for the installed file |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 88 | // is the same as the file name of the source file. |
| 89 | Filename_from_src *bool `android:"arch_variant"` |
| 90 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 91 | // Make this module available when building for ramdisk. |
Yifan Hong | 39143a9 | 2020-10-26 12:43:12 -0700 | [diff] [blame] | 92 | // On device without a dedicated recovery partition, the module is only |
| 93 | // available after switching root into |
| 94 | // /first_stage_ramdisk. To expose the module before switching root, install |
| 95 | // the recovery variant instead. |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 96 | Ramdisk_available *bool |
| 97 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 98 | // Make this module available when building for vendor ramdisk. |
Yifan Hong | 39143a9 | 2020-10-26 12:43:12 -0700 | [diff] [blame] | 99 | // On device without a dedicated recovery partition, the module is only |
| 100 | // available after switching root into |
| 101 | // /first_stage_ramdisk. To expose the module before switching root, install |
| 102 | // the recovery variant instead. |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 103 | Vendor_ramdisk_available *bool |
| 104 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 105 | // Make this module available when building for debug ramdisk. |
| 106 | Debug_ramdisk_available *bool |
| 107 | |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 108 | // Make this module available when building for recovery. |
| 109 | Recovery_available *bool |
| 110 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 111 | // Whether this module is directly installable to one of the partitions. Default: true. |
| 112 | Installable *bool |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 113 | |
| 114 | // Install symlinks to the installed file. |
| 115 | Symlinks []string `android:"arch_variant"` |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 116 | } |
| 117 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 118 | type prebuiltSubdirProperties struct { |
| 119 | // Optional subdirectory under which this file is installed into, cannot be specified with |
| 120 | // relative_install_path, prefer relative_install_path. |
| 121 | Sub_dir *string `android:"arch_variant"` |
| 122 | |
| 123 | // Optional subdirectory under which this file is installed into, cannot be specified with |
| 124 | // sub_dir. |
| 125 | Relative_install_path *string `android:"arch_variant"` |
| 126 | } |
| 127 | |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 128 | type PrebuiltEtcModule interface { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 129 | android.Module |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 130 | |
| 131 | // Returns the base install directory, such as "etc", "usr/share". |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 132 | BaseDir() string |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 133 | |
| 134 | // Returns the sub install directory relative to BaseDir(). |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 135 | SubDir() string |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 136 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 137 | // Returns an android.OutputPath to the intermediate file, which is the renamed prebuilt source |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 138 | // file. |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 139 | OutputFiles(tag string) (android.Paths, error) |
Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 140 | } |
| 141 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 142 | type PrebuiltEtc struct { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 143 | android.ModuleBase |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 144 | android.DefaultableModuleBase |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 145 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 146 | properties prebuiltEtcProperties |
| 147 | subdirProperties prebuiltSubdirProperties |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 148 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 149 | sourceFilePaths android.Paths |
| 150 | outputFilePaths android.OutputPaths |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 151 | // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share. |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 152 | installDirBase string |
| 153 | installDirBase64 string |
| 154 | installAvoidMultilibConflict bool |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 155 | // The base install location when soc_specific property is set to true, e.g. "firmware" for |
| 156 | // prebuilt_firmware. |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 157 | socInstallDirBase string |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 158 | installDirPath android.InstallPath |
| 159 | additionalDependencies *android.Paths |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 160 | |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 161 | usedSrcsProperty bool |
| 162 | |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 163 | makeClass string |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 164 | } |
| 165 | |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 166 | type Defaults struct { |
| 167 | android.ModuleBase |
| 168 | android.DefaultsModuleBase |
| 169 | } |
| 170 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 171 | func (p *PrebuiltEtc) inRamdisk() bool { |
| 172 | return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk() |
| 173 | } |
| 174 | |
| 175 | func (p *PrebuiltEtc) onlyInRamdisk() bool { |
| 176 | return p.ModuleBase.InstallInRamdisk() |
| 177 | } |
| 178 | |
| 179 | func (p *PrebuiltEtc) InstallInRamdisk() bool { |
| 180 | return p.inRamdisk() |
| 181 | } |
| 182 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 183 | func (p *PrebuiltEtc) inVendorRamdisk() bool { |
| 184 | return p.ModuleBase.InVendorRamdisk() || p.ModuleBase.InstallInVendorRamdisk() |
| 185 | } |
| 186 | |
| 187 | func (p *PrebuiltEtc) onlyInVendorRamdisk() bool { |
| 188 | return p.ModuleBase.InstallInVendorRamdisk() |
| 189 | } |
| 190 | |
| 191 | func (p *PrebuiltEtc) InstallInVendorRamdisk() bool { |
| 192 | return p.inVendorRamdisk() |
| 193 | } |
| 194 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 195 | func (p *PrebuiltEtc) inDebugRamdisk() bool { |
| 196 | return p.ModuleBase.InDebugRamdisk() || p.ModuleBase.InstallInDebugRamdisk() |
| 197 | } |
| 198 | |
| 199 | func (p *PrebuiltEtc) onlyInDebugRamdisk() bool { |
| 200 | return p.ModuleBase.InstallInDebugRamdisk() |
| 201 | } |
| 202 | |
| 203 | func (p *PrebuiltEtc) InstallInDebugRamdisk() bool { |
| 204 | return p.inDebugRamdisk() |
| 205 | } |
| 206 | |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 207 | func (p *PrebuiltEtc) InRecovery() bool { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 208 | return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery() |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | func (p *PrebuiltEtc) onlyInRecovery() bool { |
| 212 | return p.ModuleBase.InstallInRecovery() |
| 213 | } |
| 214 | |
| 215 | func (p *PrebuiltEtc) InstallInRecovery() bool { |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 216 | return p.InRecovery() |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 219 | var _ android.ImageInterface = (*PrebuiltEtc)(nil) |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 220 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 221 | func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {} |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 222 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 223 | func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool { |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 224 | return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk() && |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 225 | !p.ModuleBase.InstallInVendorRamdisk() && !p.ModuleBase.InstallInDebugRamdisk() |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 226 | } |
| 227 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 228 | func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 229 | return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 230 | } |
| 231 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 232 | func (p *PrebuiltEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 233 | return proptools.Bool(p.properties.Vendor_ramdisk_available) || p.ModuleBase.InstallInVendorRamdisk() |
| 234 | } |
| 235 | |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 236 | func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool { |
| 237 | return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk() |
| 238 | } |
| 239 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 240 | func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { |
| 241 | return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery() |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 244 | func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 245 | return nil |
| 246 | } |
| 247 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 248 | func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 251 | func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path { |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 252 | if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 253 | panic(fmt.Errorf("SourceFilePath not available on multi-source prebuilt %q", p.Name())) |
| 254 | } |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 255 | return android.PathForModuleSrc(ctx, p.properties.Src.GetOrDefault(ctx, "")) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 256 | } |
| 257 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 258 | func (p *PrebuiltEtc) InstallDirPath() android.InstallPath { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 259 | return p.installDirPath |
| 260 | } |
| 261 | |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 262 | // This allows other derivative modules (e.g. prebuilt_etc_xml) to perform |
| 263 | // additional steps (like validating the src) before the file is installed. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 264 | func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) { |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 265 | p.additionalDependencies = &paths |
| 266 | } |
| 267 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 268 | func (p *PrebuiltEtc) OutputFile() android.OutputPath { |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 269 | if p.usedSrcsProperty { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 270 | panic(fmt.Errorf("OutputFile not available on multi-source prebuilt %q", p.Name())) |
| 271 | } |
| 272 | return p.outputFilePaths[0] |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 273 | } |
| 274 | |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 275 | var _ android.OutputFileProducer = (*PrebuiltEtc)(nil) |
| 276 | |
| 277 | func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) { |
| 278 | switch tag { |
| 279 | case "": |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 280 | return p.outputFilePaths.Paths(), nil |
Jiyong Park | 76a42f5 | 2021-02-16 06:50:37 +0900 | [diff] [blame] | 281 | default: |
| 282 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 283 | } |
| 284 | } |
| 285 | |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 286 | func (p *PrebuiltEtc) SubDir() string { |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 287 | if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" { |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 288 | return subDir |
| 289 | } |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 290 | return proptools.String(p.subdirProperties.Relative_install_path) |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 291 | } |
| 292 | |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 293 | func (p *PrebuiltEtc) BaseDir() string { |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 294 | return p.installDirBase |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 295 | } |
| 296 | |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 297 | func (p *PrebuiltEtc) Installable() bool { |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 298 | return p.properties.Installable == nil || proptools.Bool(p.properties.Installable) |
Jiyong Park | ad9ce04 | 2018-10-31 22:49:57 +0900 | [diff] [blame] | 299 | } |
| 300 | |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 301 | func (p *PrebuiltEtc) InVendor() bool { |
| 302 | return p.ModuleBase.InstallInVendor() |
| 303 | } |
| 304 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 305 | func (p *PrebuiltEtc) installBaseDir(ctx android.ModuleContext) string { |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 306 | // If soc install dir was specified and SOC specific is set, set the installDirPath to the |
| 307 | // specified socInstallDirBase. |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 308 | installBaseDir := p.installDirBase |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 309 | if p.Target().Arch.ArchType.Multilib == "lib64" && p.installDirBase64 != "" { |
| 310 | installBaseDir = p.installDirBase64 |
| 311 | } |
Jooyung Han | 8e5685d | 2020-09-21 11:02:57 +0900 | [diff] [blame] | 312 | if p.SocSpecific() && p.socInstallDirBase != "" { |
| 313 | installBaseDir = p.socInstallDirBase |
| 314 | } |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 315 | if p.installAvoidMultilibConflict && !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) { |
| 316 | installBaseDir = filepath.Join(installBaseDir, ctx.Arch().ArchType.String()) |
| 317 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 318 | return installBaseDir |
| 319 | } |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 320 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 321 | func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 322 | var installs []installProperties |
Jiyong Park | c43e0ac | 2018-10-04 20:27:15 +0900 | [diff] [blame] | 323 | |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 324 | srcProperty := p.properties.Src.Get(ctx) |
| 325 | srcsProperty := p.properties.Srcs.GetOrDefault(ctx, nil) |
| 326 | if srcProperty.IsPresent() && len(srcsProperty) > 0 { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 327 | ctx.PropertyErrorf("src", "src is set. Cannot set srcs") |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 328 | } |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 329 | |
| 330 | // Check that `sub_dir` and `relative_install_path` are not set at the same time. |
| 331 | if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil { |
| 332 | ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") |
| 333 | } |
| 334 | p.installDirPath = android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir()) |
| 335 | |
| 336 | filename := proptools.String(p.properties.Filename) |
| 337 | filenameFromSrc := proptools.Bool(p.properties.Filename_from_src) |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 338 | if srcProperty.IsPresent() { |
| 339 | p.sourceFilePaths = android.PathsForModuleSrc(ctx, []string{srcProperty.Get()}) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 340 | // If the source was not found, set a fake source path to |
| 341 | // support AllowMissingDependencies executions. |
| 342 | if len(p.sourceFilePaths) == 0 { |
| 343 | p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)} |
| 344 | } |
| 345 | |
| 346 | // Determine the output file basename. |
| 347 | // If Filename is set, use the name specified by the property. |
| 348 | // If Filename_from_src is set, use the source file name. |
| 349 | // Otherwise use the module name. |
| 350 | if filename != "" { |
| 351 | if filenameFromSrc { |
| 352 | ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true") |
| 353 | return |
| 354 | } |
| 355 | } else if filenameFromSrc { |
| 356 | filename = p.sourceFilePaths[0].Base() |
| 357 | } else { |
| 358 | filename = ctx.ModuleName() |
| 359 | } |
| 360 | if strings.Contains(filename, "/") { |
| 361 | ctx.PropertyErrorf("filename", "filename cannot contain separator '/'") |
| 362 | return |
| 363 | } |
| 364 | p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath} |
| 365 | |
| 366 | ip := installProperties{ |
| 367 | filename: filename, |
| 368 | sourceFilePath: p.sourceFilePaths[0], |
| 369 | outputFilePath: p.outputFilePaths[0], |
| 370 | installDirPath: p.installDirPath, |
| 371 | symlinks: p.properties.Symlinks, |
| 372 | } |
| 373 | installs = append(installs, ip) |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 374 | } else if len(srcsProperty) > 0 { |
| 375 | p.usedSrcsProperty = true |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 376 | if filename != "" { |
| 377 | ctx.PropertyErrorf("filename", "filename cannot be set when using srcs") |
| 378 | } |
| 379 | if len(p.properties.Symlinks) > 0 { |
| 380 | ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs") |
| 381 | } |
| 382 | if p.properties.Filename_from_src != nil { |
| 383 | ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs") |
| 384 | } |
Cole Faust | fdec872 | 2024-05-22 11:38:29 -0700 | [diff] [blame^] | 385 | p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 386 | for _, src := range p.sourceFilePaths { |
| 387 | filename := src.Base() |
| 388 | output := android.PathForModuleOut(ctx, filename).OutputPath |
| 389 | ip := installProperties{ |
| 390 | filename: filename, |
| 391 | sourceFilePath: src, |
| 392 | outputFilePath: output, |
| 393 | installDirPath: p.installDirPath, |
| 394 | } |
| 395 | p.outputFilePaths = append(p.outputFilePaths, output) |
| 396 | installs = append(installs, ip) |
| 397 | } |
| 398 | } else if ctx.Config().AllowMissingDependencies() { |
| 399 | // If no srcs was set and AllowMissingDependencies is enabled then |
| 400 | // mark the module as missing dependencies and set a fake source path |
| 401 | // and file name. |
| 402 | ctx.AddMissingDependencies([]string{"MISSING_PREBUILT_SRC_FILE"}) |
| 403 | p.sourceFilePaths = android.Paths{android.PathForModuleSrc(ctx)} |
| 404 | if filename == "" { |
| 405 | filename = ctx.ModuleName() |
| 406 | } |
| 407 | p.outputFilePaths = android.OutputPaths{android.PathForModuleOut(ctx, filename).OutputPath} |
| 408 | ip := installProperties{ |
| 409 | filename: filename, |
| 410 | sourceFilePath: p.sourceFilePaths[0], |
| 411 | outputFilePath: p.outputFilePaths[0], |
| 412 | installDirPath: p.installDirPath, |
| 413 | } |
| 414 | installs = append(installs, ip) |
| 415 | } else { |
| 416 | ctx.PropertyErrorf("src", "missing prebuilt source file") |
| 417 | return |
| 418 | } |
| 419 | |
| 420 | // Call InstallFile even when uninstallable to make the module included in the package. |
| 421 | if !p.Installable() { |
| 422 | p.SkipInstall() |
| 423 | } |
| 424 | for _, ip := range installs { |
| 425 | ip.addInstallRules(ctx) |
| 426 | } |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 427 | } |
Jiyong Park | f9f6805 | 2020-09-29 20:15:08 +0900 | [diff] [blame] | 428 | |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 429 | type installProperties struct { |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 430 | filename string |
| 431 | sourceFilePath android.Path |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 432 | outputFilePath android.OutputPath |
| 433 | installDirPath android.InstallPath |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 434 | symlinks []string |
| 435 | } |
| 436 | |
| 437 | // utility function to add install rules to the build graph. |
| 438 | // Reduces code duplication between Soong and Mixed build analysis |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 439 | func (ip *installProperties) addInstallRules(ctx android.ModuleContext) { |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 440 | // Copy the file from src to a location in out/ with the correct `filename` |
| 441 | // This ensures that outputFilePath has the correct name for others to |
| 442 | // use, as the source file may have a different name. |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 443 | ctx.Build(pctx, android.BuildParams{ |
| 444 | Rule: android.Cp, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 445 | Output: ip.outputFilePath, |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 446 | Input: ip.sourceFilePath, |
| 447 | }) |
| 448 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 449 | installPath := ctx.InstallFile(ip.installDirPath, ip.filename, ip.outputFilePath) |
Spandan Das | 756d340 | 2023-06-05 22:49:50 +0000 | [diff] [blame] | 450 | for _, sl := range ip.symlinks { |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 451 | ctx.InstallSymlink(ip.installDirPath, sl, installPath) |
Jiyong Park | f9f6805 | 2020-09-29 20:15:08 +0900 | [diff] [blame] | 452 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 453 | } |
| 454 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 455 | func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 456 | nameSuffix := "" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 457 | if p.inRamdisk() && !p.onlyInRamdisk() { |
| 458 | nameSuffix = ".ramdisk" |
| 459 | } |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 460 | if p.inVendorRamdisk() && !p.onlyInVendorRamdisk() { |
| 461 | nameSuffix = ".vendor_ramdisk" |
| 462 | } |
Inseob Kim | 08758f0 | 2021-04-08 21:13:22 +0900 | [diff] [blame] | 463 | if p.inDebugRamdisk() && !p.onlyInDebugRamdisk() { |
| 464 | nameSuffix = ".debug_ramdisk" |
| 465 | } |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 466 | if p.InRecovery() && !p.onlyInRecovery() { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 467 | nameSuffix = ".recovery" |
| 468 | } |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 469 | |
| 470 | class := p.makeClass |
| 471 | if class == "" { |
| 472 | class = "ETC" |
| 473 | } |
| 474 | |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 475 | return []android.AndroidMkEntries{{ |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 476 | Class: class, |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 477 | SubName: nameSuffix, |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 478 | OutputFile: android.OptionalPathForPath(p.outputFilePaths[0]), |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 479 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 480 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 481 | entries.SetString("LOCAL_MODULE_TAGS", "optional") |
Colin Cross | c68db4b | 2021-11-11 18:59:15 -0800 | [diff] [blame] | 482 | entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.String()) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 483 | entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base()) |
Yo Chiang | 3d64d49 | 2020-05-27 17:56:39 +0800 | [diff] [blame] | 484 | if len(p.properties.Symlinks) > 0 { |
| 485 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...) |
| 486 | } |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 487 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.Installable()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 488 | if p.additionalDependencies != nil { |
Yo Chiang | 803c40d | 2020-11-16 20:32:51 +0800 | [diff] [blame] | 489 | entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 490 | } |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 491 | }, |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 492 | }, |
Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 493 | }} |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 494 | } |
| 495 | |
LaMont Jones | afe7baf | 2024-01-09 22:47:39 +0000 | [diff] [blame] | 496 | func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase { |
| 497 | return &p.ModuleBase |
| 498 | } |
| 499 | |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 500 | func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { |
| 501 | p.installDirBase = dirBase |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 502 | p.AddProperties(&p.properties) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 503 | p.AddProperties(&p.subdirProperties) |
| 504 | } |
| 505 | |
| 506 | func InitPrebuiltRootModule(p *PrebuiltEtc) { |
| 507 | p.installDirBase = "." |
| 508 | p.AddProperties(&p.properties) |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 509 | } |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 510 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 511 | // prebuilt_etc is for a prebuilt artifact that is installed in |
| 512 | // <partition>/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 513 | func PrebuiltEtcFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 514 | module := &PrebuiltEtc{} |
| 515 | InitPrebuiltEtcModule(module, "etc") |
Jiyong Park | 5a8d1be | 2018-04-25 22:57:34 +0900 | [diff] [blame] | 516 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 517 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Inseob Kim | 1e27a14 | 2021-05-06 11:46:11 +0000 | [diff] [blame] | 518 | android.InitDefaultableModule(module) |
| 519 | return module |
| 520 | } |
| 521 | |
| 522 | func defaultsFactory() android.Module { |
| 523 | return DefaultsFactory() |
| 524 | } |
| 525 | |
| 526 | func DefaultsFactory(props ...interface{}) android.Module { |
| 527 | module := &Defaults{} |
| 528 | |
| 529 | module.AddProperties(props...) |
| 530 | module.AddProperties( |
| 531 | &prebuiltEtcProperties{}, |
| 532 | &prebuiltSubdirProperties{}, |
| 533 | ) |
| 534 | |
| 535 | android.InitDefaultsModule(module) |
| 536 | |
Jiyong Park | c678ad3 | 2018-04-10 13:07:10 +0900 | [diff] [blame] | 537 | return module |
| 538 | } |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 539 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 540 | // prebuilt_etc_host is for a host prebuilt artifact that is installed in |
| 541 | // $(HOST_OUT)/etc/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 542 | func PrebuiltEtcHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 543 | module := &PrebuiltEtc{} |
| 544 | InitPrebuiltEtcModule(module, "etc") |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 545 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 546 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 547 | android.InitDefaultableModule(module) |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 548 | return module |
| 549 | } |
| 550 | |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 551 | // prebuilt_etc_host is for a host prebuilt artifact that is installed in |
| 552 | // <partition>/etc/<sub_dir> directory. |
| 553 | func PrebuiltEtcCaCertsFactory() android.Module { |
| 554 | module := &PrebuiltEtc{} |
| 555 | InitPrebuiltEtcModule(module, "cacerts") |
| 556 | // This module is device-only |
| 557 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Miguel | 32b0280 | 2022-12-01 18:38:26 +0000 | [diff] [blame] | 558 | return module |
| 559 | } |
| 560 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 561 | // prebuilt_root is for a prebuilt artifact that is installed in |
| 562 | // <partition>/ directory. Can't have any sub directories. |
| 563 | func PrebuiltRootFactory() android.Module { |
| 564 | module := &PrebuiltEtc{} |
| 565 | InitPrebuiltRootModule(module) |
| 566 | // This module is device-only |
| 567 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 568 | android.InitDefaultableModule(module) |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 569 | return module |
| 570 | } |
| 571 | |
Liz Kammer | e9ecddc | 2022-01-04 17:27:52 -0500 | [diff] [blame] | 572 | // prebuilt_root_host is for a host prebuilt artifact that is installed in $(HOST_OUT)/<sub_dir> |
| 573 | // directory. |
| 574 | func PrebuiltRootHostFactory() android.Module { |
| 575 | module := &PrebuiltEtc{} |
| 576 | InitPrebuiltEtcModule(module, ".") |
| 577 | // This module is host-only |
| 578 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
| 579 | android.InitDefaultableModule(module) |
| 580 | return module |
| 581 | } |
| 582 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 583 | // prebuilt_usr_share is for a prebuilt artifact that is installed in |
| 584 | // <partition>/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 585 | func PrebuiltUserShareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 586 | module := &PrebuiltEtc{} |
| 587 | InitPrebuiltEtcModule(module, "usr/share") |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 588 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 589 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 590 | android.InitDefaultableModule(module) |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 591 | return module |
| 592 | } |
| 593 | |
Patrice Arruda | 9e14b96 | 2019-03-11 15:58:50 -0700 | [diff] [blame] | 594 | // prebuild_usr_share_host is for a host prebuilt artifact that is installed in |
| 595 | // $(HOST_OUT)/usr/share/<sub_dir> directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 596 | func PrebuiltUserShareHostFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 597 | module := &PrebuiltEtc{} |
| 598 | InitPrebuiltEtcModule(module, "usr/share") |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 599 | // This module is host-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 600 | android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 601 | android.InitDefaultableModule(module) |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 602 | return module |
| 603 | } |
| 604 | |
yangbill | 63c5e19 | 2024-03-27 09:02:12 +0000 | [diff] [blame] | 605 | // prebuilt_usr_hyphendata is for a prebuilt artifact that is installed in |
| 606 | // <partition>/usr/hyphen-data/<sub_dir> directory. |
| 607 | func PrebuiltUserHyphenDataFactory() android.Module { |
| 608 | module := &PrebuiltEtc{} |
| 609 | InitPrebuiltEtcModule(module, "usr/hyphen-data") |
| 610 | // This module is device-only |
| 611 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 612 | android.InitDefaultableModule(module) |
| 613 | return module |
| 614 | } |
| 615 | |
yangbill | 85527e6 | 2024-04-30 08:24:50 +0000 | [diff] [blame] | 616 | // prebuilt_usr_keylayout is for a prebuilt artifact that is installed in |
| 617 | // <partition>/usr/keylayout/<sub_dir> directory. |
| 618 | func PrebuiltUserKeyLayoutFactory() android.Module { |
| 619 | module := &PrebuiltEtc{} |
| 620 | InitPrebuiltEtcModule(module, "usr/keylayout") |
| 621 | // This module is device-only |
| 622 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 623 | android.InitDefaultableModule(module) |
| 624 | return module |
| 625 | } |
| 626 | |
| 627 | // prebuilt_usr_keychars is for a prebuilt artifact that is installed in |
| 628 | // <partition>/usr/keychars/<sub_dir> directory. |
| 629 | func PrebuiltUserKeyCharsFactory() android.Module { |
| 630 | module := &PrebuiltEtc{} |
| 631 | InitPrebuiltEtcModule(module, "usr/keychars") |
| 632 | // This module is device-only |
| 633 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 634 | android.InitDefaultableModule(module) |
| 635 | return module |
| 636 | } |
| 637 | |
| 638 | // prebuilt_usr_idc is for a prebuilt artifact that is installed in |
| 639 | // <partition>/usr/idc/<sub_dir> directory. |
| 640 | func PrebuiltUserIdcFactory() android.Module { |
| 641 | module := &PrebuiltEtc{} |
| 642 | InitPrebuiltEtcModule(module, "usr/idc") |
| 643 | // This module is device-only |
| 644 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 645 | android.InitDefaultableModule(module) |
| 646 | return module |
| 647 | } |
| 648 | |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 649 | // prebuilt_font installs a font in <partition>/fonts directory. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 650 | func PrebuiltFontFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 651 | module := &PrebuiltEtc{} |
| 652 | InitPrebuiltEtcModule(module, "fonts") |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 653 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 654 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 655 | android.InitDefaultableModule(module) |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 656 | return module |
| 657 | } |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 658 | |
Kevin | 93f7cd8 | 2024-05-02 12:37:59 +0200 | [diff] [blame] | 659 | // prebuilt_overlay is for a prebuilt artifact in <partition>/overlay directory. |
| 660 | func PrebuiltOverlayFactory() android.Module { |
| 661 | module := &PrebuiltEtc{} |
| 662 | InitPrebuiltEtcModule(module, "overlay") |
| 663 | // This module is device-only |
| 664 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
| 665 | return module |
| 666 | } |
| 667 | |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 668 | // prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system |
| 669 | // image. |
| 670 | // If soc_specific property is set to true, the firmware file is installed to the |
| 671 | // vendor <partition>/firmware directory for vendor image. |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 672 | func PrebuiltFirmwareFactory() android.Module { |
Jooyung Han | a017182 | 2019-07-22 15:48:36 +0900 | [diff] [blame] | 673 | module := &PrebuiltEtc{} |
| 674 | module.socInstallDirBase = "firmware" |
| 675 | InitPrebuiltEtcModule(module, "etc/firmware") |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 676 | // This module is device-only |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 677 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 678 | android.InitDefaultableModule(module) |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 679 | return module |
| 680 | } |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 681 | |
| 682 | // prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image. |
Yo Chiang | f0e19fe | 2020-11-18 15:28:42 +0800 | [diff] [blame] | 683 | // If soc_specific property is set to true, the DSP related file is installed to the |
| 684 | // vendor <partition>/dsp directory for vendor image. |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 685 | func PrebuiltDSPFactory() android.Module { |
| 686 | module := &PrebuiltEtc{} |
| 687 | module.socInstallDirBase = "dsp" |
| 688 | InitPrebuiltEtcModule(module, "etc/dsp") |
| 689 | // This module is device-only |
| 690 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 691 | android.InitDefaultableModule(module) |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 692 | return module |
| 693 | } |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 694 | |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 695 | // prebuilt_renderscript_bitcode installs a *.bc file into /system/lib or /system/lib64. |
| 696 | func PrebuiltRenderScriptBitcodeFactory() android.Module { |
| 697 | module := &PrebuiltEtc{} |
| 698 | module.makeClass = "RENDERSCRIPT_BITCODE" |
| 699 | module.installDirBase64 = "lib64" |
Colin Cross | 2f63457 | 2023-11-13 12:12:06 -0800 | [diff] [blame] | 700 | module.installAvoidMultilibConflict = true |
Colin Cross | f17e2b5 | 2023-10-30 15:17:25 -0700 | [diff] [blame] | 701 | InitPrebuiltEtcModule(module, "lib") |
| 702 | // This module is device-only |
| 703 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth) |
| 704 | android.InitDefaultableModule(module) |
| 705 | return module |
| 706 | } |
| 707 | |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 708 | // prebuilt_rfsa installs a firmware file that will be available through Qualcomm's RFSA |
| 709 | // to the <partition>/lib/rfsa directory. |
| 710 | func PrebuiltRFSAFactory() android.Module { |
| 711 | module := &PrebuiltEtc{} |
| 712 | // Ideally these would go in /vendor/dsp, but the /vendor/lib/rfsa paths are hardcoded in too |
| 713 | // many places outside of the application processor. They could be moved to /vendor/dsp once |
| 714 | // that is cleaned up. |
| 715 | InitPrebuiltEtcModule(module, "lib/rfsa") |
| 716 | // This module is device-only |
| 717 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) |
Martin Stjernholm | dc6525e | 2021-10-14 00:42:59 +0100 | [diff] [blame] | 718 | android.InitDefaultableModule(module) |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 719 | return module |
| 720 | } |