diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-01-08 02:12:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-01-08 02:12:09 +0000 |
commit | fa987e3f54ab5b04643f6bf069677f09cccb75d8 (patch) | |
tree | 30df8d8532bd221fe9f9281ecc0310a1a17c5d76 | |
parent | 6d912c8fe8aaf5030175e2bbf6a91bae328c2cfc (diff) | |
parent | 84ffd34e611b70bda7e5979c31166f2b03525d92 (diff) | |
download | xsdc-fa987e3f54ab5b04643f6bf069677f09cccb75d8.tar.gz |
Merge "xsdc: add a genrule so that the xsd can be used as 'data' in tests"
-rw-r--r-- | build/xsdc.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/build/xsdc.go b/build/xsdc.go index f66476b..37f0440 100644 --- a/build/xsdc.go +++ b/build/xsdc.go @@ -52,6 +52,11 @@ var ( CommandDeps: []string{"${xsdcCmd}", "${config.SoongZipCmd}"}, Description: "xsdc C++ ${in} => ${out}", }, "pkgName", "outDir") + + xsdConfigRule = pctx.StaticRule("xsdConfigRule", blueprint.RuleParams{ + Command: "cp -f ${in} ${output}", + Description: "copy the xsd file: ${in} => ${output}", + }, "output") ) type xsdConfigProperties struct { @@ -71,8 +76,13 @@ type xsdConfig struct { genOutputs_h android.WritablePath docsPath android.Path + + xsdConfigPath android.OptionalPath + genOutputs android.Paths } +var _ android.SourceFileProducer = (*xsdConfig)(nil) + type ApiToCheck struct { Api_file *string Removed_api_file *string @@ -99,7 +109,7 @@ func (module *xsdConfig) GeneratedSourceFiles() android.Paths { } func (module *xsdConfig) Srcs() android.Paths { - return android.Paths{module.genOutputs_j} + return append(module.genOutputs, module.genOutputs_j) } func (module *xsdConfig) GeneratedDeps() android.Paths { @@ -114,6 +124,24 @@ func (module *xsdConfig) DepsMutator(ctx android.BottomUpMutatorContext) { android.ExtractSourcesDeps(ctx, module.properties.Srcs) } +func (module *xsdConfig) generateXsdConfig(ctx android.ModuleContext) { + if !module.xsdConfigPath.Valid() { + return + } + + output := android.PathForModuleGen(ctx, module.Name()+".xsd") + module.genOutputs = append(module.genOutputs, output) + + ctx.ModuleBuild(pctx, android.ModuleBuildParams{ + Rule: xsdConfigRule, + Input: module.xsdConfigPath.Path(), + Output: output, + Args: map[string]string{ + "output": output.String(), + }, + }) +} + func (module *xsdConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) { if len(module.properties.Srcs) != 1 { ctx.PropertyErrorf("srcs", "xsd_config must be one src") @@ -160,6 +188,8 @@ func (module *xsdConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) "outDir": android.PathForModuleGen(ctx, "cpp").String(), }, }) + module.xsdConfigPath = android.ExistentPathForSource(ctx, xsdFile.String()) + module.generateXsdConfig(ctx) } func xsdConfigMutator(mctx android.TopDownMutatorContext) { |