Change test suite's include_prefix to match workspace path

This commit is contained in:
David Tolnay 2020-10-07 16:33:55 -07:00
parent e5098cb4a7
commit d41eef59c9
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
7 changed files with 10 additions and 21 deletions

View File

@ -26,10 +26,9 @@ cxx_library(
":bridge/source",
":module/source",
],
header_namespace = "cxx-test-suite",
headers = {
"lib.rs.h": ":bridge/header",
"tests.h": "ffi/tests.h",
"ffi/lib.rs.h": ":bridge/header",
"ffi/tests.h": "ffi/tests.h",
},
deps = ["//:core"],
)

View File

@ -29,8 +29,6 @@ cc_library(
":module/source",
],
hdrs = ["ffi/tests.h"],
include_prefix = "cxx-test-suite",
strip_include_prefix = "ffi",
deps = [
":bridge/include",
"//:core",
@ -40,15 +38,11 @@ cc_library(
rust_cxx_bridge(
name = "bridge",
src = "ffi/lib.rs",
include_prefix = "cxx-test-suite",
strip_include_prefix = "ffi",
deps = [":impl"],
)
rust_cxx_bridge(
name = "module",
src = "ffi/module.rs",
include_prefix = "cxx-test-suite",
strip_include_prefix = "ffi",
deps = [":impl"],
)

View File

@ -1,8 +1,11 @@
use cxx_build::CFG;
fn main() {
if cfg!(trybuild) {
return;
}
CFG.include_prefix = "tests/ffi";
let sources = vec!["lib.rs", "module.rs"];
cxx_build::bridges(sources)
.file("tests.cc")

View File

@ -23,7 +23,7 @@ pub mod ffi {
}
extern "C" {
include!("cxx-test-suite/tests.h");
include!("tests/ffi/tests.h");
type C;

View File

@ -4,7 +4,7 @@
#[cxx::bridge(namespace = tests)]
pub mod ffi {
extern "C" {
include!("cxx-test-suite/tests.h");
include!("tests/ffi/tests.h");
type C = crate::ffi::C;

View File

@ -1,5 +1,5 @@
#include "cxx-test-suite/tests.h"
#include "cxx-test-suite/lib.rs.h"
#include "tests/ffi/tests.h"
#include "tests/ffi/lib.rs.h"
#include <cstring>
#include <iterator>
#include <numeric>

View File

@ -1,12 +1,7 @@
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
load("@rules_cc//cc:defs.bzl", "cc_library")
def rust_cxx_bridge(
name,
src,
include_prefix = None,
strip_include_prefix = None,
deps = []):
def rust_cxx_bridge(name, src, deps = []):
native.alias(
name = "%s/header" % name,
actual = src + ".h",
@ -43,6 +38,4 @@ def rust_cxx_bridge(
cc_library(
name = "%s/include" % name,
hdrs = [src + ".h"],
include_prefix = include_prefix,
strip_include_prefix = strip_include_prefix,
)