aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-22 22:18:19 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-22 22:18:19 -0700
commitc2b1cd7c456e274c7ead96e597d147e2df7d317e (patch)
treebf924cc095e8bb77dfee6484d6bdc2fb0f7aa2e3 /lib/std/process.zig
parent250664bea41cc5dde66e3054ca0c1b6e0feab9be (diff)
downloadzig-c2b1cd7c456e274c7ead96e597d147e2df7d317e.tar.gz
zig-c2b1cd7c456e274c7ead96e597d147e2df7d317e.zip
stage2: implement zig build
As part of this: * add std.process.cleanExit. closes #6395 - use it in several places * adjust the alignment of text in `zig build --help` menu * Cache: support the concept of "unhit" so that we properly keep track of the cache when we find out using the secondary hash that the cache "hit" was actually a miss. Use this to fix false negatives of caching of stage1 build artifacts. * fix not deleting the symlink hash for stage1 build artifacts causing false positives. * implement support for Package arguments in stage1 build artifacts * update and add missing usage text * add --override-lib-dir and --enable-cache CLI options - `--enable-cache` takes the place of `--cache on` * CLI supports -femit-bin=foo combined with --enable-cache to do an "update file" operation. --enable-cache without that argument will build the output into a cache directory and then print the path to stdout (matching master branch behavior). * errors surfacing from main() now print "error: Foo" instead of "error: error.Foo".
Diffstat (limited to 'lib/std/process.zig')
-rw-r--r--lib/std/process.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig
index 2813d8cbab..5303ada94b 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -19,6 +19,19 @@ pub const exit = os.exit;
pub const changeCurDir = os.chdir;
pub const changeCurDirC = os.chdirC;
+/// Indicate that we are now terminating with a successful exit code.
+/// In debug builds, this is a no-op, so that the calling code's
+/// cleanup mechanisms are tested and so that external tools that
+/// check for resource leaks can be accurate. In release builds, this
+/// calls exit(0), and does not return.
+pub fn cleanExit() void {
+ if (builtin.mode == .Debug) {
+ return;
+ } else {
+ exit(0);
+ }
+}
+
/// The result is a slice of `out_buffer`, from index `0`.
pub fn getCwd(out_buffer: []u8) ![]u8 {
return os.getcwd(out_buffer);