From a521428ea2b51c0341a983e9126221f9d51270de Mon Sep 17 00:00:00 2001 From: Matteo Settenvini Date: Sat, 22 Feb 2025 00:35:01 +0100 Subject: [PATCH] build: early check user on libclang.so due to bindgen --- .pre-commit-config.yaml | 2 +- CMakeLists.txt | 9 +++++++++ Cargo.toml | 4 ++++ crates/nss/Cargo.toml | 4 +--- rust-toolchain.toml | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eca3b78..be3a8d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: hooks: - id: commitizen - id: commitizen-branch - stages: [push] + stages: [pre-push] - repo: local hooks: diff --git a/CMakeLists.txt b/CMakeLists.txt index b7433f1..bef300d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,15 @@ setup_crates(${CMAKE_CURRENT_SOURCE_DIR}) # ------------------------------- # Install Rust libraries or binaries +# libclang is required for bindgen, just check here +# for an early failure +unset(libclang_names) +foreach(clang_ver RANGE 9 100) + list(PREPEND libclang_names "clang-${clang_ver}") +endforeach() +list(REVERSE libclang_names) +find_library(LIBCLANG NAMES clang ${libclang_names} REQUIRED) + set(libname "libnss_parental_ctrls.so") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnss_parental_ctrls.so TYPE LIB diff --git a/Cargo.toml b/Cargo.toml index a0def9a..0d13c1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ version = "0.1.0" edition = "2024" license = "EUPL-1.2" readme = "README.md" +rust-version = "1.85" + +[profile.release] +panic = "unwind" # We rely on this for the NSS module [workspace] members = ["crates/nss"] diff --git a/crates/nss/Cargo.toml b/crates/nss/Cargo.toml index b277e74..600960e 100644 --- a/crates/nss/Cargo.toml +++ b/crates/nss/Cargo.toml @@ -11,15 +11,13 @@ version = { workspace = true } authors = { workspace = true } homepage = { workspace = true } repository = { workspace = true } +rust-version = { workspace = true } [lib] name = "nss_parental_ctrls" path = "src/lib.rs" crate-type = ["cdylib"] -[profile.release] -panic = "unwind" # We rely on this - [build-dependencies] bindgen = { workspace = true } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0a7f804..ada8778 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,6 +2,6 @@ # SPDX-License-Identifier: CC0-1.0 [toolchain] -channel = "1.85" +channel = "stable" profile = "default" components = ["rustfmt"]