diff options
author | David Tolnay <dtolnay@gmail.com> | 2020-10-27 21:07:53 -0700 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2020-10-28 13:41:45 -0700 |
commit | 75c2385e3023e4cf4b0f18b09797be7304f0e4be (patch) | |
tree | 98377a7f31a443e2a7147261e96acbe631229210 /gen/src/mod.rs | |
parent | d5107638a1a4ae0c84d5b9ca5a5e5101c65ff686 (diff) | |
download | cxx-75c2385e3023e4cf4b0f18b09797be7304f0e4be.tar.gz |
Check for disallowed include strings
error[cxxbridge]: #include relative to `.` or `..` is not supported in Cargo builds
┌─ src/main.rs:10:18
│
10 │ include!("../header.h");
│ ^^^^^^^^^^^^^ #include relative to `.` or `..` is not supported in Cargo builds
│
= note: use a path starting with the crate name
Diffstat (limited to 'gen/src/mod.rs')
-rw-r--r-- | gen/src/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gen/src/mod.rs b/gen/src/mod.rs index 1a3febd3..236fece2 100644 --- a/gen/src/mod.rs +++ b/gen/src/mod.rs @@ -1,6 +1,7 @@ // Functionality that is shared between the cxx_build::bridge entry point and // the cxxbridge CLI command. +mod check; pub(super) mod error; mod file; pub(super) mod fs; @@ -13,7 +14,7 @@ use self::error::{format_err, Result}; use self::file::File; use self::include::Include; use crate::syntax::report::Errors; -use crate::syntax::{self, check, Types}; +use crate::syntax::{self, Types}; use std::path::Path; /// Options for C++ code generation. @@ -45,6 +46,7 @@ pub struct Opt { pub(super) gen_header: bool, pub(super) gen_implementation: bool, + pub(super) allow_dot_includes: bool, } /// Results of code generation. @@ -63,6 +65,7 @@ impl Default for Opt { cxx_impl_annotations: None, gen_header: true, gen_implementation: true, + allow_dot_includes: true, } } } @@ -112,6 +115,7 @@ pub(super) fn generate(syntax: File, opt: &Opt) -> Result<GeneratedCode> { let trusted = bridge.unsafety.is_some(); let ref apis = syntax::parse_items(errors, bridge.content, trusted); let ref types = Types::collect(errors, apis); + check::precheck(errors, apis, opt); errors.propagate()?; check::typecheck(errors, namespace, apis, types); errors.propagate()?; |