commit dcf8ba15fe807b2ff1150a2374c60627678dbea6
parent fa26fe68a5611827db1ce0c2ff791ab70667c778
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date: Sat, 14 Mar 2026 22:58:16 +0100
JPM support and nftw
Diffstat:
10 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1 +1,2 @@
-instowl
+instowl.log
+build/
diff --git a/Makefile b/Makefile
@@ -1,11 +0,0 @@
-PREFIX?=/usr/local
-DESTDIR?=/
-
-instowl: instowl.janet
- sed 's@\./src/@instowl/@' $< > $@
-
-.PHONY:
-install: instowl $(wildcard src/*)
- install -D -m 755 -T instowl $(DESTDIR)/$(PREFIX)/bin/instowl
- install -D -m 644 -t $(DESTDIR)/$(PREFIX)/lib/janet/instowl $(wordlist 2,$(words $^),$^)
-
diff --git a/compile_flags.txt b/compile_flags.txt
@@ -1 +1 @@
--I/home/shyman/.local/include
+-I/home/szymon/.local/include/
diff --git a/instowl b/instowl
@@ -0,0 +1,6 @@
+#!/usr/bin/env janet
+
+(import instowl/main)
+
+(defn main [& args]
+ (main/main ;args))
diff --git a/instowl.janet b/instowl.local
diff --git a/project.janet b/project.janet
@@ -1,5 +1,18 @@
-(declare-project :name "nftw")
+(declare-project
+ :name "instowl")
+
+(declare-binscript
+ :main "instowl"
+ :is-janet true)
(declare-native
- :name "nftw"
+ :name "instowl/native/nftw"
:source ["src/native/nftw.c"])
+
+(declare-source
+ :prefix "instowl"
+ :source ["src/file.janet"
+ "src/main.janet"
+ "src/libc.janet"
+ "src/tools.janet"
+ "src/utils.janet"])
diff --git a/src/file.janet b/src/file.janet
@@ -1,4 +1,5 @@
(import ./libc)
+(import ./native/nftw)
(defn file-exists? [path]
(= (os/stat path :mode) :file))
@@ -13,6 +14,13 @@
(mkdirp (libc/dirname dst))
(os/rename src dst))
+(defn rmrf [path]
+ (nftw/nftw path (fn [file stat ftype info]
+ (if (= ftype :dp)
+ (os/rmdir file)
+ (os/rm file))
+ 0) 1024 :depth :phys))
+
(defn which [exec]
(var ret nil)
(if (or (string/has-prefix? "/" exec) (string/has-prefix? "./" exec))
diff --git a/src/main.janet b/src/main.janet
@@ -93,7 +93,7 @@
(var prefix target)
(var builddir ".")
- (sh/rm "./instowl.log")
+ (os/rm "./instowl.log")
(while (not= state :exit)
(def logfile (file/open "./instowl.log" :a))
@@ -108,6 +108,7 @@
(file/file-exists? "Cargo.toml") (set state :build/cargo)
(file/file-exists? "pyproject.toml") (set state :build/pep517)
(file/file-exists? "setup.py") (set state :build/setuptools)
+ (file/file-exists? "project.janet") (set state :build/jpm)
(utils/some? (libc/glob "*.pro")) (set state :conf/qmake)
(file/file-exists? "CMakeLists.txt") (set state :conf/cmake)
(file/file-exists? "configure.ac") (set state :conf/autotools)
@@ -157,6 +158,9 @@
:build/ninja
(checkrun :install/ninja :ninja "-C" builddir)
+ :build/jpm
+ (checkrun :install/jpm :jpm "build")
+
:install/make
(checkrun :move
:make
@@ -176,6 +180,16 @@
(checkrun :install/go :go "install" "-v")
(checkrun :move :go "clean" "-modcache"))
+ :install/jpm
+ (checkrun :move
+ :jpm
+ (stropt "--dest-dir" destdir)
+ (stropt "--binpath" (path/join prefix "bin"))
+ (stropt "--manpath" (path/join prefix "man"))
+ (stropt "--modpath" (path/join prefix "lib" "janet"))
+ (stropt "--libpath" (path/join prefix "lib"))
+ "install")
+
:install/cargo
(do
(set prefix "")
@@ -191,6 +205,7 @@
:install/setuptools
(checkrun :post/python :python "setup.py" "install" (stropt "--root" destdir) (stropt "--prefix" prefix))
+
:post/python
(do
(if (file/dir-exists? (path/join destdir prefix "local")) (set prefix (path/join target "local")))
@@ -211,7 +226,7 @@
(errexit "The destination directory doesn't contain the prefix")))
:stow
- (checkrun :done :stow "-v" "-d" stowdir "-t" target pkg)
+ (checkrun :done :stow "-v" "-d" stowdir "-t" target "--override=.*" pkg)
:error
(do
@@ -225,5 +240,5 @@
:cleanup
(do
- (sh/rm (string/join [destdir]))
+ (file/rmrf (string/join [destdir]))
(set state :exit))))))
diff --git a/src/native/nftw.so b/src/native/nftw.so
@@ -0,0 +1 @@
+../../build/nftw.so
+\ No newline at end of file
diff --git a/src/tools.janet b/src/tools.janet
@@ -8,6 +8,7 @@
:qmake ["qmake" "qmake6"]
:configure ["./configure"]
:autoreconf ["autoreconf"]
+ :jpm ["jpm"]
:go ["go"]
:python ["python" "python3"]
:cargo ["cargo"]