1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-11 11:47:03 +03:00
nickel/core/build.rs
Taeer Bar-Yam 91d63ed611
add %eval_nix% primop (#1465)
* add importing nix files behind a nix-experimental feature flag

* add %eval_nix% builtin to evaluate a nix string

* basic error reporting from nix

* error messages

* use pkg-config to find nix dependency

* nice error message when feature disabled

* better errors

* resolve XXX

* put appropriate dependencies in nativeBuildInputs

* explain -sys crate option

* no %% around builtins in error messages

* clippy needs nativeBuildInputs

* clippy

* fix cargo doc

* use nix master

* c++17 -> c++20

* cargo fmt

* review comments

* fixup after merge

* fix after rebase

* revert to (hopefully) known good nix commit

* try using nix's own nixpkgs

* this worked on build02

* debug for mac CI

* debug doesn't work

* cargo fmt

* debug

* don't fail everything if we can't debug

* debug take N

* nix-version

* remove debug

* disable checks for nix on x86_64-darwin
2023-10-09 15:08:55 +00:00

32 lines
1.1 KiB
Rust

fn main() {
lalrpop::Configuration::new()
.use_cargo_dir_conventions()
.process_file("src/parser/grammar.lalrpop")
.unwrap();
#[cfg(feature = "nix-experimental")]
{
use cxx_build::CFG;
use std::path::PathBuf;
for lib in &["nix-store", "nix-cmd", "nix-expr", "nix-main"] {
let lib = pkg_config::Config::new()
.atleast_version("2.16.0")
.probe(lib)
.unwrap();
let lib_include_paths = lib.include_paths.iter().map(PathBuf::as_path);
CFG.exported_header_dirs.extend(lib_include_paths);
}
cxx_build::bridge("src/nix_ffi/mod.rs")
.file("src/nix_ffi/cpp/nix.cc")
.flag_if_supported("-std=c++20")
.flag_if_supported("-U_FORTIFY_SOURCE") // Otherwise builds with `-O0` raise a lot of warnings
.compile("nickel-lang");
println!("cargo:rerun-if-changed=src/nix_ffi/mod.rs");
println!("cargo:rerun-if-changed=src/nix_ffi/cpp/nix.cc");
println!("cargo:rerun-if-changed=src/nix_ffi/cpp/nix.hh");
}
}