diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-02 10:38:27 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-02 10:38:27 -0500 |
| commit | 67b4de33d2729fdb21337e5a0e05f6273bce23ba (patch) | |
| tree | 2f79dc7eed0d993e82f777b3f90817731c2d5314 /std/build.zig | |
| parent | 764205ac13cc340ff6dcce74667c32dafe24e510 (diff) | |
| download | zig-67b4de33d2729fdb21337e5a0e05f6273bce23ba.tar.gz zig-67b4de33d2729fdb21337e5a0e05f6273bce23ba.zip | |
compile error for import outside package path
closes #2024
there's a new cli option `--main-pkg-path` which you can use to choose
a different root package directory besides the one inferred from the
root source file
and a corresponding build.zig API:
foo.setMainPkgPath(path)
Diffstat (limited to 'std/build.zig')
| -rw-r--r-- | std/build.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/std/build.zig b/std/build.zig index e3fdfbccee..b7f76a53af 100644 --- a/std/build.zig +++ b/std/build.zig @@ -859,6 +859,7 @@ pub const LibExeObjStep = struct { verbose_cc: bool, c_std: Builder.CStd, override_std_dir: ?[]const u8, + main_pkg_path: ?[]const u8, exec_cmd_args: ?[]const ?[]const u8, name_prefix: []const u8, filter: ?[]const u8, @@ -950,6 +951,7 @@ pub const LibExeObjStep = struct { .c_std = Builder.CStd.C99, .system_linker_hack = false, .override_std_dir = null, + .main_pkg_path = null, .exec_cmd_args = null, .name_prefix = "", .filter = null, @@ -1098,6 +1100,10 @@ pub const LibExeObjStep = struct { self.override_std_dir = dir_path; } + pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void { + self.main_pkg_path = dir_path; + } + pub fn setOutputPath(self: *LibExeObjStep, file_path: []const u8) void { self.output_path = file_path; @@ -1424,6 +1430,11 @@ pub const LibExeObjStep = struct { try zig_args.append(builder.pathFromRoot(dir)); } + if (self.main_pkg_path) |dir| { + try zig_args.append("--main-pkg-path"); + try zig_args.append(builder.pathFromRoot(dir)); + } + try builder.spawnChild(zig_args.toSliceConst()); if (self.kind == Kind.Lib and !self.static and self.target.wantSharedLibSymLinks()) { |
