diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-21 17:26:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-21 17:26:37 -0500 |
| commit | fb77bd546ce42e5703cfb12ab1ebbe9772b83cef (patch) | |
| tree | 4a18f4c813a95ba23a74df1d6dea56250abf8861 | |
| parent | 0a5fc171c54bdedce0dad34701562831a497fccc (diff) | |
Fixes for builds and accessing version and install scriptv2025-12-21.5
| -rw-r--r-- | CHANGES.md | 4 | ||||
| -rw-r--r-- | README.md | 8 | ||||
| -rwxr-xr-x | install_script.sh | 4 | ||||
| -rw-r--r-- | src/stdlib/stdlib.c | 43 |
4 files changed, 49 insertions, 10 deletions
@@ -1,5 +1,9 @@ # Version History +## v2025-12-21.5 + +- Various fixes for versioning and builds. + ## v2025-12-21.4 - Version bump and deprecated `--changelog` flag @@ -35,6 +35,14 @@ of many language features or the other example programs/modules in [examples/](examples/). You can also look at the [core libraries](lib/) which are implemented in Tomo. +## Quick Installation + +If you don't want to build from source but just want to install, run this script: + +``` +curl https://raw.githubusercontent.com/bruce-hill/tomo/refs/heads/main/install_script.sh | bash` +``` + ## Features ### Performance diff --git a/install_script.sh b/install_script.sh index 1b3d92ae..21535f3d 100755 --- a/install_script.sh +++ b/install_script.sh @@ -129,7 +129,7 @@ if echo "$PATH" | tr ':' '\n' | grep -qx "$HOME/.local/bin"; then default_prefix="~/.local" fi printf '\033[1mChoose where to install Tomo (default: %s):\033[m ' "$default_prefix" -read DEST +read DEST </dev/tty if [ -z "$DEST" ]; then DEST="$default_prefix"; fi DEST="${DEST/#\~/$HOME}" @@ -141,3 +141,5 @@ else tar -xzf "$FILE" -C "$DEST" --strip-components=1 "tomo@$TAG" fi echo "Installed to $DEST" + +rm -f "$FILE" "$FILE.sha256" diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c index 688f2eb4..023791a2 100644 --- a/src/stdlib/stdlib.c +++ b/src/stdlib/stdlib.c @@ -80,20 +80,45 @@ static inline const char *get_library_path(void *func) { #error "Unsupported platform" #endif -const char *resolve_symlinks(const char *path) { - static char resolved[PATH_MAX]; - if (realpath(path, resolved) != NULL) { - return resolved; - } else { - perror("realpath"); - return NULL; +char *find_in_path(const char *name) { + if (strchr(name, '/')) { + // name contains a slash → treat as path + char *abs = realpath(name, NULL); + if (abs == NULL) fail("Couldn't find real path of: ", name); + char *ret = String(abs); + free(abs); + return ret; } + + char *path_env = getenv("PATH"); + if (!path_env) return NULL; + + char *paths = strdup(path_env); + if (!paths) return NULL; + + char *token = strtok(paths, ":"); + while (token) { + char candidate[PATH_MAX]; + snprintf(candidate, sizeof(candidate), "%s/%s", token, name); + if (access(candidate, X_OK) == 0) { + char *abs = realpath(candidate, NULL); + free(paths); + char *ret = String(abs); + free(abs); + return ret; + } + token = strtok(NULL, ":"); + } + + free(paths); + return NULL; // not found } public void tomo_configure(void) { - const char *lib_path = resolve_symlinks(get_library_path(get_library_path)); - Path_t path = Path$from_str(lib_path); + const char *p = get_library_path(get_library_path); + p = find_in_path(p); + Path_t path = Path$from_str(p); TOMO_PATH = Path$as_c_string(Path$parent(Path$parent(path))); Text_t base_name = Path$base_name(path); TOMO_VERSION_TEXT = Text$without_suffix( |
