Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build outside of source dir (using cmake crate) #36

Merged
merged 7 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -73,10 +71,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: cargo doc
Expand All @@ -92,10 +88,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo install cargo-hack
Expand All @@ -117,10 +111,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install ${{ matrix.msrv }}
uses: dtolnay/rust-toolchain@master
with:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: cargo generate-lockfile
Expand All @@ -49,10 +47,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install beta
if: hashFiles('Cargo.lock') != ''
uses: dtolnay/rust-toolchain@beta
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
Expand Down Expand Up @@ -76,10 +74,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Install nightly for -Zminimal-versions
Expand Down Expand Up @@ -118,10 +114,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install libibverbs dependencies
run: |
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev
- name: Configure CI host
run: ./configure-ci.sh
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
18 changes: 17 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions configure-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -euo pipefail

echo "Install libibverbs dependencies"
sudo apt-get update
sudo apt-get install libibverbs1 libibverbs-dev

echo "Install clang for rdma-core to be happy"
sudo apt-get install clang

echo "Move Cargo target dir to avoid super long paths"
mkdir /tmp/cargo

echo "Tell Cargo to use clang and target dir"
mkdir .cargo
cat >.cargo/config.toml <<EOF
[build]
target-dir = "/tmp/cargo"

[env]
CC = "clang"
CXX = "clang++"
LD = "clang"
EOF
3 changes: 2 additions & 1 deletion ibverbs-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ibverbs-sys"
version = "0.2.0+52.0"
version = "0.2.1+52.0"
edition = "2021"

description = "Raw, FFI bindings for RDMA ibverbs through rdma-core"
Expand All @@ -24,6 +24,7 @@ exclude = ["vendor/rdma-core/build/"]

[build-dependencies]
bindgen = "0.69.2"
cmake = "0.1.50"

# to make -Zminimal-versions work
[target.'cfg(any())'.dependencies]
Expand Down
23 changes: 15 additions & 8 deletions ibverbs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ fn main() {
println!("cargo:rustc-link-search=native={manifest_dir}/vendor/rdma-core/build/lib");
println!("cargo:rustc-link-lib=ibverbs");

// initialize and update submodules
if Path::new(".git").is_dir() {
if Path::new("vendor/rdma-core/CMakeLists.txt").exists() {
// don't touch source dir if not necessary
} else if Path::new(".git").is_dir() {
// initialize and update submodules
Command::new("git")
.args(["submodule", "update", "--init"])
.status()
Expand All @@ -22,16 +24,21 @@ fn main() {
}

// build vendor/rdma-core
Command::new("bash")
.current_dir("vendor/rdma-core/")
.args(["build.sh"])
.status()
.expect("Failed to build vendor/rdma-core using build.sh");
eprintln!("run cmake");
let built_in = cmake::Config::new("vendor/rdma-core")
.define("IN_PLACE", "1")
.define("NO_MAN_PAGES", "1")
.no_build_target(true)
.build();
let built_in = built_in
.to_str()
.expect("build directory path is not valid UTF-8");

// generate the bindings
eprintln!("run bindgen");
let bindings = bindgen::Builder::default()
.header("vendor/rdma-core/libibverbs/verbs.h")
.clang_arg("-Ivendor/rdma-core/build/include/")
.clang_arg(format!("-I{built_in}/include/"))
.allowlist_function("ibv_.*")
.allowlist_type("ibv_.*")
.bitfield_enum("ibv_access_flags")
Expand Down
Loading