diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-26 01:53:38 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-26 01:53:38 -0400 |
| commit | c77380f353e85bcd9ba03c29b292022c694b9667 (patch) | |
| tree | 363173a15204b18416de1cce953b6cd7197d3582 | |
| parent | 878976eccf34de81b03611915485ff22ed0f819f (diff) | |
Add `--version` flag to show current compiler version's git commit date
and hash
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | docs/tomo.1.md | 3 | ||||
| -rw-r--r-- | man/man1/tomo.1 | 6 | ||||
| -rw-r--r-- | src/tomo.c | 7 |
4 files changed, 20 insertions, 6 deletions
@@ -8,7 +8,6 @@ else include config.mk -VERSION=0.0.1 CC=cc CCONFIG=-std=c2x -fPIC \ -fno-signed-zeros -fno-finite-math-only -fno-trapping-math \ @@ -50,8 +49,10 @@ OSFLAGS != case $(OS) in *BSD|Darwin) echo '-D_BSD_SOURCE';; Linux) echo '-D_GNU EXTRA= G=-ggdb O=-O3 +GIT_VERSION=$(shell git log -1 --pretty=format:'%as_%h') CFLAGS=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO) \ - -DTOMO_HOME='"$(TOMO_HOME)"' -DTOMO_PREFIX='"$(PREFIX)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' + -DTOMO_HOME='"$(TOMO_HOME)"' -DTOMO_PREFIX='"$(PREFIX)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \ + -DTOMO_VERSION='"$(GIT_VERSION)"' CFLAGS_PLACEHOLDER="$$(printf '\033[2m<flags...>\033[m\n')" LDLIBS=-lgc -lcord -lm -lunistring -lgmp LIBTOMO_FLAGS=-shared @@ -143,9 +144,12 @@ api/api.md: $(API_YAML) api-docs: $(API_MD) api/api.md .PHONY: manpages -manpages: $(API_YAML) +manpages: $(API_YAML) man/man1/tomo.1 ./scripts/mandoc_gen.py $^ +man/man1/tomo.1: docs/tomo.1.md + pandoc --lua-filter=docs/.pandoc/bold-code.lua -s $< -t man -o $@ + examples: ./build/bin/tomo -qIL examples/log examples/ini examples/vectors examples/http examples/wrap examples/colorful ./build/bin/tomo -e examples/game/game.tm examples/http-server/http-server.tm \ diff --git a/docs/tomo.1.md b/docs/tomo.1.md index 694eacf9..29d9414f 100644 --- a/docs/tomo.1.md +++ b/docs/tomo.1.md @@ -62,6 +62,9 @@ C code, which is then compiled using a C compiler of your choice. `-v`, `--verbose` : Print extra verbose output. +`--version` +: Print the compiler version and exit. + `-r`, `--run` : Run an installed tomo program from `~/.local/share/tomo/installed`. diff --git a/man/man1/tomo.1 b/man/man1/tomo.1 index bbc90f8e..37252921 100644 --- a/man/man1/tomo.1 +++ b/man/man1/tomo.1 @@ -5,9 +5,6 @@ tomo \- The programming language of tomorrow. .SH SYNOPSIS .TP -Run the REPL: -\f[B]tomo\f[R] -.TP Run a program: \f[B]tomo\f[R] \f[I]program.tm\f[R] [[\f[B]\-\-\f[R]] \f[I]args\&...\f[R]] @@ -63,6 +60,9 @@ Set the optimization level. \f[B]\-v\f[R], \f[B]\-\-verbose\f[R] Print extra verbose output. .TP +\f[B]\-\-version\f[R] +Print the compiler version and exit. +.TP \f[B]\-r\f[R], \f[B]\-\-run\f[R] Run an installed tomo program from \f[B]\[ti]/.local/share/tomo/installed\f[R]. @@ -54,6 +54,7 @@ static OptionalList_t files = NONE_LIST, uninstall = NONE_LIST, libraries = NONE_LIST; static OptionalBool_t verbose = false, + show_version = false, quiet = false, show_parse_tree = false, stop_at_transpile = false, @@ -163,6 +164,7 @@ int main(int argc, char *argv[]) {"args", true, List$info(&Text$info), &args}, {"verbose", false, &Bool$info, &verbose}, {"v", false, &Bool$info, &verbose}, + {"version", false, &Bool$info, &show_version}, {"parse", false, &Bool$info, &show_parse_tree}, {"p", false, &Bool$info, &show_parse_tree}, {"quiet", false, &Bool$info, &quiet}, @@ -190,6 +192,11 @@ int main(int argc, char *argv[]) {"m", false, &Bool$info, &source_mapping}, ); + if (show_version) { + print("Tomo version: ", TOMO_VERSION); + return 0; + } + bool is_gcc = (system(String(cc, " -v 2>&1 | grep 'gcc version' >/dev/null")) == 0); if (is_gcc) { cflags = Texts(cflags, Text(" -fsanitize=signed-integer-overflow -fno-sanitize-recover" |
