commit 11ad91284a0fc9e65367916380fda74b602eb422
parent 3455bf5d755c8910ff6bda49909fc2591a2eba18
Author: Eyal Sawady <ecs@d2evs.net>
Date: Thu, 25 Mar 2021 02:35:42 -0400
hare::module::lock: create cache directory
Fixes a regression in 4c72c067bfecd0daa9c622e2a08a761bc675b5c2 where
manifest_load never succeeds in acquiring the lock if the relevant cache
directory hasn't been created yet.
Diffstat:
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha
@@ -7,6 +7,7 @@ use fs;
use hare::ast;
use hare::unparse;
use io;
+use os;
use path;
use strconv;
use strings;
@@ -261,6 +262,11 @@ export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = {
fn lock(fs: *fs::fs, cachedir: str) (*io::stream | error) = {
// XXX: I wonder if this should be some generic function in fs or
// something
+ match (os::mkdirs(cachedir)) {
+ fs::exists => void,
+ void => void,
+ e: fs::error => return e,
+ };
let lockpath = path::join(cachedir, "manifest.lock");
defer free(lockpath);
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -295,7 +295,7 @@ hare_module() {
gen_ssa hare::module \
hare::ast hare::lex hare::parse hare::unparse strio fs io strings hash \
crypto::sha256 dirs bytes encoding::utf8 ascii fmt time slice bufio \
- strconv
+ strconv os
}
gensrcs_hare_parse() {
diff --git a/stdlib.mk b/stdlib.mk
@@ -383,7 +383,7 @@ stdlib_hare_module_srcs= \
$(STDLIB)/hare/module/scan.ha \
$(STDLIB)/hare/module/manifest.ha
-$(HARECACHE)/hare/module/hare_module.ssa: $(stdlib_hare_module_srcs) $(stdlib_rt) $(stdlib_hare_ast) $(stdlib_hare_lex) $(stdlib_hare_parse) $(stdlib_hare_unparse) $(stdlib_strio) $(stdlib_fs) $(stdlib_io) $(stdlib_strings) $(stdlib_hash) $(stdlib_crypto_sha256) $(stdlib_dirs) $(stdlib_bytes) $(stdlib_encoding_utf8) $(stdlib_ascii) $(stdlib_fmt) $(stdlib_time) $(stdlib_slice) $(stdlib_bufio) $(stdlib_strconv)
+$(HARECACHE)/hare/module/hare_module.ssa: $(stdlib_hare_module_srcs) $(stdlib_rt) $(stdlib_hare_ast) $(stdlib_hare_lex) $(stdlib_hare_parse) $(stdlib_hare_unparse) $(stdlib_strio) $(stdlib_fs) $(stdlib_io) $(stdlib_strings) $(stdlib_hash) $(stdlib_crypto_sha256) $(stdlib_dirs) $(stdlib_bytes) $(stdlib_encoding_utf8) $(stdlib_ascii) $(stdlib_fmt) $(stdlib_time) $(stdlib_slice) $(stdlib_bufio) $(stdlib_strconv) $(stdlib_os)
@printf 'HAREC \t$@\n'
@mkdir -p $(HARECACHE)/hare/module
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nhare::module \
@@ -1035,7 +1035,7 @@ testlib_hare_module_srcs= \
$(STDLIB)/hare/module/scan.ha \
$(STDLIB)/hare/module/manifest.ha
-$(TESTCACHE)/hare/module/hare_module.ssa: $(testlib_hare_module_srcs) $(testlib_rt) $(testlib_hare_ast) $(testlib_hare_lex) $(testlib_hare_parse) $(testlib_hare_unparse) $(testlib_strio) $(testlib_fs) $(testlib_io) $(testlib_strings) $(testlib_hash) $(testlib_crypto_sha256) $(testlib_dirs) $(testlib_bytes) $(testlib_encoding_utf8) $(testlib_ascii) $(testlib_fmt) $(testlib_time) $(testlib_slice) $(testlib_bufio) $(testlib_strconv)
+$(TESTCACHE)/hare/module/hare_module.ssa: $(testlib_hare_module_srcs) $(testlib_rt) $(testlib_hare_ast) $(testlib_hare_lex) $(testlib_hare_parse) $(testlib_hare_unparse) $(testlib_strio) $(testlib_fs) $(testlib_io) $(testlib_strings) $(testlib_hash) $(testlib_crypto_sha256) $(testlib_dirs) $(testlib_bytes) $(testlib_encoding_utf8) $(testlib_ascii) $(testlib_fmt) $(testlib_time) $(testlib_slice) $(testlib_bufio) $(testlib_strconv) $(testlib_os)
@printf 'HAREC \t$@\n'
@mkdir -p $(TESTCACHE)/hare/module
@HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nhare::module \