mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-09-25 19:53:40 -06:00
Stricter linting rule (#582)
This commit is contained in:
@@ -28,3 +28,7 @@ dbg_macro = "deny"
|
||||
missing_const_for_fn = "deny"
|
||||
std_instead_of_alloc = "deny"
|
||||
std_instead_of_core = "deny"
|
||||
|
||||
[lints.rust]
|
||||
missing_docs = "deny"
|
||||
warnings = "deny"
|
||||
|
||||
@@ -1,71 +1,76 @@
|
||||
//! A build script.
|
||||
|
||||
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
|
||||
const LIB_GC_DIR: &str = "vendor/bdwgc";
|
||||
|
||||
#[cfg(feature = "autotools")]
|
||||
fn main() {
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("cd {dir} && ./autogen.sh"))
|
||||
.output()
|
||||
.unwrap();
|
||||
cfg_select! {
|
||||
feature = "cmake" => {
|
||||
fn main() {
|
||||
use cmake::Config;
|
||||
use std::path::Path;
|
||||
|
||||
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
|
||||
.join("src")
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.display()
|
||||
.to_string()
|
||||
.replace(r"\\?\", "");
|
||||
|
||||
let dst = Config::new(LIB_GC_DIR)
|
||||
.profile("Release")
|
||||
.define("GC_BUILD_SHARED_LIBS", "FALSE")
|
||||
.cflag(format!("-I{}", libatomic_include_path))
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
}
|
||||
}
|
||||
feature = "autotools" => {
|
||||
fn main() {
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("cd {dir} && ./autogen.sh"))
|
||||
.output()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
|
||||
.cflag("-fPIC")
|
||||
.build();
|
||||
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
|
||||
.cflag("-fPIC")
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=atomic_ops");
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=atomic_ops");
|
||||
|
||||
let dst = autotools::Config::new(LIB_GC_DIR)
|
||||
.cflag(format!(
|
||||
// spell-checker: disable-next-line
|
||||
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
|
||||
dst.join("include").display()
|
||||
))
|
||||
.build();
|
||||
let dst = autotools::Config::new(LIB_GC_DIR)
|
||||
.cflag(format!(
|
||||
// spell-checker: disable-next-line
|
||||
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
|
||||
dst.join("include").display()
|
||||
))
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("cd {dir} && git clean -dfx"))
|
||||
.output()
|
||||
.unwrap();
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("cd {dir} && git clean -dfx"))
|
||||
.output()
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cmake")]
|
||||
fn main() {
|
||||
use cmake::Config;
|
||||
use std::path::Path;
|
||||
|
||||
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
|
||||
.join("src")
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.display()
|
||||
.to_string()
|
||||
.replace(r"\\?\", "");
|
||||
|
||||
let dst = Config::new(LIB_GC_DIR)
|
||||
.profile("Release")
|
||||
.define("GC_BUILD_SHARED_LIBS", "FALSE")
|
||||
.cflag(format!("-I{}", libatomic_include_path))
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
}
|
||||
|
||||
+5
-2
@@ -3,8 +3,10 @@
|
||||
|
||||
mod error;
|
||||
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::ptr::null;
|
||||
use core::{
|
||||
alloc::{GlobalAlloc, Layout},
|
||||
ptr::null,
|
||||
};
|
||||
use libc::{c_int, c_void, size_t};
|
||||
|
||||
const GC_SUCCESS: c_int = 0;
|
||||
@@ -38,6 +40,7 @@ unsafe extern "C" {
|
||||
) -> *mut c_void;
|
||||
}
|
||||
|
||||
/// An allocator.
|
||||
pub struct Allocator;
|
||||
|
||||
impl Allocator {
|
||||
|
||||
Reference in New Issue
Block a user