summaryrefslogtreecommitdiff
path: root/rust/androidmk.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-07-08 08:39:44 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-07-20 13:40:14 -0400
commit4fef93c53fd98d6bf87fceccc4d37fa2392b958b (patch)
tree7c1bd299af56b56a142c8ba48fdaa13578220047 /rust/androidmk.go
parent20efa41af8ec6073d1ee3ecb4b92361f87c526d5 (diff)
Add SourceProviders and a rust_bindgen module type
Add SourceProvider modules which provides a base interface for more complex code generation usecases such as bindgen. Also adds the rust_bindgen module type which calls bindgen to generate Rust FFI bindings to C. Bug: 159064919 Test: Local test module generates bindings. Test: New Soong tests pass. Change-Id: Ie31467bbbe423497666ad837cf5fe1acd1e76bd8
Diffstat (limited to 'rust/androidmk.go')
-rw-r--r--rust/androidmk.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/rust/androidmk.go b/rust/androidmk.go
index aea899baa..babbf9123 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -55,6 +55,7 @@ func (mod *Module) AndroidMk() android.AndroidMkData {
ret := android.AndroidMkData{
OutputFile: mod.outputFile,
Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk",
+ SubName: mod.subName,
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
if len(mod.Properties.AndroidMkRlibs) > 0 {
@@ -75,9 +76,11 @@ func (mod *Module) AndroidMk() android.AndroidMkData {
},
},
}
-
- mod.subAndroidMk(&ret, mod.compiler)
-
+ if mod.compiler != nil {
+ mod.subAndroidMk(&ret, mod.compiler)
+ } else if mod.sourceProvider != nil {
+ mod.subAndroidMk(&ret, mod.sourceProvider)
+ }
ret.SubName += mod.Properties.SubName
return ret
@@ -155,6 +158,25 @@ func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *androi
}
+func (sourceProvider *baseSourceProvider) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
+ outFile := sourceProvider.outputFile
+ ret.Class = "ETC"
+ ret.OutputFile = android.OptionalPathForPath(outFile)
+ ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
+ _, file := filepath.Split(outFile.String())
+ stem, suffix, _ := android.SplitFileExt(file)
+ fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
+ })
+}
+
+func (bindgen *bindgenDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
+ ctx.subAndroidMk(ret, bindgen.baseSourceProvider)
+ ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ })
+}
+
func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
// Soong installation is only supported for host modules. Have Make
// installation trigger Soong installation.