diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 987d2e4675..c7f2b1913a 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,8 +1,11 @@ --- default_targets: &default_targets +- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "..." - "@docs//..." - "@examples//..." +# Bindgen currently only has a working toolchain for 18.04 +- "-@examples//ffi/rust_calling_c/simple/..." platforms: ubuntu1404: build_targets: *default_targets @@ -10,6 +13,12 @@ platforms: ubuntu1604: build_targets: *default_targets test_targets: *default_targets + ubuntu1804: + build_targets: *default_targets + test_targets: + - "..." + - "@docs//..." + - "@examples//..." macos: osx_targets: &osx_targets - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 @@ -19,11 +28,12 @@ platforms: # Skip tests for dylib support on osx, since we don't support it yet. - "-@examples//ffi/rust_calling_c:matrix_dylib_test" - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked" + - "-@examples//ffi/rust_calling_c/simple/..." build_targets: *osx_targets test_targets: *osx_targets rbe_ubuntu1604: test_targets: - - "--" + - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "//test/..." - "@examples//..." - "-//test/conflicting_deps:conflicting_deps_test" @@ -32,3 +42,4 @@ platforms: - "-@examples//fibonacci:fibonacci_doc_test" - "-@examples//hello_lib:hello_lib_doc_test" - "-//tools/runfiles:runfiles_doc_test" + - "-@examples//ffi/rust_calling_c/simple/..." diff --git a/WORKSPACE b/WORKSPACE index f5b6eeef2e..014a709fb2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -25,21 +25,22 @@ http_archive( ) # TODO: Move this to examples/WORKSPACE when recursive repositories are enabled. -load("//rust:repositories.bzl", "rust_repositories") - +load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories") rust_repositories() new_git_repository( name = "libc", - build_file = "//:libc.BUILD", + build_file = "@io_bazel_rules_rust//:libc.BUILD", remote = "https://github.com/rust-lang/libc", tag = "0.2.20", ) -load("//proto:repositories.bzl", "rust_proto_repositories") - +load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories") rust_proto_repositories() +load("@io_bazel_rules_rust//bindgen:repositories.bzl", "rust_bindgen_repositories") +rust_bindgen_repositories() + # Stardoc and its dependencies git_repository( name = "io_bazel_skydoc", @@ -71,6 +72,5 @@ http_archive( ], ) -load(":workspace.bzl", "bazel_version") - +load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version") bazel_version(name = "bazel_version") diff --git a/bindgen/BUILD b/bindgen/BUILD new file mode 100644 index 0000000000..c68f15b721 --- /dev/null +++ b/bindgen/BUILD @@ -0,0 +1,26 @@ +load("@io_bazel_rules_rust//bindgen:bindgen.bzl", "rust_bindgen_toolchain") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +package(default_visibility = ["//visibility:public"]) + +toolchain_type(name = "bindgen_toolchain") + +bzl_library( + name = "rules", + srcs = glob(["**/*.bzl"]), + deps = ["@io_bazel_rules_rust//rust:rules"], +) + +rust_bindgen_toolchain( + name = "example-bindgen-toolchain-impl", + bindgen = "//bindgen/raze:cargo_bin_bindgen", + clang = "@bindgen_clang//:clang", + libclang = "@bindgen_clang//:libclang.so", + libstdcxx = "@local_libstdcpp//:libstdc++", +) + +toolchain( + name = "example-bindgen-toolchain", + toolchain = "example-bindgen-toolchain-impl", + toolchain_type = "@io_bazel_rules_rust//bindgen:bindgen_toolchain", +) diff --git a/bindgen/README.md b/bindgen/README.md new file mode 100644 index 0000000000..79eee77f47 --- /dev/null +++ b/bindgen/README.md @@ -0,0 +1,82 @@ +# Rust Bindgen Rules + +
+rust_bindgen_toolchain(name, bindgen, clang, libclang, libstdcxx, rustfmt) ++ +The tools required for the `rust_bindgen` rule. + +### Attributes +
name |
+
+ Name; required
+ + A unique name for this target. + + |
+
bindgen |
+
+ Label; optional
+ + The label of a `bindgen` executable. + + |
+
clang |
+
+ Label; optional
+ + The label of a `clang` executable. + + |
+
libclang |
+
+ Label; optional
+ + A cc_library that provides bindgen's runtime dependency on libclang. + + |
+
libstdcxx |
+
+ Label; optional
+ + A cc_library that satisfies libclang's libstdc++ dependency. + + |
+
rustfmt |
+
+ Label; optional
+ + The label of a `rustfmt` executable. If this is provided, generated sources will be formatted. + + |
+