Skip to content

Commit 0ee9256

Browse files
committed
upgrade to edition 2024, rust 1.90, new cudd repo
This commit upgrades the crate to edition 2024 and rust version 1.90 and switches to the cudd repo of the newly formed cudd [organisation](https://github.com/cuddorg). The upgrade includes - switching to the new import syntax - replacing or escaping the 'gen' variable names where necessary - wraping 'extern' declartion in unsafe blocks - fixing the clippy complaints - upgrading github action workflow Additionally, the build process now uses sha256 sums instead of md5 sums.
1 parent b0ced69 commit 0ee9256

10 files changed

Lines changed: 122 additions & 126 deletions

File tree

.github/workflows/build.yml

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on: [push]
33
env:
44
# A fixed version used for testing, so that the builds don't
55
# spontaneously break after a few years.
6-
RUST_VERSION: "1.53.0"
6+
RUST_VERSION: "1.90.0"
7+
CARGO_TERM_COLOR: always
8+
79
jobs:
810
# Checks syntax formatting.
911
fmt:
@@ -12,17 +14,13 @@ jobs:
1214
env:
1315
RUSTFLAGS: "-D warnings"
1416
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions-rs/toolchain@v1
17-
with:
18-
profile: minimal
19-
toolchain: ${{ env.RUST_VERSION }}
20-
override: true
21-
- run: rustup component add rustfmt
22-
- uses: actions-rs/cargo@v1
23-
with:
24-
command: fmt
25-
args: --all -- --check
17+
- uses: actions/checkout@v4
18+
- name: Install rust version
19+
run: rustup install ${RUST_VERSION}
20+
- name: Add rustfmt
21+
run: rustup +${RUST_VERSION} component add rustfmt
22+
- name: Check formatting
23+
run: cargo +${RUST_VERSION} fmt -- --check
2624

2725
# Run basic code validity check.
2826
check:
@@ -32,15 +30,11 @@ jobs:
3230
env:
3331
RUSTFLAGS: "-D warnings"
3432
steps:
35-
- uses: actions/checkout@v2
36-
- uses: actions-rs/toolchain@v1
37-
with:
38-
profile: minimal
39-
toolchain: ${{ env.RUST_VERSION }}
40-
override: true
41-
- uses: actions-rs/cargo@v1
42-
with:
43-
command: check
33+
- uses: actions/checkout@v4
34+
- name: Install rust version
35+
run: rustup install ${RUST_VERSION}
36+
- name: check
37+
run: cargo +${RUST_VERSION} check
4438

4539
# Run tests.
4640
test:
@@ -50,15 +44,11 @@ jobs:
5044
env:
5145
RUSTFLAGS: "-D warnings"
5246
steps:
53-
- uses: actions/checkout@v2
54-
- uses: actions-rs/toolchain@v1
55-
with:
56-
profile: minimal
57-
toolchain: ${{ env.RUST_VERSION }}
58-
override: true
59-
- uses: actions-rs/cargo@v1
60-
with:
61-
command: test
47+
- uses: actions/checkout@v4
48+
- name: Install rust version
49+
run: rustup install ${RUST_VERSION}
50+
- name: check
51+
run: cargo +${RUST_VERSION} test
6252

6353
# Run tests on macOS.
6454
test-macos:
@@ -68,15 +58,11 @@ jobs:
6858
env:
6959
RUSTFLAGS: "-D warnings"
7060
steps:
71-
- uses: actions/checkout@v2
72-
- uses: actions-rs/toolchain@v1
73-
with:
74-
profile: minimal
75-
toolchain: ${{ env.RUST_VERSION }}
76-
override: true
77-
- uses: actions-rs/cargo@v1
78-
with:
79-
command: test
61+
- uses: actions/checkout@v4
62+
- name: Install rust version
63+
run: rustup install ${RUST_VERSION}
64+
- name: check
65+
run: cargo +${RUST_VERSION} test
8066

8167
# Checks code style.
8268
clippy:
@@ -86,13 +72,8 @@ jobs:
8672
env:
8773
RUSTFLAGS: "-D warnings"
8874
steps:
89-
- uses: actions/checkout@v2
90-
- uses: actions-rs/toolchain@v1
91-
with:
92-
profile: minimal
93-
toolchain: ${{ env.RUST_VERSION }}
94-
override: true
95-
- run: rustup component add clippy
96-
- uses: actions-rs/cargo@v1
97-
with:
98-
command: clippy
75+
- uses: actions/checkout@v4
76+
- name: Install rust version
77+
run: rustup install ${RUST_VERSION}
78+
- name: check
79+
run: cargo +${RUST_VERSION} clippy

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "cudd-sys"
33
version = "1.0.0"
4+
edition = "2024"
45
authors = ["Philip Lewis <pcl@pclewis.com>"]
56
build = "build.rs"
67
description = "Bindings for CU Decision Diagram library (CUDD)"
@@ -11,7 +12,7 @@ license = "CC0-1.0"
1112
libc = "0.2"
1213

1314
[build-dependencies]
14-
autotools = "0.2.3"
15+
autotools = "0.2.7"
1516

1617
[features]
1718
default = ["build_cudd"]
@@ -21,4 +22,4 @@ default = ["build_cudd"]
2122
build_cudd = []
2223

2324
[package.metadata.docs.rs]
24-
no-default-features = true
25+
no-default-features = true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This crate provides unsafe Rust bindings for the University of Colorado decision diagram
88
package (CUDD), including the DDDMP serialisation library. It uses version `3.0.0` of CUDD
9-
available from the unofficial [Github mirror](https://github.com/ivmai/cudd) and compiles on
9+
available from the unofficial [Github mirror](https://github.com/cuddorg/cudd) and compiles on
1010
Linux and MacOS (you should be also able to build CUDD on Windows using cygwin, but the project
1111
is not set-up to do it automatically).
1212

@@ -33,4 +33,4 @@ a function that isn't exported yet, let us know in the issues.
3333
reproduced using a semi-automated method with a manual validation step (bunch of regexes
3434
that a human makes sure didn't break anything ;)). As such, it is possible that there
3535
are some minor problems that need to be sorted out. Please file an issue if you see any
36-
unexpected behaviour or segfaults.
36+
unexpected behavior or segfaults.

build.rs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
extern crate autotools;
22

3+
use SHA256Status::{Mismatch, Unknown};
34
use autotools::Config;
45
use std::env;
56
use std::io::ErrorKind;
67
use std::path::{Path, PathBuf};
78
use std::process::Command;
8-
use MD5Status::{Mismatch, Unknown};
99

10-
const PACKAGE_URL: &str = "https://github.com/ivmai/cudd/archive/refs/tags/cudd-3.0.0.tar.gz";
11-
const PACKAGE_MD5: &str = "edca9c69528256ca8ae37be9cedef73f";
10+
const PACKAGE_URL: &str =
11+
"https://github.com/cuddorg/cudd/releases/download/cudd-3.0.0/cudd-3.0.0.tar.gz";
12+
const PACKAGE_SHA256: &str = "5fe145041c594689e6e7cf4cd623d5f2b7c36261708be8c9a72aed72cf67acce";
1213

1314
#[derive(Debug)]
15+
#[allow(dead_code)]
1416
enum FetchError {
1517
CommandError(std::process::ExitStatus),
1618
IOError(std::io::Error),
1719
PathExists,
1820
}
1921

20-
enum MD5Status {
22+
enum SHA256Status {
2123
Match,
2224
Mismatch,
2325
Unknown,
@@ -33,19 +35,23 @@ impl From<std::io::Error> for FetchError {
3335
fn run_command(cmd: &mut Command) -> Result<(String, String), FetchError> {
3436
let output = cmd.output()?;
3537

36-
return if output.status.success() {
38+
if output.status.success() {
3739
Ok((
3840
String::from_utf8(output.stdout).unwrap(),
3941
String::from_utf8(output.stderr).unwrap(),
4042
))
4143
} else {
4244
eprintln!("Command {:?} exited with status {}", cmd, output.status);
4345
Err(FetchError::CommandError(output.status))
44-
};
46+
}
4547
}
4648

47-
/// Fetch a file from a URL if it does not already exist in out_dir and verify its md5sum if possible.
48-
fn fetch_package(out_dir: &str, url: &str, md5: &str) -> Result<(PathBuf, MD5Status), FetchError> {
49+
/// Fetch a file from a URL if it does not already exist in out_dir and verify its sha256sum if possible.
50+
fn fetch_package(
51+
out_dir: &str,
52+
url: &str,
53+
sha256: &str,
54+
) -> Result<(PathBuf, SHA256Status), FetchError> {
4955
let out_path = Path::new(&out_dir);
5056
let target_path = out_path.join(Path::new(url).file_name().unwrap());
5157
let target_path_str = target_path.clone().into_os_string().into_string().unwrap();
@@ -55,7 +61,7 @@ fn fetch_package(out_dir: &str, url: &str, md5: &str) -> Result<(PathBuf, MD5Sta
5561
// Path does not exist! Start download...
5662
println!("Downloading {} to {}", url, target_path_str);
5763
let mut command = Command::new("curl");
58-
command.args(&["-L", url, "-o", target_path_str.as_str()]);
64+
command.args(["-L", url, "-o", target_path_str.as_str()]);
5965
run_command(&mut command)?;
6066
}
6167
Ok(data) if data.is_file() => {
@@ -65,20 +71,20 @@ fn fetch_package(out_dir: &str, url: &str, md5: &str) -> Result<(PathBuf, MD5Sta
6571
Err(error) => return Err(FetchError::from(error)),
6672
}
6773

68-
// Now run md5 sum check:
69-
let mut command_1 = Command::new("md5sum");
74+
// Now run sha256 sum check:
75+
let mut command_1 = Command::new("sha256sum");
7076
command_1.arg(target_path.clone());
71-
let mut command_2 = Command::new("md5");
77+
let mut command_2 = Command::new("shasum -a 256");
7278
command_2.arg(target_path.clone());
73-
let md5_result = run_command(&mut command_1).or_else(|_| run_command(&mut command_2));
79+
let sha256_result = run_command(&mut command_1).or_else(|_| run_command(&mut command_2));
7480

75-
let md5_status = match md5_result {
76-
Err(_) => MD5Status::Unknown,
77-
Ok((output, _)) if output.contains(md5) => MD5Status::Match,
78-
_ => MD5Status::Mismatch,
81+
let sha256_status = match sha256_result {
82+
Err(_) => SHA256Status::Unknown,
83+
Ok((output, _)) if output.contains(sha256) => SHA256Status::Match,
84+
_ => SHA256Status::Mismatch,
7985
};
8086

81-
Ok((target_path, md5_status))
87+
Ok((target_path, sha256_status))
8288
}
8389

8490
fn main() -> Result<(), String> {
@@ -91,13 +97,13 @@ fn main() -> Result<(), String> {
9197
let out_dir = env::var("OUT_DIR")
9298
.map_err(|_| "Environmental variable `OUT_DIR` not defined.".to_string())?;
9399

94-
let (tar_path, md5_status) = fetch_package(&out_dir, PACKAGE_URL, PACKAGE_MD5)
100+
let (tar_path, sha256_status) = fetch_package(&out_dir, PACKAGE_URL, PACKAGE_SHA256)
95101
.map_err(|e| format!("Error downloading CUDD package: {:?}.", e))?;
96102
let tar_path_str = tar_path.to_str().unwrap().to_string();
97103

98-
match md5_status {
99-
Unknown => eprintln!("WARNING: MD5 not computed. Package validation skipped."),
100-
Mismatch => return Err("CUDD package MD5 hash mismatch.".to_string()),
104+
match sha256_status {
105+
Unknown => eprintln!("WARNING: SHA256 not computed. Package validation skipped."),
106+
Mismatch => return Err("CUDD package SHA256 hash mismatch.".to_string()),
101107
_ => (),
102108
}
103109

@@ -113,7 +119,7 @@ fn main() -> Result<(), String> {
113119

114120
// un-tar package, ignoring the name of the top level folder, dumping into cudd_path instead.
115121
let mut tar_command = Command::new("tar");
116-
tar_command.args(&[
122+
tar_command.args([
117123
"xf",
118124
&tar_path_str,
119125
"--strip-components=1",

0 commit comments

Comments
 (0)