Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a second Bazel CI based on cargo-raze #59

Closed
wants to merge 13 commits into from
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ matrix:
- buck run demo-rs --verbose=0
- buck test ... --verbose=0
- name: Bazel
rust: nightly
rust: beta
before_install:
- wget -O install.sh https://github.com/bazelbuild/bazel/releases/download/2.1.1/bazel-2.1.1-installer-linux-x86_64.sh
- chmod +x install.sh
- ./install.sh --user
- pushd /tmp
- git clone --single-branch --branch optional_cargo https://github.com/sayrer/cargo-raze
- cd cargo-raze/impl
- cargo install --debug -f --path .
- popd
before_script:
- cp third-party/Cargo.lock .
- cargo vendor --versioned-dirs --locked third-party/vendor
script:
- bazel run demo-rs --verbose_failures --noshow_progress
- bazel test ... --verbose_failures --noshow_progress
- pushd tests/bazel_integration/cargo && ./update.sh && popd
34 changes: 34 additions & 0 deletions tests/bazel_integration/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Bazel infrastructure
#
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
http_archive(
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

#
# Rust
#

# Temporary patched repo
http_archive(
name = "io_bazel_rules_rust",
#sha256 = "f33bffd6b779ae5a4f57944e86307f876872b9dbfc07b3d10d0e7f0041f29d5f",
strip_prefix = "rules_rust-f92d5b1533c28f41a0455def6205e0ecbcdd65a1",
urls = [
"https://github.com/sayrer/rules_rust/archive/f92d5b1533c28f41a0455def6205e0ecbcdd65a1.tar.gz",
],
)

load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
rust_repositories()
load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
bazel_version(name = "bazel_version")
29 changes: 29 additions & 0 deletions tests/bazel_integration/cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "cxx_bazel_test"
version = "0.1.0"
edition = "2018"
features = ["std"]

[dependencies]
cxx = { git = "https://github.com/dtolnay/cxx" }
cxxbridge-cmd = { git = "https://github.com/dtolnay/cxx", path = "./cmd" }
num_cpus = "1.12.0"

[workspace]
[lib]
path = "fake_lib.rs"

[raze]
workspace_path = "//cargo"
output_buildfile_suffix = "BUILD.bazel"

[raze.crates.proc-macro2.'1.0.9']
additional_flags = [
"--cfg=span_locations",
]

[raze.crates.cxxbridge-cmd.'0.1.2']
additional_flags = [
"--cfg", "procmacro2_semver_exempt",
]
data_attr = 'glob(["**/*.h"])'
14 changes: 14 additions & 0 deletions tests/bazel_integration/cargo/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

cargo generate-lockfile && \
cargo vendor --versioned-dirs --locked && \
cargo raze && \
cat >> $(find vendor/cxx-* -name "BUILD.bazel") <<- EOM

cc_library(
name="cxx_cc_library",
hdrs=glob(["include/**/*.h"]),
srcs=glob(["src/**/*.cc"]),
)

EOM