diff options
Diffstat (limited to 'build_extra')
-rw-r--r-- | build_extra/flatbuffers/rust/BUILD.gn | 5 | ||||
-rw-r--r-- | build_extra/flatbuffers/rust/rust_flatbuffer.gni | 44 | ||||
-rw-r--r-- | build_extra/rust/rust.gni | 1 |
3 files changed, 50 insertions, 0 deletions
diff --git a/build_extra/flatbuffers/rust/BUILD.gn b/build_extra/flatbuffers/rust/BUILD.gn new file mode 100644 index 000000000..25ba496ee --- /dev/null +++ b/build_extra/flatbuffers/rust/BUILD.gn @@ -0,0 +1,5 @@ +import("//build_extra/rust/rust.gni") + +rust_component("flatbuffers") { + source_root = "//third_party/flatbuffers/rust/flatbuffers/src/lib.rs" +} diff --git a/build_extra/flatbuffers/rust/rust_flatbuffer.gni b/build_extra/flatbuffers/rust/rust_flatbuffer.gni new file mode 100644 index 000000000..f5280a8d3 --- /dev/null +++ b/build_extra/flatbuffers/rust/rust_flatbuffer.gni @@ -0,0 +1,44 @@ +import("//build_extra/rust/rust.gni") + +# TODO(ry) "flatbuffer.gni" should be "flatbuffers.gni" we should be consistant +# in our pluralization. +import("//build_extra/flatbuffers/flatbuffer.gni") + +template("rust_flatbuffer") { + action_name = "${target_name}_gen" + source_set_name = target_name + compiled_action_foreach(action_name) { + tool = "$flatbuffers_build_location:flatc" + + sources = invoker.sources + deps = [] + out_dir = target_gen_dir + + outputs = [ + "$out_dir/{{source_name_part}}_generated.rs", + ] + + args = [ + "--rust", + "-o", + rebase_path(out_dir, root_build_dir), + "-I", + rebase_path("//", root_build_dir), + ] + args += [ "{{source}}" ] + + # The deps may have steps that have to run before running flatc. + if (defined(invoker.deps)) { + deps += invoker.deps + } + } + + rust_component(source_set_name) { + sources = get_target_outputs(":$action_name") + source_root = sources[0] + deps = [ + ":$action_name", + ] + extern = [ "//build_extra/flatbuffers/rust:flatbuffers" ] + } +} diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index 2fc822837..f783126ed 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -163,6 +163,7 @@ template("rust_component") { "is_test", "testonly", "args", + "deps", ]) if (!defined(invoker.crate_type)) { crate_type = "rlib" |