hare

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

commit 2348316509a4db74a1563384cde7bb91dc7b4215
parent 9dbf9492dfac124b1c90a5606d936242ce064462
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Jan 2024 12:44:17 +0100

hare(1): enable debug features, add -R flag

This links builds to debug:: by default, and adds a -R flag to build in
"release" mode, which disables linking to debug.

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/hare/build.ha | 2++
Mcmd/hare/build/gather.ha | 3+++
Mcmd/hare/build/types.ha | 2++
Mcmd/hare/main.ha | 3+++
Mdocs/hare-build.1.scd | 7+++++++
Mdocs/hare-run.1.scd | 1+
Mdocs/hare-test.1.scd | 1+
7 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/cmd/hare/build.ha b/cmd/hare/build.ha @@ -103,6 +103,8 @@ fn build(name: str, cmd: *getopt::command) (void | error) = { output = opt.1; case 'q' => ctx.mode = build::output::SILENT; + case 'R' => + ctx.release = true; case 'T' => merge_tags(&ctx.ctx.tags, opt.1)?; case 't' => diff --git a/cmd/hare/build/gather.ha b/cmd/hare/build/gather.ha @@ -15,6 +15,9 @@ export fn gather(ctx: *context, input: str) ([]module::module | error) = { if (ctx.test) { module::gather(&ctx.ctx, &mods, ["test"])?; }; + if (!ctx.release) { + module::gather(&ctx.ctx, &mods, ["debug"])?; + }; const nsubmods = if (ctx.submods) { let id: ast::ident = []; defer ast::ident_free(id); diff --git a/cmd/hare/build/types.ha b/cmd/hare/build/types.ha @@ -67,6 +67,8 @@ export type context = struct { version: []u8, // true if invoked as `hare test` test: bool, + // true if building in release mode + release: bool, // whether submodules of the root module should have tests enabled submods: bool, // if true, the main function won't be checked by harec diff --git a/cmd/hare/main.ha b/cmd/hare/main.ha @@ -34,6 +34,7 @@ const help: []getopt::help = [ ('l', "libname", "link with a system library"), ('N', "namespace", "override namespace for module"), ('o', "path", "set output file name"), + ('R', "build in release mode"), ('T', "tagset", "set/unset build tags"), ('t', "type", "build type (s/o/bin)"), "[path]" @@ -57,6 +58,7 @@ const help: []getopt::help = [ ('j', "jobs", "set parallelism for build"), ('L', "libdir", "add directory to linker library search path"), ('l', "libname", "link with a system library"), + ('R', "build in release mode"), ('T', "tagset", "set/unset build tags"), "[path [args...]]", ]: []getopt::help), @@ -70,6 +72,7 @@ const help: []getopt::help = [ ('L', "libdir", "add directory to linker library search path"), ('l', "libname", "link with a system library"), ('o', "path", "set output file name"), + ('R', "build in release mode"), ('T', "tagset", "set/unset build tags"), "[path]" ]: []getopt::help), diff --git a/docs/hare-build.1.scd b/docs/hare-build.1.scd @@ -14,6 +14,7 @@ hare build - compile a Hare program or module [-l _libname_]++ [-N _namespace_]++ [-o _path_]++ + [-R]++ [-T _tagset_]++ [-t _type_]++ [_path_] @@ -72,6 +73,12 @@ working directory is built. Set the output file to the given path. Setting the path to *-* causes output to be written to stdout. +*-R* + Build in release mode. In debug mode (the default), the debug:: module + is imported as a dependency, which automatically installs a number of + runtime debugging features in your executable. See this module's + documentation for details on these features. + *-T* _tagset_ Set or unset build tags. See *BUILD TAGS* in *hare-module*(5). diff --git a/docs/hare-run.1.scd b/docs/hare-run.1.scd @@ -12,6 +12,7 @@ hare run - compile and run a Hare program or module [-j _jobs_]++ [-L _libdir_]++ [-l _libname_]++ + [-R]++ [-T _tagset_]++ [_path_ [_args_...]] diff --git a/docs/hare-test.1.scd b/docs/hare-test.1.scd @@ -13,6 +13,7 @@ hare test - compile and run tests for Hare code [-L _libdir_]++ [-l _libname_]++ [-o _path_]++ + [-R]++ [-T _tagset_]++ [_path_ [_tests_...]]