Skip to content

Commit e54f37a

Browse files
Bindgen code 1 72 0 (#158)
* Revert "Update minimum rust version to 1.82.0" This reverts commit 373a0e5. * Have bindgen generate code suitable for compiling with rustc 1.72.0 * Avoid linux warnings * Avoid linux warnings
1 parent dc41616 commit e54f37a

File tree

5 files changed

+34
-47
lines changed

5 files changed

+34
-47
lines changed

.github/workflows/clippy_build_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
os: [ ubuntu-latest, macos-13, macos-14, macos-15 ]
28-
rust: [ stable, beta, 1.82.0 ] # Minimum Rust Version Supported = 1.82.0
28+
rust: [ stable, beta, 1.72.0 ] # Minimum Rust Version Supported = 1.72.0
2929
experimental: [ false ]
3030
include:
3131
- os: ubuntu-latest
@@ -35,7 +35,7 @@ jobs:
3535
rust: nightly
3636
experimental: true
3737
- os: macos-13
38-
rust: 1.82.0
38+
rust: 1.72.0
3939
experimental: true
4040
- os: macos-14
4141
rust: nightly

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ documentation = "https://docs.rs/libproc/latest/libproc"
88
readme = "README.md"
99
license = "MIT"
1010
edition = "2018"
11-
rust-version = "1.82"
11+
rust-version = "1.72"
1212

1313
[dependencies]
1414
errno = "0.3.0"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUST_MIN_VERSION := 1.82.0
1+
RUST_MIN_VERSION := 1.72.0
22
ACT := $(shell command -v act 2> /dev/null)
33
UNAME := $(shell uname -s)
44

README.md

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
[![codecov](https://codecov.io/gh/andrewdavidmackenzie/libproc-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/andrewdavidmackenzie/libproc-rs)
33

44
# libproc-rs
5-
65
This is a library for getting information about running processes for Mac OS X and Linux.
76

87
Add it to your project's `Cargo.toml`:
9-
108
```toml
119
libproc = "0.14.4"
1210
```
1311

1412
And then use it in your code:
15-
1613
```rust
1714
use libproc::libproc::proc_pid;
1815

1916
match proc_pid::pidpath(pid) {
20-
Ok(path) => println ! ("PID {}: has path {}", pid, path),
21-
Err(err) => writeln ! ( & mut std::io::stderr(), "Error: {}", err).unwrap()
17+
Ok(path) => println!("PID {}: has path {}", pid, path),
18+
Err(err) => writeln!(&mut std::io::stderr(), "Error: {}", err).unwrap()
2219
}
2320
```
2421

@@ -29,74 +26,61 @@ You can find the browseable docs for the latest release on [docs.rs](https://doc
2926
NOTE: `master` branch (code and docs) can differ from those docs prior to a new release.
3027

3128
# Minimum rust version
32-
3329
The minimum rust version required, by version:
34-
35-
* libproc-rs: 0.14.6 --> 1.74.1
30+
* libproc-rs: 0.14.6 --> 1.74.1
3631
* libproc-rs: 0.14.7 --> 1.72.0
37-
* libproc-rs: 0.14.10 --> 1.82.0
3832

3933
This is tested in CI and must pass.
4034

4135
# Test Matrix
42-
4336
The Github Actions CI test `libproc-rs` on :
4437

4538
rust versions:
46-
4739
* `stable` (must pass)
4840
* `beta` (must pass)
49-
* `1.82.0` (currently the minimum rust version supported) (must pass)
50-
* `nightly` (allowed to fail)
41+
* `1.72.0` (currently the minimum rust version supported) (must pass)
42+
* `nightly` (allowed to fail)
5143

5244
on the following platforms:
53-
5445
* `ubuntu-latest`
5546
* `macos-12` (Monterey) (Intel)
5647
* `macos-13` (Ventura) (Intel)
5748
* `macos-14` (Sonoma) (Arm64)
5849

5950
# Examples
60-
6151
Two simple examples are included to show libproc-rs working.
6252

6353
- `procinfo` that takes a PID as an optional argument (uses it's own pid if none supplied) and returns
6454
information about the process on stdout
6555
- `dmesg` is a version of dmesg implemented in rust that uses libproc-rs.
6656

6757
These can be ran thus:
68-
`sudo cargo run --example procinfo` or
58+
`sudo cargo run --example procinfo` or
6959
`sudo cargo run --example dmesg`
7060

7161
# Contributing
72-
7362
You are welcome to fork this repo and make a pull request, or write an issue.
7463

7564
## Experiment in OSS funding
76-
77-
I am exploring the ideas around Open Source Software funding from [RadWorks Foundation]([https://radworks.org/) via
78-
the [Drips Project](https://www.drips.network/)
65+
I am exploring the ideas around Open Source Software funding from [RadWorks Foundation]([https://radworks.org/) via the [Drips Project](https://www.drips.network/)
7966

8067
This project is in Drips [here](https://www.drips.network/app/projects/github/andrewdavidmackenzie/libproc-rs)
8168

8269
## Input Requested
83-
8470
* Suggestions for API, module re-org and cross-platform abstractions are welcome.
8571
* How to do error reporting? Define own new Errors, or keep simple with Strings?
8672
* Would like Path/PathBuf returned when it makes sense instead of String?
8773

8874
## TODO
89-
90-
See the [list of issues](https://github.com/andrewdavidmackenzie/libproc-rs/issues).
75+
See the [list of issues](https://github.com/andrewdavidmackenzie/libproc-rs/issues).
9176
I put the "help wanted" label where I need help from others.
92-
77+
9378
- Look at what similar methods could be implemented as a starting poon Linux
9479
- Complete the API on Mac OS X - figuring out all the Mac OS X / Darwin version mess....
9580
- Add more documentation (including samples with documentation test)
9681
- Add own custom error type and implement From::from to ease reporting of multiple error types in clients
9782

9883
## Build and Test Locally
99-
10084
If you're feeling lucky today, start with `make` that will run `clippy`, `test` and will build docs also.
10185

10286
If you want to stay "pure rust" : `cargo test` will build and test as usual.
@@ -112,34 +96,29 @@ In order to have tests pass when run as `root` or not, some tests need to check
11296
at run-time (using our own `am_root()` function is handy) and avoid failing if *not* run as `root`.
11397

11498
### Using `act` to run GH Actions locally
115-
11699
If you develop on macos but want to ensure code builds and tests pass on linux while making changes,
117100
you can use the [act](https://github.com/nektos/act) tool to run the Github Actions Workflows on
118101
the test matrix.
119102

120103
Just install `act` (`brew install act` on macOS) (previously install docker if you don't have it already,
121-
and make sure the daemon is running) then run `act push`. You can test a subset of the rust
104+
and make sure the daemon is running) then run `act push`. You can test a subset of the rust
122105
and os versions of the matrix with something like `act push --matrix os:ubuntu-latest`
123106

124107
## Enter the matrix
125-
126108
If you want to test locally as much of the test matrix as possible (different OS and
127109
versions of rust), that you can use `make matrix`. On macos, if you have `act`
128110
installed, it will use it to run the linux part of the matrix.
129111

130112
### Macos: clang detection and header file finding
131-
132113
Newer versions of `bindgen` have improved the detection of `clang` and hence macos header files.
133114
If you also have llvm/clang installed directly or via `brew` this may cause the build to fail saying it
134115
cannot find `libproc.h`. This can be fixed by setting `CLANG_PATH="/usr/bin/clang"` so that `bindgen`
135116
detects the Xcode version and hence can fidn the correct header files.
136117

137118
# Other docs
138-
139119
* [Reference docs](doc/References.md) used to build and document libproc-rs
140120
* Details on methods available in different [macOS versions](doc/MacosVersions.md)
141121

142122
# LICENSE
143-
144123
This code is licensed under MIT license (see LICENCE).
145124

build.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
#[cfg(target_os = "macos")]
22
fn main() {
3+
use bindgen::{RustEdition, RustTarget};
34
use std::env;
45
use std::path::Path;
56

6-
let bindings = bindgen::builder()
7-
.header_contents("libproc_rs.h", "#include <libproc.h>")
8-
.layout_tests(false)
9-
.clang_args(&["-x", "c++", "-I", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"])
10-
.generate()
11-
.expect("Failed to build libproc bindings");
7+
match RustTarget::stable(72, 0) {
8+
Ok(rust_target) => {
9+
let bindings = bindgen::builder()
10+
.header_contents("libproc_rs.h", "#include <libproc.h>")
11+
.rust_target(rust_target)
12+
.rust_edition(RustEdition::Edition2018)
13+
.layout_tests(false)
14+
.clang_args(&["-x", "c++", "-I", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"])
15+
.generate()
16+
.expect("Failed to build libproc bindings");
1217

13-
let output_path = Path::new(&env::var("OUT_DIR")
14-
.expect("OUT_DIR env var was not defined"))
15-
.join("osx_libproc_bindings.rs");
18+
let output_path = Path::new(&env::var("OUT_DIR")
19+
.expect("OUT_DIR env var was not defined"))
20+
.join("osx_libproc_bindings.rs");
1621

17-
bindings
18-
.write_to_file(output_path)
19-
.expect("Failed to write libproc bindings");
22+
bindings
23+
.write_to_file(output_path)
24+
.expect("Failed to write libproc bindings");
25+
}
26+
_ => eprintln!("Error executing bindgen")
27+
}
2028
}
2129

2230
#[cfg(any(target_os = "linux", target_os = "redox", target_os = "android"))]

0 commit comments

Comments
 (0)