From 792ed8a5663c4e96f3a667a780e5bad55e396a64 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Fri, 15 Feb 2019 08:54:20 +0100 Subject: [PATCH] Generate simpleservo.h --- Cargo.lock | 17 +++++++++++++++++ ports/libsimpleservo/capi/Cargo.toml | 3 +++ ports/libsimpleservo/capi/build.rs | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 ports/libsimpleservo/capi/build.rs diff --git a/Cargo.lock b/Cargo.lock index 3dbac8ae545f..47ffa30f7489 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,6 +455,21 @@ dependencies = [ "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cbindgen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.18" @@ -3951,6 +3966,7 @@ dependencies = [ name = "simpleservo_capi" version = "0.0.1" dependencies = [ + "cbindgen 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "simpleservo 0.0.1", @@ -5088,6 +5104,7 @@ dependencies = [ "checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" "checksum bzip2-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2c5162604199bbb17690ede847eaa6120a3f33d5ab4dcc8e7c25b16d849ae79b" "checksum caseless 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +"checksum cbindgen 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ae5776bf2f6d5ff4f07eb63aa666fd9e1dbe0fe4b87f0fa32b469efae2940f7" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" "checksum cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc0086be9ca82f7fc89fc873435531cb898b86e850005850de1f820e2db6e9b" diff --git a/ports/libsimpleservo/capi/Cargo.toml b/ports/libsimpleservo/capi/Cargo.toml index c649e9736a37..c114f87083d8 100644 --- a/ports/libsimpleservo/capi/Cargo.toml +++ b/ports/libsimpleservo/capi/Cargo.toml @@ -17,6 +17,9 @@ simpleservo = { path = "../api" } log = "0.4" env_logger = "0.6" +[build-dependencies] +cbindgen = "0.8" + [features] default = ["unstable", "default-except-unstable"] default-except-unstable = ["webdriver", "max_log_level"] diff --git a/ports/libsimpleservo/capi/build.rs b/ports/libsimpleservo/capi/build.rs new file mode 100644 index 000000000000..84af6a6e4073 --- /dev/null +++ b/ports/libsimpleservo/capi/build.rs @@ -0,0 +1,18 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use std::env; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let target_dir = env::var("CARGO_TARGET_DIR").unwrap(); + let profile_dir = env::var("PROFILE").unwrap(); + let dest = format!("{}/{}/{}", target_dir, profile_dir, "simpleservo.h"); + cbindgen::Builder::new() + .with_crate(crate_dir) + .with_language(cbindgen::Language::C) + .generate() + .expect("Unable to generate bindings") + .write_to_file(dest); +}