Squashed 'third_party/autocxx/' content from commit 629e8fa53
git-subtree-dir: third_party/autocxx
git-subtree-split: 629e8fa531a633164c0b52e2a3cab536d4cd0849
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
Change-Id: I62a03b0049f49adf029e0204639cdb5468dde1a1
diff --git a/gen/build/Cargo.toml b/gen/build/Cargo.toml
new file mode 100644
index 0000000..2895526
--- /dev/null
+++ b/gen/build/Cargo.toml
@@ -0,0 +1,31 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+[package]
+name = "autocxx-build"
+version = "0.22.0"
+authors = ["Adrian Taylor <adetaylor@chromium.org>"]
+edition = "2021"
+license = "MIT OR Apache-2.0"
+description = "Safe autogenerated interop between Rust and C++"
+repository = "https://github.com/google/autocxx"
+keywords = ["ffi"]
+categories = ["development-tools::ffi", "api-bindings"]
+
+[features]
+runtime = [ "autocxx-engine/runtime" ]
+static = [ "autocxx-engine/static" ]
+
+[dependencies]
+autocxx-engine = { version="=0.22.0", path="../../engine", features = ["build"] }
+env_logger = "0.9.0"
+indexmap = "1.8"
+
+[dependencies.syn]
+version = "1.0"
+features = [ "full" ]
diff --git a/gen/build/README.md b/gen/build/README.md
new file mode 100644
index 0000000..9b91d4a
--- /dev/null
+++ b/gen/build/README.md
@@ -0,0 +1 @@
+This crate is a [component of autocxx](https://google.github.io/autocxx/).
diff --git a/gen/build/src/lib.rs b/gen/build/src/lib.rs
new file mode 100644
index 0000000..c1df580
--- /dev/null
+++ b/gen/build/src/lib.rs
@@ -0,0 +1,51 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![forbid(unsafe_code)]
+
+use autocxx_engine::{BuilderContext, RebuildDependencyRecorder};
+use indexmap::set::IndexSet as HashSet;
+use std::{io::Write, sync::Mutex};
+
+pub type Builder = autocxx_engine::Builder<'static, CargoBuilderContext>;
+
+#[doc(hidden)]
+pub struct CargoBuilderContext;
+
+impl BuilderContext for CargoBuilderContext {
+ fn setup() {
+ env_logger::builder()
+ .format(|buf, record| writeln!(buf, "cargo:warning=MESSAGE:{}", record.args()))
+ .init();
+ }
+ fn get_dependency_recorder() -> Option<Box<dyn RebuildDependencyRecorder>> {
+ Some(Box::new(CargoRebuildDependencyRecorder::new()))
+ }
+}
+
+#[derive(Debug)]
+struct CargoRebuildDependencyRecorder {
+ printed_already: Mutex<HashSet<String>>,
+}
+
+impl CargoRebuildDependencyRecorder {
+ fn new() -> Self {
+ Self {
+ printed_already: Mutex::new(HashSet::new()),
+ }
+ }
+}
+
+impl RebuildDependencyRecorder for CargoRebuildDependencyRecorder {
+ fn record_header_file_dependency(&self, filename: &str) {
+ let mut already = self.printed_already.lock().unwrap();
+ if already.insert(filename.into()) {
+ println!("cargo:rerun-if-changed={}", filename);
+ }
+ }
+}