diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 17:12:20 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-18 17:12:20 -0400 |
| commit | 383a942bb3fe05be887a6622ca5ed86e9bba0662 (patch) | |
| tree | 381ca712bbbeb36308fb2866c3b4c516626b1abf /src/tomo.c | |
| parent | 48aa524e8c5aab6632c680971a8a31c542121993 (diff) | |
Added automatic manpages.
Diffstat (limited to 'src/tomo.c')
| -rw-r--r-- | src/tomo.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -290,7 +290,8 @@ int main(int argc, char *argv[]) { // Uninstall libraries: for (int64_t i = 0; i < (int64_t)uninstall_libraries.length; i++) { Text_t *u = (Text_t *)(uninstall_libraries.data + i * uninstall_libraries.stride); - xsystem(as_owner, "rm -rvf '", TOMO_PATH, "'/lib/tomo_" TOMO_VERSION "/", *u); + xsystem(as_owner, "rm -rvf '", TOMO_PATH, "'/lib/tomo_" TOMO_VERSION "/", *u, " '", TOMO_PATH, "'/bin/", *u, + " '", TOMO_PATH, "'/man/man1/", *u, ".1"); print("Uninstalled ", *u); } @@ -373,7 +374,12 @@ int main(int argc, char *argv[]) { List_t object_files = EMPTY_LIST, extra_ldlibs = EMPTY_LIST; compile_files(env, List(path), &object_files, &extra_ldlibs, COMPILE_EXE); compile_executable(env, path, exe_path, object_files, extra_ldlibs); - if (should_install) xsystem(as_owner, "cp -v '", exe_path, "' '", TOMO_PATH, "'/bin/"); + if (should_install) { + xsystem(as_owner, "mkdir -p '", TOMO_PATH, "/bin' '", TOMO_PATH, "/man/man1'"); + xsystem(as_owner, "cp -v '", exe_path, "' '", TOMO_PATH, "/bin/'"); + Path_t manpage_file = build_file(Path$with_extension(path, Text(".1"), true), ""); + xsystem(as_owner, "cp -v '", manpage_file, "' '", TOMO_PATH, "/man/man1/'"); + } _exit(0); } @@ -868,6 +874,16 @@ Path_t compile_executable(env_t *base_env, Path_t path, Path_t exe_path, List_t if (!main_binding || main_binding->type->tag != FunctionType) print_err("No main() function has been defined for ", path, ", so it can't be run!"); + Path_t manpage_file = build_file(Path$with_extension(path, Text(".1"), true), ""); + if (clean_build || !Path$is_file(manpage_file, true) || is_stale(manpage_file, path, true)) { + Text_t manpage = compile_manpage(Path$base_name(exe_path), NONE_TEXT, NONE_TEXT, + Match(main_binding->type, FunctionType)->args); + if (!quiet) print("Wrote manpage:\t", Path$relative_to(manpage_file, Path$current_dir())); + Path$write(manpage_file, manpage, 0644); + } else { + if (verbose) whisper("Unchanged: ", manpage_file); + } + if (!clean_build && Path$is_file(exe_path, true) && !is_config_outdated(path) && !is_stale_for_any(exe_path, object_files, false) && !is_stale(exe_path, Path$sibling(path, Text("modules.ini")), true) |
