From c4b8335f3d8def85d078af215c2d2a4eee9142a8 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 12 Feb 2019 10:12:56 +0100 Subject: [PATCH 1/5] Test the examples on Bazel's CI --- .bazelci/presubmit.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c7f2b1913a..18b5f576af 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -6,7 +6,7 @@ default_targets: &default_targets - "@examples//..." # Bindgen currently only has a working toolchain for 18.04 - "-@examples//ffi/rust_calling_c/simple/..." -platforms: +tasks: ubuntu1404: build_targets: *default_targets test_targets: *default_targets @@ -43,3 +43,7 @@ platforms: - "-@examples//hello_lib:hello_lib_doc_test" - "-//tools/runfiles:runfiles_doc_test" - "-@examples//ffi/rust_calling_c/simple/..." + examples: + platform: ubuntu1804 + working_directory: examples + test_targets: //... From 294c82bf25cf26ba7d4522ccfefcc4e9d1a4cad9 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 12 Feb 2019 10:16:28 +0100 Subject: [PATCH 2/5] Add a "name" to the examples task. --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 18b5f576af..8c4a652f5e 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -44,6 +44,7 @@ tasks: - "-//tools/runfiles:runfiles_doc_test" - "-@examples//ffi/rust_calling_c/simple/..." examples: + name: Examples platform: ubuntu1804 working_directory: examples test_targets: //... From 2ba3a2a82047047e552ad2be9ca94a31ed51b89a Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 12 Feb 2019 10:22:31 +0100 Subject: [PATCH 3/5] Load Starlark versions of new_git_repository and http_archive. --- examples/WORKSPACE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 060338493d..34d20cd9a6 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -1,5 +1,8 @@ workspace(name = "examples") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + local_repository(name = "io_bazel_rules_rust", path = "..") load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories") From 08a75b0e97160b0354ece2e86b18a31c8c7345b1 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 12 Feb 2019 10:29:10 +0100 Subject: [PATCH 4/5] Fix test_targets attribute in config. --- .bazelci/presubmit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 8c4a652f5e..5753659631 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -47,4 +47,5 @@ tasks: name: Examples platform: ubuntu1804 working_directory: examples - test_targets: //... + test_targets: + - //... From e70bf71c2031323c82f0c751c455746f239cf60d Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 12 Feb 2019 12:54:32 +0100 Subject: [PATCH 5/5] Migrate repositories to new Starlark-based repo rules --- examples/BUILD | 0 examples/WORKSPACE | 33 +++++++++++++++++++++++-------- examples/ffi/c_calling_rust/BUILD | 2 +- examples/ffi/rust_calling_c/BUILD | 2 +- examples/libc.BUILD | 7 +++++++ 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 examples/BUILD create mode 100644 examples/libc.BUILD diff --git a/examples/BUILD b/examples/BUILD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 34d20cd9a6..c285175ed9 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -3,27 +3,44 @@ workspace(name = "examples") load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -local_repository(name = "io_bazel_rules_rust", path = "..") +local_repository( + name = "io_bazel_rules_rust", + path = "..", +) load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories") + rust_repositories() -new_git_repository( +http_archive( name = "libc", - remote = "https://github.com/rust-lang/libc", - tag = "0.2.20", - build_file = "libc.BUILD", + build_file = "@//:libc.BUILD", + sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d", + strip_prefix = "libc-0.2.20", + urls = [ + "https://mirror.bazel.build/github.com/rust-lang/libc/archive/0.2.20.zip", + "https://github.com/rust-lang/libc/archive/0.2.20.zip", + ], ) load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories") + rust_proto_repositories() http_archive( name = "bazel_skylib", - url = "https://github.com/bazelbuild/bazel-skylib/archive/0.5.0.tar.gz", - sha256 = "b5f6abe419da897b7901f90cbab08af958b97a8f3575b0d3dd062ac7ce78541f", - strip_prefix = "bazel-skylib-0.5.0" + sha256 = "eb5c57e4c12e68c0c20bc774bfbc60a568e800d025557bc4ea022c6479acc867", + strip_prefix = "bazel-skylib-0.6.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/archive/0.6.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/archive/0.6.0.tar.gz", + ], ) +load("@io_bazel_rules_rust//bindgen:repositories.bzl", "rust_bindgen_repositories") + +rust_bindgen_repositories() + load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version") + bazel_version(name = "bazel_version") diff --git a/examples/ffi/c_calling_rust/BUILD b/examples/ffi/c_calling_rust/BUILD index 3c6367b040..312a3e55b5 100644 --- a/examples/ffi/c_calling_rust/BUILD +++ b/examples/ffi/c_calling_rust/BUILD @@ -1,4 +1,4 @@ -load("@//rust:rust.bzl", "rust_binary", "rust_library", "rust_test") +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary", "rust_library", "rust_test") rust_library( name = "rusty", diff --git a/examples/ffi/rust_calling_c/BUILD b/examples/ffi/rust_calling_c/BUILD index eb49a4dfbc..16ec03bd60 100644 --- a/examples/ffi/rust_calling_c/BUILD +++ b/examples/ffi/rust_calling_c/BUILD @@ -1,6 +1,6 @@ package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"]) -load("@//rust:rust.bzl", "rust_library", "rust_test", "rust_binary", "rust_doc") +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_test", "rust_binary", "rust_doc") rust_library( name = "matrix", diff --git a/examples/libc.BUILD b/examples/libc.BUILD new file mode 100644 index 0000000000..7478979991 --- /dev/null +++ b/examples/libc.BUILD @@ -0,0 +1,7 @@ +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") + +rust_library( + name = "libc", + srcs = glob(["src/**/*.rs"]), + visibility = ["//visibility:public"], +)