Skip to content

Commit 8b2a617

Browse files
committed
Add plugin abi feature gates and nix dev shell
1 parent fc95461 commit 8b2a617

5 files changed

Lines changed: 153 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "memflow-native"
33
version = "0.2.6"
44
authors = ["Aurimas Blažulionis <0x60@pm.me>", "ko1N <ko1N1337@gmail.com>"]
55
edition = "2021"
6+
build = "build.rs"
67
description = "System call based proxy-OS for memflow"
78
documentation = "https://docs.rs/memflow-native"
89
readme = "README.md"
@@ -22,6 +23,9 @@ libc = { version = "0.2" }
2223
log = "0.4"
2324
memflow = { version = "0.2", features = ["plugins", "goblin"] }
2425

26+
[build-dependencies]
27+
memflow = { version = "0.2", features = ["plugins"] }
28+
2529
# we keep procfs on version 0.15.x because it does not build properly with the backtrace on 0.16.x
2630
# tracking issue: https://github.com/eminence/procfs/pull/309
2731
[target.'cfg(target_os = "linux")'.dependencies]

build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn main() {
2+
println!("cargo:rerun-if-changed=Cargo.toml");
3+
println!("cargo:rerun-if-changed=Cargo.lock");
4+
println!("cargo:rustc-check-cfg=cfg(memflow_plugin_api, values(\"1\", \"2\"))");
5+
6+
match memflow::plugins::MEMFLOW_PLUGIN_VERSION {
7+
1 => println!("cargo:rustc-cfg=memflow_plugin_api=\"1\""),
8+
2 => println!("cargo:rustc-cfg=memflow_plugin_api=\"2\""),
9+
other => panic!("Unsupported MEMFLOW_PLUGIN_VERSION: {other}"),
10+
}
11+
}

flake.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
description = "Development shell for memflow";
3+
4+
inputs = {
5+
flake-utils.url = "github:numtide/flake-utils";
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
rust-overlay.url = "github:oxalica/rust-overlay";
8+
};
9+
10+
outputs =
11+
{
12+
self,
13+
flake-utils,
14+
nixpkgs,
15+
rust-overlay,
16+
}:
17+
flake-utils.lib.eachDefaultSystem (
18+
system:
19+
let
20+
overlays = [
21+
(import rust-overlay)
22+
];
23+
24+
pkgs = import nixpkgs {
25+
inherit overlays system;
26+
};
27+
28+
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
29+
in
30+
{
31+
devShells.default = pkgs.mkShell {
32+
buildInputs = [
33+
pkgs.pkg-config
34+
rustToolchain
35+
];
36+
};
37+
}
38+
);
39+
}

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.82.0"
3+
components = ["clippy", "rustfmt"]

0 commit comments

Comments
 (0)