aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md18
-rw-r--r--lib/std/build.zig26
-rw-r--r--lib/std/fs/file.zig2
3 files changed, 35 insertions, 11 deletions
diff --git a/README.md b/README.md
index e72b166c77..8031aa790e 100644
--- a/README.md
+++ b/README.md
@@ -76,3 +76,21 @@ Hopefully this will be fixed upstream with LLVM 10.0.1.
##### Windows
See https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows
+
+## License
+
+The ultimate goal of the Zig project is to serve users. As a first-order
+effect, this means users of the compiler, helping programmers to write better
+code. Even more important, however, are the end users.
+
+Zig is intended to be used to help end users accomplish their goals. For
+example, it would be inappropriate and offensive to use Zig to implement
+[dark patterns](https://en.wikipedia.org/wiki/Dark_pattern) and it would be
+shameful to utilize Zig to exploit people instead of benefit them.
+
+However, such problems are best solved with social norms, not with software
+licenses. Any attempt to complicate the software license of Zig would risk
+compromising the value Zig provides to users.
+
+Therefore, Zig is available under the MIT (Expat) License, and comes with a
+humble request: use it to make software better serve the needs of end users.
diff --git a/lib/std/build.zig b/lib/std/build.zig
index 8aa473f8bc..30ecf98b76 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -1055,6 +1055,7 @@ pub const Builder = struct {
.Bin => self.exe_dir,
.Lib => self.lib_dir,
.Header => self.h_dir,
+ .Custom => |path| fs.path.join(self.allocator, &[_][]const u8{ self.install_path, path }) catch unreachable,
};
return fs.path.resolve(
self.allocator,
@@ -1219,6 +1220,8 @@ pub const LibExeObjStep = struct {
is_linking_libc: bool = false,
vcpkg_bin_path: ?[]const u8 = null,
+ /// This may be set in order to override the default install directory
+ override_dest_dir: ?InstallDir,
installed_path: ?[]const u8,
install_step: ?*InstallArtifactStep,
@@ -1363,6 +1366,7 @@ pub const LibExeObjStep = struct {
.rdynamic = false,
.output_dir = null,
.single_threaded = false,
+ .override_dest_dir = null,
.installed_path = null,
.install_step = null,
};
@@ -2337,17 +2341,17 @@ pub const InstallArtifactStep = struct {
.builder = builder,
.step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),
.artifact = artifact,
- .dest_dir = switch (artifact.kind) {
+ .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {
.Obj => unreachable,
.Test => unreachable,
- .Exe => .Bin,
- .Lib => .Lib,
+ .Exe => InstallDir{ .Bin = {} },
+ .Lib => InstallDir{ .Lib = {} },
},
.pdb_dir = if (artifact.producesPdbFile()) blk: {
if (artifact.kind == .Exe) {
- break :blk InstallDir.Bin;
+ break :blk InstallDir{ .Bin = {} };
} else {
- break :blk InstallDir.Lib;
+ break :blk InstallDir{ .Lib = {} };
}
} else null,
.h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null,
@@ -2645,11 +2649,13 @@ const VcpkgRootStatus = enum {
pub const VcpkgLinkage = std.builtin.LinkMode;
-pub const InstallDir = enum {
- Prefix,
- Lib,
- Bin,
- Header,
+pub const InstallDir = union(enum) {
+ Prefix: void,
+ Lib: void,
+ Bin: void,
+ Header: void,
+ /// A path relative to the prefix
+ Custom: []const u8,
};
pub const InstalledFile = struct {
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
index db301a9a4c..73babf5fa2 100644
--- a/lib/std/fs/file.zig
+++ b/lib/std/fs/file.zig
@@ -728,7 +728,7 @@ pub const File = struct {
}
var i: usize = 0;
while (i < trailers.len) {
- while (amt >= headers[i].iov_len) {
+ while (amt >= trailers[i].iov_len) {
amt -= trailers[i].iov_len;
i += 1;
if (i >= trailers.len) return;