aboutsummaryrefslogtreecommitdiff
path: root/std/build.zig
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jimmiholstchristensen@gmail.com>2018-10-15 09:51:15 -0400
committerGitHub <noreply@github.com>2018-10-15 09:51:15 -0400
commit378d3e44034e817093966ea42c2940d6a0482dd8 (patch)
treefe5f454097e1627b1afc65aebfb815dd70a7576d /std/build.zig
parent822d4fa216ea8f598e4a9d53161800494f449a94 (diff)
downloadzig-378d3e44034e817093966ea42c2940d6a0482dd8.tar.gz
zig-378d3e44034e817093966ea42c2940d6a0482dd8.zip
Solve the return type ambiguity (#1628)
Changed container and initializer syntax * <container> { ... } -> <container> . { ... } * <exrp> { ... } -> <expr> . { ...}
Diffstat (limited to 'std/build.zig')
-rw-r--r--std/build.zig106
1 files changed, 53 insertions, 53 deletions
diff --git a/std/build.zig b/std/build.zig
index cc12a75df5..f42969243c 100644
--- a/std/build.zig
+++ b/std/build.zig
@@ -15,7 +15,7 @@ const BufSet = std.BufSet;
const BufMap = std.BufMap;
const fmt_lib = std.fmt;
-pub const Builder = struct {
+pub const Builder = struct.{
uninstall_tls: TopLevelStep,
install_tls: TopLevelStep,
have_uninstall_step: bool,
@@ -48,7 +48,7 @@ pub const Builder = struct {
cache_root: []const u8,
release_mode: ?builtin.Mode,
- pub const CStd = enum {
+ pub const CStd = enum.{
C89,
C99,
C11,
@@ -57,25 +57,25 @@ pub const Builder = struct {
const UserInputOptionsMap = HashMap([]const u8, UserInputOption, mem.hash_slice_u8, mem.eql_slice_u8);
const AvailableOptionsMap = HashMap([]const u8, AvailableOption, mem.hash_slice_u8, mem.eql_slice_u8);
- const AvailableOption = struct {
+ const AvailableOption = struct.{
name: []const u8,
type_id: TypeId,
description: []const u8,
};
- const UserInputOption = struct {
+ const UserInputOption = struct.{
name: []const u8,
value: UserValue,
used: bool,
};
- const UserValue = union(enum) {
+ const UserValue = union(enum).{
Flag: void,
Scalar: []const u8,
List: ArrayList([]const u8),
};
- const TypeId = enum {
+ const TypeId = enum.{
Bool,
Int,
Float,
@@ -83,13 +83,13 @@ pub const Builder = struct {
List,
};
- const TopLevelStep = struct {
+ const TopLevelStep = struct.{
step: Step,
description: []const u8,
};
pub fn init(allocator: *Allocator, zig_exe: []const u8, build_root: []const u8, cache_root: []const u8) Builder {
- var self = Builder{
+ var self = Builder.{
.zig_exe = zig_exe,
.build_root = build_root,
.cache_root = os.path.relative(allocator, build_root, cache_root) catch unreachable,
@@ -116,12 +116,12 @@ pub const Builder = struct {
.lib_dir = undefined,
.exe_dir = undefined,
.installed_files = ArrayList([]const u8).init(allocator),
- .uninstall_tls = TopLevelStep{
+ .uninstall_tls = TopLevelStep.{
.step = Step.init("uninstall", allocator, makeUninstall),
.description = "Remove build artifacts from prefix path",
},
.have_uninstall_step = false,
- .install_tls = TopLevelStep{
+ .install_tls = TopLevelStep.{
.step = Step.initNoOp("install", allocator),
.description = "Copy build artifacts to prefix path",
},
@@ -212,7 +212,7 @@ pub const Builder = struct {
}
pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) Version {
- return Version{
+ return Version.{
.major = major,
.minor = minor,
.patch = patch,
@@ -356,7 +356,7 @@ pub const Builder = struct {
pub fn option(self: *Builder, comptime T: type, name: []const u8, description: []const u8) ?T {
const type_id = comptime typeToEnum(T);
- const available_option = AvailableOption{
+ const available_option = AvailableOption.{
.name = name,
.type_id = type_id,
.description = description,
@@ -408,7 +408,7 @@ pub const Builder = struct {
}
pub fn step(self: *Builder, name: []const u8, description: []const u8) *Step {
- const step_info = self.allocator.create(TopLevelStep{
+ const step_info = self.allocator.create(TopLevelStep.{
.step = Step.initNoOp(name, self.allocator),
.description = description,
}) catch unreachable;
@@ -435,9 +435,9 @@ pub const Builder = struct {
pub fn addUserInputOption(self: *Builder, name: []const u8, value: []const u8) !bool {
const gop = try self.user_input_options.getOrPut(name);
if (!gop.found_existing) {
- gop.kv.value = UserInputOption{
+ gop.kv.value = UserInputOption.{
.name = name,
- .value = UserValue{ .Scalar = value },
+ .value = UserValue.{ .Scalar = value },
.used = false,
};
return false;
@@ -450,18 +450,18 @@ pub const Builder = struct {
var list = ArrayList([]const u8).init(self.allocator);
list.append(s) catch unreachable;
list.append(value) catch unreachable;
- _ = self.user_input_options.put(name, UserInputOption{
+ _ = self.user_input_options.put(name, UserInputOption.{
.name = name,
- .value = UserValue{ .List = list },
+ .value = UserValue.{ .List = list },
.used = false,
}) catch unreachable;
},
UserValue.List => |*list| {
// append to the list
list.append(value) catch unreachable;
- _ = self.user_input_options.put(name, UserInputOption{
+ _ = self.user_input_options.put(name, UserInputOption.{
.name = name,
- .value = UserValue{ .List = list.* },
+ .value = UserValue.{ .List = list.* },
.used = false,
}) catch unreachable;
},
@@ -476,9 +476,9 @@ pub const Builder = struct {
pub fn addUserInputFlag(self: *Builder, name: []const u8) !bool {
const gop = try self.user_input_options.getOrPut(name);
if (!gop.found_existing) {
- gop.kv.value = UserInputOption{
+ gop.kv.value = UserInputOption.{
.name = name,
- .value = UserValue{ .Flag = {} },
+ .value = UserValue.{ .Flag = {} },
.used = false,
};
return false;
@@ -658,7 +658,7 @@ pub const Builder = struct {
pub fn findProgram(self: *Builder, names: []const []const u8, paths: []const []const u8) ![]const u8 {
// TODO report error for ambiguous situations
- const exe_extension = (Target{ .Native = {} }).exeFileExt();
+ const exe_extension = (Target.{ .Native = {} }).exeFileExt();
for (self.search_prefixes.toSliceConst()) |search_prefix| {
for (names) |name| {
if (os.path.isAbsolute(name)) {
@@ -677,7 +677,7 @@ pub const Builder = struct {
if (os.path.isAbsolute(name)) {
return name;
}
- var it = mem.split(PATH, []u8{os.path.delimiter});
+ var it = mem.split(PATH, []u8.{os.path.delimiter});
while (it.next()) |path| {
const full_path = try os.path.join(self.allocator, path, self.fmt("{}{}", name, exe_extension));
if (os.path.real(self.allocator, full_path)) |real_path| {
@@ -731,19 +731,19 @@ pub const Builder = struct {
}
};
-const Version = struct {
+const Version = struct.{
major: u32,
minor: u32,
patch: u32,
};
-const CrossTarget = struct {
+const CrossTarget = struct.{
arch: builtin.Arch,
os: builtin.Os,
environ: builtin.Environ,
};
-pub const Target = union(enum) {
+pub const Target = union(enum).{
Native: void,
Cross: CrossTarget,
@@ -798,7 +798,7 @@ pub const Target = union(enum) {
}
};
-pub const LibExeObjStep = struct {
+pub const LibExeObjStep = struct.{
step: Step,
builder: *Builder,
name: []const u8,
@@ -839,12 +839,12 @@ pub const LibExeObjStep = struct {
source_files: ArrayList([]const u8),
object_src: []const u8,
- const Pkg = struct {
+ const Pkg = struct.{
name: []const u8,
path: []const u8,
};
- const Kind = enum {
+ const Kind = enum.{
Exe,
Lib,
Obj,
@@ -892,7 +892,7 @@ pub const LibExeObjStep = struct {
}
fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, static: bool, ver: *const Version) LibExeObjStep {
- var self = LibExeObjStep{
+ var self = LibExeObjStep.{
.no_rosegment = false,
.strip = false,
.builder = builder,
@@ -934,7 +934,7 @@ pub const LibExeObjStep = struct {
}
fn initC(builder: *Builder, name: []const u8, kind: Kind, version: *const Version, static: bool) LibExeObjStep {
- var self = LibExeObjStep{
+ var self = LibExeObjStep.{
.no_rosegment = false,
.builder = builder,
.name = name,
@@ -1013,8 +1013,8 @@ pub const LibExeObjStep = struct {
}
pub fn setTarget(self: *LibExeObjStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
- self.target = Target{
- .Cross = CrossTarget{
+ self.target = Target.{
+ .Cross = CrossTarget.{
.arch = target_arch,
.os = target_os,
.environ = target_environ,
@@ -1143,7 +1143,7 @@ pub const LibExeObjStep = struct {
pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
assert(self.is_zig);
- self.packages.append(Pkg{
+ self.packages.append(Pkg.{
.name = name,
.path = pkg_index_path,
}) catch unreachable;
@@ -1628,7 +1628,7 @@ pub const LibExeObjStep = struct {
}
};
-pub const TestStep = struct {
+pub const TestStep = struct.{
step: Step,
builder: *Builder,
root_src: []const u8,
@@ -1647,7 +1647,7 @@ pub const TestStep = struct {
pub fn init(builder: *Builder, root_src: []const u8) TestStep {
const step_name = builder.fmt("test {}", root_src);
- return TestStep{
+ return TestStep.{
.step = Step.init(step_name, builder.allocator, make),
.builder = builder,
.root_src = root_src,
@@ -1656,7 +1656,7 @@ pub const TestStep = struct {
.name_prefix = "",
.filter = null,
.link_libs = BufSet.init(builder.allocator),
- .target = Target{ .Native = {} },
+ .target = Target.{ .Native = {} },
.exec_cmd_args = null,
.include_dirs = ArrayList([]const u8).init(builder.allocator),
.lib_paths = ArrayList([]const u8).init(builder.allocator),
@@ -1732,8 +1732,8 @@ pub const TestStep = struct {
}
pub fn setTarget(self: *TestStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
- self.target = Target{
- .Cross = CrossTarget{
+ self.target = Target.{
+ .Cross = CrossTarget.{
.arch = target_arch,
.os = target_os,
.environ = target_environ,
@@ -1854,7 +1854,7 @@ pub const TestStep = struct {
}
};
-pub const CommandStep = struct {
+pub const CommandStep = struct.{
step: Step,
builder: *Builder,
argv: [][]const u8,
@@ -1863,7 +1863,7 @@ pub const CommandStep = struct {
/// ::argv is copied.
pub fn create(builder: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) *CommandStep {
- const self = builder.allocator.create(CommandStep{
+ const self = builder.allocator.create(CommandStep.{
.builder = builder,
.step = Step.init(argv[0], builder.allocator, make),
.argv = builder.allocator.alloc([]u8, argv.len) catch unreachable,
@@ -1884,7 +1884,7 @@ pub const CommandStep = struct {
}
};
-const InstallArtifactStep = struct {
+const InstallArtifactStep = struct.{
step: Step,
builder: *Builder,
artifact: *LibExeObjStep,
@@ -1898,7 +1898,7 @@ const InstallArtifactStep = struct {
LibExeObjStep.Kind.Exe => builder.exe_dir,
LibExeObjStep.Kind.Lib => builder.lib_dir,
};
- const self = builder.allocator.create(Self{
+ const self = builder.allocator.create(Self.{
.builder = builder,
.step = Step.init(builder.fmt("install {}", artifact.step.name), builder.allocator, make),
.artifact = artifact,
@@ -1932,14 +1932,14 @@ const InstallArtifactStep = struct {
}
};
-pub const InstallFileStep = struct {
+pub const InstallFileStep = struct.{
step: Step,
builder: *Builder,
src_path: []const u8,
dest_path: []const u8,
pub fn init(builder: *Builder, src_path: []const u8, dest_path: []const u8) InstallFileStep {
- return InstallFileStep{
+ return InstallFileStep.{
.builder = builder,
.step = Step.init(builder.fmt("install {}", src_path), builder.allocator, make),
.src_path = src_path,
@@ -1953,14 +1953,14 @@ pub const InstallFileStep = struct {
}
};
-pub const WriteFileStep = struct {
+pub const WriteFileStep = struct.{
step: Step,
builder: *Builder,
file_path: []const u8,
data: []const u8,
pub fn init(builder: *Builder, file_path: []const u8, data: []const u8) WriteFileStep {
- return WriteFileStep{
+ return WriteFileStep.{
.builder = builder,
.step = Step.init(builder.fmt("writefile {}", file_path), builder.allocator, make),
.file_path = file_path,
@@ -1983,13 +1983,13 @@ pub const WriteFileStep = struct {
}
};
-pub const LogStep = struct {
+pub const LogStep = struct.{
step: Step,
builder: *Builder,
data: []const u8,
pub fn init(builder: *Builder, data: []const u8) LogStep {
- return LogStep{
+ return LogStep.{
.builder = builder,
.step = Step.init(builder.fmt("log {}", data), builder.allocator, make),
.data = data,
@@ -2002,13 +2002,13 @@ pub const LogStep = struct {
}
};
-pub const RemoveDirStep = struct {
+pub const RemoveDirStep = struct.{
step: Step,
builder: *Builder,
dir_path: []const u8,
pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep {
- return RemoveDirStep{
+ return RemoveDirStep.{
.builder = builder,
.step = Step.init(builder.fmt("RemoveDir {}", dir_path), builder.allocator, make),
.dir_path = dir_path,
@@ -2026,7 +2026,7 @@ pub const RemoveDirStep = struct {
}
};
-pub const Step = struct {
+pub const Step = struct.{
name: []const u8,
makeFn: fn (self: *Step) error!void,
dependencies: ArrayList(*Step),
@@ -2034,7 +2034,7 @@ pub const Step = struct {
done_flag: bool,
pub fn init(name: []const u8, allocator: *Allocator, makeFn: fn (*Step) error!void) Step {
- return Step{
+ return Step.{
.name = name,
.makeFn = makeFn,
.dependencies = ArrayList(*Step).init(allocator),