Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 1 | // Copyright (C) 2017 The Android Open Source Project |
| 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 hidl |
| 16 | |
| 17 | import ( |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 18 | "fmt" |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 19 | "sort" |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 20 | "strings" |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 21 | "sync" |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 22 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 23 | "github.com/google/blueprint" |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 24 | "github.com/google/blueprint/proptools" |
| 25 | |
| 26 | "android/soong/android" |
| 27 | "android/soong/cc" |
| 28 | "android/soong/genrule" |
| 29 | "android/soong/java" |
| 30 | ) |
| 31 | |
| 32 | var ( |
| 33 | hidlInterfaceSuffix = "_interface" |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 34 | |
| 35 | pctx = android.NewPackageContext("android/hidl") |
| 36 | |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 37 | hidl = pctx.HostBinToolVariable("hidl", "hidl-gen") |
| 38 | vtsc = pctx.HostBinToolVariable("vtsc", "vtsc") |
| 39 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 40 | hidlRule = pctx.StaticRule("hidlRule", blueprint.RuleParams{ |
| 41 | Depfile: "${depfile}", |
| 42 | Deps: blueprint.DepsGCC, |
Steven Moreland | bc98bdb | 2018-10-31 14:47:07 -0700 | [diff] [blame] | 43 | Command: "rm -rf ${genDir} && ${hidl} -R -p . -d ${depfile} -o ${genDir} -L ${language} ${roots} ${fqName}", |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 44 | CommandDeps: []string{"${hidl}"}, |
| 45 | Description: "HIDL ${language}: ${in} => ${out}", |
| 46 | }, "depfile", "fqName", "genDir", "language", "roots") |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 47 | |
| 48 | vtsRule = pctx.StaticRule("vtsRule", blueprint.RuleParams{ |
| 49 | Command: "rm -rf ${genDir} && ${vtsc} -m${mode} -t${type} ${inputDir}/${packagePath} ${genDir}/${packagePath}", |
| 50 | CommandDeps: []string{"${vtsc}"}, |
| 51 | Description: "VTS ${mode} ${type}: ${in} => ${out}", |
| 52 | }, "mode", "type", "inputDir", "genDir", "packagePath") |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 53 | ) |
| 54 | |
| 55 | func init() { |
| 56 | android.RegisterModuleType("hidl_interface", hidlInterfaceFactory) |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 57 | android.RegisterMakeVarsProvider(pctx, makeVarsProvider) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 60 | type hidlGenProperties struct { |
| 61 | Language string |
| 62 | FqName string |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 63 | Root string |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 64 | Interfaces []string |
| 65 | Inputs []string |
| 66 | Outputs []string |
| 67 | } |
| 68 | |
| 69 | type hidlGenRule struct { |
| 70 | android.ModuleBase |
| 71 | |
| 72 | properties hidlGenProperties |
| 73 | |
| 74 | genOutputDir android.Path |
| 75 | genInputs android.Paths |
| 76 | genOutputs android.WritablePaths |
| 77 | } |
| 78 | |
| 79 | var _ android.SourceFileProducer = (*hidlGenRule)(nil) |
| 80 | var _ genrule.SourceFileGenerator = (*hidlGenRule)(nil) |
| 81 | |
| 82 | func (g *hidlGenRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 83 | g.genOutputDir = android.PathForModuleGen(ctx) |
| 84 | |
| 85 | for _, input := range g.properties.Inputs { |
| 86 | g.genInputs = append(g.genInputs, android.PathForModuleSrc(ctx, input)) |
| 87 | } |
| 88 | |
| 89 | for _, output := range g.properties.Outputs { |
| 90 | g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, output)) |
| 91 | } |
| 92 | |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 93 | if g.properties.Language == "vts" && isVtsSpecPackage(ctx.ModuleName()) { |
| 94 | vtsList := vtsList(ctx.AConfig()) |
| 95 | vtsListMutex.Lock() |
| 96 | *vtsList = append(*vtsList, g.genOutputs.Paths()...) |
| 97 | vtsListMutex.Unlock() |
| 98 | } |
| 99 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 100 | var fullRootOptions []string |
Steven Moreland | 9ae68ab | 2019-01-16 14:04:08 -0800 | [diff] [blame] | 101 | var currentPath android.OptionalPath |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 102 | ctx.VisitDirectDeps(func(dep android.Module) { |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 103 | switch t := dep.(type) { |
| 104 | case *hidlInterface: |
| 105 | fullRootOptions = append(fullRootOptions, t.properties.Full_root_option) |
| 106 | case *hidlPackageRoot: |
Steven Moreland | 9ae68ab | 2019-01-16 14:04:08 -0800 | [diff] [blame] | 107 | if currentPath.Valid() { |
| 108 | panic(fmt.Sprintf("Expecting only one path, but found %v %v", currentPath, t.getCurrentPath())) |
| 109 | } |
| 110 | |
| 111 | currentPath = t.getCurrentPath() |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 112 | default: |
| 113 | panic(fmt.Sprintf("Unrecognized hidlGenProperties dependency: %T", t)) |
| 114 | } |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 115 | }) |
| 116 | |
| 117 | fullRootOptions = android.FirstUniqueStrings(fullRootOptions) |
| 118 | |
Steven Moreland | 9ae68ab | 2019-01-16 14:04:08 -0800 | [diff] [blame] | 119 | inputs := g.genInputs |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 120 | if currentPath.Valid() { |
Steven Moreland | 9ae68ab | 2019-01-16 14:04:08 -0800 | [diff] [blame] | 121 | inputs = append(inputs, currentPath.Path()) |
| 122 | } |
| 123 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 124 | ctx.ModuleBuild(pctx, android.ModuleBuildParams{ |
| 125 | Rule: hidlRule, |
Steven Moreland | 9ae68ab | 2019-01-16 14:04:08 -0800 | [diff] [blame] | 126 | Inputs: inputs, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 127 | Output: g.genOutputs[0], |
| 128 | ImplicitOutputs: g.genOutputs[1:], |
| 129 | Args: map[string]string{ |
| 130 | "depfile": g.genOutputs[0].String() + ".d", |
| 131 | "genDir": g.genOutputDir.String(), |
| 132 | "fqName": g.properties.FqName, |
| 133 | "language": g.properties.Language, |
| 134 | "roots": strings.Join(fullRootOptions, " "), |
| 135 | }, |
| 136 | }) |
| 137 | } |
| 138 | |
| 139 | func (g *hidlGenRule) GeneratedSourceFiles() android.Paths { |
| 140 | return g.genOutputs.Paths() |
| 141 | } |
| 142 | |
| 143 | func (g *hidlGenRule) Srcs() android.Paths { |
| 144 | return g.genOutputs.Paths() |
| 145 | } |
| 146 | |
| 147 | func (g *hidlGenRule) GeneratedDeps() android.Paths { |
| 148 | return g.genOutputs.Paths() |
| 149 | } |
| 150 | |
| 151 | func (g *hidlGenRule) GeneratedHeaderDirs() android.Paths { |
| 152 | return android.Paths{g.genOutputDir} |
| 153 | } |
| 154 | |
| 155 | func (g *hidlGenRule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 156 | ctx.AddDependency(ctx.Module(), nil, g.properties.FqName+hidlInterfaceSuffix) |
| 157 | ctx.AddDependency(ctx.Module(), nil, wrap("", g.properties.Interfaces, hidlInterfaceSuffix)...) |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 158 | ctx.AddDependency(ctx.Module(), nil, g.properties.Root) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | func hidlGenFactory() android.Module { |
| 162 | g := &hidlGenRule{} |
| 163 | g.AddProperties(&g.properties) |
| 164 | android.InitAndroidModule(g) |
| 165 | return g |
| 166 | } |
| 167 | |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 168 | type vtscProperties struct { |
| 169 | Mode string |
| 170 | Type string |
| 171 | SpecName string // e.g. foo-vts.spec |
| 172 | Outputs []string |
| 173 | PackagePath string // e.g. android/hardware/foo/1.0/ |
| 174 | } |
| 175 | |
| 176 | type vtscRule struct { |
| 177 | android.ModuleBase |
| 178 | |
| 179 | properties vtscProperties |
| 180 | |
| 181 | genOutputDir android.Path |
| 182 | genInputDir android.Path |
| 183 | genInputs android.Paths |
| 184 | genOutputs android.WritablePaths |
| 185 | } |
| 186 | |
| 187 | var _ android.SourceFileProducer = (*vtscRule)(nil) |
| 188 | var _ genrule.SourceFileGenerator = (*vtscRule)(nil) |
| 189 | |
| 190 | func (g *vtscRule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 191 | g.genOutputDir = android.PathForModuleGen(ctx) |
| 192 | |
| 193 | ctx.VisitDirectDeps(func(dep android.Module) { |
| 194 | if specs, ok := dep.(*hidlGenRule); ok { |
| 195 | g.genInputDir = specs.genOutputDir |
| 196 | g.genInputs = specs.genOutputs.Paths() |
| 197 | } |
| 198 | }) |
| 199 | |
| 200 | for _, output := range g.properties.Outputs { |
| 201 | g.genOutputs = append(g.genOutputs, android.PathForModuleGen(ctx, output)) |
| 202 | } |
| 203 | |
| 204 | ctx.ModuleBuild(pctx, android.ModuleBuildParams{ |
| 205 | Rule: vtsRule, |
| 206 | Inputs: g.genInputs, |
| 207 | Outputs: g.genOutputs, |
| 208 | Args: map[string]string{ |
| 209 | "mode": g.properties.Mode, |
| 210 | "type": g.properties.Type, |
| 211 | "inputDir": g.genInputDir.String(), |
| 212 | "genDir": g.genOutputDir.String(), |
| 213 | "packagePath": g.properties.PackagePath, |
| 214 | }, |
| 215 | }) |
| 216 | } |
| 217 | |
| 218 | func (g *vtscRule) GeneratedSourceFiles() android.Paths { |
| 219 | return g.genOutputs.Paths() |
| 220 | } |
| 221 | |
| 222 | func (g *vtscRule) Srcs() android.Paths { |
| 223 | return g.genOutputs.Paths() |
| 224 | } |
| 225 | |
| 226 | func (g *vtscRule) GeneratedDeps() android.Paths { |
| 227 | return g.genOutputs.Paths() |
| 228 | } |
| 229 | |
| 230 | func (g *vtscRule) GeneratedHeaderDirs() android.Paths { |
| 231 | return android.Paths{g.genOutputDir} |
| 232 | } |
| 233 | |
| 234 | func (g *vtscRule) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 235 | ctx.AddDependency(ctx.Module(), nil, g.properties.SpecName) |
| 236 | } |
| 237 | |
| 238 | func vtscFactory() android.Module { |
| 239 | g := &vtscRule{} |
| 240 | g.AddProperties(&g.properties) |
| 241 | android.InitAndroidModule(g) |
| 242 | return g |
| 243 | } |
| 244 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 245 | type hidlInterfaceProperties struct { |
| 246 | // Vndk properties for interface library only. |
| 247 | cc.VndkProperties |
| 248 | |
| 249 | // List of .hal files which compose this interface. |
| 250 | Srcs []string |
| 251 | |
| 252 | // List of hal interface packages that this library depends on. |
| 253 | Interfaces []string |
| 254 | |
| 255 | // Package root for this package, must be a prefix of name |
| 256 | Root string |
| 257 | |
| 258 | // List of non-TypeDef types declared in types.hal. |
| 259 | Types []string |
| 260 | |
| 261 | // Whether to generate the Java library stubs. |
| 262 | // Default: true |
| 263 | Gen_java *bool |
| 264 | |
| 265 | // Whether to generate a Java library containing constants |
| 266 | // expressed by @export annotations in the hal files. |
| 267 | Gen_java_constants bool |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 268 | |
Steven Moreland | 9f7c297 | 2019-03-01 09:56:20 -0800 | [diff] [blame^] | 269 | // Whether to generate VTS-related testing libraries. |
| 270 | Gen_vts *bool |
| 271 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 272 | // example: -randroid.hardware:hardware/interfaces |
| 273 | Full_root_option string `blueprint:"mutated"` |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 276 | // TODO(b/119771576): These properties are shared by all Android modules, and we are specifically |
| 277 | // calling these out to be copied to every create module. However, if a new property is added, it |
| 278 | // could break things because this code has no way to know about that. |
| 279 | type manuallyInheritCommonProperties struct { |
| 280 | Enabled *bool |
| 281 | Compile_multilib *string |
| 282 | Target struct { |
| 283 | Host struct { |
| 284 | Compile_multilib *string |
| 285 | } |
| 286 | Android struct { |
| 287 | Compile_multilib *string |
| 288 | } |
| 289 | } |
| 290 | Proprietary *bool |
| 291 | Owner *string |
| 292 | Vendor *bool |
| 293 | Soc_specific *bool |
| 294 | Device_specific *bool |
| 295 | Product_specific *bool |
| 296 | Product_services_specific *bool |
| 297 | Recovery *bool |
| 298 | Init_rc []string |
| 299 | Vintf_fragments []string |
| 300 | Required []string |
| 301 | Notice *string |
| 302 | Dist struct { |
| 303 | Targets []string |
| 304 | Dest *string |
| 305 | Dir *string |
| 306 | Suffix *string |
| 307 | } |
| 308 | } |
| 309 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 310 | type hidlInterface struct { |
| 311 | android.ModuleBase |
| 312 | |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 313 | properties hidlInterfaceProperties |
| 314 | inheritCommonProperties manuallyInheritCommonProperties |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 317 | func processSources(mctx android.LoadHookContext, srcs []string) ([]string, []string, bool) { |
| 318 | var interfaces []string |
| 319 | var types []string // hidl-gen only supports types.hal, but don't assume that here |
| 320 | |
| 321 | hasError := false |
| 322 | |
| 323 | for _, v := range srcs { |
| 324 | if !strings.HasSuffix(v, ".hal") { |
| 325 | mctx.PropertyErrorf("srcs", "Source must be a .hal file: "+v) |
| 326 | hasError = true |
| 327 | continue |
| 328 | } |
| 329 | |
| 330 | name := strings.TrimSuffix(v, ".hal") |
| 331 | |
| 332 | if strings.HasPrefix(name, "I") { |
| 333 | baseName := strings.TrimPrefix(name, "I") |
| 334 | interfaces = append(interfaces, baseName) |
| 335 | } else { |
| 336 | types = append(types, name) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return interfaces, types, !hasError |
| 341 | } |
| 342 | |
| 343 | func processDependencies(mctx android.LoadHookContext, interfaces []string) ([]string, []string, bool) { |
| 344 | var dependencies []string |
| 345 | var javaDependencies []string |
| 346 | |
| 347 | hasError := false |
| 348 | |
| 349 | for _, v := range interfaces { |
| 350 | name, err := parseFqName(v) |
| 351 | if err != nil { |
| 352 | mctx.PropertyErrorf("interfaces", err.Error()) |
| 353 | hasError = true |
| 354 | continue |
| 355 | } |
| 356 | dependencies = append(dependencies, name.string()) |
| 357 | javaDependencies = append(javaDependencies, name.javaName()) |
| 358 | } |
| 359 | |
| 360 | return dependencies, javaDependencies, !hasError |
| 361 | } |
| 362 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 363 | func removeCoreDependencies(mctx android.LoadHookContext, dependencies []string) []string { |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 364 | var ret []string |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 365 | |
| 366 | for _, i := range dependencies { |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 367 | if !isCorePackage(i) { |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 368 | ret = append(ret, i) |
| 369 | } |
| 370 | } |
| 371 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 372 | return ret |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | func hidlInterfaceMutator(mctx android.LoadHookContext, i *hidlInterface) { |
| 376 | name, err := parseFqName(i.ModuleBase.Name()) |
| 377 | if err != nil { |
| 378 | mctx.PropertyErrorf("name", err.Error()) |
| 379 | } |
| 380 | |
| 381 | if !name.inPackage(i.properties.Root) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 382 | mctx.PropertyErrorf("root", i.properties.Root+" must be a prefix of "+name.string()+".") |
| 383 | } |
| 384 | if lookupPackageRoot(i.properties.Root) == nil { |
| 385 | mctx.PropertyErrorf("interfaces", `Cannot find package root specification for package `+ |
| 386 | `root '%s' needed for module '%s'. Either this is a mispelling of the package `+ |
| 387 | `root, or a new hidl_package_root module needs to be added. For example, you can `+ |
| 388 | `fix this error by adding the following to <some path>/Android.bp: |
| 389 | |
| 390 | hidl_package_root { |
| 391 | name: "%s", |
| 392 | path: "<some path>", |
| 393 | } |
| 394 | |
| 395 | This corresponds to the "-r%s:<some path>" option that would be passed into hidl-gen.`, |
| 396 | i.properties.Root, name, i.properties.Root, i.properties.Root) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | interfaces, types, _ := processSources(mctx, i.properties.Srcs) |
| 400 | |
| 401 | if len(interfaces) == 0 && len(types) == 0 { |
| 402 | mctx.PropertyErrorf("srcs", "No sources provided.") |
| 403 | } |
| 404 | |
| 405 | dependencies, javaDependencies, _ := processDependencies(mctx, i.properties.Interfaces) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 406 | cppDependencies := removeCoreDependencies(mctx, dependencies) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 407 | |
| 408 | if mctx.Failed() { |
| 409 | return |
| 410 | } |
| 411 | |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 412 | shouldGenerateLibrary := !isCorePackage(name.string()) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 413 | // explicitly true if not specified to give early warning to devs |
Steven Moreland | 9f7c297 | 2019-03-01 09:56:20 -0800 | [diff] [blame^] | 414 | shouldGenerateJava := proptools.BoolDefault(i.properties.Gen_java, true) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 415 | shouldGenerateJavaConstants := i.properties.Gen_java_constants |
Steven Moreland | 9f7c297 | 2019-03-01 09:56:20 -0800 | [diff] [blame^] | 416 | shouldGenerateVts := shouldGenerateLibrary && proptools.BoolDefault(i.properties.Gen_vts, true) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 417 | |
| 418 | var libraryIfExists []string |
| 419 | if shouldGenerateLibrary { |
| 420 | libraryIfExists = []string{name.string()} |
| 421 | } |
| 422 | |
| 423 | // TODO(b/69002743): remove filegroups |
Pirama Arumuga Nainar | f43bb1e | 2018-04-18 11:34:56 -0700 | [diff] [blame] | 424 | mctx.CreateModule(android.ModuleFactoryAdaptor(android.FileGroupFactory), &fileGroupProperties{ |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 425 | Name: proptools.StringPtr(name.fileGroupName()), |
| 426 | Srcs: i.properties.Srcs, |
| 427 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 428 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 429 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 430 | Name: proptools.StringPtr(name.sourcesName()), |
| 431 | }, &hidlGenProperties{ |
| 432 | Language: "c++-sources", |
| 433 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 434 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 435 | Interfaces: i.properties.Interfaces, |
| 436 | Inputs: i.properties.Srcs, |
| 437 | Outputs: concat(wrap(name.dir(), interfaces, "All.cpp"), wrap(name.dir(), types, ".cpp")), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 438 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 439 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 440 | Name: proptools.StringPtr(name.headersName()), |
| 441 | }, &hidlGenProperties{ |
| 442 | Language: "c++-headers", |
| 443 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 444 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 445 | Interfaces: i.properties.Interfaces, |
| 446 | Inputs: i.properties.Srcs, |
| 447 | Outputs: concat(wrap(name.dir()+"I", interfaces, ".h"), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 448 | wrap(name.dir()+"Bs", interfaces, ".h"), |
| 449 | wrap(name.dir()+"BnHw", interfaces, ".h"), |
| 450 | wrap(name.dir()+"BpHw", interfaces, ".h"), |
| 451 | wrap(name.dir()+"IHw", interfaces, ".h"), |
| 452 | wrap(name.dir(), types, ".h"), |
| 453 | wrap(name.dir()+"hw", types, ".h")), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 454 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 455 | |
| 456 | if shouldGenerateLibrary { |
| 457 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
Jerry Zhang | f2a9396 | 2018-05-30 17:16:05 -0700 | [diff] [blame] | 458 | Name: proptools.StringPtr(name.string()), |
Jerry Zhang | f2a9396 | 2018-05-30 17:16:05 -0700 | [diff] [blame] | 459 | Recovery_available: proptools.BoolPtr(true), |
| 460 | Vendor_available: proptools.BoolPtr(true), |
| 461 | Double_loadable: proptools.BoolPtr(isDoubleLoadable(name.string())), |
| 462 | Defaults: []string{"hidl-module-defaults"}, |
| 463 | Generated_sources: []string{name.sourcesName()}, |
| 464 | Generated_headers: []string{name.headersName()}, |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 465 | Shared_libs: concat(cppDependencies, []string{ |
| 466 | "libhidlbase", |
| 467 | "libhidltransport", |
| 468 | "libhwbinder", |
| 469 | "liblog", |
| 470 | "libutils", |
| 471 | "libcutils", |
| 472 | }), |
| 473 | Export_shared_lib_headers: concat(cppDependencies, []string{ |
| 474 | "libhidlbase", |
| 475 | "libhidltransport", |
| 476 | "libhwbinder", |
| 477 | "libutils", |
| 478 | }), |
| 479 | Export_generated_headers: []string{name.headersName()}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 480 | }, &i.properties.VndkProperties, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | if shouldGenerateJava { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 484 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 485 | Name: proptools.StringPtr(name.javaSourcesName()), |
| 486 | }, &hidlGenProperties{ |
| 487 | Language: "java", |
| 488 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 489 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 490 | Interfaces: i.properties.Interfaces, |
| 491 | Inputs: i.properties.Srcs, |
| 492 | Outputs: concat(wrap(name.sanitizedDir()+"I", interfaces, ".java"), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 493 | wrap(name.sanitizedDir(), i.properties.Types, ".java")), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 494 | }, &i.inheritCommonProperties) |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 495 | mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 496 | Name: proptools.StringPtr(name.javaName()), |
| 497 | Defaults: []string{"hidl-java-module-defaults"}, |
| 498 | No_framework_libs: proptools.BoolPtr(true), |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 499 | Installable: proptools.BoolPtr(true), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 500 | Srcs: []string{":" + name.javaSourcesName()}, |
Steven Moreland | fcfbeaf | 2018-01-29 19:34:52 -0800 | [diff] [blame] | 501 | Static_libs: javaDependencies, |
Colin Cross | a505055 | 2018-03-29 10:30:03 -0700 | [diff] [blame] | 502 | |
| 503 | // This should ideally be system_current, but android.hidl.base-V1.0-java is used |
| 504 | // to build framework, which is used to build system_current. Use core_current |
| 505 | // plus hwbinder.stubs, which together form a subset of system_current that does |
| 506 | // not depend on framework. |
| 507 | Sdk_version: proptools.StringPtr("core_current"), |
| 508 | Libs: []string{"hwbinder.stubs"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 509 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | if shouldGenerateJavaConstants { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 513 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 514 | Name: proptools.StringPtr(name.javaConstantsSourcesName()), |
| 515 | }, &hidlGenProperties{ |
| 516 | Language: "java-constants", |
| 517 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 518 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 519 | Interfaces: i.properties.Interfaces, |
| 520 | Inputs: i.properties.Srcs, |
| 521 | Outputs: []string{name.sanitizedDir() + "Constants.java"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 522 | }, &i.inheritCommonProperties) |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 523 | mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 524 | Name: proptools.StringPtr(name.javaConstantsName()), |
| 525 | Defaults: []string{"hidl-java-module-defaults"}, |
| 526 | No_framework_libs: proptools.BoolPtr(true), |
| 527 | Srcs: []string{":" + name.javaConstantsSourcesName()}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 528 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 531 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 532 | Name: proptools.StringPtr(name.adapterHelperSourcesName()), |
| 533 | }, &hidlGenProperties{ |
| 534 | Language: "c++-adapter-sources", |
| 535 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 536 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 537 | Interfaces: i.properties.Interfaces, |
| 538 | Inputs: i.properties.Srcs, |
| 539 | Outputs: wrap(name.dir()+"A", concat(interfaces, types), ".cpp"), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 540 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 541 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 542 | Name: proptools.StringPtr(name.adapterHelperHeadersName()), |
| 543 | }, &hidlGenProperties{ |
| 544 | Language: "c++-adapter-headers", |
| 545 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 546 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 547 | Interfaces: i.properties.Interfaces, |
| 548 | Inputs: i.properties.Srcs, |
| 549 | Outputs: wrap(name.dir()+"A", concat(interfaces, types), ".h"), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 550 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 551 | |
| 552 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 553 | Name: proptools.StringPtr(name.adapterHelperName()), |
| 554 | Vendor_available: proptools.BoolPtr(true), |
| 555 | Defaults: []string{"hidl-module-defaults"}, |
| 556 | Generated_sources: []string{name.adapterHelperSourcesName()}, |
| 557 | Generated_headers: []string{name.adapterHelperHeadersName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 558 | Shared_libs: []string{ |
Steven Moreland | d90bdaa | 2018-01-03 11:12:43 -0800 | [diff] [blame] | 559 | "libbase", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 560 | "libcutils", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 561 | "libhidlbase", |
| 562 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 563 | "libhwbinder", |
| 564 | "liblog", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 565 | "libutils", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 566 | }, |
| 567 | Static_libs: concat([]string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 568 | "libhidladapter", |
| 569 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 570 | Export_shared_lib_headers: []string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 571 | "libhidlbase", |
| 572 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 573 | }, |
| 574 | Export_static_lib_headers: concat([]string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 575 | "libhidladapter", |
| 576 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
| 577 | Export_generated_headers: []string{name.adapterHelperHeadersName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 578 | Group_static_libs: proptools.BoolPtr(true), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 579 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 580 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 581 | Name: proptools.StringPtr(name.adapterSourcesName()), |
| 582 | }, &hidlGenProperties{ |
| 583 | Language: "c++-adapter-main", |
| 584 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 585 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 586 | Interfaces: i.properties.Interfaces, |
| 587 | Inputs: i.properties.Srcs, |
| 588 | Outputs: []string{"main.cpp"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 589 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 590 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.TestFactory), &ccProperties{ |
| 591 | Name: proptools.StringPtr(name.adapterName()), |
| 592 | Generated_sources: []string{name.adapterSourcesName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 593 | Shared_libs: []string{ |
Steven Moreland | d90bdaa | 2018-01-03 11:12:43 -0800 | [diff] [blame] | 594 | "libbase", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 595 | "libcutils", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 596 | "libhidlbase", |
| 597 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 598 | "libhwbinder", |
| 599 | "liblog", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 600 | "libutils", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 601 | }, |
| 602 | Static_libs: concat([]string{ |
| 603 | "libhidladapter", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 604 | name.adapterHelperName(), |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 605 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
| 606 | Group_static_libs: proptools.BoolPtr(true), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 607 | }, &i.inheritCommonProperties) |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 608 | |
| 609 | if shouldGenerateVts { |
| 610 | vtsSpecs := concat(wrap(name.dir(), interfaces, ".vts"), wrap(name.dir(), types, ".vts")) |
| 611 | |
| 612 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 613 | Name: proptools.StringPtr(name.vtsSpecName()), |
| 614 | }, &hidlGenProperties{ |
| 615 | Language: "vts", |
| 616 | FqName: name.string(), |
| 617 | Root: i.properties.Root, |
| 618 | Interfaces: i.properties.Interfaces, |
| 619 | Inputs: i.properties.Srcs, |
| 620 | Outputs: vtsSpecs, |
| 621 | }, &i.inheritCommonProperties) |
| 622 | |
| 623 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 624 | Name: proptools.StringPtr(name.vtsDriverSourcesName()), |
| 625 | }, &vtscProperties{ |
| 626 | Mode: "DRIVER", |
| 627 | Type: "SOURCE", |
| 628 | SpecName: name.vtsSpecName(), |
| 629 | Outputs: wrap("", vtsSpecs, ".cpp"), |
| 630 | PackagePath: name.dir(), |
| 631 | }, &i.inheritCommonProperties) |
| 632 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 633 | Name: proptools.StringPtr(name.vtsDriverHeadersName()), |
| 634 | }, &vtscProperties{ |
| 635 | Mode: "DRIVER", |
| 636 | Type: "HEADER", |
| 637 | SpecName: name.vtsSpecName(), |
| 638 | Outputs: wrap("", vtsSpecs, ".h"), |
| 639 | PackagePath: name.dir(), |
| 640 | }, &i.inheritCommonProperties) |
| 641 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 642 | Name: proptools.StringPtr(name.vtsDriverName()), |
| 643 | Defaults: []string{"VtsHalDriverDefaults"}, |
| 644 | Generated_sources: []string{name.vtsDriverSourcesName()}, |
| 645 | Generated_headers: []string{name.vtsDriverHeadersName()}, |
| 646 | Export_generated_headers: []string{name.vtsDriverHeadersName()}, |
| 647 | Shared_libs: wrap("", cppDependencies, "-vts.driver"), |
| 648 | Export_shared_lib_headers: wrap("", cppDependencies, "-vts.driver"), |
| 649 | Static_libs: concat(cppDependencies, libraryIfExists), |
| 650 | |
| 651 | // TODO(b/126244142) |
| 652 | Cflags: []string{"-Wno-unused-variable"}, |
| 653 | }, &i.inheritCommonProperties) |
| 654 | |
| 655 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 656 | Name: proptools.StringPtr(name.vtsProfilerSourcesName()), |
| 657 | }, &vtscProperties{ |
| 658 | Mode: "PROFILER", |
| 659 | Type: "SOURCE", |
| 660 | SpecName: name.vtsSpecName(), |
| 661 | Outputs: wrap("", vtsSpecs, ".cpp"), |
| 662 | PackagePath: name.dir(), |
| 663 | }, &i.inheritCommonProperties) |
| 664 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 665 | Name: proptools.StringPtr(name.vtsProfilerHeadersName()), |
| 666 | }, &vtscProperties{ |
| 667 | Mode: "PROFILER", |
| 668 | Type: "HEADER", |
| 669 | SpecName: name.vtsSpecName(), |
| 670 | Outputs: wrap("", vtsSpecs, ".h"), |
| 671 | PackagePath: name.dir(), |
| 672 | }, &i.inheritCommonProperties) |
| 673 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 674 | Name: proptools.StringPtr(name.vtsProfilerName()), |
| 675 | Defaults: []string{"VtsHalProfilerDefaults"}, |
| 676 | Generated_sources: []string{name.vtsProfilerSourcesName()}, |
| 677 | Generated_headers: []string{name.vtsProfilerHeadersName()}, |
| 678 | Export_generated_headers: []string{name.vtsProfilerHeadersName()}, |
| 679 | Shared_libs: wrap("", cppDependencies, "-vts.profiler"), |
| 680 | Export_shared_lib_headers: wrap("", cppDependencies, "-vts.profiler"), |
| 681 | Static_libs: concat(cppDependencies, libraryIfExists), |
| 682 | |
| 683 | // TODO(b/126244142) |
| 684 | Cflags: []string{"-Wno-unused-variable"}, |
| 685 | }, &i.inheritCommonProperties) |
| 686 | } |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | func (h *hidlInterface) Name() string { |
| 690 | return h.ModuleBase.Name() + hidlInterfaceSuffix |
| 691 | } |
| 692 | func (h *hidlInterface) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 693 | visited := false |
| 694 | ctx.VisitDirectDeps(func(dep android.Module) { |
| 695 | if visited { |
| 696 | panic("internal error, multiple dependencies found but only one added") |
| 697 | } |
| 698 | visited = true |
Steven Moreland | 136abb8 | 2018-11-08 17:27:42 -0800 | [diff] [blame] | 699 | h.properties.Full_root_option = dep.(*hidlPackageRoot).getFullPackageRoot() |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 700 | }) |
| 701 | if !visited { |
| 702 | panic("internal error, no dependencies found but dependency added") |
| 703 | } |
| 704 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 705 | } |
| 706 | func (h *hidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 707 | ctx.AddDependency(ctx.Module(), nil, h.properties.Root) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 708 | } |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 709 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 710 | func hidlInterfaceFactory() android.Module { |
| 711 | i := &hidlInterface{} |
| 712 | i.AddProperties(&i.properties) |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 713 | i.AddProperties(&i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 714 | android.InitAndroidModule(i) |
| 715 | android.AddLoadHook(i, func(ctx android.LoadHookContext) { hidlInterfaceMutator(ctx, i) }) |
| 716 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 717 | return i |
| 718 | } |
| 719 | |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 720 | var doubleLoadablePackageNames = []string{ |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 721 | "android.hardware.cas@1.0", |
| 722 | "android.hardware.cas.native@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 723 | "android.hardware.configstore@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 724 | "android.hardware.drm@1.0", |
| 725 | "android.hardware.drm@1.1", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 726 | "android.hardware.graphics.allocator@", |
| 727 | "android.hardware.graphics.bufferqueue@", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 728 | "android.hardware.media@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 729 | "android.hardware.media.omx@", |
| 730 | "android.hardware.memtrack@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 731 | "android.hardware.neuralnetworks@", |
| 732 | "android.hidl.allocator@", |
| 733 | "android.hidl.token@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 734 | "android.system.suspend@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | func isDoubleLoadable(name string) bool { |
| 738 | for _, pkgname := range doubleLoadablePackageNames { |
| 739 | if strings.HasPrefix(name, pkgname) { |
| 740 | return true |
| 741 | } |
| 742 | } |
| 743 | return false |
| 744 | } |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 745 | |
| 746 | // packages in libhidltransport |
| 747 | var coreDependencyPackageNames = []string{ |
| 748 | "android.hidl.base@", |
| 749 | "android.hidl.manager@", |
| 750 | } |
| 751 | |
| 752 | func isCorePackage(name string) bool { |
| 753 | for _, pkgname := range coreDependencyPackageNames { |
| 754 | if strings.HasPrefix(name, pkgname) { |
| 755 | return true |
| 756 | } |
| 757 | } |
| 758 | return false |
| 759 | } |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame] | 760 | |
| 761 | // TODO(b/126383715): centralize this logic/support filtering in core VTS build |
| 762 | var coreVtsSpecs = []string{ |
| 763 | "android.frameworks.", |
| 764 | "android.hardware.", |
| 765 | "android.hidl.", |
| 766 | "android.system.", |
| 767 | } |
| 768 | |
| 769 | func isVtsSpecPackage(name string) bool { |
| 770 | for _, pkgname := range coreVtsSpecs { |
| 771 | if strings.HasPrefix(name, pkgname) { |
| 772 | return true |
| 773 | } |
| 774 | } |
| 775 | return false |
| 776 | } |
| 777 | |
| 778 | var vtsListKey = android.NewOnceKey("vtsList") |
| 779 | |
| 780 | func vtsList(config android.Config) *android.Paths { |
| 781 | return config.Once(vtsListKey, func() interface{} { |
| 782 | return &android.Paths{} |
| 783 | }).(*android.Paths) |
| 784 | } |
| 785 | |
| 786 | var vtsListMutex sync.Mutex |
| 787 | |
| 788 | func makeVarsProvider(ctx android.MakeVarsContext) { |
| 789 | vtsList := vtsList(ctx.Config()).Strings() |
| 790 | sort.Strings(vtsList) |
| 791 | |
| 792 | ctx.Strict("VTS_SPEC_FILE_LIST", strings.Join(vtsList, " ")) |
| 793 | } |