diff options
author | Paul Duffin <paulduffin@google.com> | 2021-07-09 23:07:56 +0100 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2021-07-09 23:14:39 +0100 |
commit | 62d44c8c1094b95bbcaf2a362e70518a35c07820 (patch) | |
tree | 33f14446191819655f62fa418beea35a21057046 | |
parent | 35abebfab57ef37c3f8084ad25d60d586680c6c4 (diff) | |
download | libchrome-62d44c8c1094b95bbcaf2a362e70518a35c07820.tar.gz |
Stop using deprecated functionality for managing path depsandroid-s-beta-5android-s-beta-5
This change stops using deprecated functionality and migrates this
repository's custom Soong code to support current practices to manage
path property related dependencies. i.e. when a property includes
something that looks like ":module".
ExtractSourcesDeps has been deprecated in favor of tagging properties
with `android:"path"` which will cause the pathDepsMutator to add the
dependencies automatically.
ModuleContext.ExpandSources has been deprecated in favor of
android.PathsForModuleSrc and android.PathsForModuleSrcExcludes as the
latter can be used with other context types and the former does not
require passing a nil list of excludes if there are not needed.
android.SourceDepTag has been deprecated as the underlying type needs
to be changed and this will no longer work for its current uses.
* ctx.GetDirectDepWithTag(moduleName, android.SourceDepTag) will not
work to retrieve a reference to the module dependency added for
path properties. GetModuleFromPathDep(ctx, moduleName, "") must be
used instead.
* depTag == android.SourceDepTag can no longer be used to check to
see if depTag was used to add a module dependency for a module
reference in a path property without any output tag.
IsSourceDepTagWithOutputTag(depTag, "") must be used instead.
Bug: 193228441
Test: m nothing
Change-Id: I1dc2af889985b79e2554c763f6489cab9932e143
-rw-r--r-- | soong/bindings_generator.go | 60 |
1 files changed, 15 insertions, 45 deletions
diff --git a/soong/bindings_generator.go b/soong/bindings_generator.go index 7ff98262ed..98a27a2781 100644 --- a/soong/bindings_generator.go +++ b/soong/bindings_generator.go @@ -79,7 +79,7 @@ var ( type mojomDowngradedFilesProperties struct { // list of input files - Srcs []string + Srcs []string `android:"path"` } type mojomDowngradedFiles struct { @@ -93,14 +93,10 @@ type mojomDowngradedFiles struct { var _ genrule.SourceFileGenerator = (*mojomDowngradedFiles)(nil) -func (m *mojomDowngradedFiles) DepsMutator(ctx android.BottomUpMutatorContext) { - android.ExtractSourcesDeps(ctx, m.properties.Srcs) -} - func (m *mojomDowngradedFiles) GenerateAndroidBuildActions(ctx android.ModuleContext) { m.outDir = android.PathForModuleGen(ctx, "") - for _, in := range ctx.ExpandSources(m.properties.Srcs, nil) { + for _, in := range android.PathsForModuleSrc(ctx, m.properties.Srcs) { if !strings.HasSuffix(in.Rel(), ".mojom") { ctx.PropertyErrorf("srcs", "Source is not a .mojom file: %s", in.Rel()) continue @@ -145,7 +141,7 @@ func mojomDowngradedFilesFactory() android.Module { type mojomPicklesProperties struct { // list of input files - Srcs []string + Srcs []string `android:"path"` } type mojomPickles struct { @@ -159,14 +155,10 @@ type mojomPickles struct { var _ genrule.SourceFileGenerator = (*mojomPickles)(nil) -func (m *mojomPickles) DepsMutator(ctx android.BottomUpMutatorContext) { - android.ExtractSourcesDeps(ctx, m.properties.Srcs) -} - func (m *mojomPickles) GenerateAndroidBuildActions(ctx android.ModuleContext) { m.outDir = android.PathForModuleGen(ctx, "") - for _, in := range ctx.ExpandSources(m.properties.Srcs, nil) { + for _, in := range android.PathsForModuleSrc(ctx, m.properties.Srcs) { if !strings.HasSuffix(in.Rel(), ".mojom") { ctx.PropertyErrorf("srcs", "Source is not a .mojom file: %s", in.Rel()) continue @@ -218,46 +210,36 @@ func mojomPicklesFactory() android.Module { // source and Java source modules. type mojomGenerationProperties struct { // list of input files - Srcs []string + Srcs []string `android:"path"` // name of the output .srcjar Srcjar string // name of the templates module - Templates string + Templates string `android:"path"` // Additional flags to pass to the bindings generation script Flags string // list of pickles modules that will be imported - Pickles []string + Pickles []string `android:"path"` // list of include paths Includes []string // list of typemaps modules that will be imported - Typemaps []string + Typemaps []string `android:"path"` // If true, set --use_once_callback flag to the generator. // This works only on C++ generation. Use_once_callback bool } -// extractSources adds any necessary dependencies to satisfy filegroup or -// generated sources modules listed in the properties using ":module" syntax, -// if any. -func (p *mojomGenerationProperties) extractSources(ctx android.BottomUpMutatorContext) { - android.ExtractSourcesDeps(ctx, p.Srcs) - android.ExtractSourcesDeps(ctx, p.Typemaps) - android.ExtractSourcesDeps(ctx, p.Pickles) - android.ExtractSourceDeps(ctx, &p.Templates) -} - // flags generates all needed flags for the build rule. func (p *mojomGenerationProperties) flags(ctx android.ModuleContext) string { flags := []string{} - for _, typemap := range ctx.ExpandSources(p.Typemaps, nil) { + for _, typemap := range android.PathsForModuleSrc(ctx, p.Typemaps) { flags = append(flags, fmt.Sprintf("--typemap=%s", typemap.String())) } for _, include := range android.PathsForSource(ctx, p.Includes) { @@ -269,7 +251,7 @@ func (p *mojomGenerationProperties) flags(ctx android.ModuleContext) string { ctx.PropertyErrorf("pickles", "not a module: %q", m) continue } - module := ctx.GetDirectDepWithTag(m, android.SourceDepTag).(*mojomPickles) + module := android.GetModuleFromPathDep(ctx, m, "").(*mojomPickles) flags = append(flags, fmt.Sprintf("--gen_dir=%s", module.outDir.String())) } if p.Flags != "" { @@ -285,15 +267,15 @@ func (p *mojomGenerationProperties) flags(ctx android.ModuleContext) string { // implicitDeps collects all dependencies of the module. func (p *mojomGenerationProperties) implicitDeps(ctx android.ModuleContext) android.Paths { deps := android.Paths{} - deps = append(deps, ctx.ExpandSources(p.Pickles, nil)...) - deps = append(deps, ctx.ExpandSources(p.Typemaps, nil)...) - deps = append(deps, ctx.ExpandSources([]string{p.Templates}, nil)...) + deps = append(deps, android.PathsForModuleSrc(ctx, p.Pickles)...) + deps = append(deps, android.PathsForModuleSrc(ctx, p.Typemaps)...) + deps = append(deps, android.PathsForModuleSrc(ctx, []string{p.Templates})...) return deps } // templateDir returns the path where the template .zips are located. func (p *mojomGenerationProperties) templateDir(ctx android.ModuleContext) string { - srcFiles := ctx.ExpandSources([]string{p.Templates}, nil) + srcFiles := android.PathsForModuleSrc(ctx, []string{p.Templates}) if len(srcFiles) == 0 { ctx.PropertyErrorf("templates", "module %s does not produce any files", p.Templates) return "" @@ -320,7 +302,7 @@ func (p *mojomGenerationProperties) generateBuildActions( templateDir := p.templateDir(ctx) generatedSrcs := android.Paths{} - for _, in := range ctx.ExpandSources(p.Srcs, nil) { + for _, in := range android.PathsForModuleSrc(ctx, p.Srcs) { if !strings.HasSuffix(in.Rel(), ".mojom") { ctx.PropertyErrorf("srcs", "Source is not a .mojom file: %s", in.Rel()) continue @@ -366,10 +348,6 @@ type mojomHeaders struct { var _ genrule.SourceFileGenerator = (*mojomHeaders)(nil) -func (m *mojomHeaders) DepsMutator(ctx android.BottomUpMutatorContext) { - m.properties.extractSources(ctx) -} - func (m *mojomHeaders) GenerateAndroidBuildActions(ctx android.ModuleContext) { m.generatedSrcs = m.properties.generateBuildActions( ctx, @@ -426,10 +404,6 @@ type mojomSrcs struct { var _ genrule.SourceFileGenerator = (*mojomSrcs)(nil) -func (m *mojomSrcs) DepsMutator(ctx android.BottomUpMutatorContext) { - m.properties.extractSources(ctx) -} - func (m *mojomSrcs) GenerateAndroidBuildActions(ctx android.ModuleContext) { m.generatedSrcs = m.properties.generateBuildActions( ctx, @@ -482,10 +456,6 @@ type mojomSrcjar struct { var _ genrule.SourceFileGenerator = (*mojomSrcjar)(nil) -func (m *mojomSrcjar) DepsMutator(ctx android.BottomUpMutatorContext) { - m.properties.extractSources(ctx) -} - func (m *mojomSrcjar) GenerateAndroidBuildActions(ctx android.ModuleContext) { srcjars := m.properties.generateBuildActions( ctx, |