Merge "Use protobuf-codegen default and add mod_stem.rs"
This commit is contained in:
commit
f4155dc551
|
@ -156,7 +156,7 @@ func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *androi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sourceProvider *BaseSourceProvider) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (sourceProvider *BaseSourceProvider) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
outFile := sourceProvider.OutputFile
|
outFile := sourceProvider.OutputFiles[0]
|
||||||
ret.Class = "ETC"
|
ret.Class = "ETC"
|
||||||
ret.OutputFile = android.OptionalPathForPath(outFile)
|
ret.OutputFile = android.OptionalPathForPath(outFile)
|
||||||
ret.SubName += sourceProvider.subName
|
ret.SubName += sourceProvider.subName
|
||||||
|
|
|
@ -202,7 +202,7 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
b.BaseSourceProvider.OutputFile = outputFile
|
b.BaseSourceProvider.OutputFiles = android.Paths{outputFile}
|
||||||
return outputFile
|
return outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,15 +61,22 @@ func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps)
|
||||||
}
|
}
|
||||||
|
|
||||||
outDir := android.PathForModuleOut(ctx)
|
outDir := android.PathForModuleOut(ctx)
|
||||||
depFile := android.PathForModuleOut(ctx, proto.BaseSourceProvider.getStem(ctx)+".d")
|
stem := proto.BaseSourceProvider.getStem(ctx)
|
||||||
outputs := android.WritablePaths{android.PathForModuleOut(ctx, proto.BaseSourceProvider.getStem(ctx)+".rs")}
|
// rust protobuf-codegen output <stem>.rs
|
||||||
|
stemFile := android.PathForModuleOut(ctx, stem+".rs")
|
||||||
|
// add mod_<stem>.rs to import <stem>.rs
|
||||||
|
modFile := android.PathForModuleOut(ctx, "mod_"+stem+".rs")
|
||||||
|
// mod_<stem>.rs is the main/first output file to be included/compiled
|
||||||
|
outputs := android.WritablePaths{modFile, stemFile}
|
||||||
|
depFile := android.PathForModuleOut(ctx, "mod_"+stem+".d")
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
android.ProtoRule(ctx, rule, protoFile.Path(), protoFlags, protoFlags.Deps, outDir, depFile, outputs)
|
android.ProtoRule(ctx, rule, protoFile.Path(), protoFlags, protoFlags.Deps, outDir, depFile, outputs)
|
||||||
|
rule.Command().Text("printf '// @generated\\npub mod %s;\\n' '" + stem + "' >").Output(modFile)
|
||||||
rule.Build(pctx, ctx, "protoc_"+protoFile.Path().Rel(), "protoc "+protoFile.Path().Rel())
|
rule.Build(pctx, ctx, "protoc_"+protoFile.Path().Rel(), "protoc "+protoFile.Path().Rel())
|
||||||
|
|
||||||
proto.BaseSourceProvider.OutputFile = outputs[0]
|
proto.BaseSourceProvider.OutputFiles = android.Paths{modFile, stemFile}
|
||||||
return outputs[0]
|
return modFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proto *protobufDecorator) SourceProviderProps() []interface{} {
|
func (proto *protobufDecorator) SourceProviderProps() []interface{} {
|
||||||
|
|
|
@ -684,7 +684,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
||||||
} else {
|
} else {
|
||||||
sourceMod := actx.GetDirectDepWithTag(mod.Name(), sourceDepTag)
|
sourceMod := actx.GetDirectDepWithTag(mod.Name(), sourceDepTag)
|
||||||
sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
|
sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
|
||||||
mod.sourceProvider.setOutputFile(sourceLib.sourceProvider.Srcs()[0])
|
mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ type SourceProviderProperties struct {
|
||||||
type BaseSourceProvider struct {
|
type BaseSourceProvider struct {
|
||||||
Properties SourceProviderProperties
|
Properties SourceProviderProperties
|
||||||
|
|
||||||
OutputFile android.Path
|
OutputFiles android.Paths
|
||||||
subAndroidMkOnce map[SubAndroidMkProvider]bool
|
subAndroidMkOnce map[SubAndroidMkProvider]bool
|
||||||
subName string
|
subName string
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@ type SourceProvider interface {
|
||||||
SourceProviderProps() []interface{}
|
SourceProviderProps() []interface{}
|
||||||
SourceProviderDeps(ctx DepsContext, deps Deps) Deps
|
SourceProviderDeps(ctx DepsContext, deps Deps) Deps
|
||||||
setSubName(subName string)
|
setSubName(subName string)
|
||||||
setOutputFile(outputFile android.Path)
|
setOutputFiles(outputFiles android.Paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *BaseSourceProvider) Srcs() android.Paths {
|
func (sp *BaseSourceProvider) Srcs() android.Paths {
|
||||||
return android.Paths{sp.OutputFile}
|
return sp.OutputFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *BaseSourceProvider) GenerateSource(ctx ModuleContext, deps PathDeps) android.Path {
|
func (sp *BaseSourceProvider) GenerateSource(ctx ModuleContext, deps PathDeps) android.Path {
|
||||||
|
@ -97,6 +97,6 @@ func (sp *BaseSourceProvider) setSubName(subName string) {
|
||||||
sp.subName = subName
|
sp.subName = subName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *BaseSourceProvider) setOutputFile(outputFile android.Path) {
|
func (sp *BaseSourceProvider) setOutputFiles(outputFiles android.Paths) {
|
||||||
sp.OutputFile = outputFile
|
sp.OutputFiles = outputFiles
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue