Repository navigation
fix: ship the licences of the Rust libraries inside MemoryStick - #12
Merged
Merged
Conversation
build.rs collects the licence texts of every crate linked into the executable for the target being built, from cargo metadata run locked and offline, and embeds them. Preferences > About shows them under Third-party licences.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MIT, BSD, Apache-2.0, ISC and similar licences require a binary distribution to carry their notices. The executable statically links about 320 Rust crates, and until now only
Cargo.lockwas pointed at.What changes
src-tauri/build.rsruns$CARGO metadata --format-version 1 --locked --offline --filter-platform $TARGET, follows the normal dependencies reachable frommemorystick(build and dev dependencies are not linked in), and reads each crate'sLICENSE*,LICENCE*,UNLICENSE*,COPYING*,COPYRIGHT*andNOTICE*files plus any declaredlicense-file. Texts that differ only in whitespace are kept once, under the sortedname@version (SPDX)list of crates that ship them. Crates with no licence file are listed at the end with their SPDX expression. The result goes to$OUT_DIR/rust-licenses.txt. No new dependency:serde_jsonwas already in the lockfile.src/licenses.rsembeds that file and exposes it through a newthird_party_licensescommand, declared inbuild.rsand allowed incapabilities/default.json(allow-third-party-licenses).pre. New stringspreferences_third_partyandpreferences_third_party_descin English and French (the existing parity test covers them).docs/third-party-notices.mdreplaces theCargo.locksentence with how the notices travel in the binary; the README licence section mentions them.Offline behaviour
--offlinemeans the build script never reaches the network: it only reads packages Cargo already downloaded to build them. With--filter-platform,cargo metadataneeds exactly the target and host packages the build itself fetched. Verified locally on Linux (no lock contention with the outer build); this PR's CI exercises Windows, macOS and the MSRV toolchain.Binary size
The embedded text for
x86_64-unknown-linux-gnuis 536,217 bytes (168 distinct licence texts for 322 crates; whitespace-only duplicates of the Apache-2.0 text are merged). It is stored uncompressed, so the release binary grows by about 536 KB, about 4.5% of v0.1.1'smemorystick-linux(11,899,808 bytes). Windows and macOS link a different set of crates, so their text and delta differ slightly.Tests
licenses::tests::names_the_libraries_memorystick_is_built_on: the generated text is non-empty and liststauri,comrakandserde.cargo test --lockedpasses locally (9 tests).