From 7b3a651da64e3e1951ab01e5650c5ceaa1dd5d84 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Dec 2025 17:04:08 -0500 Subject: Remove xxd dependency (no more building with changelog) --- .github/workflows/release.yml | 9 ++- .gitignore | 2 - CHANGES.md | 4 ++ Makefile | 11 ---- install_dependencies.sh | 22 +++---- install_script.sh | 143 ++++++++++++++++++++++++++++++++++++++++++ src/tomo.c | 9 +-- 7 files changed, 165 insertions(+), 35 deletions(-) create mode 100755 install_script.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80d5bb67..cdbf541d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,8 @@ jobs: - name: Package run: | - tar -czf tomo-linux-x86_64.tar.gz build/* + TAG=${GITHUB_REF#refs/tags/} + tar -C build -czf tomo-linux-x86_64.tar.gz tomo@${TAG} sha256sum tomo-linux-x86_64.tar.gz > tomo-linux-x86_64.tar.gz.sha256 - name: Upload @@ -62,7 +63,8 @@ jobs: - name: Package run: | - tar -czf tomo-linux-aarch64.tar.gz build/* + TAG=${GITHUB_REF#refs/tags/} + tar -C build -czf tomo-linux-aarch64.tar.gz tomo@{TAG} sha256sum tomo-linux-aarch64.tar.gz > tomo-linux-aarch64.tar.gz.sha256 - name: Upload @@ -89,7 +91,8 @@ jobs: - name: Package run: | - tar -czf tomo-macos-universal.tar.gz build/* + TAG=${GITHUB_REF#refs/tags/} + tar -C build -czf tomo-macos-universal.tar.gz tomo@${TAG} shasum -a 256 tomo-macos-universal.tar.gz > tomo-macos-universal.tar.gz.sha256 - name: Upload diff --git a/.gitignore b/.gitignore index 78087392..5f521074 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ /lib/*/*.so /lib/*/*.a -/src/changes.md.h - .build /build *.o diff --git a/CHANGES.md b/CHANGES.md index 12796657..14e0dc5f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Version History +## v2025-12-21.4 + +- Version bump and deprecated `--changelog` flag + ## v2025-12-21.3 - Version bump diff --git a/Makefile b/Makefile index e7e689d0..95384d50 100644 --- a/Makefile +++ b/Makefile @@ -200,17 +200,6 @@ src/stdlib/int64.o src/stdlib/int32.o src/stdlib/int16.o src/stdlib/int8.o: src/ # Num implementations depend on the shared header: src/stdlib/num32.o src/stdlib/num64.o: src/stdlib/numX.c.h -# These files all depend on the current tomo version: -src/compile/files.o src/compile/headers.o src/compile/statements.o src/config.o src/environment.o \ - src/modules.o src/stdlib/stacktrace.o src/stdlib/stdlib.o src/tomo.o src/typecheck.o: CHANGES.md - -src/changes.md.h: CHANGES.md - @$(ECHO) "Embedding changes.md" - xxd -i $< > $@ - -# The main Tomo executable embeds the changelog: -src/tomo.o: src/changes.md.h - %: %.tm ./local-tomo -e $< diff --git a/install_dependencies.sh b/install_dependencies.sh index be5810d0..9b9026e9 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -48,19 +48,19 @@ fi # Install packages case "$PKG_MGR" in - apt) $SUDO apt install libgc-dev libunistring-dev binutils libgmp-dev xxd ;; - dnf) $SUDO dnf install gc-devel libunistring-devel binutils gmp-devel xxd ;; - pacman) $SUDO pacman -S gc libunistring binutils gmp xxd ;; - yay|paru) $PKG_MGR -S gc libunistring binutils gmp xxd ;; - xbps) $SUDO xbps-install -S gc libunistring binutils gmp xxd ;; - pkg_add) $SUDO pkg_add boehm-gc libunistring binutils gmp xxd ;; - freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils gmp xxd ;; + apt) $SUDO apt install libgc-dev libunistring-dev binutils libgmp-dev ;; + dnf) $SUDO dnf install gc-devel libunistring-devel binutils gmp-devel ;; + pacman) $SUDO pacman -S gc libunistring binutils gmp ;; + yay|paru) $PKG_MGR -S gc libunistring binutils gmp ;; + xbps) $SUDO xbps-install -S gc libunistring binutils gmp ;; + pkg_add) $SUDO pkg_add boehm-gc libunistring binutils gmp ;; + freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils gmp ;; brew) brew install bdw-gc libunistring binutils llvm gmp ;; macports) $SUDO port install boehm-gc libunistring binutils gmp ;; - zypper) $SUDO zypper install gc-devel libunistring-devel binutils gmp-devel xxd ;; - nix) nix-env -iA nixpkgs.boehmgc.dev nixpkgs.libunistring nixpkgs.binutils nixpkgs.nixpkgs.gmp xxd ;; - spack) spack install boehm-gc libunistring binutils gmp xxd ;; - conda) conda install boehm-gc libunistring binutils gmp xxd ;; + zypper) $SUDO zypper install gc-devel libunistring-devel binutils gmp-devel ;; + nix) nix-env -iA nixpkgs.boehmgc.dev nixpkgs.libunistring nixpkgs.binutils nixpkgs.nixpkgs.gmp ;; + spack) spack install boehm-gc libunistring binutils gmp ;; + conda) conda install boehm-gc libunistring binutils gmp ;; *) echo "Unknown package manager: $PKG_MGR" >&2 exit 1 diff --git a/install_script.sh b/install_script.sh new file mode 100755 index 00000000..1b3d92ae --- /dev/null +++ b/install_script.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +set -euo pipefail + +OWNER="bruce-hill" +REPO="tomo" + +# Fetch latest release tag +TAG=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/releases/latest" \ + | grep -Po '"tag_name": "\K.*?(?=")') + +if [[ -z "$TAG" ]]; then + echo "Failed to get latest release tag" + exit 1 +fi + +# Detect platform +OS="$(uname -s)" +ARCH="$(uname -m)" +case "$OS" in + Linux) + case "$ARCH" in + x86_64) FILE="tomo-linux-x86_64.tar.gz" ;; + aarch64|arm64) FILE="tomo-linux-aarch64.tar.gz" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; + esac + ;; + Darwin) + FILE="tomo-macos-universal.tar.gz" + ;; + *) + echo "Unsupported OS: $OS" + exit 1 + ;; +esac + +# Download the artifact (if not present) +if ! [ -e "$FILE" ]; then + URL="https://github.com/$OWNER/$REPO/releases/download/$TAG/$FILE" + echo "Downloading $URL ..." + curl -L -o "$FILE" "$URL" + echo "Downloaded $FILE" +fi + +# Download checksum (if not present) +if ! [ -e "$FILE.sha256" ]; then + CHECKSUM_URL="$URL.sha256" + echo "Downloading checksum $CHECKSUM_URL ..." + curl -L -o "$FILE.sha256" "$CHECKSUM_URL" +fi + +# Verify checksum +shasum --check "$FILE.sha256" +echo "Verified checksum" + +# Configure `doas` vs `sudo` +if command -v doas >/dev/null 2>&1; then + SUDO="doas" +elif command -v sudo >/dev/null 2>&1; then + SUDO="sudo" +else + echo "Neither doas nor sudo found." >&2 + exit 1 +fi + +# Autodetect package manager: +if [ -z "${PACKAGE_MANAGER:-}" ]; then + if command -v dnf >/dev/null 2>&1; then + PACKAGE_MANAGER="dnf" + elif command -v yay >/dev/null 2>&1; then + PACKAGE_MANAGER="yay" + elif command -v paru >/dev/null 2>&1; then + PACKAGE_MANAGER="paru" + elif command -v pacman >/dev/null 2>&1; then + PACKAGE_MANAGER="pacman" + elif command -v xbps-install >/dev/null 2>&1; then + PACKAGE_MANAGER="xbps" + elif command -v pkg_add >/dev/null 2>&1; then + PACKAGE_MANAGER="pkg_add" + elif command -v pkg >/dev/null 2>&1; then + PACKAGE_MANAGER="freebsd-pkg" + elif command -v brew >/dev/null 2>&1; then + PACKAGE_MANAGER="brew" + elif command -v port >/dev/null 2>&1; then + PACKAGE_MANAGER="macports" + elif command -v zypper >/dev/null 2>&1; then + PACKAGE_MANAGER="zypper" + elif command -v nix-env >/dev/null 2>&1; then + PACKAGE_MANAGER="nix" + elif command -v spack >/dev/null 2>&1; then + PACKAGE_MANAGER="spack" + elif command -v conda >/dev/null 2>&1; then + PACKAGE_MANAGER="conda" + elif command -v apt >/dev/null 2>&1; then + PACKAGE_MANAGER="apt" + elif command -v apt-get >/dev/null 2>&1; then + PACKAGE_MANAGER="apt-get" + else + echo "Unsupported package manager" >&2 + exit 1 + fi +fi + +# Install packages +echo 'Installing dependencies...' +case "$PACKAGE_MANAGER" in + apt) $SUDO apt install libgc-dev libunistring-dev binutils libgmp-dev ;; + apt-get) $SUDO apt-get install libgc-dev libunistring-dev binutils libgmp-dev ;; + dnf) $SUDO dnf install gc-devel libunistring-devel binutils gmp-devel ;; + pacman) $SUDO pacman -S gc libunistring binutils gmp ;; + yay|paru) $PACKAGE_MANAGER -S gc libunistring binutils gmp ;; + xbps) $SUDO xbps-install -S gc libunistring binutils gmp ;; + pkg_add) $SUDO pkg_add boehm-gc libunistring binutils gmp ;; + freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils gmp ;; + brew) brew install bdw-gc libunistring binutils llvm gmp ;; + macports) $SUDO port install boehm-gc libunistring binutils gmp ;; + zypper) $SUDO zypper install gc-devel libunistring-devel binutils gmp-devel ;; + nix) nix-env -iA nixpkgs.boehmgc.dev nixpkgs.libunistring nixpkgs.binutils nixpkgs.nixpkgs.gmp ;; + spack) spack install boehm-gc libunistring binutils gmp ;; + conda) conda install boehm-gc libunistring binutils gmp ;; + *) + echo "Unknown package manager: $PACKAGE_MANAGER" >&2 + exit 1 + ;; +esac + +# Choose installation location +default_prefix='/usr/local' +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 +if [ -z "$DEST" ]; then DEST="$default_prefix"; fi +DEST="${DEST/#\~/$HOME}" + +# Install +if ! [ -w "$DEST" ]; then + USER="$(ls -ld "$DEST" | awk '{print $$3}')" + $(SUDO) -u "$USER" tar -xzf "$FILE" -C "$DEST" --strip-components=1 "tomo@$TAG" +else + tar -xzf "$FILE" -C "$DEST" --strip-components=1 "tomo@$TAG" +fi +echo "Installed to $DEST" diff --git a/src/tomo.c b/src/tomo.c index f829951c..1517259e 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -14,7 +14,6 @@ #endif #include "ast.h" -#include "changes.md.h" #include "compile/cli.h" #include "compile/files.h" #include "compile/headers.h" @@ -77,7 +76,7 @@ static const char *paths_str(List_t paths) { #endif static OptionalBool_t verbose = false, quiet = false, show_version = false, show_prefix = false, clean_build = false, - source_mapping = true, show_changelog = false, should_install = false; + source_mapping = true, should_install = false; static List_t format_files = EMPTY_LIST, format_files_inplace = EMPTY_LIST, parse_files = EMPTY_LIST, transpile_files = EMPTY_LIST, compile_objects = EMPTY_LIST, compile_executables = EMPTY_LIST, @@ -244,7 +243,6 @@ int main(int argc, char *argv[]) { {"optimization", &optimization, &Text$info, .short_flag = 'O'}, // {"force-rebuild", &clean_build, &Bool$info, .short_flag = 'f'}, // {"source-mapping", &source_mapping, &Bool$info, .short_flag = 'm'}, - {"changelog", &show_changelog, &Bool$info}, // }; tomo_parse_args(argc, argv, usage, help, TOMO_VERSION, sizeof(tomo_args) / sizeof(tomo_args[0]), tomo_args); @@ -253,11 +251,6 @@ int main(int argc, char *argv[]) { return 0; } - if (show_changelog) { - print_inline(string_slice((const char *)CHANGES_md, (size_t)CHANGES_md_len)); - return 0; - } - if (show_version) { if (verbose) print(TOMO_VERSION, " ", GIT_VERSION); else print(TOMO_VERSION); -- cgit v1.2.3