Skip to content

Commit

Permalink
feat(ci): nix scripts for spdk integration
Browse files Browse the repository at this point in the history
* Added shell script to configure and make SPDK.
* Added Nix overlays for SPDK, FIO, Nvme, Rust.
* Added Nix shell configuration that provides environment for SPDK development.

Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed May 21, 2024
1 parent a8b4170 commit f38c9a1
Show file tree
Hide file tree
Showing 17 changed files with 1,136 additions and 308 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.idea
.pregenerated
/Cargo.lock
/build_logs
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Read about SPDK here: [https://spdk.io/](https://spdk.io/).
both linking to an SPDK library installed system-wide, or to SPDK libraries
and headers located in the SPDK build directory.

`spdk-rs` uses `SPDK_PATH` environment variable to locate SPDK. If it is not
`spdk-rs` uses `SPDK_ROOT_DIR` environment variable to locate SPDK. If it is not
set, `spdk-rs` tries to find SPDK in `spdk-rs/spdk` directory.

In order to get SPDK on the system, one can either use the Nix scripts
Expand Down Expand Up @@ -87,7 +87,7 @@ make
* ISAL is now mandatory
* When upgrading from previous versions, clean the SPDK directory
before building (e.g. git clean).
* An `AS` is now required, either `yasm` or `nasm`.
* An `AS` shell var must be set, either `yasm` or `nasm`.
* Zone support for uring must be disabled.
* Crypto must be disabled.

Expand All @@ -101,6 +101,26 @@ AS=yasm ./configure --enable-debug --target-arch=nehalem --without-shared \
make
```

#### Version >= 24.01
* ISAL is now mandatory
* When upgrading from previous versions, clean the SPDK directory
before building (e.g. git clean).
* `AS` must be `nasm` now.
* Zone support for uring must be disabled.
* Crypto must be disabled.
* FUSE must be disabled.

```
AS=nasm ./configure --enable-debug --target-arch=nehalem --without-shared \
--without-crypto \
--without-nvme-cuse --without-fuse \
--with-uring --without-uring-zns \
--disable-unit-tests --disable-tests \
--with-fio=$(realpath $(dirname $(which fio))/..)
make
```

---
**NOTE**

Expand All @@ -110,11 +130,11 @@ and _install_ SPDK in other directory using `Makefile` is not supported.
___


After build, SPDK can be used to build `spdk-rs`. Either set `SPDK_PATH`,
After build, SPDK can be used to build `spdk-rs`. Either set `SPDK_ROOT_DIR`,
or create a symlink in `spdk-rs` directory to point to your SPDK.

```
export SPDK_PATH=${your_spdk_dir}
export SPDK_ROOT_DIR=${your_spdk_dir}
```
or
```
Expand Down Expand Up @@ -142,5 +162,5 @@ start it again with:
nix-shell
```

`SPDK_PATH` variable takes precedence over SPDK found in `spdk-rs/spdk`,
`SPDK_ROOT_DIR` variable takes precedence over SPDK found in `spdk-rs/spdk`,
so no need to remove or rename it.
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ fn rust_fmt_nightly() -> Option<PathBuf> {

/// Returns absolute path for SPDK library.
fn get_spdk_path() -> Result<PathBuf, Error> {
let spdk_path = match env::var_os("SPDK_PATH") {
let spdk_path = match env::var_os("SPDK_ROOT_DIR") {
Some(s) => {
println!("SPDK_PATH variable is set to {}", s.to_str().unwrap());
println!("SPDK_ROOT_DIR variable is set to {}", s.to_str().unwrap());
PathBuf::from(s)
}
None => {
let mut spdk_path = get_root_dir();
spdk_path.push("spdk");
println!(
"SPDK_PATH variable not set, trying {}",
"SPDK_ROOT_DIR variable not set, trying {}",
spdk_path.to_str().unwrap()
);
spdk_path
Expand Down Expand Up @@ -190,7 +190,7 @@ fn configure_spdk() -> Result<LibraryConfig, Error> {
println!("Link against static SPDK...");
spdk_lib.cargo();

println!("cargo:rerun-if-env-changed=SPDK_PATH");
println!("cargo:rerun-if-env-changed=SPDK_ROOT_DIR");
println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH_FOR_TARGET");

Ok(spdk_lib)
Expand Down
Loading

0 comments on commit f38c9a1

Please sign in to comment.