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 | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 18 | "path/filepath" |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 19 | |
| 20 | "github.com/google/blueprint" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 21 | ) |
| 22 | |
| 23 | var ( |
| 24 | DeviceSharedLibrary = "shared_library" |
| 25 | DeviceStaticLibrary = "static_library" |
| 26 | DeviceExecutable = "executable" |
| 27 | HostSharedLibrary = "host_shared_library" |
| 28 | HostStaticLibrary = "host_static_library" |
| 29 | HostExecutable = "host_executable" |
| 30 | ) |
| 31 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 32 | type androidBaseContext interface { |
| 33 | Arch() Arch |
| 34 | Host() bool |
| 35 | Device() bool |
| 36 | Debug() bool |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 37 | AConfig() Config |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | type AndroidBaseContext interface { |
| 41 | blueprint.BaseModuleContext |
| 42 | androidBaseContext |
| 43 | } |
| 44 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 45 | type AndroidModuleContext interface { |
| 46 | blueprint.ModuleContext |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 47 | androidBaseContext |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 48 | |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 49 | InstallFile(installPath, srcPath string, deps ...string) string |
| 50 | InstallFileName(installPath, name, srcPath string, deps ...string) string |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 51 | CheckbuildFile(srcPath string) |
| 52 | } |
| 53 | |
| 54 | type AndroidModule interface { |
| 55 | blueprint.Module |
| 56 | |
| 57 | GenerateAndroidBuildActions(AndroidModuleContext) |
| 58 | |
| 59 | base() *AndroidModuleBase |
| 60 | Disabled() bool |
| 61 | HostOrDevice() HostOrDevice |
| 62 | } |
| 63 | |
| 64 | type AndroidDynamicDepender interface { |
| 65 | AndroidDynamicDependencies(ctx AndroidDynamicDependerModuleContext) []string |
| 66 | } |
| 67 | |
| 68 | type AndroidDynamicDependerModuleContext interface { |
| 69 | blueprint.DynamicDependerModuleContext |
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 | } |
| 72 | |
| 73 | type commonProperties struct { |
Colin Cross | c77f9d1 | 2015-04-02 13:54:39 -0700 | [diff] [blame] | 74 | Name string |
| 75 | Deps []string |
| 76 | Tags []string |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 77 | |
| 78 | // disabled: don't emit any build rules for this module |
| 79 | Disabled bool `android:"arch_variant"` |
| 80 | |
| 81 | // multilib: control whether this module compiles for 32-bit, 64-bit, or both. Possible values |
| 82 | // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both |
| 83 | // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit |
| 84 | // platform |
| 85 | Compile_multilib string |
| 86 | |
| 87 | // Set by ArchMutator |
| 88 | CompileArch Arch `blueprint:"mutated"` |
| 89 | |
| 90 | // Set by InitAndroidModule |
| 91 | HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"` |
| 92 | } |
| 93 | |
| 94 | type hostAndDeviceProperties struct { |
| 95 | Host_supported bool |
| 96 | Device_supported bool |
| 97 | } |
| 98 | |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 99 | type Multilib string |
| 100 | |
| 101 | const ( |
Colin Cross | 2fe6687 | 2015-03-30 17:20:39 -0700 | [diff] [blame] | 102 | MultilibBoth Multilib = "both" |
| 103 | MultilibFirst Multilib = "first" |
| 104 | MultilibCommon Multilib = "common" |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 105 | ) |
| 106 | |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 107 | func InitAndroidModule(m AndroidModule, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 108 | propertyStructs ...interface{}) (blueprint.Module, []interface{}) { |
| 109 | |
| 110 | base := m.base() |
| 111 | base.module = m |
Colin Cross | 28d7659 | 2015-03-26 16:14:04 -0700 | [diff] [blame] | 112 | base.extendedProperties = make(map[string]struct{}) |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 113 | |
| 114 | propertyStructs = append(propertyStructs, &base.commonProperties) |
| 115 | |
| 116 | return m, propertyStructs |
| 117 | } |
| 118 | |
| 119 | func InitAndroidArchModule(m AndroidModule, hod HostOrDeviceSupported, defaultMultilib Multilib, |
| 120 | propertyStructs ...interface{}) (blueprint.Module, []interface{}) { |
| 121 | |
| 122 | _, propertyStructs = InitAndroidModule(m, propertyStructs...) |
| 123 | |
| 124 | base := m.base() |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 125 | base.commonProperties.HostOrDeviceSupported = hod |
| 126 | |
| 127 | if hod == HostAndDeviceSupported { |
| 128 | // Default to module to device supported, host not supported, can override in module |
| 129 | // properties |
| 130 | base.hostAndDeviceProperties.Device_supported = true |
| 131 | propertyStructs = append(propertyStructs, &base.hostAndDeviceProperties) |
| 132 | } |
| 133 | |
| 134 | return InitArchModule(m, defaultMultilib, propertyStructs...) |
| 135 | } |
| 136 | |
| 137 | // A AndroidModuleBase object contains the properties that are common to all Android |
| 138 | // modules. It should be included as an anonymous field in every module |
| 139 | // struct definition. InitAndroidModule should then be called from the module's |
| 140 | // factory function, and the return values from InitAndroidModule should be |
| 141 | // returned from the factory function. |
| 142 | // |
| 143 | // The AndroidModuleBase type is responsible for implementing the |
| 144 | // GenerateBuildActions method to support the blueprint.Module interface. This |
| 145 | // method will then call the module's GenerateAndroidBuildActions method once |
| 146 | // for each build variant that is to be built. GenerateAndroidBuildActions is |
| 147 | // passed a AndroidModuleContext rather than the usual blueprint.ModuleContext. |
| 148 | // AndroidModuleContext exposes extra functionality specific to the Android build |
| 149 | // system including details about the particular build variant that is to be |
| 150 | // generated. |
| 151 | // |
| 152 | // For example: |
| 153 | // |
| 154 | // import ( |
| 155 | // "android/soong/common" |
Colin Cross | 70b4059 | 2015-03-23 12:57:34 -0700 | [diff] [blame] | 156 | // "github.com/google/blueprint" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 157 | // ) |
| 158 | // |
| 159 | // type myModule struct { |
| 160 | // common.AndroidModuleBase |
| 161 | // properties struct { |
| 162 | // MyProperty string |
| 163 | // } |
| 164 | // } |
| 165 | // |
| 166 | // func NewMyModule() (blueprint.Module, []interface{}) { |
| 167 | // m := &myModule{} |
| 168 | // return common.InitAndroidModule(m, &m.properties) |
| 169 | // } |
| 170 | // |
| 171 | // func (m *myModule) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { |
| 172 | // // Get the CPU architecture for the current build variant. |
| 173 | // variantArch := ctx.Arch() |
| 174 | // |
| 175 | // // ... |
| 176 | // } |
| 177 | type AndroidModuleBase struct { |
| 178 | // Putting the curiously recurring thing pointing to the thing that contains |
| 179 | // the thing pattern to good use. |
| 180 | module AndroidModule |
| 181 | |
| 182 | commonProperties commonProperties |
| 183 | hostAndDeviceProperties hostAndDeviceProperties |
| 184 | generalProperties []interface{} |
| 185 | archProperties []*archProperties |
Colin Cross | 28d7659 | 2015-03-26 16:14:04 -0700 | [diff] [blame] | 186 | extendedProperties map[string]struct{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 187 | |
| 188 | noAddressSanitizer bool |
| 189 | installFiles []string |
| 190 | checkbuildFiles []string |
| 191 | } |
| 192 | |
| 193 | func (a *AndroidModuleBase) base() *AndroidModuleBase { |
| 194 | return a |
| 195 | } |
| 196 | |
| 197 | func (a *AndroidModuleBase) SetArch(arch Arch) { |
| 198 | a.commonProperties.CompileArch = arch |
| 199 | } |
| 200 | |
| 201 | func (a *AndroidModuleBase) HostOrDevice() HostOrDevice { |
| 202 | return a.commonProperties.CompileArch.HostOrDevice |
| 203 | } |
| 204 | |
| 205 | func (a *AndroidModuleBase) HostSupported() bool { |
| 206 | return a.commonProperties.HostOrDeviceSupported == HostSupported || |
| 207 | a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && |
| 208 | a.hostAndDeviceProperties.Host_supported |
| 209 | } |
| 210 | |
| 211 | func (a *AndroidModuleBase) DeviceSupported() bool { |
| 212 | return a.commonProperties.HostOrDeviceSupported == DeviceSupported || |
| 213 | a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && |
| 214 | a.hostAndDeviceProperties.Device_supported |
| 215 | } |
| 216 | |
| 217 | func (a *AndroidModuleBase) Disabled() bool { |
| 218 | return a.commonProperties.Disabled |
| 219 | } |
| 220 | |
| 221 | func (a *AndroidModuleBase) computeInstallDeps( |
| 222 | ctx blueprint.ModuleContext) []string { |
| 223 | |
| 224 | result := []string{} |
| 225 | ctx.VisitDepsDepthFirstIf(isFileInstaller, |
| 226 | func(m blueprint.Module) { |
| 227 | fileInstaller := m.(fileInstaller) |
| 228 | files := fileInstaller.filesToInstall() |
| 229 | result = append(result, files...) |
| 230 | }) |
| 231 | |
| 232 | return result |
| 233 | } |
| 234 | |
| 235 | func (a *AndroidModuleBase) filesToInstall() []string { |
| 236 | return a.installFiles |
| 237 | } |
| 238 | |
| 239 | func (p *AndroidModuleBase) NoAddressSanitizer() bool { |
| 240 | return p.noAddressSanitizer |
| 241 | } |
| 242 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 243 | func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { |
| 244 | if a != ctx.FinalModule().(AndroidModule).base() { |
| 245 | return |
| 246 | } |
| 247 | |
| 248 | allInstalledFiles := []string{} |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 249 | allCheckbuildFiles := []string{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 250 | ctx.VisitAllModuleVariants(func(module blueprint.Module) { |
Colin Cross | c940435 | 2015-03-26 16:10:12 -0700 | [diff] [blame] | 251 | a := module.(AndroidModule).base() |
| 252 | allInstalledFiles = append(allInstalledFiles, a.installFiles...) |
| 253 | allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 254 | }) |
| 255 | |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 256 | deps := []string{} |
| 257 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 258 | if len(allInstalledFiles) > 0 { |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 259 | name := ctx.ModuleName() + "-install" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 260 | ctx.Build(pctx, blueprint.BuildParams{ |
Colin Cross | 9454bfa | 2015-03-17 13:24:18 -0700 | [diff] [blame] | 261 | Rule: blueprint.Phony, |
| 262 | Outputs: []string{name}, |
| 263 | Implicits: allInstalledFiles, |
| 264 | }) |
| 265 | deps = append(deps, name) |
| 266 | } |
| 267 | |
| 268 | if len(allCheckbuildFiles) > 0 { |
| 269 | name := ctx.ModuleName() + "-checkbuild" |
| 270 | ctx.Build(pctx, blueprint.BuildParams{ |
| 271 | Rule: blueprint.Phony, |
| 272 | Outputs: []string{name}, |
| 273 | Implicits: allCheckbuildFiles, |
| 274 | Optional: true, |
| 275 | }) |
| 276 | deps = append(deps, name) |
| 277 | } |
| 278 | |
| 279 | if len(deps) > 0 { |
| 280 | ctx.Build(pctx, blueprint.BuildParams{ |
| 281 | Rule: blueprint.Phony, |
| 282 | Outputs: []string{ctx.ModuleName()}, |
| 283 | Implicits: deps, |
| 284 | Optional: true, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 285 | }) |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | func (a *AndroidModuleBase) DynamicDependencies(ctx blueprint.DynamicDependerModuleContext) []string { |
| 290 | actx := &androidDynamicDependerContext{ |
| 291 | DynamicDependerModuleContext: ctx, |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 292 | androidBaseContextImpl: androidBaseContextImpl{ |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 293 | arch: a.commonProperties.CompileArch, |
| 294 | config: ctx.Config().(Config), |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 295 | }, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | if dynamic, ok := a.module.(AndroidDynamicDepender); ok { |
| 299 | return dynamic.AndroidDynamicDependencies(actx) |
| 300 | } |
| 301 | |
| 302 | return nil |
| 303 | } |
| 304 | |
| 305 | func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { |
| 306 | androidCtx := &androidModuleContext{ |
| 307 | ModuleContext: ctx, |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 308 | androidBaseContextImpl: androidBaseContextImpl{ |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 309 | arch: a.commonProperties.CompileArch, |
| 310 | config: ctx.Config().(Config), |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 311 | }, |
Colin Cross | 28d7659 | 2015-03-26 16:14:04 -0700 | [diff] [blame] | 312 | installDeps: a.computeInstallDeps(ctx), |
| 313 | installFiles: a.installFiles, |
| 314 | extendedProperties: a.extendedProperties, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | if a.commonProperties.Disabled { |
| 318 | return |
| 319 | } |
| 320 | |
| 321 | a.module.GenerateAndroidBuildActions(androidCtx) |
| 322 | if ctx.Failed() { |
| 323 | return |
| 324 | } |
| 325 | |
Colin Cross | c940435 | 2015-03-26 16:10:12 -0700 | [diff] [blame] | 326 | a.installFiles = append(a.installFiles, androidCtx.installFiles...) |
| 327 | a.checkbuildFiles = append(a.checkbuildFiles, androidCtx.checkbuildFiles...) |
| 328 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 329 | a.generateModuleTarget(ctx) |
| 330 | if ctx.Failed() { |
| 331 | return |
| 332 | } |
| 333 | } |
| 334 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 335 | type androidBaseContextImpl struct { |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 336 | arch Arch |
| 337 | debug bool |
| 338 | config Config |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 341 | type androidModuleContext struct { |
| 342 | blueprint.ModuleContext |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 343 | androidBaseContextImpl |
Colin Cross | 28d7659 | 2015-03-26 16:14:04 -0700 | [diff] [blame] | 344 | installDeps []string |
| 345 | installFiles []string |
| 346 | checkbuildFiles []string |
| 347 | extendedProperties map[string]struct{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | func (a *androidModuleContext) Build(pctx *blueprint.PackageContext, params blueprint.BuildParams) { |
| 351 | params.Optional = true |
| 352 | a.ModuleContext.Build(pctx, params) |
| 353 | } |
| 354 | |
Colin Cross | 28d7659 | 2015-03-26 16:14:04 -0700 | [diff] [blame] | 355 | func (a *androidModuleContext) ContainsProperty(property string) bool { |
| 356 | if a.ModuleContext.ContainsProperty(property) { |
| 357 | return true |
| 358 | } |
| 359 | _, ok := a.extendedProperties[property] |
| 360 | return ok |
| 361 | } |
| 362 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 363 | func (a *androidBaseContextImpl) Arch() Arch { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 364 | return a.arch |
| 365 | } |
| 366 | |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 367 | func (a *androidBaseContextImpl) Host() bool { |
| 368 | return a.arch.HostOrDevice.Host() |
| 369 | } |
| 370 | |
| 371 | func (a *androidBaseContextImpl) Device() bool { |
| 372 | return a.arch.HostOrDevice.Device() |
| 373 | } |
| 374 | |
| 375 | func (a *androidBaseContextImpl) Debug() bool { |
| 376 | return a.debug |
| 377 | } |
| 378 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 379 | func (a *androidBaseContextImpl) AConfig() Config { |
| 380 | return a.config |
| 381 | } |
| 382 | |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 383 | func (a *androidModuleContext) InstallFileName(installPath, name, srcPath string, |
| 384 | deps ...string) string { |
| 385 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 386 | config := a.AConfig() |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 387 | var fullInstallPath string |
| 388 | if a.arch.HostOrDevice.Device() { |
| 389 | // TODO: replace unset with a device name once we have device targeting |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 390 | fullInstallPath = filepath.Join(config.DeviceOut(), "system", |
| 391 | installPath, name) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 392 | } else { |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 393 | fullInstallPath = filepath.Join(config.HostOut(), installPath, name) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 394 | } |
| 395 | |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 396 | deps = append(deps, a.installDeps...) |
| 397 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 398 | a.ModuleContext.Build(pctx, blueprint.BuildParams{ |
| 399 | Rule: Cp, |
| 400 | Outputs: []string{fullInstallPath}, |
| 401 | Inputs: []string{srcPath}, |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 402 | OrderOnly: deps, |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 403 | }) |
| 404 | |
| 405 | a.installFiles = append(a.installFiles, fullInstallPath) |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 406 | return fullInstallPath |
| 407 | } |
| 408 | |
| 409 | func (a *androidModuleContext) InstallFile(installPath, srcPath string, deps ...string) string { |
| 410 | return a.InstallFileName(installPath, filepath.Base(srcPath), srcPath, deps...) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | func (a *androidModuleContext) CheckbuildFile(srcPath string) { |
| 414 | a.checkbuildFiles = append(a.checkbuildFiles, srcPath) |
| 415 | } |
| 416 | |
| 417 | type androidDynamicDependerContext struct { |
| 418 | blueprint.DynamicDependerModuleContext |
Colin Cross | f6566ed | 2015-03-24 11:13:38 -0700 | [diff] [blame] | 419 | androidBaseContextImpl |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | type fileInstaller interface { |
| 423 | filesToInstall() []string |
| 424 | } |
| 425 | |
| 426 | func isFileInstaller(m blueprint.Module) bool { |
| 427 | _, ok := m.(fileInstaller) |
| 428 | return ok |
| 429 | } |
| 430 | |
| 431 | func isAndroidModule(m blueprint.Module) bool { |
| 432 | _, ok := m.(AndroidModule) |
| 433 | return ok |
| 434 | } |
Colin Cross | fce5327 | 2015-04-08 11:21:40 -0700 | [diff] [blame^] | 435 | |
| 436 | func ExpandSources(ctx AndroidModuleContext, srcFiles []string) []string { |
| 437 | prefix := ModuleSrcDir(ctx) |
| 438 | for i, srcFile := range srcFiles { |
| 439 | if srcFile[0] == '-' { |
| 440 | srcFiles[i] = "-" + filepath.Join(prefix, srcFile[1:]) |
| 441 | } else { |
| 442 | srcFiles[i] = filepath.Join(prefix, srcFile) |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | srcFiles = expandGlobs(ctx, srcFiles) |
| 447 | return srcFiles |
| 448 | } |