Make CC an environment variable that's read from

This commit is contained in:
Bruce Hill 2024-02-24 15:31:26 -05:00
parent a33de1a36e
commit a1593ad8e4
2 changed files with 8 additions and 6 deletions

View File

@ -40,7 +40,7 @@ tags:
ctags *.[ch] **/*.[ch]
test: nextlang
for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 ./nextlang "$$f" || break; done
for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 CC=tcc ./nextlang "$$f" || break; done
clean:
rm -f nextlang *.o SipHash/halfsiphash.o builtins/*.o libnext.so

View File

@ -79,11 +79,13 @@ int main(int argc, char *argv[])
const char *ldflags = "-Wl,-rpath '-Wl,$ORIGIN'";
// const char *run = heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs);
const char *run = heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs);
FILE *cc = popen(run, "w");
CORD_put(program, cc);
fclose(cc);
const char *cc = getenv("CC");
if (!cc) cc = "tcc";
const char *run = streq(cc, "tcc") ? heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs)
: heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs);
FILE *runner = popen(run, "w");
CORD_put(program, runner);
fclose(runner);
return 0;
}