hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit aedd3dc7e23b33b3fe7c5bd41acc36ec1887285f
parent 4c72c067bfecd0daa9c622e2a08a761bc675b5c2
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 24 Mar 2021 12:52:26 -0400

cmd/hare: skip dependencies which are current (WIP)

This depends on the partially-implemented hare::module::current
function, which always returns false. We need to be sure that module
inputs are sorted before we tackle this further.

Diffstat:
Mcmd/hare/schedule.ha | 11++++++++++-
Mhare/module/manifest.ha | 36+++++++++++++++++++++++++++---------
2 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha @@ -154,6 +154,7 @@ fn sched_hare_object( append(harec.cmd, "-D", plan.context.defines[i]); }; + let current = false; let output = if (len(namespace) != 0) { let version = hex::encode(ver.hash); let ns = unparse::ident_s(namespace); @@ -173,6 +174,7 @@ fn sched_hare_object( m: module::manifest => m, }; defer module::manifest_finish(&manifest); + current = module::current(&manifest, &ver); let name = fmt::asprintf("{}.{}", version, if (mixed) "a" else "o"); @@ -197,7 +199,14 @@ fn sched_hare_object( }; }; - append(plan.scheduled, harec); + if (current) { + harec.status = status::COMPLETE; + harec.output = output; + append(plan.complete, harec); + return harec; + } else { + append(plan.scheduled, harec); + }; let s = mkfile(plan, "s"); let qbe = sched_qbe(plan, s, harec); diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -23,10 +23,10 @@ use time; def VERSION: int = 1; -fn getinput(m: *manifest, hash: []u8) nullable *input = { - for (let i = 0z; i < len(m.inputs); i += 1) { - if (bytes::equal(m.inputs[i].hash, hash)) { - return &m.inputs[i]; +fn getinput(in: []input, hash: []u8) nullable *input = { + for (let i = 0z; i < len(in); i += 1) { + if (bytes::equal(in[i].hash, hash)) { + return &in[i]; }; }; return null; @@ -148,7 +148,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { b: []u8 => b, }; - let inputs: []input = []; + let minputs: []input = []; for (true) { let hash = match (strings::next_token(&tok)) { void => break, @@ -160,17 +160,16 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { }; defer free(hash); - let input = match (getinput(&manifest, hash)) { + let input = match (getinput(inputs, hash)) { null => return manifest, i: *input => i, }; - - append(inputs, *input); + append(minputs, *input); }; append(versions, version { hash = modhash, - inputs = inputs, + inputs = minputs, }); } else { return manifest; @@ -188,6 +187,25 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { return manifest; }; +// Returns true if the desired module version is present and current in this +// manifest. +export fn current(manifest: *manifest, version: *version) bool = { + let cached: nullable *version = null; + for (let i = 0z; i < len(manifest.versions); i += 1) { + if (bytes::equal(manifest.versions[i].hash, version.hash)) { + cached = &manifest.versions[i]; + break; + }; + }; + let cached = match (cached) { + null => return false, + v: *version => v, + }; + + // TODO: Blocked on sort + return false; +}; + // Writes a module manifest to the build cache. export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = { let ipath = ident_path(manifest.ident);