diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-14 21:11:25 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-14 21:11:25 +0200 |
commit | b009bc157a6f64f3904015f2e0fe90980c5c8657 (patch) | |
tree | c02721e774f9f667b90413c525d0186f41140352 | |
parent | f7c81dc4ac2ca6e3aed325945927cfe3417f6b9a (diff) |
Support gperf
-rw-r--r-- | make.c | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -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); @@ -169,6 +178,24 @@ out: } 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) { glob_t g; |