Skip to content

Commit

Permalink
Merge pull request #246 from jugglerchris/add_windows_ci
Browse files Browse the repository at this point in the history
Add Windows builder and remove build-time bindgen
  • Loading branch information
jugglerchris committed Feb 6, 2022
2 parents ac739a6 + 95f95c2 commit 173856a
Show file tree
Hide file tree
Showing 17 changed files with 7,607 additions and 97 deletions.
60 changes: 59 additions & 1 deletion .circleci/config.yml
@@ -1,4 +1,7 @@
version: 2
version: 2.1

orbs:
win: circleci/windows@2.2.0

jobs:
build-default:
Expand Down Expand Up @@ -26,6 +29,12 @@ jobs:
- run:
name: Run all tests
command: cargo test --all
- run:
name: Check bindgen
command: |
cargo install bindgen
scripts/update-bindgen.sh
git diff --exit-code
- run:
name: Check Formatting
command: |
Expand Down Expand Up @@ -64,6 +73,12 @@ jobs:
- run:
name: Run all tests
command: cargo test --no-default-features --features=builtin-lua53 --all
- run:
name: Check bindgen
command: |
cargo install bindgen
scripts/update-bindgen.sh
git diff --exit-code
- run:
name: Check Formatting
command: |
Expand Down Expand Up @@ -108,6 +123,12 @@ jobs:
- run:
name: Run all tests
command: cargo test --no-default-features --features=system-lua51 --all
- run:
name: Check bindgen
command: |
cargo install bindgen
scripts/update-bindgen.sh
git diff --exit-code
- run:
name: Check Formatting
command: |
Expand All @@ -121,10 +142,47 @@ jobs:
- target/debug/build
- target/debug/deps
key: cargo-cache-lua51-{{ arch }}-{{ checksum "Cargo.lock" }}
build-windows:
executor:
name: win/default
size: "medium"
shell: bash.exe
steps:
- checkout
- run:
name: Install Rust
command: |
curl https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe --output rustup-init.exe
./rustup-init.exe -y
- run:
name: Version information
command: |
export PATH=$USERPROFILE/.cargo/bin:$PATH
rustc --version; cargo --version; rustup --version
- run:
name: Calculate dependencies
command: |
export PATH=$USERPROFILE/.cargo/bin:$PATH
echo "[net]" >> $USERPROFILE/.cargo/config
echo "git-fetch-with-cli = true" >> $USERPROFILE/.cargo/config
cargo generate-lockfile
- run:
name: Build all targets
command: |
export PATH=$USERPROFILE/.cargo/bin:$PATH
cargo build --all --all-targets
- run:
name: Run all tests
command: |
export PATH=$USERPROFILE/.cargo/bin:$PATH
cargo test --all
workflows:
version: 2
build:
jobs:
- "build-default"
- "build-lua53"
- "build-lua51"
- "build-windows"
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## [0.19.1]
- The -sys crates (bumped to 0.1.1) now use pregenerated bindgen outputs in the
package instead of running bindgen at build time. This means that libclang is
no longer needed when building.
- A Windows build has been added to CI.

## [0.19.0]
- The Lua C library build now uses separate -sys crates, and bindgen rather than
hand-maintained declarations. (Thanks @pollend!) The "builtin-lua51" feature
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rlua"
version = "0.19.0"
version = "0.19.1"
authors = ["kyren <kerriganw@gmail.com>"]
edition = "2018"
description = "High level bindings to Lua 5.x"
Expand Down Expand Up @@ -32,9 +32,9 @@ libc = { version = "0.2" }
num-traits = { version = "0.2.14" }
bitflags = { version = "1.0.4" }
bstr = {version = "0.2", features = ["std"], default_features = false }
rlua-lua54-sys = { version = "0.1.0", optional = true }
rlua-lua53-sys = { version = "0.1.0", optional = true }
rlua-lua51-sys = { version = "0.1.0", optional = true }
rlua-lua54-sys = { version = "0.1.1", optional = true }
rlua-lua53-sys = { version = "0.1.1", optional = true }
rlua-lua51-sys = { version = "0.1.1", optional = true }


[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions crates/rlua-lua51-sys/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rlua-lua51-sys"
version = "0.1.0"
version = "0.1.1"
keywords = ["bindings", "lua"]
categories = ["external-ffi-bindings"]
description = "Bindings to lua's C API"
Expand All @@ -16,7 +16,6 @@ libc = "0.2"

[build-dependencies]
cc = "1.0"
bindgen = "0.59.2"
pkg-config = "0.3.24"

[features]
Expand Down
23 changes: 1 addition & 22 deletions crates/rlua-lua51-sys/build.rs
Expand Up @@ -5,17 +5,11 @@ use std::path::PathBuf;

fn main() {
let lua_folder = "lua-5.1.5";
let wrapper_h = "wrapper_lua51.h";

let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());

let mut binding_config = bindgen::Builder::default();

if cfg!(feature = "lua51-pkg-config") {
let library = pkg_config::Config::new().probe("lua5.1").unwrap();
for path in &library.include_paths {
binding_config = binding_config.clang_arg(format!("-I{}", path.to_string_lossy()));
}
let _library = pkg_config::Config::new().probe("lua5.1").unwrap();
} else {
let lua_dir = PathBuf::from(lua_folder).join("src");
let target_os = env::var("CARGO_CFG_TARGET_OS");
Expand Down Expand Up @@ -70,20 +64,5 @@ fn main() {
cc_config_build
.out_dir(dst.join("lib"))
.compile("liblua5.1.a");

binding_config = binding_config.clang_arg(format!("-I{}", lua_dir.to_string_lossy()));
}

println!("cargo:rerun-if-changed={}", wrapper_h);
let bindings = binding_config
.size_t_is_usize(true)
.header(wrapper_h)
.clang_arg("-x")
.clang_arg("c")
.generate()
.expect("Unable to generate bindings");

bindings
.write_to_file(dst.join("bindings.rs"))
.expect("Couldn't write bindings!");
}

0 comments on commit 173856a

Please sign in to comment.