| ... | @@ -20,7 +20,7 @@ static int usage(const char *arg0) { | ... | @@ -20,7 +20,7 @@ static int usage(const char *arg0) { |
| 20 | " build create executable, object, or library from target\n" | 20 | " build create executable, object, or library from target\n" |
| 21 | " version print version number and exit\n" | 21 | " version print version number and exit\n" |
| 22 | " parseh convert a c header file to zig extern declarations\n" | 22 | " parseh convert a c header file to zig extern declarations\n" |
| 23 | "Command: build target\n" | 23 | "Options:\n" |
| 24 | " --release build with optimizations on and debug protection off\n" | 24 | " --release build with optimizations on and debug protection off\n" |
| 25 | " --static output will be statically linked\n" | 25 | " --static output will be statically linked\n" |
| 26 | " --strip exclude debug symbols\n" | 26 | " --strip exclude debug symbols\n" |
| ... | @@ -30,10 +30,8 @@ static int usage(const char *arg0) { | ... | @@ -30,10 +30,8 @@ static int usage(const char *arg0) { |
| 30 | " --verbose turn on compiler debug output\n" | 30 | " --verbose turn on compiler debug output\n" |
| 31 | " --color [auto|off|on] enable or disable colored error messages\n" | 31 | " --color [auto|off|on] enable or disable colored error messages\n" |
| 32 | " --libc-path [path] set the C compiler data path\n" | 32 | " --libc-path [path] set the C compiler data path\n" |
| 33 | "Command: parseh target\n" | | |
| 34 | " -isystem [dir] add additional search path for other .h files\n" | 33 | " -isystem [dir] add additional search path for other .h files\n" |
| 35 | " -dirafter [dir] same as -isystem but do it last\n" | 34 | " -dirafter [dir] same as -isystem but do it last\n" |
| 36 | " -B[prefix] set the C compiler data path\n" | | |
| 37 | , arg0); | 35 | , arg0); |
| 38 | return EXIT_FAILURE; | 36 | return EXIT_FAILURE; |
| 39 | } | 37 | } |
| ... | @@ -54,6 +52,7 @@ struct Build { | ... | @@ -54,6 +52,7 @@ struct Build { |
| 54 | bool verbose; | 52 | bool verbose; |
| 55 | ErrColor color; | 53 | ErrColor color; |
| 56 | const char *libc_path; | 54 | const char *libc_path; |
| | 55 | ZigList<const char *> clang_argv; |
| 57 | }; | 56 | }; |
| 58 | | 57 | |
| 59 | static int build(const char *arg0, int argc, char **argv) { | 58 | static int build(const char *arg0, int argc, char **argv) { |
| ... | @@ -62,7 +61,7 @@ static int build(const char *arg0, int argc, char **argv) { | ... | @@ -62,7 +61,7 @@ static int build(const char *arg0, int argc, char **argv) { |
| 62 | | 61 | |
| 63 | for (int i = 0; i < argc; i += 1) { | 62 | for (int i = 0; i < argc; i += 1) { |
| 64 | char *arg = argv[i]; | 63 | char *arg = argv[i]; |
| 65 | if (arg[0] == '-' && arg[1] == '-') { | 64 | if (arg[0] == '-') { |
| 66 | if (strcmp(arg, "--release") == 0) { | 65 | if (strcmp(arg, "--release") == 0) { |
| 67 | b.release = true; | 66 | b.release = true; |
| 68 | } else if (strcmp(arg, "--strip") == 0) { | 67 | } else if (strcmp(arg, "--strip") == 0) { |
| ... | @@ -103,6 +102,12 @@ static int build(const char *arg0, int argc, char **argv) { | ... | @@ -103,6 +102,12 @@ static int build(const char *arg0, int argc, char **argv) { |
| 103 | b.out_name = argv[i]; | 102 | b.out_name = argv[i]; |
| 104 | } else if (strcmp(arg, "--libc-path") == 0) { | 103 | } else if (strcmp(arg, "--libc-path") == 0) { |
| 105 | b.libc_path = argv[i]; | 104 | b.libc_path = argv[i]; |
| | 105 | } else if (strcmp(arg, "-isystem") == 0) { |
| | 106 | b.clang_argv.append("-isystem"); |
| | 107 | b.clang_argv.append(argv[i]); |
| | 108 | } else if (strcmp(arg, "-dirafter") == 0) { |
| | 109 | b.clang_argv.append("-dirafter"); |
| | 110 | b.clang_argv.append(argv[i]); |
| 106 | } else { | 111 | } else { |
| 107 | return usage(arg0); | 112 | return usage(arg0); |
| 108 | } | 113 | } |
| ... | @@ -140,6 +145,7 @@ static int build(const char *arg0, int argc, char **argv) { | ... | @@ -140,6 +145,7 @@ static int build(const char *arg0, int argc, char **argv) { |
| 140 | | 145 | |
| 141 | CodeGen *g = codegen_create(&root_source_dir); | 146 | CodeGen *g = codegen_create(&root_source_dir); |
| 142 | codegen_set_build_type(g, b.release ? CodeGenBuildTypeRelease : CodeGenBuildTypeDebug); | 147 | codegen_set_build_type(g, b.release ? CodeGenBuildTypeRelease : CodeGenBuildTypeDebug); |
| | 148 | codegen_set_clang_argv(g, b.clang_argv.items, b.clang_argv.length); |
| 143 | codegen_set_strip(g, b.strip); | 149 | codegen_set_strip(g, b.strip); |
| 144 | codegen_set_is_static(g, b.is_static); | 150 | codegen_set_is_static(g, b.is_static); |
| 145 | if (b.out_type != OutTypeUnknown) | 151 | if (b.out_type != OutTypeUnknown) |
| ... | @@ -202,8 +208,7 @@ static int parseh(const char *arg0, int argc, char **argv) { | ... | @@ -202,8 +208,7 @@ static int parseh(const char *arg0, int argc, char **argv) { |
| 202 | } | 208 | } |
| 203 | clang_argv.append("-isystem"); | 209 | clang_argv.append("-isystem"); |
| 204 | clang_argv.append(argv[i + 1]); | 210 | clang_argv.append(argv[i + 1]); |
| 205 | } else if (arg[1] == 'B') { | 211 | i += 1; |
| 206 | clang_argv.append(arg); | | |
| 207 | } else { | 212 | } else { |
| 208 | fprintf(stderr, "unrecognized argument: %s", arg); | 213 | fprintf(stderr, "unrecognized argument: %s", arg); |
| 209 | return usage(arg0); | 214 | return usage(arg0); |