aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tomo.118
-rw-r--r--tomo.1.md17
-rw-r--r--tomo.c18
3 files changed, 30 insertions, 23 deletions
diff --git a/tomo.1 b/tomo.1
index 529a8c88..93db4f7d 100644
--- a/tomo.1
+++ b/tomo.1
@@ -35,27 +35,31 @@ compiler of your choice.
\f[B]\-h\f[R], \f[B]\-\-help\f[R]
Print the usage and exit.
.TP
-\f[B]\-t\f[R]
+\f[B]\-t\f[R], \f[B]\-\-transpile\f[R]
Transpile the input files to C code without compiling them.
.TP
-\f[B]\-c\f[R]
+\f[B]\-c\f[R], \f[B]\-\-compile\-obj\f[R]
Compile the input files to static objects, rather than running them.
.TP
-\f[B]\-e\f[R]
+\f[B]\-e\f[R], \f[B]\-\-compile\-exe\f[R]
Compile the input file to an executable.
.TP
-\f[B]\-L\f[R]
+\f[B]\-L\f[R], \f[B]\-\-library\f[R]
Compile the input files to a library \f[B].so\f[R] file and header.
.TP
-\f[B]\-I\f[R]
+\f[B]\-I\f[R], \f[B]\-\-install\f[R]
Install the compiled executable or library.
.TP
-\f[B]\-C\f[R]
-Print transpiled C code to the console.
+\f[B]\-C\f[R] \f[I]\f[R], \f[B]\-\-show\-codegen\f[R] \f[I]\f[R]
+Set a program (e.g.\ \f[B]cat\f[R] or \f[B]bat\f[R]) to display the
+generated code
.TP
\f[B]\-\-c\-compiler\f[R]
Set which C compiler is used.
.TP
+\f[B]\-O\f[R] \f[B]level\f[R], \f[B]\-\-optimization\f[R] \f[B]level\f[R]
+Set the optimization level.
+.TP
\f[B]\-v\f[R], \f[B]\-\-verbose\f[R]
Print extra verbose output.
.TP
diff --git a/tomo.1.md b/tomo.1.md
index 5484945b..d6d7d78b 100644
--- a/tomo.1.md
+++ b/tomo.1.md
@@ -38,27 +38,30 @@ C code, which is then compiled using a C compiler of your choice.
`-h`, `--help`
: Print the usage and exit.
-`-t`
+`-t`, `--transpile`
: Transpile the input files to C code without compiling them.
-`-c`
+`-c`, `--compile-obj`
: Compile the input files to static objects, rather than running them.
-`-e`
+`-e`, `--compile-exe`
: Compile the input file to an executable.
-`-L`
+`-L`, `--library`
: Compile the input files to a library `.so` file and header.
-`-I`
+`-I`, `--install`
: Install the compiled executable or library.
-`-C`
-: Print transpiled C code to the console.
+`-C` *<program>*, `--show-codegen` *<program>*
+: Set a program (e.g. `cat` or `bat`) to display the generated code
`--c-compiler`
: Set which C compiler is used.
+`-O` **level**, `--optimization` **level**
+: Set the optimization level.
+
`-v`, `--verbose`
: Print extra verbose output.
diff --git a/tomo.c b/tomo.c
index 8199d94e..ef86e10b 100644
--- a/tomo.c
+++ b/tomo.c
@@ -34,7 +34,6 @@ static OptionalArray_t files = NONE_ARRAY,
args = NONE_ARRAY;
static OptionalBool_t verbose = false,
quiet = false,
- show_codegen = false,
stop_at_transpile = false,
stop_at_obj_compilation = false,
stop_at_exe_compilation = false,
@@ -43,6 +42,7 @@ static OptionalBool_t verbose = false,
uninstall = false;
static OptionalText_t
+ show_codegen = NONE_TEXT,
cflags = Text("-Werror -fdollars-in-identifiers -std=gnu11 -Wno-trigraphs -fsanitize=signed-integer-overflow -fno-sanitize-recover"
" -fno-signed-zeros -fno-finite-math-only -fno-signaling-nans -fno-trapping-math"
" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -fPIC -ggdb"
@@ -105,8 +105,8 @@ int main(int argc, char *argv[])
{"u", false, &Bool$info, &uninstall},
{"library", false, &Bool$info, &library_mode},
{"L", false, &Bool$info, &library_mode},
- {"show-codegen", false, &Bool$info, &show_codegen},
- {"C", false, &Bool$info, &show_codegen},
+ {"show-codegen", false, &Text$info, &show_codegen},
+ {"C", false, &Text$info, &show_codegen},
{"install", false, &Bool$info, &should_install},
{"I", false, &Bool$info, &should_install},
{"c-compiler", false, &Text$info, &cc},
@@ -522,8 +522,8 @@ void transpile_header(env_t *base_env, Text_t filename, bool force_retranspile)
if (!quiet || verbose)
printf("\x1b[2mTranspiled to %k\x1b[m\n", &h_filename);
- if (show_codegen)
- system(heap_strf("bat -P %k", &h_filename));
+ if (show_codegen.length > 0)
+ system(heap_strf("%k %k", &show_codegen, &h_filename));
}
void transpile_code(env_t *base_env, Text_t filename, bool force_retranspile)
@@ -565,8 +565,8 @@ void transpile_code(env_t *base_env, Text_t filename, bool force_retranspile)
if (!quiet || verbose)
printf("\x1b[2mTranspiled to %k\x1b[m\n", &c_filename);
- if (show_codegen)
- system(heap_strf("bat -P %k", &c_filename));
+ if (show_codegen.length > 0)
+ system(heap_strf("%k %k", &show_codegen, &c_filename));
}
void compile_object_file(Text_t filename, bool force_recompile)
@@ -613,8 +613,8 @@ Text_t compile_executable(env_t *base_env, Text_t filename, Array_t object_files
"}\n"
);
- if (show_codegen) {
- FILE *out = run_cmd("bat -P --file-name=run.c");
+ if (show_codegen.length > 0) {
+ FILE *out = run_cmd("%k", &show_codegen);
CORD_put(program, out);
pclose(out);
}