summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-09-25 16:08:34 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-09-25 16:15:26 -0400
commitbc9e421215be5ef92080ae239302c12f8821dcc1 (patch)
tree8b418e89fc24525c3e988d7e16a50883eafa99bd /cc
parente0510d7a696b97b2477e82f35df69b5072165060 (diff)
rust: Allow rust_bindgen to use cc_defaults.
rust_bindgen modules can't inherit properties in cc_defaults that would be useful for generating bindings (such as cflags). This CL moves these common properties out into a new struct in cc and adds that struct to cc_default. Additionally, Cppflags is added to rust_bindgen to make sure that these get picked up as well from cc_defaults. Bug: 163598610 Test: rust_bindgen module uses cflags in cc_defaults. Test: New Soong test passes Change-Id: I702442a355244dc01954083f98a2eebbcea12e47
Diffstat (limited to 'cc')
-rw-r--r--cc/cc.go2
-rw-r--r--cc/compiler.go40
2 files changed, 42 insertions, 0 deletions
diff --git a/cc/cc.go b/cc/cc.go
index e71f85924..7c34b5182 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3101,6 +3101,8 @@ func DefaultsFactory(props ...interface{}) android.Module {
&LTOProperties{},
&PgoProperties{},
&android.ProtoProperties{},
+ // RustBindgenProperties is included here so that cc_defaults can be used for rust_bindgen modules.
+ &RustBindgenClangProperties{},
)
android.InitDefaultsModule(module)
diff --git a/cc/compiler.go b/cc/compiler.go
index bb5c7bf2a..21da2fc60 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -652,3 +652,43 @@ func isThirdParty(path string) bool {
}
return true
}
+
+// Properties for rust_bindgen related to generating rust bindings.
+// This exists here so these properties can be included in a cc_default
+// which can be used in both cc and rust modules.
+type RustBindgenClangProperties struct {
+ // list of directories relative to the Blueprints file that will
+ // be added to the include path using -I
+ Local_include_dirs []string `android:"arch_variant,variant_prepend"`
+
+ // list of static libraries that provide headers for this binding.
+ Static_libs []string `android:"arch_variant,variant_prepend"`
+
+ // list of shared libraries that provide headers for this binding.
+ Shared_libs []string `android:"arch_variant"`
+
+ // list of clang flags required to correctly interpret the headers.
+ Cflags []string `android:"arch_variant"`
+
+ // list of c++ specific clang flags required to correctly interpret the headers.
+ // This is provided primarily to make sure cppflags defined in cc_defaults are pulled in.
+ Cppflags []string `android:"arch_variant"`
+
+ // C standard version to use. Can be a specific version (such as "gnu11"),
+ // "experimental" (which will use draft versions like C1x when available),
+ // or the empty string (which will use the default).
+ //
+ // If this is set, the file extension will be ignored and this will be used as the std version value. Setting this
+ // to "default" will use the build system default version. This cannot be set at the same time as cpp_std.
+ C_std *string
+
+ // C++ standard version to use. Can be a specific version (such as
+ // "gnu++11"), "experimental" (which will use draft versions like C++1z when
+ // available), or the empty string (which will use the default).
+ //
+ // If this is set, the file extension will be ignored and this will be used as the std version value. Setting this
+ // to "default" will use the build system default version. This cannot be set at the same time as c_std.
+ Cpp_std *string
+
+ //TODO(b/161141999) Add support for headers from cc_library_header modules.
+}