Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1 | // Copyright 2015 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 | |
| 15 | package common |
| 16 | |
| 17 | import ( |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 18 | "fmt" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 19 | "path/filepath" |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 20 | "strings" |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 21 | |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 22 | "android/soong" |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 23 | "android/soong/glob" |
| 24 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 25 | "github.com/google/blueprint" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 26 | ) |
| 27 | |
| 28 | var ( |
| 29 | DeviceSharedLibrary = "shared_library" |
| 30 | DeviceStaticLibrary = "static_library" |
| 31 | DeviceExecutable = "executable" |
| 32 | HostSharedLibrary = "host_shared_library" |
| 33 | HostStaticLibrary = "host_static_library" |
| 34 | HostExecutable = "host_executable" |
| 35 | ) |
| 36 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 37 | type ModuleBuildParams struct { |
| 38 | Rule blueprint.Rule |
| 39 | Output WritablePath |
| 40 | Outputs WritablePaths |
| 41 | Input Path |
| 42 | Inputs Paths |
| 43 | Implicit Path |
| 44 | Implicits Paths |
| 45 | OrderOnly Paths |
| 46 | Default bool |
| 47 | Args map[string]string |
| 48 | } |
| 49 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 50 | type androidBaseContext interface { |
| 51 | Arch() Arch |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 52 | HostOrDevice() HostOrDevice |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 53 | HostType() HostType |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 54 | Host() bool |
| 55 | Device() bool |
Colin Cross | 0af4b84 | 2015-04-30 16:36:18 -0700 | [diff] [blame] | 56 | Darwin() bool |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 57 | Debug() bool |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 58 | AConfig() Config |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 59 | Proprietary() bool |
| 60 | InstallInData() bool |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | type AndroidBaseContext interface { |
| 64 | blueprint.BaseModuleContext |
| 65 | androidBaseContext |
| 66 | } |
| 67 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 68 | type AndroidModuleContext interface { |
| 69 | blueprint.ModuleContext |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 70 | androidBaseContext |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 71 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 72 | // Similar to Build, but takes Paths instead of []string, |
| 73 | // and performs more verification. |
| 74 | ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 75 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 76 | ExpandSources(srcFiles, excludes []string) Paths |
| 77 | Glob(outDir, globPattern string, excludes []string) Paths |
| 78 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 79 | InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path |
| 80 | InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) Path |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 81 | CheckbuildFile(srcPath Path) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | type AndroidModule interface { |
| 85 | blueprint.Module |
| 86 | |
| 87 | GenerateAndroidBuildActions(AndroidModuleContext) |
| 88 | |
| 89 | base() *AndroidModuleBase |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 90 | Enabled() bool |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 91 | HostOrDevice() HostOrDevice |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 92 | InstallInData() bool |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 93 | } |
| 94 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 95 | type commonProperties struct { |
Colin Cross | c77f9d1 | 2015-04-02 13:54:39 -0700 | [diff] [blame] | 96 | Name string |
| 97 | Deps []string |
| 98 | Tags []string |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 99 | |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 100 | // emit build rules for this module |
| 101 | Enabled *bool `android:"arch_variant"` |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 102 | |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 103 | // control whether this module compiles for 32-bit, 64-bit, or both. Possible values |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 104 | // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both |
| 105 | // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit |
| 106 | // platform |
| 107 | Compile_multilib string |
| 108 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 109 | // whether this is a proprietary vendor module, and should be installed into /vendor |
| 110 | Proprietary bool |
| 111 | |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 112 | // Set by HostOrDeviceMutator |
| 113 | CompileHostOrDevice HostOrDevice `blueprint:"mutated"` |
| 114 | |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 115 | // Set by HostTypeMutator |
| 116 | CompileHostType HostType `blueprint:"mutated"` |
| 117 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 118 | // Set by ArchMutator |
| 119 | CompileArch Arch `blueprint:"mutated"` |
| 120 | |
| 121 | // Set by InitAndroidModule |
| 122 | HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"` |
| 123 | } |
| 124 | |
| 125 | type hostAndDeviceProperties struct { |
| 126 | Host_supported bool |
| 127 | Device_supported bool |
| 128 | } |
| 129 | |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 130 | type Multilib string |
| 131 | |
| 132 | const ( |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 133 | MultilibBoth Multilib = "both" |
| 134 | MultilibFirst Multilib = "first" |
| 135 | MultilibCommon Multilib = "common" |
| 136 | MultilibDefault Multilib = "" |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 137 | ) |
| 138 | |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 139 | func InitAndroidModule(m AndroidModule, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 140 | propertyStructs ...interface{}) (blueprint.Module, []interface{}) { |
| 141 | |
| 142 | base := m.base() |
| 143 | base.module = m |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 144 | |
Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 145 | propertyStructs = append(propertyStructs, &base.commonProperties, &base.variableProperties) |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 146 | |
| 147 | return m, propertyStructs |
| 148 | } |
| 149 | |
| 150 | func InitAndroidArchModule(m AndroidModule, hod HostOrDeviceSupported, defaultMultilib Multilib, |
| 151 | propertyStructs ...interface{}) (blueprint.Module, []interface{}) { |
| 152 | |
| 153 | _, propertyStructs = InitAndroidModule(m, propertyStructs...) |
| 154 | |
| 155 | base := m.base() |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 156 | base.commonProperties.HostOrDeviceSupported = hod |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 157 | base.commonProperties.Compile_multilib = string(defaultMultilib) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 158 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 159 | switch hod { |
| 160 | case HostAndDeviceSupported: |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 161 | // Default to module to device supported, host not supported, can override in module |
| 162 | // properties |
| 163 | base.hostAndDeviceProperties.Device_supported = true |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 164 | fallthrough |
| 165 | case HostAndDeviceDefault: |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 166 | propertyStructs = append(propertyStructs, &base.hostAndDeviceProperties) |
| 167 | } |
| 168 | |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 169 | return InitArchModule(m, propertyStructs...) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | // A AndroidModuleBase object contains the properties that are common to all Android |
| 173 | // modules. It should be included as an anonymous field in every module |
| 174 | // struct definition. InitAndroidModule should then be called from the module's |
| 175 | // factory function, and the return values from InitAndroidModule should be |
| 176 | // returned from the factory function. |
| 177 | // |
| 178 | // The AndroidModuleBase type is responsible for implementing the |
| 179 | // GenerateBuildActions method to support the blueprint.Module interface. This |
| 180 | // method will then call the module's GenerateAndroidBuildActions method once |
| 181 | // for each build variant that is to be built. GenerateAndroidBuildActions is |
| 182 | // passed a AndroidModuleContext rather than the usual blueprint.ModuleContext. |
| 183 | // AndroidModuleContext exposes extra functionality specific to the Android build |
| 184 | // system including details about the particular build variant that is to be |
| 185 | // generated. |
| 186 | // |
| 187 | // For example: |
| 188 | // |
| 189 | // import ( |
| 190 | // "android/soong/common" |
Colin Cross | 70b4059 | 2015-03-23 12:57:34 -0700 | [diff] [blame] | 191 | // "github.com/google/blueprint" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 192 | // ) |
| 193 | // |
| 194 | // type myModule struct { |
| 195 | // common.AndroidModuleBase |
| 196 | // properties struct { |
| 197 | // MyProperty string |
| 198 | // } |
| 199 | // } |
| 200 | // |
| 201 | // func NewMyModule() (blueprint.Module, []interface{}) { |
| 202 | // m := &myModule{} |
| 203 | // return common.InitAndroidModule(m, &m.properties) |
| 204 | // } |
| 205 | // |
| 206 | // func (m *myModule) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { |
| 207 | // // Get the CPU architecture for the current build variant. |
| 208 | // variantArch := ctx.Arch() |
| 209 | // |
| 210 | // // ... |
| 211 | // } |
| 212 | type AndroidModuleBase struct { |
| 213 | // Putting the curiously recurring thing pointing to the thing that contains |
| 214 | // the thing pattern to good use. |
| 215 | module AndroidModule |
| 216 | |
| 217 | commonProperties commonProperties |
Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 218 | variableProperties variableProperties |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 219 | hostAndDeviceProperties hostAndDeviceProperties |
| 220 | generalProperties []interface{} |
| 221 | archProperties []*archProperties |
| 222 | |
| 223 | noAddressSanitizer bool |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 224 | installFiles Paths |
| 225 | checkbuildFiles Paths |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 226 | |
| 227 | // Used by buildTargetSingleton to create checkbuild and per-directory build targets |
| 228 | // Only set on the final variant of each module |
| 229 | installTarget string |
| 230 | checkbuildTarget string |
| 231 | blueprintDir string |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | func (a *AndroidModuleBase) base() *AndroidModuleBase { |
| 235 | return a |
| 236 | } |
| 237 | |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 238 | func (a *AndroidModuleBase) SetHostOrDevice(hod HostOrDevice) { |
| 239 | a.commonProperties.CompileHostOrDevice = hod |
| 240 | } |
| 241 | |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 242 | func (a *AndroidModuleBase) SetHostType(ht HostType) { |
| 243 | a.commonProperties.CompileHostType = ht |
| 244 | } |
| 245 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 246 | func (a *AndroidModuleBase) SetArch(arch Arch) { |
| 247 | a.commonProperties.CompileArch = arch |
| 248 | } |
| 249 | |
| 250 | func (a *AndroidModuleBase) HostOrDevice() HostOrDevice { |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 251 | return a.commonProperties.CompileHostOrDevice |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 254 | func (a *AndroidModuleBase) HostType() HostType { |
| 255 | return a.commonProperties.CompileHostType |
| 256 | } |
| 257 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 258 | func (a *AndroidModuleBase) HostSupported() bool { |
| 259 | return a.commonProperties.HostOrDeviceSupported == HostSupported || |
| 260 | a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && |
| 261 | a.hostAndDeviceProperties.Host_supported |
| 262 | } |
| 263 | |
| 264 | func (a *AndroidModuleBase) DeviceSupported() bool { |
| 265 | return a.commonProperties.HostOrDeviceSupported == DeviceSupported || |
| 266 | a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && |
| 267 | a.hostAndDeviceProperties.Device_supported |
| 268 | } |
| 269 | |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 270 | func (a *AndroidModuleBase) Enabled() bool { |
| 271 | if a.commonProperties.Enabled == nil { |
| 272 | if a.HostSupported() && a.HostOrDevice().Host() && a.HostType() == Windows { |
| 273 | return false |
| 274 | } else { |
| 275 | return true |
| 276 | } |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 277 | } |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 278 | return *a.commonProperties.Enabled |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | func (a *AndroidModuleBase) computeInstallDeps( |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 282 | ctx blueprint.ModuleContext) Paths { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 283 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 284 | result := Paths{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 285 | ctx.VisitDepsDepthFirstIf(isFileInstaller, |
| 286 | func(m blueprint.Module) { |
| 287 | fileInstaller := m.(fileInstaller) |
| 288 | files := fileInstaller.filesToInstall() |
| 289 | result = append(result, files...) |
| 290 | }) |
| 291 | |
| 292 | return result |
| 293 | } |
| 294 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 295 | func (a *AndroidModuleBase) filesToInstall() Paths { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 296 | return a.installFiles |
| 297 | } |
| 298 | |
| 299 | func (p *AndroidModuleBase) NoAddressSanitizer() bool { |
| 300 | return p.noAddressSanitizer |
| 301 | } |
| 302 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 303 | func (p *AndroidModuleBase) InstallInData() bool { |
| 304 | return false |
| 305 | } |
| 306 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 307 | func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { |
| 308 | if a != ctx.FinalModule().(AndroidModule).base() { |
| 309 | return |
| 310 | } |
| 311 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 312 | allInstalledFiles := Paths{} |
| 313 | allCheckbuildFiles := Paths{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 314 | ctx.VisitAllModuleVariants(func(module blueprint.Module) { |
Colin Cross | c940435 | 2015-03-26 16:10:12 -0700 | [diff] [blame] | 315 | a := module.(AndroidModule).base() |
| 316 | allInstalledFiles = append(allInstalledFiles, a.installFiles...) |
| 317 | allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 318 | }) |
| 319 | |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 320 | deps := []string{} |
| 321 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 322 | if len(allInstalledFiles) > 0 { |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 323 | name := ctx.ModuleName() + "-install" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 324 | ctx.Build(pctx, blueprint.BuildParams{ |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 325 | Rule: blueprint.Phony, |
| 326 | Outputs: []string{name}, |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 327 | Implicits: allInstalledFiles.Strings(), |
Colin Cross | 346aa13 | 2015-12-17 17:19:51 -0800 | [diff] [blame] | 328 | Optional: ctx.Config().(Config).EmbeddedInMake(), |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 329 | }) |
| 330 | deps = append(deps, name) |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 331 | a.installTarget = name |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | if len(allCheckbuildFiles) > 0 { |
| 335 | name := ctx.ModuleName() + "-checkbuild" |
| 336 | ctx.Build(pctx, blueprint.BuildParams{ |
| 337 | Rule: blueprint.Phony, |
| 338 | Outputs: []string{name}, |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 339 | Implicits: allCheckbuildFiles.Strings(), |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 340 | Optional: true, |
| 341 | }) |
| 342 | deps = append(deps, name) |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 343 | a.checkbuildTarget = name |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | if len(deps) > 0 { |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 347 | suffix := "" |
| 348 | if ctx.Config().(Config).EmbeddedInMake() { |
| 349 | suffix = "-soong" |
| 350 | } |
| 351 | |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 352 | ctx.Build(pctx, blueprint.BuildParams{ |
| 353 | Rule: blueprint.Phony, |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 354 | Outputs: []string{ctx.ModuleName() + suffix}, |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 355 | Implicits: deps, |
| 356 | Optional: true, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 357 | }) |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 358 | |
| 359 | a.blueprintDir = ctx.ModuleDir() |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 363 | func (a *AndroidModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl { |
| 364 | return androidBaseContextImpl{ |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 365 | arch: a.commonProperties.CompileArch, |
| 366 | hod: a.commonProperties.CompileHostOrDevice, |
| 367 | ht: a.commonProperties.CompileHostType, |
| 368 | proprietary: a.commonProperties.Proprietary, |
| 369 | config: ctx.Config().(Config), |
| 370 | installInData: a.module.InstallInData(), |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 371 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { |
| 375 | androidCtx := &androidModuleContext{ |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 376 | ModuleContext: ctx, |
| 377 | androidBaseContextImpl: a.androidBaseContextFactory(ctx), |
| 378 | installDeps: a.computeInstallDeps(ctx), |
| 379 | installFiles: a.installFiles, |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 380 | missingDeps: ctx.GetMissingDependencies(), |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 381 | } |
| 382 | |
Dan Willemsen | 0effe06 | 2015-11-30 16:06:01 -0800 | [diff] [blame] | 383 | if !a.Enabled() { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 384 | return |
| 385 | } |
| 386 | |
| 387 | a.module.GenerateAndroidBuildActions(androidCtx) |
| 388 | if ctx.Failed() { |
| 389 | return |
| 390 | } |
| 391 | |
Colin Cross | c940435 | 2015-03-26 16:10:12 -0700 | [diff] [blame] | 392 | a.installFiles = append(a.installFiles, androidCtx.installFiles...) |
| 393 | a.checkbuildFiles = append(a.checkbuildFiles, androidCtx.checkbuildFiles...) |
| 394 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 395 | a.generateModuleTarget(ctx) |
| 396 | if ctx.Failed() { |
| 397 | return |
| 398 | } |
| 399 | } |
| 400 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 401 | type androidBaseContextImpl struct { |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 402 | arch Arch |
| 403 | hod HostOrDevice |
| 404 | ht HostType |
| 405 | debug bool |
| 406 | config Config |
| 407 | proprietary bool |
| 408 | installInData bool |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 411 | type androidModuleContext struct { |
| 412 | blueprint.ModuleContext |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 413 | androidBaseContextImpl |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 414 | installDeps Paths |
| 415 | installFiles Paths |
| 416 | checkbuildFiles Paths |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 417 | missingDeps []string |
| 418 | } |
| 419 | |
| 420 | func (a *androidModuleContext) ninjaError(outputs []string, err error) { |
| 421 | a.ModuleContext.Build(pctx, blueprint.BuildParams{ |
| 422 | Rule: ErrorRule, |
| 423 | Outputs: outputs, |
| 424 | Optional: true, |
| 425 | Args: map[string]string{ |
| 426 | "error": err.Error(), |
| 427 | }, |
| 428 | }) |
| 429 | return |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 430 | } |
| 431 | |
Dan Willemsen | 14e5c2a | 2015-11-30 13:59:34 -0800 | [diff] [blame] | 432 | func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params blueprint.BuildParams) { |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 433 | if a.missingDeps != nil { |
| 434 | a.ninjaError(params.Outputs, fmt.Errorf("module %s missing dependencies: %s\n", |
| 435 | a.ModuleName(), strings.Join(a.missingDeps, ", "))) |
| 436 | return |
| 437 | } |
| 438 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 439 | params.Optional = true |
| 440 | a.ModuleContext.Build(pctx, params) |
| 441 | } |
| 442 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 443 | func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) { |
| 444 | bparams := blueprint.BuildParams{ |
| 445 | Rule: params.Rule, |
| 446 | Outputs: params.Outputs.Strings(), |
| 447 | Inputs: params.Inputs.Strings(), |
| 448 | Implicits: params.Implicits.Strings(), |
| 449 | OrderOnly: params.OrderOnly.Strings(), |
| 450 | Args: params.Args, |
| 451 | Optional: !params.Default, |
| 452 | } |
| 453 | |
| 454 | if params.Output != nil { |
| 455 | bparams.Outputs = append(bparams.Outputs, params.Output.String()) |
| 456 | } |
| 457 | if params.Input != nil { |
| 458 | bparams.Inputs = append(bparams.Inputs, params.Input.String()) |
| 459 | } |
| 460 | if params.Implicit != nil { |
| 461 | bparams.Implicits = append(bparams.Implicits, params.Implicit.String()) |
| 462 | } |
| 463 | |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 464 | if a.missingDeps != nil { |
| 465 | a.ninjaError(bparams.Outputs, fmt.Errorf("module %s missing dependencies: %s\n", |
| 466 | a.ModuleName(), strings.Join(a.missingDeps, ", "))) |
| 467 | return |
| 468 | } |
| 469 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 470 | a.ModuleContext.Build(pctx, bparams) |
| 471 | } |
| 472 | |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 473 | func (a *androidModuleContext) GetMissingDependencies() []string { |
| 474 | return a.missingDeps |
| 475 | } |
| 476 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 477 | func (a *androidBaseContextImpl) Arch() Arch { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 478 | return a.arch |
| 479 | } |
| 480 | |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 481 | func (a *androidBaseContextImpl) HostOrDevice() HostOrDevice { |
| 482 | return a.hod |
| 483 | } |
| 484 | |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 485 | func (a *androidBaseContextImpl) HostType() HostType { |
| 486 | return a.ht |
| 487 | } |
| 488 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 489 | func (a *androidBaseContextImpl) Host() bool { |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 490 | return a.hod.Host() |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | func (a *androidBaseContextImpl) Device() bool { |
Colin Cross | d3ba039 | 2015-05-07 14:11:29 -0700 | [diff] [blame] | 494 | return a.hod.Device() |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 495 | } |
| 496 | |
Colin Cross | 0af4b84 | 2015-04-30 16:36:18 -0700 | [diff] [blame] | 497 | func (a *androidBaseContextImpl) Darwin() bool { |
Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 498 | return a.hod.Host() && a.ht == Darwin |
Colin Cross | 0af4b84 | 2015-04-30 16:36:18 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 501 | func (a *androidBaseContextImpl) Debug() bool { |
| 502 | return a.debug |
| 503 | } |
| 504 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 505 | func (a *androidBaseContextImpl) AConfig() Config { |
| 506 | return a.config |
| 507 | } |
| 508 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 509 | func (a *androidBaseContextImpl) Proprietary() bool { |
| 510 | return a.proprietary |
| 511 | } |
| 512 | |
| 513 | func (a *androidBaseContextImpl) InstallInData() bool { |
| 514 | return a.installInData |
| 515 | } |
| 516 | |
| 517 | func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path, |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 518 | deps ...Path) Path { |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 519 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 520 | fullInstallPath := installPath.Join(a, name) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 521 | |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 522 | if !a.AConfig().SkipInstall() { |
| 523 | deps = append(deps, a.installDeps...) |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 524 | |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 525 | a.ModuleBuild(pctx, ModuleBuildParams{ |
| 526 | Rule: Cp, |
| 527 | Output: fullInstallPath, |
| 528 | Input: srcPath, |
| 529 | OrderOnly: Paths(deps), |
| 530 | Default: true, |
| 531 | }) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 532 | |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 533 | a.installFiles = append(a.installFiles, fullInstallPath) |
| 534 | } |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 535 | a.checkbuildFiles = append(a.checkbuildFiles, srcPath) |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 536 | return fullInstallPath |
| 537 | } |
| 538 | |
Dan Willemsen | 782a2d1 | 2015-12-21 14:55:28 -0800 | [diff] [blame] | 539 | func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 540 | return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 541 | } |
| 542 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 543 | func (a *androidModuleContext) CheckbuildFile(srcPath Path) { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 544 | a.checkbuildFiles = append(a.checkbuildFiles, srcPath) |
| 545 | } |
| 546 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 547 | type fileInstaller interface { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 548 | filesToInstall() Paths |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | func isFileInstaller(m blueprint.Module) bool { |
| 552 | _, ok := m.(fileInstaller) |
| 553 | return ok |
| 554 | } |
| 555 | |
| 556 | func isAndroidModule(m blueprint.Module) bool { |
| 557 | _, ok := m.(AndroidModule) |
| 558 | return ok |
| 559 | } |
Colin Cross | fce5327 | 2015-04-08 11:21:40 -0700 | [diff] [blame] | 560 | |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 561 | func findStringInSlice(str string, slice []string) int { |
| 562 | for i, s := range slice { |
| 563 | if s == str { |
| 564 | return i |
Colin Cross | fce5327 | 2015-04-08 11:21:40 -0700 | [diff] [blame] | 565 | } |
| 566 | } |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 567 | return -1 |
| 568 | } |
| 569 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 570 | func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths { |
| 571 | prefix := PathForModuleSrc(ctx).String() |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 572 | for i, e := range excludes { |
| 573 | j := findStringInSlice(e, srcFiles) |
| 574 | if j != -1 { |
| 575 | srcFiles = append(srcFiles[:j], srcFiles[j+1:]...) |
| 576 | } |
| 577 | |
| 578 | excludes[i] = filepath.Join(prefix, e) |
| 579 | } |
| 580 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 581 | globbedSrcFiles := make(Paths, 0, len(srcFiles)) |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 582 | for _, s := range srcFiles { |
Dan Willemsen | 2ef08f4 | 2015-06-30 18:15:24 -0700 | [diff] [blame] | 583 | if glob.IsGlob(s) { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 584 | globbedSrcFiles = append(globbedSrcFiles, ctx.Glob("src_glob", filepath.Join(prefix, s), excludes)...) |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 585 | } else { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 586 | globbedSrcFiles = append(globbedSrcFiles, PathForModuleSrc(ctx, s)) |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | |
| 590 | return globbedSrcFiles |
| 591 | } |
| 592 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 593 | func (ctx *androidModuleContext) Glob(outDir, globPattern string, excludes []string) Paths { |
| 594 | ret, err := Glob(ctx, PathForModuleOut(ctx, outDir).String(), globPattern, excludes) |
Colin Cross | 8f101b4 | 2015-06-17 15:09:06 -0700 | [diff] [blame] | 595 | if err != nil { |
| 596 | ctx.ModuleErrorf("glob: %s", err.Error()) |
| 597 | } |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 598 | return pathsForModuleSrcFromFullPath(ctx, ret) |
Colin Cross | fce5327 | 2015-04-08 11:21:40 -0700 | [diff] [blame] | 599 | } |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 600 | |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 601 | func init() { |
| 602 | soong.RegisterSingletonType("buildtarget", BuildTargetSingleton) |
| 603 | } |
| 604 | |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 605 | func BuildTargetSingleton() blueprint.Singleton { |
| 606 | return &buildTargetSingleton{} |
| 607 | } |
| 608 | |
| 609 | type buildTargetSingleton struct{} |
| 610 | |
| 611 | func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) { |
| 612 | checkbuildDeps := []string{} |
| 613 | |
| 614 | dirModules := make(map[string][]string) |
| 615 | |
| 616 | ctx.VisitAllModules(func(module blueprint.Module) { |
| 617 | if a, ok := module.(AndroidModule); ok { |
| 618 | blueprintDir := a.base().blueprintDir |
| 619 | installTarget := a.base().installTarget |
| 620 | checkbuildTarget := a.base().checkbuildTarget |
| 621 | |
| 622 | if checkbuildTarget != "" { |
| 623 | checkbuildDeps = append(checkbuildDeps, checkbuildTarget) |
| 624 | dirModules[blueprintDir] = append(dirModules[blueprintDir], checkbuildTarget) |
| 625 | } |
| 626 | |
| 627 | if installTarget != "" { |
| 628 | dirModules[blueprintDir] = append(dirModules[blueprintDir], installTarget) |
| 629 | } |
| 630 | } |
| 631 | }) |
| 632 | |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 633 | suffix := "" |
| 634 | if ctx.Config().(Config).EmbeddedInMake() { |
| 635 | suffix = "-soong" |
| 636 | } |
| 637 | |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 638 | // Create a top-level checkbuild target that depends on all modules |
| 639 | ctx.Build(pctx, blueprint.BuildParams{ |
| 640 | Rule: blueprint.Phony, |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 641 | Outputs: []string{"checkbuild" + suffix}, |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 642 | Implicits: checkbuildDeps, |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 643 | Optional: true, |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 644 | }) |
| 645 | |
| 646 | // Create a mm/<directory> target that depends on all modules in a directory |
| 647 | dirs := sortedKeys(dirModules) |
| 648 | for _, dir := range dirs { |
| 649 | ctx.Build(pctx, blueprint.BuildParams{ |
| 650 | Rule: blueprint.Phony, |
| 651 | Outputs: []string{filepath.Join("mm", dir)}, |
| 652 | Implicits: dirModules[dir], |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 653 | // HACK: checkbuild should be an optional build, but force it |
| 654 | // enabled for now in standalone builds |
Colin Cross | 1604ecf | 2015-12-17 16:33:43 -0800 | [diff] [blame] | 655 | Optional: ctx.Config().(Config).EmbeddedInMake(), |
Colin Cross | 1f8c52b | 2015-06-16 16:38:17 -0700 | [diff] [blame] | 656 | }) |
| 657 | } |
| 658 | } |
Colin Cross | d779da4 | 2015-12-17 18:00:23 -0800 | [diff] [blame] | 659 | |
| 660 | type AndroidModulesByName struct { |
| 661 | slice []AndroidModule |
| 662 | ctx interface { |
| 663 | ModuleName(blueprint.Module) string |
| 664 | ModuleSubDir(blueprint.Module) string |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | func (s AndroidModulesByName) Len() int { return len(s.slice) } |
| 669 | func (s AndroidModulesByName) Less(i, j int) bool { |
| 670 | mi, mj := s.slice[i], s.slice[j] |
| 671 | ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj) |
| 672 | |
| 673 | if ni != nj { |
| 674 | return ni < nj |
| 675 | } else { |
| 676 | return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj) |
| 677 | } |
| 678 | } |
| 679 | func (s AndroidModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] } |