Commit 10dbc735fe

Andrew Kelley <superjoe30@gmail.com>
2017-04-06 19:59:11
zig build: use -D for options instead of -O
because -O is usually optimization level
1 parent 6fbe163
Changed files (2)
std/special/build_runner.zig
@@ -25,10 +25,10 @@ pub fn main() -> %void {
     var arg_i: usize = 1;
     while (arg_i < os.args.count(); arg_i += 1) {
         const arg = os.args.at(arg_i);
-        if (mem.startsWith(u8, arg, "-O")) {
+        if (mem.startsWith(u8, arg, "-D")) {
             const option_contents = arg[2...];
             if (option_contents.len == 0) {
-                %%io.stderr.printf("Expected option name after '-O'\n\n");
+                %%io.stderr.printf("Expected option name after '-D'\n\n");
                 return usage(&builder, maybe_zig_exe, false, &io.stderr);
             }
             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,
         const allocator = builder.allocator;
         for (builder.available_options_list.toSliceConst()) |option| {
             const name = %%fmt.allocPrint(allocator,
-                "  -O{}=({})", option.name, Builder.typeIdName(option.type_id));
+                "  -D{}=({})", option.name, Builder.typeIdName(option.type_id));
             defer allocator.free(name);
             %%out_stream.printf("{s24} {}\n", name, option.description);
         }
std/build.zig
@@ -268,13 +268,13 @@ pub const Builder = struct {
                     } else if (mem.eql(u8, s, "false")) {
                         return false;
                     } else {
-                        %%io.stderr.printf("Expected -O{} to be a boolean, but received '{}'\n", name, s);
+                        %%io.stderr.printf("Expected -D{} to be a boolean, but received '{}'\n", name, s);
                         self.markInvalidUserInput();
                         return null;
                     }
                 },
                 UserValue.List => {
-                    %%io.stderr.printf("Expected -O{} to be a boolean, but received a list.\n", name);
+                    %%io.stderr.printf("Expected -D{} to be a boolean, but received a list.\n", name);
                     self.markInvalidUserInput();
                     return null;
                 },
@@ -312,7 +312,7 @@ pub const Builder = struct {
                     });
                 },
                 UserValue.Flag => {
-                    %%io.stderr.printf("Option '-O{}={}' conflicts with flag '-O{}'.\n", name, value, name);
+                    %%io.stderr.printf("Option '-D{}={}' conflicts with flag '-D{}'.\n", name, value, name);
                     return true;
                 },
             }
@@ -328,11 +328,11 @@ pub const Builder = struct {
         })) {
             switch (prev_value.value) {
                 UserValue.Scalar => |s| {
-                    %%io.stderr.printf("Flag '-O{}' conflicts with option '-O{}={}'.\n", name, name, s);
+                    %%io.stderr.printf("Flag '-D{}' conflicts with option '-D{}={}'.\n", name, name, s);
                     return true;
                 },
                 UserValue.List => {
-                    %%io.stderr.printf("Flag '-O{}' conflicts with multiple options of the same name.\n", name);
+                    %%io.stderr.printf("Flag '-D{}' conflicts with multiple options of the same name.\n", name);
                     return true;
                 },
                 UserValue.Flag => {},
@@ -374,7 +374,7 @@ pub const Builder = struct {
         while (true) {
             const entry = it.next() ?? break;
             if (!entry.value.used) {
-                %%io.stderr.printf("Invalid option: -O{}\n\n", entry.key);
+                %%io.stderr.printf("Invalid option: -D{}\n\n", entry.key);
                 self.markInvalidUserInput();
             }
         }