Fork me on GitHub
#babashka
<
2022-06-15
>
teodorlu07:06:23

One thing I like about Makefiles is that I can declare dependencies between tasks. This generally speeds things up task running. It also enables a more subtle advantage. When make decides that no actions are needed, no files are touched. This makes it possible to run make with a file watcher that watches the whole directory tree. For example watchexec make or rg --files | entr make. If I were to convert https://github.com/teodorlu/playground.teod.eu/blob/master/Makefile to a bb.edn, and run watchexec bb run make, I would be running updates all the time, because each call to bb run make would recreate files on each call, which would (in turn) trigger a rerun of the make script. So I would be running the make task all the time - not just when something has changed. Then I might as well run watch -n 0.001 bb run make. Which I would prefer not to. Has "add dependency tracking to bb.edn tasks" been discussed before? (I couldn't find any issues).

borkdude07:06:53

@U3X7174KS Eeeeh, bb.edn supports dependencies between tasks :)

teodorlu07:06:24

let me read some docs.

teodorlu07:06:10

How do I declare which files depend on which? For instance, in this makefile line:

feedback-loops-api-design-how-it-works/index.html: feedback-loops-api-design-how-it-works/index.org
	pandoc -s --toc --from=org+smart -i feedback-loops-api-design-how-it-works/index.org -o feedback-loops-api-design-how-it-works/index.html
I say that in order to produce feedback-loops-api-design-how-it-works/index.html, one must run
pandoc -s --toc --from=org+smart -i feedback-loops-api-design-how-it-works/index.org -o feedback-loops-api-design-how-it-works/index.html
, which should be re-run any time
feedback-loops-api-design-how-it-works/index.org
is changed.

borkdude07:06:51

You use fs/modified-since for this. I have a blog post about it (will send link later once I'm at kbd)

teodorlu07:06:20

You've already written a blog post about this, perfect 😁 Thanks!

teodorlu07:06:33

If I'm reading your post right, you might be aiming for something more flexible. Avoiding huge makefiles that need to be generated (like with cmake). Interesting.

teodorlu07:06:44

Specifically - my usecase was wanting to run watchexec bb run tests in the Neil repo, which resulted in ./neil being regenerated on each run (bb gen-script), which triggered a rerun.

borkdude07:06:47

Right. There's also the fswatcher pod you can use for this btw

teodorlu07:06:09

more to read up on 😄

teodorlu07:06:55

(and i do reallly want to use Clojure + EDN for this rather than bash + makefile dependencies)

craftybones13:06:08

If I want to process some jpeg files in babashka, what are my options? I don't have javax.imageio

craftybones13:06:52

Ideally all I want to do is read them and process them raw as byte buffers.

craftybones13:06:24

(ImageIO/read "foo.jpeg") is all I need.

craftybones13:06:35

After that, I anyway only operate with the raw bytes.

borkdude13:06:01

OK, and this returns a BufferedImage and what are you going to do with that?

borkdude13:06:25

If you want bytes you can use fs/read-all-bytes

craftybones16:06:59

I'm not reading the raw bytes of the file, I am reading the raw bytes of the pixels from the jpeg. I'm using the bytes from the BufferedImage to find the brightest pixels on the image

craftybones16:06:30

Thanks anyway. I can afford to use clj for the project anyway, so I might just stick to clj for this