diff --git a/changes/native-notices.md b/changes/native-notices.md new file mode 100644 index 00000000..979f6ca5 --- /dev/null +++ b/changes/native-notices.md @@ -0,0 +1,6 @@ +bump: patch +type: feat +**A native library's licence ships with it.** `ludic bundle` copies each linked package's +`native/LICENSE*` files beside the `.exe` on Windows and into `Contents/Resources` on macOS, so +Jolt Physics' MIT notice travels with every copy of the game. `tools/native/lib.sh` passes lld-link +`-implib`, which Git Bash leaves alone (it rewrote `/implib:` into a Windows path). diff --git a/tools/ludic-cli/bundle.ludic b/tools/ludic-cli/bundle.ludic index 4d19854c..1591e630 100644 --- a/tools/ludic-cli/bundle.ludic +++ b/tools/ludic-cli/bundle.ludic @@ -283,10 +283,29 @@ function bundle_natives_mac(contents: pointer, exe: pointer) -> bool { err(`ludic bundle: could not place {g_built_natives[i]}\n`) return false } + bundle_native_notices(g_built_natives[i], `{contents}/Resources`) } return true } +# a path with every backslash made a slash (a Windows path from the compiler) +function fwd_path(p: pointer) -> pointer { + var out = "" + var i = 0 + while p[i] != 0 { + if p[i] == 92 { out = out + "/" } else { out = out + p[i..i + 1] } + i += 1 + } + return out +} + +# a native library's licence goes with every copy of it: the package's native/LICENSE* files, +# found from the library's own path (/lib//) +function bundle_native_notices(lib: pointer, dest: pointer) -> void { + let pkg = dir_of_path(dir_of_path(dir_of_path(fwd_path(lib)))) + shell(`cp "{pkg}"/native/LICENSE* "{dest}/" 2>/dev/null`) +} + # copy the .dll files ludicc wrote into .natives beside the executable function bundle_natives_win(list: pointer, root: pointer) -> bool { let txt = read_file(list) @@ -297,6 +316,7 @@ function bundle_natives_win(list: pointer, root: pointer) -> bool { err(`ludic bundle: could not place {libs[i]}\n`) return false } + if libs[i] != "" { bundle_native_notices(fwd_path(libs[i]), root) } } return true }