From 88ee0be35d63c329b41e9ea6348c96e5127116c0 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 23 Jan 2025 13:12:39 +1100 Subject: [PATCH 1/4] feat(ion): dynamic Signed-off-by: Anhad Singh --- recipes/core/ion/recipe.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/core/ion/recipe.toml b/recipes/core/ion/recipe.toml index 80c82e33e..cfc46e9ed 100644 --- a/recipes/core/ion/recipe.toml +++ b/recipes/core/ion/recipe.toml @@ -2,4 +2,9 @@ git = "https://gitlab.redox-os.org/redox-os/ion.git" [build] -template = "cargo" +template = "custom" +script = """ +DYNAMIC_INIT +cookbook_cargo +""" + From 8b663ee3688c7f02500b91fbf0e3ba7d7ace4acd Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 23 Jan 2025 16:05:33 +1100 Subject: [PATCH 2/4] fix(cookbook): shared dependencies These shall only be added iff `PREFER_STATIC` is not set. Signed-off-by: Anhad Singh --- recipes/core/ion/recipe.toml | 2 ++ recipes/dev/gnu-make/recipe.toml | 2 ++ recipes/libs/libgmp/recipe.toml | 2 ++ recipes/libs/libiconv/recipe.toml | 3 ++ recipes/libs/libmpfr/recipe.toml | 2 ++ recipes/libs/mpc/recipe.toml | 6 ++++ recipes/libs/nghttp2/recipe.toml | 3 ++ recipes/libs/zlib/recipe.toml | 2 ++ recipes/tools/gnu-binutils/recipe.toml | 3 +- src/bin/cook.rs | 45 +++++++++++++++++++++++++- src/recipe.rs | 4 +++ 11 files changed, 71 insertions(+), 3 deletions(-) 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(), }, } ); From a8aec7a5106661c6452b16e154628fb927158c5b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 23 Jan 2025 21:39:26 +1100 Subject: [PATCH 3/4] feat(patchelf) Signed-off-by: Anhad Singh --- recipes/tools/patchelf/recipe.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 recipes/tools/patchelf/recipe.toml diff --git a/recipes/tools/patchelf/recipe.toml b/recipes/tools/patchelf/recipe.toml new file mode 100644 index 000000000..4e4cfc434 --- /dev/null +++ b/recipes/tools/patchelf/recipe.toml @@ -0,0 +1,18 @@ +[source] +tar = "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2" +blake3 = "f843b32bdf3ee8a1f465e92d3fef34f30c48ccef9c112fdb793e2e7f2ae7283a" +script = """ +DYNAMIC_INIT +autotools_recursive_regenerate +""" + +[build] +template = "custom" +script = """ +DYNAMIC_INIT +cookbook_configure +""" + +[package] +shared-deps = ["libgcc"] + From 1eb6a6b0e8380f664e6a692d1fe308640cc85f17 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 24 Jan 2025 22:19:07 +1100 Subject: [PATCH 4/4] chore: delete old WIP patchelf recipe Signed-off-by: Anhad Singh --- recipes/wip/tools/patchelf/recipe.toml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 recipes/wip/tools/patchelf/recipe.toml diff --git a/recipes/wip/tools/patchelf/recipe.toml b/recipes/wip/tools/patchelf/recipe.toml deleted file mode 100644 index 84e86bf2a..000000000 --- a/recipes/wip/tools/patchelf/recipe.toml +++ /dev/null @@ -1,5 +0,0 @@ -#TODO compiled but not tested -[source] -tar = "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2" -[build] -template = "configure"