commit 9183c7d83c98a2742c168889575c5faa5bbc7dbd
parent e3a8a3608adf0efd91a54165cc0ed2f0dbfdf7e8
Author: Adnan Maolood <me@adnano.co>
Date: Sat, 8 Oct 2022 15:03:08 -0400
cmd/hare: implement compile-only builds
Signed-off-by: Adnan Maolood <me@adnano.co>
Diffstat:
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha
@@ -107,7 +107,7 @@ fn sched_module(plan: *plan, ident: ast::ident, link: *[]*task) *task = {
append(depends, obj);
};
- let obj = sched_hare_object(plan, ver, ident, depends...);
+ let obj = sched_hare_object(plan, ver, ident, void, depends...);
append(bucket, modcache {
hash = hash,
task = obj,
@@ -218,6 +218,7 @@ fn sched_hare_object(
plan: *plan,
ver: module::version,
namespace: ast::ident,
+ output: (void | str),
depend: *task...
) *task = {
// XXX: Do we care to support assembly-only modules?
@@ -260,7 +261,10 @@ fn sched_hare_object(
};
let current = false;
- let output = if (len(namespace) != 0) {
+ let output = if (output is str) {
+ // TODO: Should we use the cache here?
+ yield fmt::asprintf("{}.{}", output, if (mixed) "a" else "o");
+ } else if (len(namespace) != 0) {
let version = hex::encodestr(ver.hash);
let env = module::identuscore(namespace);
defer free(env);
@@ -366,7 +370,7 @@ fn sched_hare_exe(
output: str,
depend: *task...
) *task = {
- let obj = sched_hare_object(plan, ver, [], depend...);
+ let obj = sched_hare_object(plan, ver, [], void, depend...);
// TODO: We should be able to use partial variadic application
let link: []*task = alloc([], len(depend));
defer free(link);
diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha
@@ -131,8 +131,6 @@ fn build(args: []str) void = {
};
};
- assert(goal == goal::EXE); // TODO
-
const input =
if (len(cmd.args) == 0) os::getcwd()
else if (len(cmd.args) == 1) cmd.args[0]
@@ -174,7 +172,13 @@ fn build(args: []str) void = {
if (output == "") {
output = path::basename(ver.basedir);
};
- sched_hare_exe(&plan, ver, output, depends...);
+ switch (goal) {
+ case goal::EXE =>
+ sched_hare_exe(&plan, ver, output, depends...);
+ case goal::OBJ =>
+ let task = sched_hare_object(&plan, ver, [], output, depends...);
+ append(plan.scheduled, task);
+ };
match (plan_execute(&plan, verbose)) {
case void => void;
case !exec::exit_status =>