diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-09-25 17:59:41 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-25 17:59:52 -0400 |
| commit | 568c183d2a5400a49e20f029a20ddb94db7d4082 (patch) | |
| tree | 73ab1d9a6ed542f3ef7513aafa4348ed6467e280 /doc | |
| parent | f112e8af2760f9b475289966db7c0c53f4c6b310 (diff) | |
| download | zig-568c183d2a5400a49e20f029a20ddb94db7d4082.tar.gz zig-568c183d2a5400a49e20f029a20ddb94db7d4082.zip | |
docgen: slightly better caching
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docgen.zig | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig index 267c99c321..923f601a89 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -1042,22 +1042,18 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var switch (code.id) { Code.Id.Exe => |expected_outcome| code_block: { const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext); - const tmp_bin_file_name = try fs.path.join( - allocator, - [_][]const u8{ tmp_dir_name, name_plus_bin_ext }, - ); var build_args = std.ArrayList([]const u8).init(allocator); defer build_args.deinit(); try build_args.appendSlice([_][]const u8{ zig_exe, "build-exe", tmp_source_file_name, - "--output-dir", - tmp_dir_name, "--name", code.name, "--color", "on", + "--cache", + "on", }); try out.print("<pre><code class=\"shell\">$ zig build-exe {}.zig", code.name); switch (code.mode) { @@ -1128,7 +1124,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try out.print("\n{}</code></pre>\n", colored_stderr); break :code_block; } - _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile"); + const exec_result = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile"); if (code.target_str) |triple| { if (mem.startsWith(u8, triple, "wasm32") or @@ -1141,7 +1137,8 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var } } - const run_args = [_][]const u8{tmp_bin_file_name}; + const path_to_exe = mem.trim(u8, exec_result.stdout, " \r\n"); + const run_args = [_][]const u8{path_to_exe}; const result = if (expected_outcome == ExpectedOutcome.Fail) blk: { const result = try ChildProcess.exec(allocator, run_args, null, &env_map, max_doc_file_size); @@ -1179,8 +1176,8 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var zig_exe, "test", tmp_source_file_name, - "--output-dir", - tmp_dir_name, + "--cache", + "on", }); try out.print("<pre><code class=\"shell\">$ zig test {}.zig", code.name); switch (code.mode) { |
