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 | |
| 269 | // example: -randroid.hardware:hardware/interfaces |
| 270 | Full_root_option string `blueprint:"mutated"` |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 273 | // TODO(b/119771576): These properties are shared by all Android modules, and we are specifically |
| 274 | // calling these out to be copied to every create module. However, if a new property is added, it |
| 275 | // could break things because this code has no way to know about that. |
| 276 | type manuallyInheritCommonProperties struct { |
| 277 | Enabled *bool |
| 278 | Compile_multilib *string |
| 279 | Target struct { |
| 280 | Host struct { |
| 281 | Compile_multilib *string |
| 282 | } |
| 283 | Android struct { |
| 284 | Compile_multilib *string |
| 285 | } |
| 286 | } |
| 287 | Proprietary *bool |
| 288 | Owner *string |
| 289 | Vendor *bool |
| 290 | Soc_specific *bool |
| 291 | Device_specific *bool |
| 292 | Product_specific *bool |
| 293 | Product_services_specific *bool |
| 294 | Recovery *bool |
| 295 | Init_rc []string |
| 296 | Vintf_fragments []string |
| 297 | Required []string |
| 298 | Notice *string |
| 299 | Dist struct { |
| 300 | Targets []string |
| 301 | Dest *string |
| 302 | Dir *string |
| 303 | Suffix *string |
| 304 | } |
| 305 | } |
| 306 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 307 | type hidlInterface struct { |
| 308 | android.ModuleBase |
| 309 | |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 310 | properties hidlInterfaceProperties |
| 311 | inheritCommonProperties manuallyInheritCommonProperties |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 314 | func processSources(mctx android.LoadHookContext, srcs []string) ([]string, []string, bool) { |
| 315 | var interfaces []string |
| 316 | var types []string // hidl-gen only supports types.hal, but don't assume that here |
| 317 | |
| 318 | hasError := false |
| 319 | |
| 320 | for _, v := range srcs { |
| 321 | if !strings.HasSuffix(v, ".hal") { |
| 322 | mctx.PropertyErrorf("srcs", "Source must be a .hal file: "+v) |
| 323 | hasError = true |
| 324 | continue |
| 325 | } |
| 326 | |
| 327 | name := strings.TrimSuffix(v, ".hal") |
| 328 | |
| 329 | if strings.HasPrefix(name, "I") { |
| 330 | baseName := strings.TrimPrefix(name, "I") |
| 331 | interfaces = append(interfaces, baseName) |
| 332 | } else { |
| 333 | types = append(types, name) |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | return interfaces, types, !hasError |
| 338 | } |
| 339 | |
| 340 | func processDependencies(mctx android.LoadHookContext, interfaces []string) ([]string, []string, bool) { |
| 341 | var dependencies []string |
| 342 | var javaDependencies []string |
| 343 | |
| 344 | hasError := false |
| 345 | |
| 346 | for _, v := range interfaces { |
| 347 | name, err := parseFqName(v) |
| 348 | if err != nil { |
| 349 | mctx.PropertyErrorf("interfaces", err.Error()) |
| 350 | hasError = true |
| 351 | continue |
| 352 | } |
| 353 | dependencies = append(dependencies, name.string()) |
| 354 | javaDependencies = append(javaDependencies, name.javaName()) |
| 355 | } |
| 356 | |
| 357 | return dependencies, javaDependencies, !hasError |
| 358 | } |
| 359 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 360 | func removeCoreDependencies(mctx android.LoadHookContext, dependencies []string) []string { |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 361 | var ret []string |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 362 | |
| 363 | for _, i := range dependencies { |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 364 | if !isCorePackage(i) { |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 365 | ret = append(ret, i) |
| 366 | } |
| 367 | } |
| 368 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 369 | return ret |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | func hidlInterfaceMutator(mctx android.LoadHookContext, i *hidlInterface) { |
| 373 | name, err := parseFqName(i.ModuleBase.Name()) |
| 374 | if err != nil { |
| 375 | mctx.PropertyErrorf("name", err.Error()) |
| 376 | } |
| 377 | |
| 378 | if !name.inPackage(i.properties.Root) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 379 | mctx.PropertyErrorf("root", i.properties.Root+" must be a prefix of "+name.string()+".") |
| 380 | } |
| 381 | if lookupPackageRoot(i.properties.Root) == nil { |
| 382 | mctx.PropertyErrorf("interfaces", `Cannot find package root specification for package `+ |
| 383 | `root '%s' needed for module '%s'. Either this is a mispelling of the package `+ |
| 384 | `root, or a new hidl_package_root module needs to be added. For example, you can `+ |
| 385 | `fix this error by adding the following to <some path>/Android.bp: |
| 386 | |
| 387 | hidl_package_root { |
| 388 | name: "%s", |
| 389 | path: "<some path>", |
| 390 | } |
| 391 | |
| 392 | This corresponds to the "-r%s:<some path>" option that would be passed into hidl-gen.`, |
| 393 | i.properties.Root, name, i.properties.Root, i.properties.Root) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | interfaces, types, _ := processSources(mctx, i.properties.Srcs) |
| 397 | |
| 398 | if len(interfaces) == 0 && len(types) == 0 { |
| 399 | mctx.PropertyErrorf("srcs", "No sources provided.") |
| 400 | } |
| 401 | |
| 402 | dependencies, javaDependencies, _ := processDependencies(mctx, i.properties.Interfaces) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 403 | cppDependencies := removeCoreDependencies(mctx, dependencies) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 404 | |
| 405 | if mctx.Failed() { |
| 406 | return |
| 407 | } |
| 408 | |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 409 | shouldGenerateLibrary := !isCorePackage(name.string()) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 410 | // explicitly true if not specified to give early warning to devs |
| 411 | shouldGenerateJava := i.properties.Gen_java == nil || *i.properties.Gen_java |
| 412 | shouldGenerateJavaConstants := i.properties.Gen_java_constants |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame^] | 413 | shouldGenerateVts := shouldGenerateLibrary |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 414 | |
| 415 | var libraryIfExists []string |
| 416 | if shouldGenerateLibrary { |
| 417 | libraryIfExists = []string{name.string()} |
| 418 | } |
| 419 | |
| 420 | // TODO(b/69002743): remove filegroups |
Pirama Arumuga Nainar | f43bb1e | 2018-04-18 11:34:56 -0700 | [diff] [blame] | 421 | mctx.CreateModule(android.ModuleFactoryAdaptor(android.FileGroupFactory), &fileGroupProperties{ |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 422 | Name: proptools.StringPtr(name.fileGroupName()), |
| 423 | Srcs: i.properties.Srcs, |
| 424 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 425 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 426 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 427 | Name: proptools.StringPtr(name.sourcesName()), |
| 428 | }, &hidlGenProperties{ |
| 429 | Language: "c++-sources", |
| 430 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 431 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 432 | Interfaces: i.properties.Interfaces, |
| 433 | Inputs: i.properties.Srcs, |
| 434 | 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] | 435 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 436 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 437 | Name: proptools.StringPtr(name.headersName()), |
| 438 | }, &hidlGenProperties{ |
| 439 | Language: "c++-headers", |
| 440 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 441 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 442 | Interfaces: i.properties.Interfaces, |
| 443 | Inputs: i.properties.Srcs, |
| 444 | Outputs: concat(wrap(name.dir()+"I", interfaces, ".h"), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 445 | wrap(name.dir()+"Bs", interfaces, ".h"), |
| 446 | wrap(name.dir()+"BnHw", interfaces, ".h"), |
| 447 | wrap(name.dir()+"BpHw", interfaces, ".h"), |
| 448 | wrap(name.dir()+"IHw", interfaces, ".h"), |
| 449 | wrap(name.dir(), types, ".h"), |
| 450 | wrap(name.dir()+"hw", types, ".h")), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 451 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 452 | |
| 453 | if shouldGenerateLibrary { |
| 454 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
Jerry Zhang | f2a9396 | 2018-05-30 17:16:05 -0700 | [diff] [blame] | 455 | Name: proptools.StringPtr(name.string()), |
Jerry Zhang | f2a9396 | 2018-05-30 17:16:05 -0700 | [diff] [blame] | 456 | Recovery_available: proptools.BoolPtr(true), |
| 457 | Vendor_available: proptools.BoolPtr(true), |
| 458 | Double_loadable: proptools.BoolPtr(isDoubleLoadable(name.string())), |
| 459 | Defaults: []string{"hidl-module-defaults"}, |
| 460 | Generated_sources: []string{name.sourcesName()}, |
| 461 | Generated_headers: []string{name.headersName()}, |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 462 | Shared_libs: concat(cppDependencies, []string{ |
| 463 | "libhidlbase", |
| 464 | "libhidltransport", |
| 465 | "libhwbinder", |
| 466 | "liblog", |
| 467 | "libutils", |
| 468 | "libcutils", |
| 469 | }), |
| 470 | Export_shared_lib_headers: concat(cppDependencies, []string{ |
| 471 | "libhidlbase", |
| 472 | "libhidltransport", |
| 473 | "libhwbinder", |
| 474 | "libutils", |
| 475 | }), |
| 476 | Export_generated_headers: []string{name.headersName()}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 477 | }, &i.properties.VndkProperties, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | if shouldGenerateJava { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 481 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 482 | Name: proptools.StringPtr(name.javaSourcesName()), |
| 483 | }, &hidlGenProperties{ |
| 484 | Language: "java", |
| 485 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 486 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 487 | Interfaces: i.properties.Interfaces, |
| 488 | Inputs: i.properties.Srcs, |
| 489 | Outputs: concat(wrap(name.sanitizedDir()+"I", interfaces, ".java"), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 490 | wrap(name.sanitizedDir(), i.properties.Types, ".java")), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 491 | }, &i.inheritCommonProperties) |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 492 | mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 493 | Name: proptools.StringPtr(name.javaName()), |
| 494 | Defaults: []string{"hidl-java-module-defaults"}, |
| 495 | No_framework_libs: proptools.BoolPtr(true), |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 496 | Installable: proptools.BoolPtr(true), |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 497 | Srcs: []string{":" + name.javaSourcesName()}, |
Steven Moreland | fcfbeaf | 2018-01-29 19:34:52 -0800 | [diff] [blame] | 498 | Static_libs: javaDependencies, |
Colin Cross | a505055 | 2018-03-29 10:30:03 -0700 | [diff] [blame] | 499 | |
| 500 | // This should ideally be system_current, but android.hidl.base-V1.0-java is used |
| 501 | // to build framework, which is used to build system_current. Use core_current |
| 502 | // plus hwbinder.stubs, which together form a subset of system_current that does |
| 503 | // not depend on framework. |
| 504 | Sdk_version: proptools.StringPtr("core_current"), |
| 505 | Libs: []string{"hwbinder.stubs"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 506 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | if shouldGenerateJavaConstants { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 510 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 511 | Name: proptools.StringPtr(name.javaConstantsSourcesName()), |
| 512 | }, &hidlGenProperties{ |
| 513 | Language: "java-constants", |
| 514 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 515 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 516 | Interfaces: i.properties.Interfaces, |
| 517 | Inputs: i.properties.Srcs, |
| 518 | Outputs: []string{name.sanitizedDir() + "Constants.java"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 519 | }, &i.inheritCommonProperties) |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 520 | mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 521 | Name: proptools.StringPtr(name.javaConstantsName()), |
| 522 | Defaults: []string{"hidl-java-module-defaults"}, |
| 523 | No_framework_libs: proptools.BoolPtr(true), |
| 524 | Srcs: []string{":" + name.javaConstantsSourcesName()}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 525 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 528 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 529 | Name: proptools.StringPtr(name.adapterHelperSourcesName()), |
| 530 | }, &hidlGenProperties{ |
| 531 | Language: "c++-adapter-sources", |
| 532 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 533 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 534 | Interfaces: i.properties.Interfaces, |
| 535 | Inputs: i.properties.Srcs, |
| 536 | Outputs: wrap(name.dir()+"A", concat(interfaces, types), ".cpp"), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 537 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 538 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 539 | Name: proptools.StringPtr(name.adapterHelperHeadersName()), |
| 540 | }, &hidlGenProperties{ |
| 541 | Language: "c++-adapter-headers", |
| 542 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 543 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 544 | Interfaces: i.properties.Interfaces, |
| 545 | Inputs: i.properties.Srcs, |
| 546 | Outputs: wrap(name.dir()+"A", concat(interfaces, types), ".h"), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 547 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 548 | |
| 549 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 550 | Name: proptools.StringPtr(name.adapterHelperName()), |
| 551 | Vendor_available: proptools.BoolPtr(true), |
| 552 | Defaults: []string{"hidl-module-defaults"}, |
| 553 | Generated_sources: []string{name.adapterHelperSourcesName()}, |
| 554 | Generated_headers: []string{name.adapterHelperHeadersName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 555 | Shared_libs: []string{ |
Steven Moreland | d90bdaa | 2018-01-03 11:12:43 -0800 | [diff] [blame] | 556 | "libbase", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 557 | "libcutils", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 558 | "libhidlbase", |
| 559 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 560 | "libhwbinder", |
| 561 | "liblog", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 562 | "libutils", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 563 | }, |
| 564 | Static_libs: concat([]string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 565 | "libhidladapter", |
| 566 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 567 | Export_shared_lib_headers: []string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 568 | "libhidlbase", |
| 569 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 570 | }, |
| 571 | Export_static_lib_headers: concat([]string{ |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 572 | "libhidladapter", |
| 573 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
| 574 | Export_generated_headers: []string{name.adapterHelperHeadersName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 575 | Group_static_libs: proptools.BoolPtr(true), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 576 | }, &i.inheritCommonProperties) |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 577 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 578 | Name: proptools.StringPtr(name.adapterSourcesName()), |
| 579 | }, &hidlGenProperties{ |
| 580 | Language: "c++-adapter-main", |
| 581 | FqName: name.string(), |
Steven Moreland | d9fd195 | 2018-11-08 18:14:37 -0800 | [diff] [blame] | 582 | Root: i.properties.Root, |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 583 | Interfaces: i.properties.Interfaces, |
| 584 | Inputs: i.properties.Srcs, |
| 585 | Outputs: []string{"main.cpp"}, |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 586 | }, &i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 587 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.TestFactory), &ccProperties{ |
| 588 | Name: proptools.StringPtr(name.adapterName()), |
| 589 | Generated_sources: []string{name.adapterSourcesName()}, |
Steven Moreland | 10d1ec4 | 2017-11-29 13:56:28 -0800 | [diff] [blame] | 590 | Shared_libs: []string{ |
Steven Moreland | d90bdaa | 2018-01-03 11:12:43 -0800 | [diff] [blame] | 591 | "libbase", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 592 | "libcutils", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 593 | "libhidlbase", |
| 594 | "libhidltransport", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 595 | "libhwbinder", |
| 596 | "liblog", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 597 | "libutils", |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 598 | }, |
| 599 | Static_libs: concat([]string{ |
| 600 | "libhidladapter", |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 601 | name.adapterHelperName(), |
Steven Moreland | ffa2528 | 2017-11-13 14:23:25 -0800 | [diff] [blame] | 602 | }, wrap("", dependencies, "-adapter-helper"), cppDependencies, libraryIfExists), |
| 603 | Group_static_libs: proptools.BoolPtr(true), |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 604 | }, &i.inheritCommonProperties) |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame^] | 605 | |
| 606 | if shouldGenerateVts { |
| 607 | vtsSpecs := concat(wrap(name.dir(), interfaces, ".vts"), wrap(name.dir(), types, ".vts")) |
| 608 | |
| 609 | mctx.CreateModule(android.ModuleFactoryAdaptor(hidlGenFactory), &nameProperties{ |
| 610 | Name: proptools.StringPtr(name.vtsSpecName()), |
| 611 | }, &hidlGenProperties{ |
| 612 | Language: "vts", |
| 613 | FqName: name.string(), |
| 614 | Root: i.properties.Root, |
| 615 | Interfaces: i.properties.Interfaces, |
| 616 | Inputs: i.properties.Srcs, |
| 617 | Outputs: vtsSpecs, |
| 618 | }, &i.inheritCommonProperties) |
| 619 | |
| 620 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 621 | Name: proptools.StringPtr(name.vtsDriverSourcesName()), |
| 622 | }, &vtscProperties{ |
| 623 | Mode: "DRIVER", |
| 624 | Type: "SOURCE", |
| 625 | SpecName: name.vtsSpecName(), |
| 626 | Outputs: wrap("", vtsSpecs, ".cpp"), |
| 627 | PackagePath: name.dir(), |
| 628 | }, &i.inheritCommonProperties) |
| 629 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 630 | Name: proptools.StringPtr(name.vtsDriverHeadersName()), |
| 631 | }, &vtscProperties{ |
| 632 | Mode: "DRIVER", |
| 633 | Type: "HEADER", |
| 634 | SpecName: name.vtsSpecName(), |
| 635 | Outputs: wrap("", vtsSpecs, ".h"), |
| 636 | PackagePath: name.dir(), |
| 637 | }, &i.inheritCommonProperties) |
| 638 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 639 | Name: proptools.StringPtr(name.vtsDriverName()), |
| 640 | Defaults: []string{"VtsHalDriverDefaults"}, |
| 641 | Generated_sources: []string{name.vtsDriverSourcesName()}, |
| 642 | Generated_headers: []string{name.vtsDriverHeadersName()}, |
| 643 | Export_generated_headers: []string{name.vtsDriverHeadersName()}, |
| 644 | Shared_libs: wrap("", cppDependencies, "-vts.driver"), |
| 645 | Export_shared_lib_headers: wrap("", cppDependencies, "-vts.driver"), |
| 646 | Static_libs: concat(cppDependencies, libraryIfExists), |
| 647 | |
| 648 | // TODO(b/126244142) |
| 649 | Cflags: []string{"-Wno-unused-variable"}, |
| 650 | }, &i.inheritCommonProperties) |
| 651 | |
| 652 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 653 | Name: proptools.StringPtr(name.vtsProfilerSourcesName()), |
| 654 | }, &vtscProperties{ |
| 655 | Mode: "PROFILER", |
| 656 | Type: "SOURCE", |
| 657 | SpecName: name.vtsSpecName(), |
| 658 | Outputs: wrap("", vtsSpecs, ".cpp"), |
| 659 | PackagePath: name.dir(), |
| 660 | }, &i.inheritCommonProperties) |
| 661 | mctx.CreateModule(android.ModuleFactoryAdaptor(vtscFactory), &nameProperties{ |
| 662 | Name: proptools.StringPtr(name.vtsProfilerHeadersName()), |
| 663 | }, &vtscProperties{ |
| 664 | Mode: "PROFILER", |
| 665 | Type: "HEADER", |
| 666 | SpecName: name.vtsSpecName(), |
| 667 | Outputs: wrap("", vtsSpecs, ".h"), |
| 668 | PackagePath: name.dir(), |
| 669 | }, &i.inheritCommonProperties) |
| 670 | mctx.CreateModule(android.ModuleFactoryAdaptor(cc.LibraryFactory), &ccProperties{ |
| 671 | Name: proptools.StringPtr(name.vtsProfilerName()), |
| 672 | Defaults: []string{"VtsHalProfilerDefaults"}, |
| 673 | Generated_sources: []string{name.vtsProfilerSourcesName()}, |
| 674 | Generated_headers: []string{name.vtsProfilerHeadersName()}, |
| 675 | Export_generated_headers: []string{name.vtsProfilerHeadersName()}, |
| 676 | Shared_libs: wrap("", cppDependencies, "-vts.profiler"), |
| 677 | Export_shared_lib_headers: wrap("", cppDependencies, "-vts.profiler"), |
| 678 | Static_libs: concat(cppDependencies, libraryIfExists), |
| 679 | |
| 680 | // TODO(b/126244142) |
| 681 | Cflags: []string{"-Wno-unused-variable"}, |
| 682 | }, &i.inheritCommonProperties) |
| 683 | } |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | func (h *hidlInterface) Name() string { |
| 687 | return h.ModuleBase.Name() + hidlInterfaceSuffix |
| 688 | } |
| 689 | func (h *hidlInterface) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 690 | visited := false |
| 691 | ctx.VisitDirectDeps(func(dep android.Module) { |
| 692 | if visited { |
| 693 | panic("internal error, multiple dependencies found but only one added") |
| 694 | } |
| 695 | visited = true |
Steven Moreland | 136abb8 | 2018-11-08 17:27:42 -0800 | [diff] [blame] | 696 | h.properties.Full_root_option = dep.(*hidlPackageRoot).getFullPackageRoot() |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 697 | }) |
| 698 | if !visited { |
| 699 | panic("internal error, no dependencies found but dependency added") |
| 700 | } |
| 701 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 702 | } |
| 703 | func (h *hidlInterface) DepsMutator(ctx android.BottomUpMutatorContext) { |
Steven Moreland | 744eb32 | 2018-07-25 16:31:08 -0700 | [diff] [blame] | 704 | ctx.AddDependency(ctx.Module(), nil, h.properties.Root) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 705 | } |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 706 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 707 | func hidlInterfaceFactory() android.Module { |
| 708 | i := &hidlInterface{} |
| 709 | i.AddProperties(&i.properties) |
Steven Moreland | 650bc51 | 2018-12-06 11:53:09 -0800 | [diff] [blame] | 710 | i.AddProperties(&i.inheritCommonProperties) |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 711 | android.InitAndroidModule(i) |
| 712 | android.AddLoadHook(i, func(ctx android.LoadHookContext) { hidlInterfaceMutator(ctx, i) }) |
| 713 | |
Steven Moreland | d56e5bb | 2017-07-18 22:04:16 -0700 | [diff] [blame] | 714 | return i |
| 715 | } |
| 716 | |
Colin Cross | f5536c3 | 2018-06-26 23:29:10 -0700 | [diff] [blame] | 717 | var doubleLoadablePackageNames = []string{ |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 718 | "android.hardware.cas@1.0", |
| 719 | "android.hardware.cas.native@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 720 | "android.hardware.configstore@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 721 | "android.hardware.drm@1.0", |
| 722 | "android.hardware.drm@1.1", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 723 | "android.hardware.graphics.allocator@", |
| 724 | "android.hardware.graphics.bufferqueue@", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 725 | "android.hardware.media@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 726 | "android.hardware.media.omx@", |
| 727 | "android.hardware.memtrack@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 728 | "android.hardware.neuralnetworks@", |
| 729 | "android.hidl.allocator@", |
| 730 | "android.hidl.token@", |
Jooyung Han | 407469c | 2019-01-18 18:16:21 +0900 | [diff] [blame] | 731 | "android.system.suspend@1.0", |
Jiyong Park | d26759f | 2018-04-09 12:22:18 +0900 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | func isDoubleLoadable(name string) bool { |
| 735 | for _, pkgname := range doubleLoadablePackageNames { |
| 736 | if strings.HasPrefix(name, pkgname) { |
| 737 | return true |
| 738 | } |
| 739 | } |
| 740 | return false |
| 741 | } |
Steven Moreland | b49d3a7 | 2018-07-25 16:40:03 -0700 | [diff] [blame] | 742 | |
| 743 | // packages in libhidltransport |
| 744 | var coreDependencyPackageNames = []string{ |
| 745 | "android.hidl.base@", |
| 746 | "android.hidl.manager@", |
| 747 | } |
| 748 | |
| 749 | func isCorePackage(name string) bool { |
| 750 | for _, pkgname := range coreDependencyPackageNames { |
| 751 | if strings.HasPrefix(name, pkgname) { |
| 752 | return true |
| 753 | } |
| 754 | } |
| 755 | return false |
| 756 | } |
Steven Moreland | eaba923 | 2019-01-16 17:55:05 -0800 | [diff] [blame^] | 757 | |
| 758 | // TODO(b/126383715): centralize this logic/support filtering in core VTS build |
| 759 | var coreVtsSpecs = []string{ |
| 760 | "android.frameworks.", |
| 761 | "android.hardware.", |
| 762 | "android.hidl.", |
| 763 | "android.system.", |
| 764 | } |
| 765 | |
| 766 | func isVtsSpecPackage(name string) bool { |
| 767 | for _, pkgname := range coreVtsSpecs { |
| 768 | if strings.HasPrefix(name, pkgname) { |
| 769 | return true |
| 770 | } |
| 771 | } |
| 772 | return false |
| 773 | } |
| 774 | |
| 775 | var vtsListKey = android.NewOnceKey("vtsList") |
| 776 | |
| 777 | func vtsList(config android.Config) *android.Paths { |
| 778 | return config.Once(vtsListKey, func() interface{} { |
| 779 | return &android.Paths{} |
| 780 | }).(*android.Paths) |
| 781 | } |
| 782 | |
| 783 | var vtsListMutex sync.Mutex |
| 784 | |
| 785 | func makeVarsProvider(ctx android.MakeVarsContext) { |
| 786 | vtsList := vtsList(ctx.Config()).Strings() |
| 787 | sort.Strings(vtsList) |
| 788 | |
| 789 | ctx.Strict("VTS_SPEC_FILE_LIST", strings.Join(vtsList, " ")) |
| 790 | } |