mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-07-17 08:48:43 +08:00
Merge branch 'dynamic_linking' into 'master'
fix(cook): build shared dependencies See merge request redox-os/cookbook!438
This commit is contained in:
commit
3d492f9ae3
@ -1,5 +1,5 @@
|
|||||||
use cookbook::blake3::blake3_progress;
|
use cookbook::blake3::blake3_progress;
|
||||||
use cookbook::recipe::{BuildKind, BuildRecipe, PackageRecipe, Recipe, SourceRecipe};
|
use cookbook::recipe::{BuildKind, PackageRecipe, Recipe, SourceRecipe};
|
||||||
use cookbook::recipe_find::recipe_find;
|
use cookbook::recipe_find::recipe_find;
|
||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs,
|
||||||
@ -454,10 +454,10 @@ fn build(
|
|||||||
source_dir: &Path,
|
source_dir: &Path,
|
||||||
target_dir: &Path,
|
target_dir: &Path,
|
||||||
name: &str,
|
name: &str,
|
||||||
build: &BuildRecipe,
|
recipe: &Recipe,
|
||||||
) -> Result<PathBuf, String> {
|
) -> Result<PathBuf, String> {
|
||||||
let mut dep_pkgars = vec![];
|
let mut dep_pkgars = vec![];
|
||||||
for dependency in build.dependencies.iter() {
|
for dependency in recipe.dependencies_iter() {
|
||||||
//TODO: sanitize name
|
//TODO: sanitize name
|
||||||
let dependency_dir = recipe_find(dependency, Path::new("recipes"))?;
|
let dependency_dir = recipe_find(dependency, Path::new("recipes"))?;
|
||||||
if dependency_dir.is_none() {
|
if dependency_dir.is_none() {
|
||||||
@ -720,7 +720,7 @@ done
|
|||||||
//TODO: better integration with redoxer (library instead of binary)
|
//TODO: better integration with redoxer (library instead of binary)
|
||||||
//TODO: configurable target
|
//TODO: configurable target
|
||||||
//TODO: Add more configurability, convert scripts to Rust?
|
//TODO: Add more configurability, convert scripts to Rust?
|
||||||
let script = match &build.kind {
|
let script = match &recipe.build.kind {
|
||||||
BuildKind::Cargo {
|
BuildKind::Cargo {
|
||||||
package_path,
|
package_path,
|
||||||
cargoflags,
|
cargoflags,
|
||||||
@ -862,7 +862,7 @@ fn cook(recipe_dir: &Path, name: &str, recipe: &Recipe, fetch_only: bool) -> Res
|
|||||||
create_dir(&target_dir)?;
|
create_dir(&target_dir)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stage_dir = build(recipe_dir, &source_dir, &target_dir, name, &recipe.build)
|
let stage_dir = build(recipe_dir, &source_dir, &target_dir, name, &recipe)
|
||||||
.map_err(|err| format!("failed to build: {}", err))?;
|
.map_err(|err| format!("failed to build: {}", err))?;
|
||||||
|
|
||||||
let _package_file = package(recipe_dir, &stage_dir, &target_dir, name, &recipe.package)
|
let _package_file = package(recipe_dir, &stage_dir, &target_dir, name, &recipe.package)
|
||||||
@ -925,7 +925,7 @@ impl CookRecipe {
|
|||||||
let recipe = Self::new(name.clone())?;
|
let recipe = Self::new(name.clone())?;
|
||||||
|
|
||||||
let dependencies =
|
let dependencies =
|
||||||
Self::new_recursive(&recipe.recipe.build.dependencies, recursion - 1).map_err(
|
Self::new_recursive(&recipe.recipe.dependencies(), recursion - 1).map_err(
|
||||||
|err| format!("{}: failed on loading build dependencies:\n{}", name, err),
|
|err| format!("{}: failed on loading build dependencies:\n{}", name, err),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,18 @@ pub struct Recipe {
|
|||||||
pub package: PackageRecipe,
|
pub package: PackageRecipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Recipe {
|
||||||
|
#[inline]
|
||||||
|
pub fn dependencies_iter(&self) -> impl Iterator<Item = &String> {
|
||||||
|
self.build.dependencies.iter().chain(self.package.shared_deps.iter())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn dependencies(&self) -> Vec<String> {
|
||||||
|
self.dependencies_iter().cloned().collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user