Fork me on GitHub
#babashka
<
2023-11-08
>
Nathan Smith17:11:44

Is there a way to package up bb and my project into a single binary I can ship?

Bob B17:11:44

just to be clear, note that these aren't not OS-agnostic, e.g. shipping a mac binary and codebase to a windows machine won't work

borkdude17:11:46

With the uberjar approach you can build binaries for any OS on any OS though

💡 1
Nathan Smith17:11:15

Great thanks! That’s the page I was looking for.

Ingy döt Net18:11:07

cat ./bb uber.jar > my-binary
looks crazy! How does that even work?

borkdude18:11:47

magic ™️

🧙 1
borkdude18:11:17

it works by virtue of two things: 1. executables can have arbitrary blobs attached to them 2. zip files can have arbitrary blobs in front of them

Ingy döt Net18:11:34

I need that magic to "compile" ys... Do you have a link to the place in your code that unpacks this and makes it work?

borkdude18:11:46

bb doesn't unpack anything. the logic is: 1. if the invoked executable doesn't have the name bb 2. it checks if the invoked executable is a valid zip file 3. if so, then bb treats the invoked executable as an uberjar, as if you would have written: bb uberjar.jar

Ingy döt Net18:11:51

Where did you learn that trick?

Ingy döt Net18:11:36

I'm surprised that executables can have arbitrary blobs attached to them works on all OSes

borkdude18:11:18

somebody I had lunch with told me

Ingy döt Net18:11:12

well nice work putting it to good use in bb!

🙏 1
Ingy döt Net18:11:28

> With the uberjar approach you can build binaries for any OS on any OS though I assume you mean any OS that can run bb which is just the ones with graalvm support, right?

borkdude18:11:55

any OS that bb was compiled for, obviously