diff options
| author | 2025-11-08 09:45:48 +0100 | |
|---|---|---|
| committer | 2025-11-08 09:45:48 +0100 | |
| commit | a5cb382018dade88d20f385ba7557f80902b52c3 (patch) | |
| tree | 214d1f824b7b94e3366e598897390a86d4e88339 /main.c | |
| parent | e8310e8ec900e91366af44791030e6ffc9d414fe (diff) | |
driver: add -I commandline option
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -9,6 +9,15 @@ struct option ccopt; struct inclpaths *cinclpaths; +static void +addinclpath(const char *path) +{ + struct inclpaths *p = alloc(&globarena, sizeof *cinclpaths, 0); + p->next = cinclpaths; + p->path = path; + cinclpaths = p; +} + /* parse an argument of the form 'opt=abcd' * e.g. arg="foo=bar123"; opt="foo"; returns "bar123" */ static const char * @@ -151,6 +160,10 @@ optparse(char **args) task.outft = OFTobj; } else if (!strcmp(arg, "E")) { task.outft = OFTc; + } else if (*arg == 'I') { + const char *p = arg[1] ? arg+1 : *++args; + if (!p) fatal(NULL, "missing path after `-I`"); + else addinclpath(p); } else Bad: warn(NULL, "invalid option: %'s", arg-1); } @@ -390,12 +403,8 @@ sysinclpaths(void) "/usr/local/include", "/usr/include" }; - for (int i = 0; i < arraylength(paths); ++i) { - struct inclpaths *p = alloc(&globarena, sizeof *cinclpaths, 0); - p->next = cinclpaths; - p->path = paths[i]; - cinclpaths = p; - } + for (int i = 0; i < arraylength(paths); ++i) + addinclpath(paths[i]); } int |