hare

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

commit 0c6c1db22c64c92bd8a254582063c173c8e66196
parent 8648d2dcc69cf77cee69e1de3716daae7bfd61b5
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 12 Mar 2021 13:29:10 -0500

subcmds: deduplicate tag initialization

Diffstat:
Msubcmds.ha | 38++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/subcmds.ha b/subcmds.ha @@ -5,11 +5,21 @@ use os; use os::exec; use path; +fn default_tags() []module::tag = { + // TODO: Bake me into the executable once harec -D works + return alloc([module::tag { + name = os::machine(), + mode = module::tag_mode::INCLUSIVE, + }, module::tag { + // TEMP: + name = "linux", + mode = module::tag_mode::INCLUSIVE, + }]); +}; + type goal = enum { OBJ, EXE, - RUN, - TEST, }; fn build(args: []str) void = { @@ -58,14 +68,10 @@ fn build(args: []str) void = { os::exit(1); }; - let ctx = module::context_init([module::tag { - name = os::machine(), - mode = module::tag_mode::INCLUSIVE, - }, module::tag { - // TEMP: - name = "linux", - mode = module::tag_mode::INCLUSIVE, - }]); + let tags = default_tags(); + defer free(tags); + + let ctx = module::context_init(tags); defer module::context_finish(&ctx); let plan = mkplan(&ctx); @@ -130,14 +136,10 @@ fn run(args: []str) void = { runargs = cmd.args[1..]; }; - let ctx = module::context_init([module::tag { - name = os::machine(), - mode = module::tag_mode::INCLUSIVE, - }, module::tag { - // TEMP: - name = "linux", - mode = module::tag_mode::INCLUSIVE, - }]); + let tags = default_tags(); + defer free(tags); + + let ctx = module::context_init(tags); defer module::context_finish(&ctx); let plan = mkplan(&ctx);