From 9539decb556817d14efc5c7995eb331426150c51 Mon Sep 17 00:00:00 2001 From: Sander Mertens Date: Sun, 29 Sep 2019 22:41:29 -0700 Subject: [PATCH] Add support for runtime dependencies with use-runtime attribute --- include/bake/project.h | 1 + src/crawler.c | 8 ++++++++ src/git.c | 1 + src/project.c | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/include/bake/project.h b/include/bake/project.h index 0b6537e..4a315ac 100644 --- a/include/bake/project.h +++ b/include/bake/project.h @@ -91,6 +91,7 @@ struct bake_project { ut_ll use; /* Project dependencies */ ut_ll use_private; /* Local dependencies (not visible to dependees) */ ut_ll use_build; /* Packages only required by the build */ + ut_ll use_runtime; /* Packages required when running the project */ ut_ll link; /* All resolved dependencies package must link with */ ut_ll sources; /* Paths to source files */ ut_ll includes; /* Paths to include files */ diff --git a/src/crawler.c b/src/crawler.c index ef38042..f70a3a8 100644 --- a/src/crawler.c +++ b/src/crawler.c @@ -219,6 +219,7 @@ int16_t bake_crawler_walk_dependencies( p->unresolved_dependencies = ut_ll_count(p->use); p->unresolved_dependencies += ut_ll_count(p->use_build); p->unresolved_dependencies += ut_ll_count(p->use_private); + p->unresolved_dependencies += ut_ll_count(p->use_runtime); /* Add project to dependent lists of dependencies */ ut_iter it = ut_ll_iter(p->use); @@ -241,6 +242,13 @@ int16_t bake_crawler_walk_dependencies( ut_try( action(config, p, use), NULL); } + /* Add project to dependent lists of runtime dependencies */ + it = ut_ll_iter(p->use_runtime); + while (ut_iter_hasNext(&it)) { + char *use = ut_iter_next(&it); + ut_try( action(config, p, use), NULL); + } + return 0; error: return -1; diff --git a/src/git.c b/src/git.c index f21d856..01a67cc 100644 --- a/src/git.c +++ b/src/git.c @@ -348,6 +348,7 @@ int16_t bake_update_dependencies( { ut_try(bake_update_dependency_list(config, base_url, project->use, to_env, always_clone, notify_state), NULL); ut_try(bake_update_dependency_list(config, base_url, project->use_private, to_env, always_clone, notify_state), NULL); + ut_try(bake_update_dependency_list(config, base_url, project->use_runtime, to_env, always_clone, notify_state), NULL); return 0; error: return -1; diff --git a/src/project.c b/src/project.c index c3f05a4..52c5829 100644 --- a/src/project.c +++ b/src/project.c @@ -412,6 +412,9 @@ int16_t bake_project_parse_value( if (!strcmp(member, "use_private") || !strcmp(member, "use-private")) { ut_try (bake_json_set_array(&p->use_private, member, v), NULL); } else + if (!strcmp(member, "use_runtime") || !strcmp(member, "use-runtime")) { + ut_try (bake_json_set_array(&p->use_runtime, member, v), NULL); + } else if (!strcmp(member, "use_bundle") || !strcmp(member, "use-bundle")) { ut_try (bake_json_set_array(&p->use_bundle, member, v), NULL); } else @@ -831,6 +834,9 @@ int16_t bake_project_init( if (!project->use_build) { project->use_build = ut_ll_new(); } + if (!project->use_runtime) { + project->use_runtime = ut_ll_new(); + } if (!project->link) { project->link = ut_ll_new(); } @@ -950,6 +956,7 @@ void bake_project_free( bake_attr_free_string_array(project->use); bake_attr_free_string_array(project->use_private); bake_attr_free_string_array(project->use_build); + bake_attr_free_string_array(project->use_runtime); bake_attr_free_string_array(project->sources); bake_attr_free_string_array(project->includes); bake_attr_free_string_array(project->link);