authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-06 13:59:11-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-06 13:59:11-04:00
log10dbc735fe4e4575821837f00eb173286a1f88ee
tree1ca87def8ca8d85d8b73e61e3fb007ca0815e844
parent6fbe1632d0c958b9abbc9f38a7e497ef69543bf1

zig build: use -D for options instead of -O

because -O is usually optimization level

2 files changed, 9 insertions(+), 9 deletions(-)

std/build.zig+6-6
...@@ -268,13 +268,13 @@ pub const Builder = struct {...@@ -268,13 +268,13 @@ pub const Builder = struct {
268 } else if (mem.eql(u8, s, "false")) {268 } else if (mem.eql(u8, s, "false")) {
269 return false;269 return false;
270 } else {270 } else {
271 %%io.stderr.printf("Expected -O{} to be a boolean, but received '{}'\n", name, s);271 %%io.stderr.printf("Expected -D{} to be a boolean, but received '{}'\n", name, s);
272 self.markInvalidUserInput();272 self.markInvalidUserInput();
273 return null;273 return null;
274 }274 }
275 },275 },
276 UserValue.List => {276 UserValue.List => {
277 %%io.stderr.printf("Expected -O{} to be a boolean, but received a list.\n", name);277 %%io.stderr.printf("Expected -D{} to be a boolean, but received a list.\n", name);
278 self.markInvalidUserInput();278 self.markInvalidUserInput();
279 return null;279 return null;
280 },280 },
...@@ -312,7 +312,7 @@ pub const Builder = struct {...@@ -312,7 +312,7 @@ pub const Builder = struct {
312 });312 });
313 },313 },
314 UserValue.Flag => {314 UserValue.Flag => {
315 %%io.stderr.printf("Option '-O{}={}' conflicts with flag '-O{}'.\n", name, value, name);315 %%io.stderr.printf("Option '-D{}={}' conflicts with flag '-D{}'.\n", name, value, name);
316 return true;316 return true;
317 },317 },
318 }318 }
...@@ -328,11 +328,11 @@ pub const Builder = struct {...@@ -328,11 +328,11 @@ pub const Builder = struct {
328 })) {328 })) {
329 switch (prev_value.value) {329 switch (prev_value.value) {
330 UserValue.Scalar => |s| {330 UserValue.Scalar => |s| {
331 %%io.stderr.printf("Flag '-O{}' conflicts with option '-O{}={}'.\n", name, name, s);331 %%io.stderr.printf("Flag '-D{}' conflicts with option '-D{}={}'.\n", name, name, s);
332 return true;332 return true;
333 },333 },
334 UserValue.List => {334 UserValue.List => {
335 %%io.stderr.printf("Flag '-O{}' conflicts with multiple options of the same name.\n", name);335 %%io.stderr.printf("Flag '-D{}' conflicts with multiple options of the same name.\n", name);
336 return true;336 return true;
337 },337 },
338 UserValue.Flag => {},338 UserValue.Flag => {},
...@@ -374,7 +374,7 @@ pub const Builder = struct {...@@ -374,7 +374,7 @@ pub const Builder = struct {
374 while (true) {374 while (true) {
375 const entry = it.next() ?? break;375 const entry = it.next() ?? break;
376 if (!entry.value.used) {376 if (!entry.value.used) {
377 %%io.stderr.printf("Invalid option: -O{}\n\n", entry.key);377 %%io.stderr.printf("Invalid option: -D{}\n\n", entry.key);
378 self.markInvalidUserInput();378 self.markInvalidUserInput();
379 }379 }
380 }380 }
std/special/build_runner.zig+3-3
...@@ -25,10 +25,10 @@ pub fn main() -> %void {...@@ -25,10 +25,10 @@ pub fn main() -> %void {
25 var arg_i: usize = 1;25 var arg_i: usize = 1;
26 while (arg_i < os.args.count(); arg_i += 1) {26 while (arg_i < os.args.count(); arg_i += 1) {
27 const arg = os.args.at(arg_i);27 const arg = os.args.at(arg_i);
28 if (mem.startsWith(u8, arg, "-O")) {28 if (mem.startsWith(u8, arg, "-D")) {
29 const option_contents = arg[2...];29 const option_contents = arg[2...];
30 if (option_contents.len == 0) {30 if (option_contents.len == 0) {
31 %%io.stderr.printf("Expected option name after '-O'\n\n");31 %%io.stderr.printf("Expected option name after '-D'\n\n");
32 return usage(&builder, maybe_zig_exe, false, &io.stderr);32 return usage(&builder, maybe_zig_exe, false, &io.stderr);
33 }33 }
34 if (const name_end ?= mem.indexOfScalar(u8, option_contents, '=')) {34 if (const name_end ?= mem.indexOfScalar(u8, option_contents, '=')) {
...@@ -95,7 +95,7 @@ fn usage(builder: &Builder, maybe_zig_exe: ?[]const u8, already_ran_build: bool,...@@ -95,7 +95,7 @@ fn usage(builder: &Builder, maybe_zig_exe: ?[]const u8, already_ran_build: bool,
95 const allocator = builder.allocator;95 const allocator = builder.allocator;
96 for (builder.available_options_list.toSliceConst()) |option| {96 for (builder.available_options_list.toSliceConst()) |option| {
97 const name = %%fmt.allocPrint(allocator,97 const name = %%fmt.allocPrint(allocator,
98 " -O{}=({})", option.name, Builder.typeIdName(option.type_id));98 " -D{}=({})", option.name, Builder.typeIdName(option.type_id));
99 defer allocator.free(name);99 defer allocator.free(name);
100 %%out_stream.printf("{s24} {}\n", name, option.description);100 %%out_stream.printf("{s24} {}\n", name, option.description);
101 }101 }