From b009bc157a6f64f3904015f2e0fe90980c5c8657 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 14 Jun 2024 21:11:25 +0200 Subject: Support gperf --- make.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/make.c b/make.c index 2a7d606..bca5530 100644 --- a/make.c +++ b/make.c @@ -53,6 +53,7 @@ static bool fflag, rflag, Sflag; static int simd_flags; static void cc(void *); +static void gperf(void *); static void ld(void); static bool tagvalid(const char *); static void ckd_cpu_flags(void); @@ -101,7 +102,7 @@ main(int argc, char **argv) if (argc > 0) { if (strcmp("clean", *argv) == 0) { strspushl(&cmd, "find", ".", "-name", TARGET, "-or", "-name", "*.o", - "-delete"); + "-or", "-name", "*.gen.c", "-delete"); cmdput(cmd); cmdexec(cmd); } else { @@ -114,15 +115,23 @@ main(int argc, char **argv) ckd_cpu_flags(); - glob_t g; - assert(glob("src/*.c", 0, globerr, &g) == 0); - int procs = nproc(); if (procs == -1) procs = 8; tpool tp; tpinit(&tp, procs); + + glob_t g; + assert(glob("src/*.gperf", 0, globerr, &g) == 0); + + for (size_t i = 0; i < g.gl_pathc; i++) + tpenq(&tp, gperf, g.gl_pathv[i], NULL); + tpwait(&tp); + + globfree(&g); + assert(glob("src/*.c", 0, globerr, &g) == 0); + for (size_t i = 0; i < g.gl_pathc; i++) tpenq(&tp, cc, g.gl_pathv[i], NULL); tpwait(&tp); @@ -168,6 +177,24 @@ out: free(dst); } +void +gperf(void *arg) +{ + struct strs cmd = {0}; + char *dst = swpext(arg, "gen.c"), *src = arg; + + if (!fflag && !foutdatedl(dst, src)) + goto out; + + strspushl(&cmd, "gperf", src, "--output-file", dst); + + cmdput(cmd); + cmdexec(cmd); + strsfree(&cmd); +out: + free(dst); +} + void ld(void) { -- cgit v1.2.3