From 91955dee587214722daa09e6f3dbff059ac3752e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 8 Mar 2019 22:53:35 -0500 Subject: breaking changes to zig build API and improved caching * in Zig build scripts, getOutputPath() is no longer a valid function to call, unless setOutputDir() was used, or within a custom make() function. Instead there is more convenient API to use which takes advantage of the caching system. Search this commit diff for `exe.run()` for an example. * Zig build by default enables caching. All build artifacts will go into zig-cache. If you want to access build artifacts in a convenient location, it is recommended to add an `install` step. Otherwise you can use the `run()` API mentioned above to execute programs directly from their location in the cache. Closes #330. `addSystemCommand` is available for programs not built with Zig build. * Please note that Zig does no cache evicting yet. You may have to manually delete zig-cache directories periodically to keep disk usage down. It's planned for this to be a simple Least Recently Used eviction system eventually. * `--output`, `--output-lib`, and `--output-h` are removed. Instead, use `--output-dir` which defaults to the current working directory. Or take advantage of `--cache on`, which will print the main output path to stdout, and the other artifacts will be in the same directory with predictable file names. `--disable-gen-h` is available when one wants to prevent .h file generation. * `@cImport` is always independently cached now. Closes #2015. It always writes the generated Zig code to disk which makes debug info and compile errors better. No more "TODO: remember C source location to display here" * Fix .d file parsing. (Fixes the MacOS CI failure) * Zig no longer creates "temporary files" other than inside a zig-cache directory. This breaks the CLI API that Godbolt uses. The suggested new invocation can be found in this commit diff, in the changes to `test/cli.zig`. --- src/ast_render.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ast_render.cpp') diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 7b57841205..76a0622058 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -470,6 +470,9 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { fprintf(ar->f, ", "); } } + if (node->data.fn_proto.is_var_args) { + fprintf(ar->f, ", ..."); + } fprintf(ar->f, ")"); if (node->data.fn_proto.align_expr) { fprintf(ar->f, " align("); -- cgit v1.2.3 From 85d23e68eecc8b2af89a3836296ac0689ec7a5b9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 8 Mar 2019 23:40:39 -0500 Subject: fix .d file parsing and string literal ast rendering --- src/ast_render.cpp | 8 ++++---- src/cache_hash.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ast_render.cpp') diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 76a0622058..84a952fa99 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -317,7 +317,7 @@ static bool is_digit(uint8_t c) { static bool is_printable(uint8_t c) { static const uint8_t printables[] = - " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,"; + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.~`!@#$%^&*()_-+=\\{}[];'\"?/<>,:"; for (size_t i = 0; i < array_length(printables); i += 1) { if (c == printables[i]) return true; } @@ -328,9 +328,7 @@ static void string_literal_escape(Buf *source, Buf *dest) { buf_resize(dest, 0); for (size_t i = 0; i < buf_len(source); i += 1) { uint8_t c = *((uint8_t*)buf_ptr(source) + i); - if (is_printable(c)) { - buf_append_char(dest, c); - } else if (c == '\'') { + if (c == '\'') { buf_append_str(dest, "\\'"); } else if (c == '"') { buf_append_str(dest, "\\\""); @@ -350,6 +348,8 @@ static void string_literal_escape(Buf *source, Buf *dest) { buf_append_str(dest, "\\t"); } else if (c == '\v') { buf_append_str(dest, "\\v"); + } else if (is_printable(c)) { + buf_append_char(dest, c); } else { buf_appendf(dest, "\\x%x", (int)c); } diff --git a/src/cache_hash.cpp b/src/cache_hash.cpp index cd336b71ae..6c9cf12962 100644 --- a/src/cache_hash.cpp +++ b/src/cache_hash.cpp @@ -472,10 +472,11 @@ Error cache_add_dep_file(CacheHash *ch, Buf *dep_file_path, bool verbose) { } } else { // sometimes there are multiple files on the same line; we actually need space tokenization. - SplitIterator line_it = memSplit(opt_line.value, str(" \t\\")); + SplitIterator line_it = memSplit(opt_line.value, str(" \t")); Slice filename; while (SplitIterator_next(&line_it).unwrap(&filename)) { Buf *filename_buf = buf_create_from_slice(filename); + if (buf_eql_str(filename_buf, "\\")) continue; if ((err = cache_add_file(ch, filename_buf))) { if (verbose) { fprintf(stderr, "unable to add %s to cache: %s\n", buf_ptr(filename_buf), err_str(err)); -- cgit v1.2.3