This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-22
Channels
- # announcements (13)
- # babashka (22)
- # beginners (22)
- # biff (17)
- # calva (6)
- # clerk (20)
- # clj-kondo (25)
- # clj-together (5)
- # clj-yaml (20)
- # cljdoc (16)
- # cljs-dev (1)
- # clojure (42)
- # clojure-brasil (1)
- # clojure-europe (26)
- # clojure-nl (6)
- # clojure-norway (24)
- # clojure-turkiye (3)
- # clojure-uk (5)
- # clojurescript (37)
- # core-async (7)
- # core-logic (2)
- # datalevin (7)
- # datomic (43)
- # events (2)
- # fulcro (7)
- # gratitude (1)
- # hyperfiddle (7)
- # java (7)
- # jobs (3)
- # lsp (4)
- # off-topic (16)
- # pathom (18)
- # polylith (1)
- # portal (27)
- # reitit (4)
- # releases (3)
- # shadow-cljs (47)
- # tools-build (14)
- # tools-deps (16)
- # yamlscript (11)
Curious if anyone has a Makefile shim laying around that sneakily installs babashka and forwards other make
invocations to the bb
task runner? Basically I'd like to have a Makefile in my repo and a disclaimer that it installs this tool called babashka, but without making users actually install it themselves. Then I want them to be able to call e.g. make build
and have it use bb build
.
I know, I know: this is dimb because babashka is easy to set up, and make
is doing nothing in my scenario. But in practice, I feel like having the install fully automated and exposing functionality via make
reduces the friction for people to accept it. And I really do not want to write Makefiles lol.
This works more or less:
$ cat Makefile
$(shell exec bb </dev/tty 2>&1 >/dev/tty)
$ make
user=> (println "Hello!")
Hello!
nil
user=>

This is even better if you assume bash
and rlwrap
:
$ cat Makefile
SHELL := bash
$(shell exec rlwrap bb </dev/tty &>/dev/tty)
$ make
Babashka v1.3.182 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (println "hi")
(println "hi")
hi
nil
user=>
That's not what you asked but I'm ok with make
.
I'll give it a go.
nice! any idea for a cross-platform way to install bb from the makefile? so that make install
or whatever does it for you
ok this seems to be a start to what you want:
$ cat Makefile
SHELL := bash
%:
@[[ -n $$(command -v bb) ]] || command-to-install-bb
@bb $(MAKECMDGOALS)
$ make version
babashka v1.3.182
$
You'll want to check if make
is GNU make, and you can inline all the code you want to install bb
. You do without bash
if you want but I just think in bash so...
Let me know if you need help and if you get something working I'd be happy to review it for you.
Here's on without Bash:
$ cat Makefile
%:
@command -v bb >/dev/null || { command-to-install-bb; }
@bb $(MAKECMDGOALS)
$ make version
babashka v1.3.182
$
you can put mutliple commands inside { ... }
(separated by semis).
MAKECMDGOALS
might be GNU make specific, but lots of systems depend on GNU make and it's by far the most common.Here's another more sane Makefile from a project of mine that proxies several of its targets to lein
: https://github.com/yaml/yamlscript/blob/clojure/clojure/Makefile
FWIW I will always put a Makefile in front of my tooling for any project in any language(s), even in environments where that's not the norm. I think it's a great idea!
And a shameless plug for a little something I once wrote that lets you define GNU make target dependencies functionally instead of only file stamp based, called MakePlus: https://makeplus.net/
New bb release! https://clojurians.slack.com/archives/C06MAR553/p1692707318477779
LOL. it runs on cron schedule: 15 */3 * * *
Or when I trigger manually, like right now! Enjoy new update.