diff --git a/recipes/core/ion/recipe.toml b/recipes/core/ion/recipe.toml index cfc46e9ed..de1b3ca69 100644 --- a/recipes/core/ion/recipe.toml +++ b/recipes/core/ion/recipe.toml @@ -8,3 +8,5 @@ DYNAMIC_INIT cookbook_cargo """ +[package] +shared-deps = ["libgcc"] diff --git a/recipes/dev/gnu-make/recipe.toml b/recipes/dev/gnu-make/recipe.toml index fb274e60b..48e78b61c 100644 --- a/recipes/dev/gnu-make/recipe.toml +++ b/recipes/dev/gnu-make/recipe.toml @@ -17,3 +17,5 @@ cp -rp "$COOKBOOK_SOURCE/." ./ cookbook_configure """ +[package] +shared-deps = ["libgcc"] diff --git a/recipes/libs/libgmp/recipe.toml b/recipes/libs/libgmp/recipe.toml index a2330bd67..2740fa0ee 100644 --- a/recipes/libs/libgmp/recipe.toml +++ b/recipes/libs/libgmp/recipe.toml @@ -17,3 +17,5 @@ DYNAMIC_INIT cookbook_configure """ +[package] +shared-deps = ["libgcc"] diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index 38e46cce2..7505d6556 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -38,3 +38,6 @@ else fi cookbook_configure """ + +[package] +shared-deps = ["libgcc"] diff --git a/recipes/libs/libmpfr/recipe.toml b/recipes/libs/libmpfr/recipe.toml index 3e653153c..ba0b80999 100644 --- a/recipes/libs/libmpfr/recipe.toml +++ b/recipes/libs/libmpfr/recipe.toml @@ -16,3 +16,5 @@ DYNAMIC_INIT cookbook_configure """ +[package] +shared-deps = ["libgcc", "libgmp"] diff --git a/recipes/libs/mpc/recipe.toml b/recipes/libs/mpc/recipe.toml index 749805ad4..f27c60ea9 100644 --- a/recipes/libs/mpc/recipe.toml +++ b/recipes/libs/mpc/recipe.toml @@ -19,3 +19,9 @@ DYNAMIC_INIT cookbook_configure """ +[package] +shared-deps = [ + "libgcc", + "libgmp", + "libmpfr", +] diff --git a/recipes/libs/nghttp2/recipe.toml b/recipes/libs/nghttp2/recipe.toml index ce862c9f7..05a5dec85 100644 --- a/recipes/libs/nghttp2/recipe.toml +++ b/recipes/libs/nghttp2/recipe.toml @@ -16,3 +16,6 @@ COOKBOOK_CONFIGURE_FLAGS+=( ) cookbook_configure """ + +[package] +shared-deps = ["libgcc"] diff --git a/recipes/libs/zlib/recipe.toml b/recipes/libs/zlib/recipe.toml index fe1fc8390..0ff21eb5e 100644 --- a/recipes/libs/zlib/recipe.toml +++ b/recipes/libs/zlib/recipe.toml @@ -11,3 +11,5 @@ script = """ "${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" """ +[package] +shared-deps = ["libgcc"] diff --git a/recipes/tools/gnu-binutils/recipe.toml b/recipes/tools/gnu-binutils/recipe.toml index 198037b1d..ec269f387 100644 --- a/recipes/tools/gnu-binutils/recipe.toml +++ b/recipes/tools/gnu-binutils/recipe.toml @@ -37,11 +37,10 @@ cookbook_configure """ [package] -dependencies = [ +shared-deps = [ "libgcc", "expat", "libgmp", "libmpfr", "zlib", ] - diff --git a/src/bin/cook.rs b/src/bin/cook.rs index fcfab14a9..c573311c0 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -11,6 +11,12 @@ use std::{ use termion::{color, style}; use walkdir::{DirEntry, WalkDir}; +fn should_build_shared() -> bool { + use std::sync::OnceLock; + static YES: OnceLock = OnceLock::new(); + *YES.get_or_init(|| env::var("COOKBOOK_PREFER_STATIC").expect("COOKBOOK_PREFER_STATIC").is_empty()) +} + fn remove_all(path: &Path) -> Result<(), String> { if path.is_dir() { fs::remove_dir_all(path) @@ -639,6 +645,38 @@ function cookbook_configure { "${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}" "${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" } + +function cookbook_cmake { + cat > CMakeToolchain-x86_64.cmake <, } + let depends = if should_build_shared() { + package.dependencies.iter().chain(package.shared_deps.iter()).cloned().collect() + } else { + package.dependencies.clone() + }; let stage_toml = toml::to_string(&StageToml { name: name.into(), version: "TODO".into(), target: env::var("TARGET") .map_err(|err| format!("failed to read TARGET: {:?}", err))?, - depends: package.dependencies.clone(), + depends }) .map_err(|err| format!("failed to serialize stage.toml: {:?}", err))?; fs::write(target_dir.join("stage.toml"), stage_toml) diff --git a/src/recipe.rs b/src/recipe.rs index 2f1566e19..9ed96ecc4 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -78,6 +78,8 @@ pub struct BuildRecipe { pub struct PackageRecipe { #[serde(default)] pub dependencies: Vec, + #[serde(rename = "shared-deps", default)] + pub shared_deps: Vec, } /// Everything required to build a Redox package @@ -129,6 +131,7 @@ mod tests { }, package: PackageRecipe { dependencies: Vec::new(), + shared_deps: Vec::new(), }, } ); @@ -171,6 +174,7 @@ mod tests { }, package: PackageRecipe { dependencies: Vec::new(), + shared_deps: Vec::new(), }, } );