From 02654031466db75254229562162400c8f3205352 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 21 Aug 2020 15:52:58 -0600 Subject: [PATCH] Run cookbook rust version for fetch, if possible --- fetch.sh | 6 ++++++ src/bin/cook.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fetch.sh b/fetch.sh index 99b811340..03368c77a 100755 --- a/fetch.sh +++ b/fetch.sh @@ -12,5 +12,11 @@ fi for recipe in $recipes do + if [ -e "recipes/$recipe/recipe.toml" ] + then + target/release/cook --fetch-only "$recipe" + continue + fi + ./cook.sh "$recipe" fetch done diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 75d75d0f0..9f0c3f214 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -557,12 +557,14 @@ fn package(recipe_dir: &Path, stage_dir: &Path, package: &PackageRecipe) -> Resu Ok(package_file) } -fn cook(recipe_dir: &Path, recipe: &Recipe) -> Result<(), String> { +fn cook(recipe_dir: &Path, recipe: &Recipe, fetch_only: bool) -> Result<(), String> { let source_dir = fetch(&recipe_dir, &recipe.source).map_err(|err| format!( "failed to fetch: {}", err ))?; + if fetch_only { return Ok(()); } + let stage_dir = build(&recipe_dir, &source_dir, &recipe.build).map_err(|err| format!( "failed to build: {}", err @@ -658,12 +660,14 @@ impl CookRecipe { fn main() { let mut matching = true; let mut dry_run = false; + let mut fetch_only = false; let mut quiet = false; let mut recipe_names = Vec::new(); for arg in env::args().skip(1) { match arg.as_str() { "--" if matching => matching = false, "-d" | "--dry-run" if matching => dry_run = true, + "--fetch-only" if matching => fetch_only = true, "-q" | "--quiet" if matching => quiet = true, _ => recipe_names.push(arg), } @@ -702,7 +706,7 @@ fn main() { } Ok(()) } else { - cook(&recipe.dir, &recipe.recipe) + cook(&recipe.dir, &recipe.recipe, fetch_only) }; match res {