split the repo into a workspace

remove `clap` dependency 🎉

update the book installation instructions
This commit is contained in:
Christian Poveda
2022-09-23 21:36:14 -05:00
parent 39ae245004
commit 1213b3dfb1
1217 changed files with 682 additions and 306 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ jobs:
# TODO: Actually run quickchecks once `bindgen` is reliable enough.
- name: Build quickcheck tests
run: cd tests/quickchecking && cargo test
run: cd bindgen-tests/tests/quickchecking && cargo test
test-expectations:
runs-on: ${{matrix.os}}
@@ -88,7 +88,7 @@ jobs:
override: true
- name: Test expectations
run: cd tests/expectations && cargo test
run: cd bindgen-tests/tests/expectations && cargo test
test:
runs-on: ${{matrix.os}}
+2 -1
View File
@@ -2,7 +2,8 @@
target/
*~
bindgen-integration/Cargo.lock
tests/expectations/Cargo.lock
bindgen-tests/tests/expectations/Cargo.lock
bindgen-tests/tests/quickchecking/Cargo.lock
#*#
# Test script output
Generated
+339 -25
View File
@@ -2,13 +2,31 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
dependencies = [
"memchr 0.1.11",
]
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
"memchr 2.5.0",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi 0.3.9",
]
[[package]]
@@ -19,7 +37,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
"winapi 0.3.9",
]
[[package]]
@@ -35,29 +53,67 @@ dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"clap",
"diff",
"env_logger",
"lazy_static",
"lazycell",
"log",
"log 0.4.14",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"regex 1.5.5",
"rustc-hash",
"shlex",
"syn",
"tempfile",
"which",
]
[[package]]
name = "bindgen-cli"
version = "0.60.1"
dependencies = [
"bindgen",
"clap 3.2.12",
"env_logger 0.9.0",
"log 0.4.14",
"shlex",
]
[[package]]
name = "bindgen-integration"
version = "0.1.0"
dependencies = [
"bindgen",
"cc",
]
[[package]]
name = "bindgen-tests"
version = "0.1.0"
dependencies = [
"bindgen",
"clap 3.2.12",
"diff",
"shlex",
"tempfile",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cexpr"
version = "0.6.0"
@@ -81,7 +137,22 @@ checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
dependencies = [
"glob",
"libc",
"libloading",
"libloading 0.7.0",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]]
@@ -94,9 +165,9 @@ dependencies = [
"bitflags",
"clap_lex",
"indexmap",
"strsim",
"strsim 0.10.0",
"termcolor",
"textwrap",
"textwrap 0.15.0",
]
[[package]]
@@ -120,6 +191,16 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "env_logger"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
dependencies = [
"log 0.3.9",
"regex 0.1.80",
]
[[package]]
name = "env_logger"
version = "0.9.0"
@@ -128,11 +209,17 @@ checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"log 0.4.14",
"regex 1.5.5",
"termcolor",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "getrandom"
version = "0.2.3"
@@ -181,6 +268,16 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -199,6 +296,16 @@ version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libloading"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
dependencies = [
"cfg-if",
"winapi 0.3.9",
]
[[package]]
name = "libloading"
version = "0.7.0"
@@ -206,7 +313,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a"
dependencies = [
"cfg-if",
"winapi",
"winapi 0.3.9",
]
[[package]]
name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
dependencies = [
"log 0.4.14",
]
[[package]]
@@ -218,6 +334,24 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "2.5.0"
@@ -236,11 +370,20 @@ version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1"
dependencies = [
"memchr",
"memchr 2.5.0",
"minimal-lexical",
"version_check",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "os_str_bytes"
version = "6.2.0"
@@ -268,6 +411,28 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "quickcheck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406"
dependencies = [
"env_logger 0.3.5",
"log 0.3.9",
"rand 0.3.23",
]
[[package]]
name = "quickchecking"
version = "0.1.0"
dependencies = [
"clap 2.34.0",
"lazy_static",
"quickcheck",
"rand 0.3.23",
"tempdir",
]
[[package]]
name = "quote"
version = "1.0.9"
@@ -277,6 +442,29 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
dependencies = [
"libc",
"rand 0.4.6",
]
[[package]]
name = "rand"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
"rdrand",
"winapi 0.3.9",
]
[[package]]
name = "rand"
version = "0.8.4"
@@ -285,7 +473,7 @@ checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
"rand_core 0.6.3",
"rand_hc",
]
@@ -296,9 +484,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
"rand_core 0.6.3",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.6.3"
@@ -314,7 +517,16 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core",
"rand_core 0.6.3",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
@@ -326,17 +538,36 @@ dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "0.1.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
dependencies = [
"aho-corasick 0.5.3",
"memchr 0.1.11",
"regex-syntax 0.3.9",
"thread_local",
"utf8-ranges",
]
[[package]]
name = "regex"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"aho-corasick 0.7.18",
"memchr 2.5.0",
"regex-syntax 0.6.25",
]
[[package]]
name = "regex-syntax"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
[[package]]
name = "regex-syntax"
version = "0.6.25"
@@ -349,7 +580,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
"winapi 0.3.9",
]
[[package]]
@@ -364,6 +595,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
@@ -381,6 +618,16 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [
"rand 0.4.6",
"remove_dir_all",
]
[[package]]
name = "tempfile"
version = "3.2.0"
@@ -389,10 +636,10 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if",
"libc",
"rand",
"rand 0.8.4",
"redox_syscall",
"remove_dir_all",
"winapi",
"winapi 0.3.9",
]
[[package]]
@@ -404,18 +651,73 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "tests_expectations"
version = "0.1.0"
dependencies = [
"block",
"libloading 0.6.7",
"objc",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thread-id"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
dependencies = [
"kernel32-sys",
"libc",
]
[[package]]
name = "thread_local"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
dependencies = [
"thread-id",
]
[[package]]
name = "unicode-ident"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "unicode-width"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "utf8-ranges"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
@@ -439,6 +741,12 @@ dependencies = [
"libc",
]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.9"
@@ -449,6 +757,12 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
@@ -461,7 +775,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
"winapi 0.3.9",
]
[[package]]
+13 -86
View File
@@ -1,88 +1,15 @@
[package]
authors = [
"Jyun-Yan You <jyyou.tw@gmail.com>",
"Emilio Cobos Álvarez <emilio@crisal.io>",
"Nick Fitzgerald <fitzgen@gmail.com>",
"The Servo project developers",
]
description = "Automatically generates Rust FFI bindings to C and C++ libraries."
keywords = ["bindings", "ffi", "code-generation"]
categories = ["external-ffi-bindings", "development-tools::ffi"]
license = "BSD-3-Clause"
name = "bindgen"
readme = "README.md"
repository = "https://github.com/rust-lang/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang.github.io/rust-bindgen/"
version = "0.60.1"
edition = "2018"
build = "build.rs"
# If you change this, also update README.md and msrv in .github/workflows/bindgen.yml
rust-version = "1.57.0"
include = [
"LICENSE",
"README.md",
"Cargo.toml",
"build.rs",
"src/*.rs",
"src/**/*.rs",
[workspace]
members = [
"bindgen",
"bindgen-cli",
"bindgen-integration",
"bindgen-tests",
"bindgen-tests/tests/quickchecking",
"bindgen-tests/tests/expectations",
]
[badges]
travis-ci = { repository = "rust-lang/rust-bindgen" }
[lib]
path = "src/lib.rs"
[[bin]]
name = "bindgen"
path = "src/main.rs"
doc = false
required-features = ["clap"]
[dev-dependencies]
diff = "0.1"
clap = "3"
shlex = "1"
tempfile = "3"
[dependencies]
bitflags = "1.0.3"
cexpr = "0.6"
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
clap = { version = "3", optional = true }
clang-sys = { version = "1", features = ["clang_6_0"] }
lazycell = "1"
lazy_static = "1"
peeking_take_while = "0.1.2"
quote = { version = "1", default-features = false }
syn = { version = "1.0.99", features = ["full", "extra-traits"]}
regex = { version = "1.5", default-features = false , features = ["std", "unicode"] }
which = { version = "4.2.1", optional = true, default-features = false }
shlex = "1"
rustc-hash = "1.0.1"
proc-macro2 = { version = "1", default-features = false }
[dependencies.env_logger]
optional = true
version = "0.9.0"
[dependencies.log]
optional = true
version = "0.4"
[features]
default = ["logging", "clap", "runtime", "which-rustfmt"]
logging = ["env_logger", "log"]
static = ["clang-sys/static"]
runtime = ["clang-sys/runtime"]
# Dynamically discover a `rustfmt` binary using the `which` crate
which-rustfmt = ["which"]
# These features only exist for CI testing -- don't use them if you're not hacking
# on bindgen!
testing_only_docs = []
testing_only_extra_assertions = []
testing_only_libclang_9 = []
testing_only_libclang_5 = []
default-members = [
"bindgen",
"bindgen-cli",
"bindgen-tests",
]
+44
View File
@@ -0,0 +1,44 @@
[package]
authors = [
"The rust-bindgen project contributors",
]
description = "Automatically generates Rust FFI bindings to C and C++ libraries."
keywords = ["bindings", "ffi", "code-generation"]
categories = ["external-ffi-bindings", "development-tools::ffi"]
license = "BSD-3-Clause"
name = "bindgen-cli"
readme = "README.md"
repository = "https://github.com/rust-lang/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang.github.io/rust-bindgen/"
version = "0.60.1"
edition = "2018"
# If you change this, also update README.md and msrv in .github/workflows/bindgen.yml
rust-version = "1.57.0"
include = [
"Cargo.toml",
"build.rs",
]
[[bin]]
path = "main.rs"
name = "bindgen"
[badges]
travis-ci = { repository = "rust-lang/rust-bindgen" }
[dependencies]
bindgen = { path = "../bindgen" }
shlex = "1"
clap = "3"
env_logger = { version = "0.9.0", optional = true }
log = { version = "0.4", optional = true }
[features]
default = ["logging", "runtime", "which-rustfmt"]
logging = ["bindgen/logging", "env_logger", "log"]
static = ["bindgen/static"]
runtime = ["bindgen/runtime"]
# Dynamically discover a `rustfmt` binary using the `which` crate
which-rustfmt = ["bindgen/which-rustfmt"]
+7 -39
View File
@@ -1,24 +1,19 @@
extern crate bindgen;
extern crate clap;
#[cfg(feature = "logging")]
extern crate env_logger;
#[macro_use]
#[cfg(feature = "logging")]
extern crate log;
extern crate clap;
use bindgen::clang_version;
use std::env;
use std::panic;
#[macro_use]
#[cfg(not(feature = "logging"))]
mod log_stubs;
mod options;
use crate::options::builder_from_flags;
#[cfg(feature = "logging")]
fn clang_version_check() {
let version = clang_version();
let version = bindgen::clang_version();
let expected_version = if cfg!(feature = "testing_only_libclang_9") {
Some((9, 0))
} else if cfg!(feature = "testing_only_libclang_5") {
@@ -27,9 +22,10 @@ fn clang_version_check() {
None
};
info!(
log::info!(
"Clang Version: {}, parsed: {:?}",
version.full, version.parsed
version.full,
version.parsed
);
if expected_version.is_some() {
@@ -43,6 +39,7 @@ pub fn main() {
match builder_from_flags(env::args()) {
Ok((builder, output, verbose)) => {
#[cfg(feature = "logging")]
clang_version_check();
let builder_result = panic::catch_unwind(|| {
builder.generate().expect("Unable to generate bindings")
@@ -78,32 +75,3 @@ fn print_verbose_err() {
https://github.com/rust-lang/rust-bindgen/issues/new"
);
}
#[cfg(test)]
mod test {
fn build_flags_output_helper(builder: &bindgen::Builder) {
let mut command_line_flags = builder.command_line_flags();
command_line_flags.insert(0, "bindgen".to_string());
let flags_quoted: Vec<String> = command_line_flags
.iter()
.map(|x| format!("{}", shlex::quote(x)))
.collect();
let flags_str = flags_quoted.join(" ");
println!("{}", flags_str);
let (builder, _output, _verbose) =
crate::options::builder_from_flags(command_line_flags.into_iter())
.unwrap();
builder.generate().expect("failed to generate bindings");
}
#[test]
fn commandline_multiple_headers() {
let bindings = bindgen::Builder::default()
.header("tests/headers/char.h")
.header("tests/headers/func_ptr.h")
.header("tests/headers/16-byte-alignment.h");
build_flags_output_helper(&bindings);
}
}
+1 -1
View File
@@ -581,7 +581,7 @@ where
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
);
if verbose {
println!("Clang: {}", crate::clang_version().full);
println!("Clang: {}", bindgen::clang_version().full);
}
std::process::exit(0);
}
+1 -1
View File
@@ -7,7 +7,7 @@ publish = false
build = "build.rs"
[build-dependencies]
bindgen = { path = ".." }
bindgen = { path = "../bindgen" }
cc = "1.0"
[features]
+15 -12
View File
@@ -123,13 +123,9 @@ impl ParseCallbacks for MacroCallback {
// Test the "custom derives" capability by adding `PartialEq` to the `Test` struct.
fn add_derives(&self, name: &str) -> Vec<String> {
if name == "Test" {
vec![
"PartialEq".into(),
]
vec!["PartialEq".into()]
} else if name == "MyOrderedEnum" {
vec![
"std::cmp::PartialOrd".into(),
]
vec!["std::cmp::PartialOrd".into()]
} else {
vec![]
}
@@ -162,7 +158,9 @@ fn main() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let out_rust_file = out_path.join("test.rs");
let out_rust_file_relative = out_rust_file.strip_prefix(std::env::current_dir().unwrap()).unwrap();
let out_rust_file_relative = out_rust_file
.strip_prefix(std::env::current_dir().unwrap().parent().unwrap())
.unwrap();
let out_dep_file = out_path.join("test.d");
let bindings = Builder::default()
@@ -189,13 +187,18 @@ fn main() {
.expect("Unable to generate bindings");
assert!(macros.read().unwrap().contains("TESTMACRO"));
bindings.write_to_file(&out_rust_file).expect("Couldn't write bindings!");
bindings
.write_to_file(&out_rust_file)
.expect("Couldn't write bindings!");
let observed_deps = std::fs::read_to_string(out_dep_file).expect("Couldn't read depfile!");
let expected_deps = format!("{}: cpp/Test.h include/stub.h", out_rust_file_relative.display());
let observed_deps =
std::fs::read_to_string(out_dep_file).expect("Couldn't read depfile!");
let expected_deps = format!(
"{}: cpp/Test.h include/stub.h",
out_rust_file_relative.display()
);
assert_eq!(
observed_deps,
expected_deps,
observed_deps, expected_deps,
"including stub via include dir must produce correct dep path",
);
}
+28
View File
@@ -0,0 +1,28 @@
[package]
name = "bindgen-tests"
edition = "2018"
version = "0.1.0"
publish = false
include = [
"Cargo.toml",
"build.rs",
]
[dev-dependencies]
bindgen = { path = "../bindgen" }
diff = "0.1"
shlex = "1"
clap = "3"
tempfile = "3"
[features]
logging = ["bindgen/logging"]
static = ["bindgen/static"]
runtime = ["bindgen/runtime"]
which-rustfmt = ["bindgen/which-rustfmt"]
testing_only_docs = ["bindgen/testing_only_docs"]
testing_only_extra_assertions = ["bindgen/testing_only_extra_assertions"]
testing_only_libclang_9 = ["bindgen/testing_only_libclang_9"]
testing_only_libclang_5 = ["bindgen/testing_only_libclang_5"]
+49
View File
@@ -0,0 +1,49 @@
use std::char;
use std::env;
use std::ffi::OsStr;
use std::fs::{self, File};
use std::io::Write;
use std::path::{Path, PathBuf};
pub fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let mut dst = File::create(Path::new(&out_dir).join("tests.rs")).unwrap();
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let headers_dir = manifest_dir.join("tests").join("headers");
let headers = match fs::read_dir(headers_dir) {
Ok(dir) => dir,
// We may not have headers directory after packaging.
Err(..) => return,
};
let entries =
headers.map(|result| result.expect("Couldn't read header file"));
println!("cargo:rerun-if-changed=tests/headers");
for entry in entries {
match entry.path().extension().and_then(OsStr::to_str) {
Some("h") | Some("hpp") => {
let func = entry
.file_name()
.to_str()
.unwrap()
.replace(|c| !char::is_alphanumeric(c), "_")
.replace("__", "_")
.to_lowercase();
writeln!(
dst,
"test_header!(header_{}, {:?});",
func,
entry.path(),
)
.unwrap();
}
_ => {}
}
}
dst.flush().unwrap();
}
@@ -8,10 +8,8 @@ use std::fs;
use std::io::Write;
use std::path::Path;
const LIBCLANG_VERSION_DIRS: &'static [&'static str] = &[
"libclang-5",
"libclang-9",
];
const LIBCLANG_VERSION_DIRS: &'static [&'static str] =
&["libclang-5", "libclang-9"];
fn main() {
println!("cargo:rerun-if-changed=build.rs");

Some files were not shown because too many files have changed in this diff Show More