diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-10 11:20:14 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-10 11:20:14 -0400 |
| commit | 56b9684362a6f1cb599a1d9f77b48c3ebe68036d (patch) | |
| tree | efe0fd80341327e4f04c376010e02477ee081c13 /tomo.c | |
| parent | 77aa022df0dc8c73f8936f5c920941e8a817b1e7 (diff) | |
Make library name specifiable by a command line arg
Diffstat (limited to 'tomo.c')
| -rw-r--r-- | tomo.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -37,13 +37,20 @@ int main(int argc, char *argv[]) { mode_e mode = MODE_RUN; int after_flags = 1; + const char *libname = NULL; for (int i = 1; i < argc; i++) { if (streq(argv[i], "-t")) { mode = MODE_TRANSPILE; } else if (streq(argv[i], "-c")) { mode = MODE_COMPILE_OBJ; + } else if (strncmp(argv[i], "-s=", 3) == 0) { + mode = MODE_COMPILE_SHARED_OBJ; + libname = argv[i] + strlen("-s="); } else if (streq(argv[i], "-s")) { mode = MODE_COMPILE_SHARED_OBJ; + if (i+1 >= argc) + errx(1, "You must provide at least one file to build a shared library"); + libname = file_base_name(argv[i+1]); } else if (streq(argv[i], "-r")) { mode = MODE_RUN; } else if (streq(argv[i], "-e")) { @@ -167,9 +174,6 @@ int main(int argc, char *argv[]) // For shared objects, link up all the object files into one .so file: if (mode == MODE_COMPILE_SHARED_OBJ) { - const char *first_file = argv[after_flags]; - const char *libname = file_base_name(first_file); - const char *h_filename = heap_strf("lib%s.h", libname); FILE *h_file = fopen(h_filename, "w"); if (!h_file) |
