instow

:)
git clone https://git.sr.ht/~ashymad/instow
Log | Files | Refs | LICENSE

commit ac3e709b945dbbb24370d8398359caf222b10dfa
parent 954a0505c9933ea2304aa186bbd1fcc41aabcfad
Author: Ashymad <szymon.mikulicz@posteo.net>
Date:   Sat, 28 Feb 2026 16:04:38 +0100

qmake and term width

Diffstat:
Msrc/libc.janet | 23+++++++++++++++++++++++
Msrc/main.janet | 16+++++++++++++---
Msrc/tools.janet | 1+
3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/libc.janet b/src/libc.janet @@ -16,6 +16,29 @@ (defmacro defbind/str [name] ~(def ,name (bind/str ,(string/join [name])))) +(def c/glob :private (bind "glob" :int :string :int :ptr :ptr)) +(def c/globfree :private (bind "globfree" :void :ptr)) +(def c/glob_t :private (ffi/struct :size :ptr :size)) + +(defn glob [pattern] + (def globbed (ffi/write c/glob_t [0 nil 0])) + (if (= 0 (c/glob pattern 0 nil globbed)) + (let [returned (ffi/read c/glob_t globbed) + globlen (int/to-number (returned 0)) + paths (ffi/read @[:string globlen] (returned 1))] + (c/globfree globbed) + paths))) + +(def c/ioctl :private (bind "ioctl" :int :int :ulong :ptr)) +(def c/winsize :private (ffi/struct :short :short :short :short)) + +(defn ioctl [fd op] + (case op + :TIOCGWINSZ + (let [winsize (ffi/write c/winsize [0 0 0 0])] + (c/ioctl fd 21523 winsize) + (ffi/read c/winsize winsize)))) + (defbind get_nprocs :int) (defbind/str dirname) (defbind/str basename) diff --git a/src/main.janet b/src/main.janet @@ -3,6 +3,8 @@ (import ./file) (import ./tools) +(def columns ((libc/ioctl 1 :TIOCGWINSZ) 1)) + (def spinner "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏") (var ch (string/slice spinner 0 3)) @@ -14,7 +16,8 @@ (defn msg [state line logfile] (file/write logfile line "\n") - (prinf "\x1b[2K{%s}⸉%s⸊→%s\r" state ch (string/slice line 0 (min 80 (length line)))) + (def pre (string/format "\x1b[2K{%s}⸉%s⸊→" state ch)) + (prinf "%s%s\r" pre (string/slice line 0 (min (- columns (length pre)) (length line)))) (flush)) (defn prinfer [state logfile pipe] @@ -94,6 +97,7 @@ (cond (file/file-exists? "go.mod") (set state :build/go) (file/file-exists? "Cargo.toml") (set state :build/cargo) + (not (nil? (libc/glob "*.pro"))) (set state :conf/qmake) (file/file-exists? "configure") (set state :conf/configure) (file/file-exists? "configure.ac") (set state :conf/autotools) (file/file-exists? "Makefile") (set state :build/make) @@ -105,8 +109,13 @@ :conf/configure (checkrun :build/make :configure (string/join ["--prefix=" prefix])) + :conf/qmake + (do + (set prefix "/usr/local") + (checkrun :build/make :qmake)) + :build/make - (checkrun :install/make :make (string/format "-j%d" (libc/get_nprocs))) + (checkrun :install/make :make "CC=gcc" (string/format "-j%d" (libc/get_nprocs))) :build/go (checkrun :install/go :go "build" "-v") @@ -119,7 +128,8 @@ :make "install" (string/join ["DESTDIR=" destdir]) - (string/join ["PREFIX=" prefix])) + (string/join ["PREFIX=" prefix]) + (string/join ["INSTALL_ROOT=" destdir])) :install/go (do diff --git a/src/tools.janet b/src/tools.janet @@ -3,6 +3,7 @@ (defn toolpath [tool] (case tool :make ["make" "gmake"] + :qmake ["qmake" "qmake6"] :configure ["./configure"] :autoreconf ["autoreconf"] :go ["go"]