sodium-friends / sodium-native

Low level bindings for libsodium
MIT License
300 stars 64 forks source link

Move to static build #151

Closed mafintosh closed 2 years ago

mafintosh commented 2 years ago

This greatly simplifies the build process by moving to building a static library rather than the dynamic lib that the bindings link against.

For context, we originally needed the dynamic lib because we needed a build PER Node.js abi, so the shared lib reduced the size substantially. Now that we are only using a single n-api build, it doesn't really add anything other than complexity.

Additionally this means we can use the official windows prebuild from libsodium itself on windows and super easily support more platforms like alpine by including a musl tagged build.

The deps/index.js script handles fetching libsodium, on demand or statically, and building it if needed. This means that all the building is now triggered from gyp directly, when it shells out to print the different flags. Note that this makes the gyp step take longer with no output compared to before as it is building sodium in the background if it hasn't before.

This step can be "prewarmed" by simply running ./deps/index.js first when forwards all outputs.

mafintosh commented 2 years ago

Fixes https://github.com/sodium-friends/sodium-native/issues/111