diff options
author | Edward Barnard <eabarnard@gmail.com> | 2014-12-23 21:25:54 +0100 |
---|---|---|
committer | Edward Barnard <eabarnard@gmail.com> | 2014-12-23 21:29:56 +0100 |
commit | 3468420fd4aeb841c7d184570d20d6e64c04c970 (patch) | |
tree | 5251021e7d544884490d3f3a4ab4f1e7af14101d | |
parent | fbdb913b31d572bf9c67ec080b73aafe42db7e3e (diff) |
Add basic build script
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | build.rs | 25 | ||||
-rw-r--r-- | build/Makefile | 18 | ||||
-rw-r--r-- | src/clangll.rs | 1 |
4 files changed, 26 insertions, 20 deletions
@@ -5,7 +5,7 @@ version = "0.13.0" authors = ["Jyun-Yan You <jyyou.tw@gmail.com>"] license = "BSD-3-Clause" -build = ["make -e -C build"] +build = "build.rs" [lib] diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..fbc8e952 --- /dev/null +++ b/build.rs @@ -0,0 +1,25 @@ +use std::os; +use std::io::fs::PathExtensions; + +fn main() { + let clang_dir = if let Some(dir) = os::getenv("LIBCLANG_PATH") { + dir + } else if cfg!(any(target_os = "linux", target_os = "freebsd")) { + "/usr/lib".to_string() + } else if cfg!(target_os = "macos") { + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib".to_string() + } else { + panic!("Platform not supported"); + }; + + let clang_dir = Path::new(clang_dir); + + let clang_lib = os::dll_filename("clang"); + + let clang_path = clang_dir.join(clang_lib.clone()); + if !clang_path.exists() { + panic!("Unable to find {}", clang_lib); + } + + println!("cargo:rustc-flags=-l clang -L {}", clang_dir.as_str().unwrap()); +}
\ No newline at end of file diff --git a/build/Makefile b/build/Makefile deleted file mode 100644 index d91d54b6..00000000 --- a/build/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -LIBCLANG_PATH=/usr/lib -DYLIB_EXT=.so - -ifeq ($(OS),Windows_NT) - # Not sure where default location is on windows - DYLIB_EXT=.dll -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Darwin) - LIBCLANG_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib - DYLIB_EXT=.dylib - endif -endif - -all: - rm -rf $(OUT_DIR)/* - ln -sf $(LIBCLANG_PATH)/libclang$(DYLIB_EXT) $(OUT_DIR) - diff --git a/src/clangll.rs b/src/clangll.rs index 8a32d2e1..af8167dd 100644 --- a/src/clangll.rs +++ b/src/clangll.rs @@ -839,7 +839,6 @@ pub const CXIndexOpt_IndexFunctionLocalSymbols: ::libc::c_uint = 2; pub const CXIndexOpt_IndexImplicitTemplateInstantiations: ::libc::c_uint = 4; pub const CXIndexOpt_SuppressWarnings: ::libc::c_uint = 8; pub const CXIndexOpt_SkipParsedBodiesInSession: ::libc::c_uint = 16; -#[link(name = "clang")] extern "C" { pub fn clang_getCString(string: CXString) -> *const ::libc::c_char; pub fn clang_disposeString(string: CXString); |