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