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