From 623e4436ead7e9cd5c0d29eb14437c5cc5d20674 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Tue, 2 Jul 2024 13:50:56 +0530 Subject: evanix: add --max-build flag --- include/evanix.h | 1 + include/solver_util.h | 2 +- src/evanix.c | 18 ++++++++++++++++++ src/solver_util.c | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/evanix.h b/include/evanix.h index c4285fc..32f6ed6 100644 --- a/include/evanix.h +++ b/include/evanix.h @@ -8,6 +8,7 @@ struct evanix_opts_t { bool ispipelined; bool close_stderr_exec; char *system; + int max_build; }; extern struct evanix_opts_t evanix_opts; diff --git a/include/solver_util.h b/include/solver_util.h index 5c5f5d2..08f7f16 100644 --- a/include/solver_util.h +++ b/include/solver_util.h @@ -8,7 +8,7 @@ struct jobid { struct job **jobs; size_t filled, size; uint32_t *cost; - /* user directly asked for this to be build, not a transitively acquired + /* user directly asked for this to be built, not a transitively acquired * dependency */ bool *isdirect; }; diff --git a/src/evanix.c b/src/evanix.c index 27ab428..29b78f3 100644 --- a/src/evanix.c +++ b/src/evanix.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "build.h" @@ -15,6 +16,7 @@ static const char usage[] = " -d, --dry-run Show what derivations would be " "built.\n" " -s, --system System to build for." + " -m, --max-build Max number of builds." " -p, --pipelined Use evanix build pipeline.\n" " -c, --close-stderr-exec Close stderr on exec.\n" "\n"; @@ -24,6 +26,7 @@ struct evanix_opts_t evanix_opts = { .isflake = false, .ispipelined = true, .isdryrun = false, + .max_build = 0, .system = NULL, }; @@ -102,6 +105,7 @@ int main(int argc, char *argv[]) {"flake", no_argument, NULL, 'f'}, {"dry-run", no_argument, NULL, 'd'}, {"system", required_argument, NULL, 's'}, + {"max-build", required_argument, NULL, 'm'}, {"pipelined", required_argument, NULL, 'p'}, {"close-stderr-exec", required_argument, NULL, 'c'}, {NULL, 0, NULL, 0}, @@ -123,6 +127,20 @@ int main(int argc, char *argv[]) case 's': evanix_opts.system = optarg; break; + case 'm': + ret = atoi(optarg); + if (ret <= 0) { + fprintf(stderr, + "option --%s requires a natural number " + "argument\n" + "Try 'evanix --help' for more " + "information.\n", + longopts[longindex].name); + exit(EXIT_FAILURE); + } + + evanix_opts.max_build = ret; + break; case 'p': ret = atob(optarg); if (ret < 0) { diff --git a/src/solver_util.c b/src/solver_util.c index 950c176..a4fd092 100644 --- a/src/solver_util.c +++ b/src/solver_util.c @@ -7,6 +7,8 @@ #include "solver_util.h" #include "util.h" +static int dag_id_assign(struct job *j, struct jobid *jobid); + static int dag_id_assign(struct job *j, struct jobid *jobid) { size_t newsize; -- cgit v1.2.3