hare

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

commit 1632ae537e6b671d26cde0967ab499da99934483
parent 502e858e0593bc90a13377b520f58d59e765e145
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  9 Mar 2021 21:56:36 -0500

hare::module: store module path in version struct

Diffstat:
Mhare/module/scan.ha | 7+++++--
Mhare/module/types.ha | 1+
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -39,6 +39,7 @@ export fn scan(ctx: *context, path: path::path) (version | error) = { hash::write(sha, in.hash); return version { hash = hash::finish(sha), + basedir = path::dup(path::dirname(path)), depends = deps, inputs = inputs, }; @@ -46,7 +47,10 @@ export fn scan(ctx: *context, path: path::path) (version | error) = { err: fs::error => return err, iter: *fs::iterator => iter, }; - let ver = version { ... }; + let ver = version { + basedir = path::dup(path), + ... + }; scan_directory(ctx, &ver, sha, path, iter)?; ver.hash = hash::finish(sha); return ver; @@ -98,7 +102,6 @@ fn scan_directory( // which includes all eligible build inputs. export fn lookup(ctx: *context, name: ast::ident) (version | error) = { let ipath = ident_path(name); - defer ast::ident_free(name); for (let i = len(ctx.paths); i > 0; i -= 1) { let cand = path::join(ctx.paths[i - 1], ipath); defer path::path_free(cand); diff --git a/hare/module/types.ha b/hare/module/types.ha @@ -26,6 +26,7 @@ export type manifest = struct { // A module version: a set of possible input files for that module. export type version = struct { hash: []u8, + basedir: path::path, depends: []ast::ident, inputs: []input, };