diff --git a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs index 39743b083b..9403e50d01 100644 --- a/c2rust-ast-exporter/build.rs +++ b/c2rust-ast-exporter/build.rs @@ -127,8 +127,16 @@ fn build_native(llvm_info: &LLVMInfo) { // Build libclangAstExporter.a with cmake let dst = Config::new("src") // Where to find LLVM/Clang CMake files - .define("LLVM_DIR", &format!("{}/cmake/llvm", llvm_lib_dir)) - .define("Clang_DIR", &format!("{}/cmake/clang", llvm_lib_dir)) + .define( + "LLVM_DIR", + &env::var("CMAKE_LLVM_DIR") + .unwrap_or_else(|_| format!("{}/cmake/llvm", llvm_lib_dir)), + ) + .define( + "Clang_DIR", + &env::var("CMAKE_CLANG_DIR") + .unwrap_or_else(|_| format!("{}/cmake/clang", llvm_lib_dir)), + ) // What to build .build_target("clangAstExporter") .build(); diff --git a/shell.nix b/default.nix similarity index 53% rename from shell.nix rename to default.nix index 4b52603e75..cf6bbada8e 100644 --- a/shell.nix +++ b/default.nix @@ -1,5 +1,5 @@ let - nixpkgs = import {}; + nixpkgs = import { }; inherit (nixpkgs) pkgs llvmPackages; stdenv = pkgs.clangStdenv; in @@ -9,11 +9,14 @@ stdenv.mkDerivation { pkgs.clang pkgs.cmake pkgs.llvm + pkgs.libllvm pkgs.openssl pkgs.pkgconfig pkgs.python3 pkgs.rustup pkgs.zlib ]; - LIBCLANG_PATH="${llvmPackages.libclang}/lib"; + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + CMAKE_LLVM_DIR = "${llvmPackages.libllvm.dev}/lib/cmake/llvm"; + CMAKE_CLANG_DIR = "${llvmPackages.libclang.dev}/lib/cmake/clang"; }