Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ on:
- master

jobs:
fmt:
name: Check formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: cargo fmt -- --check

test:
name: Test
runs-on: ${{ matrix.os }}
Expand Down
33 changes: 17 additions & 16 deletions build/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ thread_local! {
/// Adds an error encountered by the build script while executing a command.
fn add_command_error(name: &str, path: &str, arguments: &[&str], message: String) {
COMMAND_ERRORS.with(|e| {
e.borrow_mut()
.entry(name.into())
.or_default()
.push(format!(
"couldn't execute `{} {}` (path={}) ({})",
name,
arguments.join(" "),
path,
message,
))
e.borrow_mut().entry(name.into()).or_default().push(format!(
"couldn't execute `{} {}` (path={}) ({})",
name,
arguments.join(" "),
path,
message,
))
});
}

Expand Down Expand Up @@ -190,14 +187,14 @@ const DIRECTORIES_WINDOWS: &[(&str, bool)] = &[
("C:\\LLVM\\lib", true),
// LLVM + Clang can be installed as a component of Visual Studio.
// https://github.com/KyleMayes/clang-sys/issues/121
("C:\\Program Files*\\Microsoft Visual Studio\\**\\VC\\Tools\\Llvm\\**\\lib", true),
(
"C:\\Program Files*\\Microsoft Visual Studio\\**\\VC\\Tools\\Llvm\\**\\lib",
true,
),
];

/// `libclang` directory patterns for illumos
const DIRECTORIES_ILLUMOS: &[&str] = &[
"/opt/ooce/llvm-*/lib",
"/opt/ooce/clang-*/lib",
];
const DIRECTORIES_ILLUMOS: &[&str] = &["/opt/ooce/llvm-*/lib", "/opt/ooce/clang-*/lib"];

//================================================
// Searching
Expand Down Expand Up @@ -345,7 +342,11 @@ pub fn search_libclang_directories(filenames: &[String], variable: &str) -> Vec<
let directories = if test!() {
directories
.iter()
.map(|d| d.strip_prefix('/').or_else(|| d.strip_prefix("C:\\")).unwrap_or(d))
.map(|d| {
d.strip_prefix('/')
.or_else(|| d.strip_prefix("C:\\"))
.unwrap_or(d)
})
.collect::<Vec<_>>()
} else {
directories
Expand Down
9 changes: 7 additions & 2 deletions build/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ fn search_libclang_directories(runtime: bool) -> Result<Vec<(PathBuf, String, Ve
}
}

if target_os!("freebsd") || target_os!("haiku") || target_os!("netbsd") || target_os!("openbsd") {
if target_os!("freebsd") || target_os!("haiku") || target_os!("netbsd") || target_os!("openbsd")
{
// Some BSD distributions don't create a `libclang.so` symlink either,
// but use a different naming scheme for versioned files (e.g.,
// `libclang.so.7.0`).
Expand Down Expand Up @@ -267,7 +268,11 @@ pub fn link() {

// Strip extensions and trailing version numbers (e.g., the `.so.7.0` in
// `libclang.so.7.0`) and also `.dll` for MinGW / MSYS.
let name = match name.find(".dylib").or_else(|| name.find(".so")).or_else(|| name.find(".dll")) {
let name = match name
.find(".dylib")
.or_else(|| name.find(".so"))
.or_else(|| name.find(".dll"))
{
Some(index) => &name[0..index],
None => name,
};
Expand Down
4 changes: 3 additions & 1 deletion build/macros.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: Apache-2.0

macro_rules! test {
() => (cfg!(test) && ::std::env::var("_CLANG_SYS_TEST").is_ok());
() => {
cfg!(test) && ::std::env::var("_CLANG_SYS_TEST").is_ok()
};
}

macro_rules! target_os {
Expand Down
Loading