From eaf79f46ed368370c28a58d0dafb45ade285d239 Mon Sep 17 00:00:00 2001 From: "Chris West (Faux)" Date: Thu, 13 Jul 2017 13:49:36 +0100 Subject: [PATCH] switch to gcc build script --- Cargo.toml | 3 +++ apt-pkg-c/.gitignore | 1 + apt-pkg-c/Makefile | 9 ++++----- build.rs | 4 +++- src/raw.rs | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 apt-pkg-c/.gitignore diff --git a/Cargo.toml b/Cargo.toml index 5157cb9..cd651c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,6 @@ authors = ["Chris West (Faux) "] [dependencies] lazy_static = "0.2.8" libc = "0.2.26" + +[build-dependencies] +gcc = "0.3.51" diff --git a/apt-pkg-c/.gitignore b/apt-pkg-c/.gitignore new file mode 100644 index 0000000..a50a7d6 --- /dev/null +++ b/apt-pkg-c/.gitignore @@ -0,0 +1 @@ +lib.o diff --git a/apt-pkg-c/Makefile b/apt-pkg-c/Makefile index 69c4b42..b4954a5 100644 --- a/apt-pkg-c/Makefile +++ b/apt-pkg-c/Makefile @@ -1,11 +1,10 @@ CXXFLAGS=-Wall -Wextra -g -all: libapt-pkg-c.a +all: clean check -lib.o: lib.cpp lib.h +check: lib.o -libapt-pkg-c.a: lib.o - ar rcs $@ $< +lib.o: lib.cpp clean: - $(RM) libapt-pkg-c.a lib.o + $(RM) lib.o diff --git a/build.rs b/build.rs index a4e2b34..0582ce1 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,5 @@ +extern crate gcc; + fn main() { - println!("cargo:rustc-link-search=apt-pkg-c") + gcc::compile_library("libapt-pkg-c.a", &["apt-pkg-c/lib.cpp"]); } diff --git a/src/raw.rs b/src/raw.rs index cd8dfca..1562509 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -9,7 +9,7 @@ use libc::c_char; pub type PCache = *mut c_void; pub type PPkgIterator = *mut c_void; -#[link(name = "apt-pkg-c")] +#[link(name = "apt-pkg-c", kind = "static")] #[link(name = "apt-pkg")] #[link(name = "stdc++")] extern {