commit b3575db38c69b977f74fedb95acf9ef4292c6e98
parent 85f1c204e87fc848c33746bbe207505c50c27431
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 6 Mar 2021 11:35:50 -0500
Resolve dependencies for build
Diffstat:
3 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/gen-stdlib b/gen-stdlib
@@ -100,6 +100,7 @@ ascii() {
bufio() {
printf '# bufio\n'
gen_srcs bufio \
+ buffered.ha \
dynamic.ha \
fixed.ha
gen_ssa bufio io bytes strings
@@ -215,8 +216,9 @@ fs() {
hare_ast() {
printf '# hare::ast\n'
gen_srcs hare::ast \
- types.ha
- gen_ssa hare::ast
+ types.ha \
+ unparse.ha
+ gen_ssa hare::ast io fmt strio
}
gensrcs_hare_lex() {
diff --git a/main.ha b/main.ha
@@ -1,8 +1,11 @@
+use encoding::hex;
use fmt;
+use hare::ast;
use hare::module;
use io;
use os::exec;
use os;
+use strio;
export fn main() void = {
if (len(os::args) == 1) {
@@ -18,6 +21,26 @@ export fn main() void = {
let plan = plan { ... };
+ for (let i = 0z; i < len(ver.depends); i += 1z) {
+ const dep = ver.depends[i];
+ let ident = ast::ident_unparse_s(dep);
+ defer free(ident);
+ match (module::lookup(&ctx, dep)) {
+ err: module::error => fmt::fatal("Error resolving {}: {}",
+ ident, module::errstr(err)),
+ ver: module::version => {
+ let hash = hex::encode(ver.hash);
+ defer free(hash);
+ fmt::printfln("{}: selecting version {}",
+ ident, hash);
+ for (let i = 0z; i < len(ver.inputs); i += 1) {
+ fmt::printfln("\t{}",
+ ver.inputs[i].path as str);
+ };
+ },
+ };
+ };
+
let harec = alloc(task {
status = status::SCHEDULED,
inputs = ver.inputs,
@@ -53,6 +76,11 @@ export fn main() void = {
err: exec::error => fmt::fatal("Error: exec {}: {}",
task.cmd[0], exec::errstr(err)),
};
+ for (let i = 0z; i < len(cmd.argv); i += 1) {
+ fmt::errorf("{} ", cmd.argv[i]);
+ };
+ fmt::errorln();
+
let proc = match (exec::start(&cmd)) {
err: exec::error => fmt::fatal("Error: start {}: {}",
task.cmd[0], exec::errstr(err)),
diff --git a/mk/stdlib.mk b/mk/stdlib.mk
@@ -160,6 +160,7 @@ $(HARECACHE)/ascii/ascii.ssa: $(stdlib_ascii_srcs) $(stdlib_rt) $(stdlib_strings
# bufio
stdlib_bufio_srcs= \
+ $(STDLIB)/bufio/buffered.ha \
$(STDLIB)/bufio/dynamic.ha \
$(STDLIB)/bufio/fixed.ha
@@ -294,9 +295,10 @@ $(HARECACHE)/fs/fs.ssa: $(stdlib_fs_srcs) $(stdlib_rt) $(stdlib_io) $(stdlib_str
# hare::ast
stdlib_hare_ast_srcs= \
- $(STDLIB)/hare/ast/types.ha
+ $(STDLIB)/hare/ast/types.ha \
+ $(STDLIB)/hare/ast/unparse.ha
-$(HARECACHE)/hare/ast/hare.ast.ssa: $(stdlib_hare_ast_srcs) $(stdlib_rt)
+$(HARECACHE)/hare/ast/hare.ast.ssa: $(stdlib_hare_ast_srcs) $(stdlib_rt) $(stdlib_io) $(stdlib_fmt) $(stdlib_strio)
@printf 'HAREC \t$@\n'
@mkdir -p $(HARECACHE)/hare/ast
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nhare::ast \
@@ -660,6 +662,7 @@ $(TESTCACHE)/ascii/ascii.ssa: $(testlib_ascii_srcs) $(testlib_rt) $(testlib_stri
# bufio
testlib_bufio_srcs= \
+ $(STDLIB)/bufio/buffered.ha \
$(STDLIB)/bufio/dynamic.ha \
$(STDLIB)/bufio/fixed.ha
@@ -795,9 +798,10 @@ $(TESTCACHE)/fs/fs.ssa: $(testlib_fs_srcs) $(testlib_rt) $(testlib_io) $(testlib
# hare::ast
testlib_hare_ast_srcs= \
- $(STDLIB)/hare/ast/types.ha
+ $(STDLIB)/hare/ast/types.ha \
+ $(STDLIB)/hare/ast/unparse.ha
-$(TESTCACHE)/hare/ast/hare.ast.ssa: $(testlib_hare_ast_srcs) $(testlib_rt)
+$(TESTCACHE)/hare/ast/hare.ast.ssa: $(testlib_hare_ast_srcs) $(testlib_rt) $(testlib_io) $(testlib_fmt) $(testlib_strio)
@printf 'HAREC \t$@\n'
@mkdir -p $(TESTCACHE)/hare/ast
@HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nhare::ast \