| author | |
| committer | |
| log | 0860be03b154e648a963edf26867b23596ed98f0 |
| tree | fe52321c10fce3a432acc2236607ffb640f74651 |
| parent | f6cd02be6551f3ca702b76b7ca2ab7567effe680 |
| parent | 67a39a4c99106714588676db0168fef52e0ecd9c |
| signature | Commit is signed but in an unrecognized format. |
5 files changed, 25 insertions(+), 6 deletions(-)
src/cache_hash.cpp+4-2| ... | @@ -352,8 +352,9 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -352,8 +352,9 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 352 | // if the mtime matches we can trust the digest | 352 | // if the mtime matches we can trust the digest |
| 353 | OsFile this_file; | 353 | OsFile this_file; |
| 354 | if ((err = os_file_open_r(chf->path, &this_file))) { | 354 | if ((err = os_file_open_r(chf->path, &this_file))) { |
| 355 | fprintf(stderr, "Unable to open %s\n: %s", buf_ptr(chf->path), err_str(err)); | ||
| 355 | os_file_close(ch->manifest_file); | 356 | os_file_close(ch->manifest_file); |
| 356 | return err; | 357 | return ErrorCacheUnavailable; |
| 357 | } | 358 | } |
| 358 | OsTimeStamp actual_mtime; | 359 | OsTimeStamp actual_mtime; |
| 359 | if ((err = os_file_mtime(this_file, &actual_mtime))) { | 360 | if ((err = os_file_mtime(this_file, &actual_mtime))) { |
| ... | @@ -392,8 +393,9 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { | ... | @@ -392,8 +393,9 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) { |
| 392 | for (; file_i < input_file_count; file_i += 1) { | 393 | for (; file_i < input_file_count; file_i += 1) { |
| 393 | CacheHashFile *chf = &ch->files.at(file_i); | 394 | CacheHashFile *chf = &ch->files.at(file_i); |
| 394 | if ((err = populate_file_hash(ch, chf, nullptr))) { | 395 | if ((err = populate_file_hash(ch, chf, nullptr))) { |
| 396 | fprintf(stderr, "Unable to hash %s: %s\n", buf_ptr(chf->path), err_str(err)); | ||
| 395 | os_file_close(ch->manifest_file); | 397 | os_file_close(ch->manifest_file); |
| 396 | return err; | 398 | return ErrorCacheUnavailable; |
| 397 | } | 399 | } |
| 398 | } | 400 | } |
| 399 | return ErrorNone; | 401 | return ErrorNone; |
src/codegen.cpp+10-1| ... | @@ -129,6 +129,11 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out | ... | @@ -129,6 +129,11 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 129 | Buf *src_dir = buf_alloc(); | 129 | Buf *src_dir = buf_alloc(); |
| 130 | os_path_split(root_src_path, src_dir, src_basename); | 130 | os_path_split(root_src_path, src_dir, src_basename); |
| 131 | 131 | ||
| 132 | if (buf_len(src_basename) == 0) { | ||
| 133 | fprintf(stderr, "Invalid root source path: %s\n", buf_ptr(root_src_path)); | ||
| 134 | exit(1); | ||
| 135 | } | ||
| 136 | |||
| 132 | g->root_package = new_package(buf_ptr(src_dir), buf_ptr(src_basename)); | 137 | g->root_package = new_package(buf_ptr(src_dir), buf_ptr(src_basename)); |
| 133 | g->std_package = new_package(buf_ptr(g->zig_std_dir), "index.zig"); | 138 | g->std_package = new_package(buf_ptr(g->zig_std_dir), "index.zig"); |
| 134 | g->root_package->package_table.put(buf_create_from_str("std"), g->std_package); | 139 | g->root_package->package_table.put(buf_create_from_str("std"), g->std_package); |
| ... | @@ -8178,7 +8183,11 @@ void codegen_build_and_link(CodeGen *g) { | ... | @@ -8178,7 +8183,11 @@ void codegen_build_and_link(CodeGen *g) { |
| 8178 | os_path_join(stage1_dir, buf_create_from_str("build"), manifest_dir); | 8183 | os_path_join(stage1_dir, buf_create_from_str("build"), manifest_dir); |
| 8179 | 8184 | ||
| 8180 | if ((err = check_cache(g, manifest_dir, &digest))) { | 8185 | if ((err = check_cache(g, manifest_dir, &digest))) { |
| 8181 | fprintf(stderr, "Unable to check cache: %s\n", err_str(err)); | 8186 | if (err == ErrorCacheUnavailable) { |
| 8187 | // message already printed | ||
| 8188 | } else { | ||
| 8189 | fprintf(stderr, "Unable to check cache: %s\n", err_str(err)); | ||
| 8190 | } | ||
| 8182 | exit(1); | 8191 | exit(1); |
| 8183 | } | 8192 | } |
| 8184 | 8193 |
src/error.cpp+1| ... | @@ -33,6 +33,7 @@ const char *err_str(Error err) { | ... | @@ -33,6 +33,7 @@ const char *err_str(Error err) { |
| 33 | case ErrorSharingViolation: return "sharing violation"; | 33 | case ErrorSharingViolation: return "sharing violation"; |
| 34 | case ErrorPipeBusy: return "pipe busy"; | 34 | case ErrorPipeBusy: return "pipe busy"; |
| 35 | case ErrorPrimitiveTypeNotFound: return "primitive type not found"; | 35 | case ErrorPrimitiveTypeNotFound: return "primitive type not found"; |
| 36 | case ErrorCacheUnavailable: return "cache unavailable"; | ||
| 36 | } | 37 | } |
| 37 | return "(invalid error)"; | 38 | return "(invalid error)"; |
| 38 | } | 39 | } |
src/error.hpp+1| ... | @@ -35,6 +35,7 @@ enum Error { | ... | @@ -35,6 +35,7 @@ enum Error { |
| 35 | ErrorSharingViolation, | 35 | ErrorSharingViolation, |
| 36 | ErrorPipeBusy, | 36 | ErrorPipeBusy, |
| 37 | ErrorPrimitiveTypeNotFound, | 37 | ErrorPrimitiveTypeNotFound, |
| 38 | ErrorCacheUnavailable, | ||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | const char *err_str(Error err); | 41 | const char *err_str(Error err); |
src/os.cpp+9-3| ... | @@ -188,14 +188,20 @@ void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename) { | ... | @@ -188,14 +188,20 @@ void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename) { |
| 188 | size_t len = buf_len(full_path); | 188 | size_t len = buf_len(full_path); |
| 189 | if (len != 0) { | 189 | if (len != 0) { |
| 190 | size_t last_index = len - 1; | 190 | size_t last_index = len - 1; |
| 191 | if (os_is_sep(buf_ptr(full_path)[last_index])) { | 191 | char last_char = buf_ptr(full_path)[last_index]; |
| 192 | if (os_is_sep(last_char)) { | ||
| 193 | if (last_index == 0) { | ||
| 194 | if (out_dirname) buf_init_from_mem(out_dirname, &last_char, 1); | ||
| 195 | if (out_basename) buf_init_from_str(out_basename, ""); | ||
| 196 | return; | ||
| 197 | } | ||
| 192 | last_index -= 1; | 198 | last_index -= 1; |
| 193 | } | 199 | } |
| 194 | for (size_t i = last_index;;) { | 200 | for (size_t i = last_index;;) { |
| 195 | uint8_t c = buf_ptr(full_path)[i]; | 201 | uint8_t c = buf_ptr(full_path)[i]; |
| 196 | if (os_is_sep(c)) { | 202 | if (os_is_sep(c)) { |
| 197 | if (out_dirname) { | 203 | if (out_dirname) { |
| 198 | buf_init_from_mem(out_dirname, buf_ptr(full_path), i); | 204 | buf_init_from_mem(out_dirname, buf_ptr(full_path), (i == 0) ? 1 : i); |
| 199 | } | 205 | } |
| 200 | if (out_basename) { | 206 | if (out_basename) { |
| 201 | buf_init_from_mem(out_basename, buf_ptr(full_path) + i + 1, buf_len(full_path) - (i + 1)); | 207 | buf_init_from_mem(out_basename, buf_ptr(full_path) + i + 1, buf_len(full_path) - (i + 1)); |
| ... | @@ -1976,7 +1982,7 @@ Error os_file_read(OsFile file, void *ptr, size_t *len) { | ... | @@ -1976,7 +1982,7 @@ Error os_file_read(OsFile file, void *ptr, size_t *len) { |
| 1976 | case EFAULT: | 1982 | case EFAULT: |
| 1977 | zig_unreachable(); | 1983 | zig_unreachable(); |
| 1978 | case EISDIR: | 1984 | case EISDIR: |
| 1979 | zig_unreachable(); | 1985 | return ErrorIsDir; |
| 1980 | default: | 1986 | default: |
| 1981 | return ErrorFileSystem; | 1987 | return ErrorFileSystem; |
| 1982 | } | 1988 | } |