Skip to content
Snippets Groups Projects
Commit f8f5c8ec authored by Lennard Gäher's avatar Lennard Gäher
Browse files

Fix regression with building dependencies


Co-authored-by: default avatarLennard Gäher <l.gaeher@posteo.de>
Co-authored-by: default avatarVincent Lafeychine <vincent.lafeychine@proton.me>
parent 1b248432
No related branches found
No related tags found
1 merge request!50Fix regression with building dependencies
Pipeline #103857 passed
......@@ -158,7 +158,7 @@
buildInputs = [rust.toolchain pkgs.gnupatch];
nativeBuildInputs = with pkgs;
[makeWrapper]
++ lib.optionals stdenv.isDarwin [libzip];
++ lib.optionals stdenv.isDarwin [libzip libiconv];
postInstall = with pkgs.lib.strings; ''
wrapProgram $out/bin/refinedrust-rustc \
......
......@@ -435,6 +435,7 @@ name = "rrconfig"
version = "0.1.0"
dependencies = [
"config",
"lazy_static",
"log",
"path-clean",
"serde",
......
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "deps_build"
version = "0.1.0"
dependencies = [
"libc",
]
[[package]]
name = "libc"
version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[package]
name = "deps_build"
version = "0.1.0"
edition = "2021"
[dependencies]
libc = "0.2"
[workspace]
members = []
(lang dune 3.8)
(using coq 0.8)
(name deps_build)
/// This is empty to test the build of the libc dependency, as a guard against regressions of https://gitlab.mpi-sws.org/lgaeher/refinedrust-dev/-/merge_requests/50.
fn dummy() {}
use std::{env, path, process};
const TARGET_DIR: &str = if cfg!(debug_assertions) { "debug" } else { "release" };
fn build_refinedrust() {
let mut cargo = process::Command::new("cargo");
cargo.arg("build");
let status = cargo.status().expect("failed to build refinedrust project");
assert!(status.success());
}
fn build_subproject(project_path: &str) {
let Ok(crate_dir) = env::var("CARGO_MANIFEST_DIR") else {
panic!("CARGO_MANIFEST_DIR must be set to find the home of the crate");
};
let Some(workspace_dir) = path::Path::new(&crate_dir).parent() else {
unreachable!("The crate `refinedrust_frontend` is inside a workspace");
};
let target_dir = workspace_dir.join("target").join(TARGET_DIR);
let path = format!("{}:{}", target_dir.display(), env::var("PATH").unwrap_or_default());
let mut cargo = process::Command::new("cargo");
cargo.env("PATH", path);
cargo.args(["-Z", "unstable-options"]).args(["-C", project_path]);
cargo.arg("refinedrust");
let status = cargo.status().expect(project_path);
assert!(status.success());
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn run_deps_build() {
build_refinedrust();
build_subproject("./tests/deps_build/");
}
}
......@@ -13,3 +13,4 @@ log.workspace = true
path-clean.workspace = true
serde.workspace = true
serde_json.workspace = true
lazy_static.workspace = true
......@@ -5,18 +5,21 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::cell::RefCell;
use std::env;
use std::path::PathBuf;
use std::sync::RwLock;
use std::{env, mem};
use config::{Config, Environment, File, FileFormat};
use lazy_static::lazy_static;
use path_clean::PathClean;
use serde::Deserialize;
pub mod arg_value;
pub mod launch;
thread_local! {
static SETTINGS: RefCell<Config> = {
lazy_static! {
// RwLock due to rustc parallelism
static ref SETTINGS: RwLock<Config> = RwLock::new({
let mk_config = || {
let mut builder = Config::builder();
......@@ -66,14 +69,14 @@ thread_local! {
builder.build()
};
RefCell::new(mk_config().unwrap())
}
mk_config().unwrap()
});
}
/// Generate a dump of the settings
#[must_use]
pub fn dump() -> String {
SETTINGS.with_borrow(|c| format!("{:#?}", c))
format!("{:#?}", SETTINGS.read().unwrap())
}
/// Makes the path absolute with respect to the `work_dir`.
......@@ -98,7 +101,7 @@ fn read_optional_setting<T>(name: &'static str) -> Option<T>
where
T: Deserialize<'static>,
{
SETTINGS.with_borrow(|c| c.get(name).ok())
SETTINGS.read().unwrap().get(name).ok()
}
fn read_setting<T>(name: &'static str) -> T
......@@ -110,8 +113,10 @@ where
fn write_setting<T: Into<config::Value>>(key: &'static str, value: T) {
let builder = Config::builder().set_override(key, value).unwrap();
SETTINGS.set(builder.add_source(SETTINGS.take()).build().unwrap());
let mut w = SETTINGS.write().unwrap();
let old_settings = mem::take(&mut *w);
let new_settings = builder.add_source(old_settings).build().unwrap();
*w = new_settings;
}
#[must_use]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment