diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-05-01 16:35:10 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-05-01 16:35:10 -0400 |
| commit | 3cbd0065fa4b0f659dfb1733b25bd09e37442d09 (patch) | |
| tree | 2a732cbe2cd3cbd0fd804db39885e5c57117591e /std | |
| parent | 17b935325e7c315304952f38037c7200595c5f10 (diff) | |
| download | zig-3cbd0065fa4b0f659dfb1733b25bd09e37442d09.tar.gz zig-3cbd0065fa4b0f659dfb1733b25bd09e37442d09.zip | |
basic support for specifying packages at the command line
See #226
Diffstat (limited to 'std')
| -rw-r--r-- | std/build.zig | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/std/build.zig b/std/build.zig index e173720a02..939b4e8d57 100644 --- a/std/build.zig +++ b/std/build.zig @@ -679,6 +679,12 @@ pub const LibExeObjStep = struct { name_only_filename: []const u8, object_files: List([]const u8), assembly_files: List([]const u8), + packages: List(Pkg), + + const Pkg = struct { + name: []const u8, + path: []const u8, + }; const Kind = enum { Exe, @@ -736,6 +742,7 @@ pub const LibExeObjStep = struct { .name_only_filename = undefined, .object_files = List([]const u8).init(builder.allocator), .assembly_files = List([]const u8).init(builder.allocator), + .packages = List(Pkg).init(builder.allocator), }; self.computeOutFileNames(); return self; @@ -835,6 +842,13 @@ pub const LibExeObjStep = struct { %%self.object_files.append(obj.getOutputPath()); } + pub fn addPackagePath(self: &LibExeObjStep, name: []const u8, pkg_index_path: []const u8) { + %%self.packages.append(Pkg { + .name = name, + .path = pkg_index_path, + }); + } + fn make(step: &Step) -> %void { const self = @fieldParentPtr(LibExeObjStep, "step", step); const builder = self.builder; @@ -883,9 +897,11 @@ pub const LibExeObjStep = struct { %%zig_args.append("--output"); %%zig_args.append(output_path); - const output_h_path = self.getOutputHPath(); - %%zig_args.append("--output-h"); - %%zig_args.append(builder.pathFromRoot(output_h_path)); + if (self.kind != Kind.Exe) { + const output_h_path = self.getOutputHPath(); + %%zig_args.append("--output-h"); + %%zig_args.append(builder.pathFromRoot(output_h_path)); + } %%zig_args.append("--name"); %%zig_args.append(self.name); @@ -929,6 +945,13 @@ pub const LibExeObjStep = struct { } } + for (self.packages.toSliceConst()) |pkg| { + %%zig_args.append("--pkg-begin"); + %%zig_args.append(pkg.name); + %%zig_args.append(builder.pathFromRoot(pkg.path)); + %%zig_args.append("--pkg-end"); + } + for (builder.include_paths.toSliceConst()) |include_path| { %%zig_args.append("-isystem"); %%zig_args.append(include_path); |
