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 --- src/evanix.c | 18 ++++++++++++++++++ src/solver_util.c | 2 ++ 2 files changed, 20 insertions(+) (limited to 'src') 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