anki/cargo
RumovZ 0efa3f944f
Garbage collect unused Fluent strings (#1482)
* Canonify import of i18n module

Should always be imported as `tr`, or `tr2` if there is a name collision
(Svelte).

* Add helper for garbage collecting ftl strings

Also add a serializer for ftl asts.

* Add helper for filter-mapping `DirEntry`s

* Fix `i18n_helpers/BUILD.bazel`

* run cargo-raze

* Refactor `garbage_collection.rs`

- Improve helper for file iterating
- Remove unused terms as well
- Fix issue with checking for nested messages by switching to a regex-
based approach (which runs before deleting)
- Some more refactorings and lint fixes

* Fix lints in `serialize.rs`

* Write json pretty and sorted

* Update `serialize.rs` and fix header

* Fix doc and remove `dbg!`

* Add binaries for ftl garbage collection

Also relax type constraints and strip debug tests.

* add rust_binary targets for i18n helpers (dae)

* add scripts to update desktop usage/garbage collect (dae)

Since we've already diverged from 2.1.49, we won't gain anything
from generating a stable json just yet. But once 2.1.50 is released,
we should run 'ftl/update-desktop-usage.sh stable'.

* add keys from AnkiMobile (dae)

* Mention caveats in `remove-unused.sh`
2021-11-12 18:19:01 +10:00
..
remote Garbage collect unused Fluent strings (#1482) 2021-11-12 18:19:01 +10:00
BUILD.bazel Garbage collect unused Fluent strings (#1482) 2021-11-12 18:19:01 +10:00
BUILD.reqwest.native.bazel update Rust deps with cargo-raze 0.13.0 2021-10-26 08:16:40 +10:00
BUILD.reqwest.rustls.bazel update Rust deps with cargo-raze 0.13.0 2021-10-26 08:16:40 +10:00
BUILD.term-0.7.0.bazel update Rust deps 2021-10-02 20:42:03 +10:00
crates.bzl Garbage collect unused Fluent strings (#1482) 2021-11-12 18:19:01 +10:00
licenses.json update Rust deps with cargo-raze 0.13.0 2021-10-26 08:16:40 +10:00
README.md Fix invalid path in cargo-env.bat (#1477) 2021-11-05 11:08:23 +10:00
update.py update Rust deps 2021-10-02 20:42:03 +10:00

This folder integrates Rust crates.io fetching into Bazel.

To update dependencies, ensure a local Rust environment is available (eg source scripts/cargo-env), then install cargo-raze:

cargo install cargo-raze --version 0.13.0
cargo install cargo-license

After updating dependencies in ../rslib/Cargo.toml, change to this folder and run python update.py to update the external Bazel repositories to point to the updated deps.

Note: cargo-raze does not currently work when run from Windows, and nobody has investigated why yet. For now, you'll need a Mac or Linux machine, or will need to run update.py from within WSL.

A couple of crates need extra work to build with Bazel, and are listed in ../Cargo.toml. For example:

[package.metadata.raze.crates.pyo3.'*']
compile_data_attr = "glob([\"**\"])"

With minor version updates, you should not normally need to modify the entries in that file.

Because update.py modifies a lot of files in remote/, it makes it difficult to review in a PR, and the changes can sometimes break platforms like Windows. For this reason, please don't submit PRs that do minor version bumps - those will typically be done after stable releases. If you need a new crate for a feature you're working on, please raise it in an issue first.

Reqwest

Things are complicated with reqwest at the moment, because:

  • we're using a fork to implement better timeouts for syncing
  • we want to build it with different features on Linux (where we can't build a wheel that links to OpenSSL), and on other platforms.

For minor version bumps, update.py should take care of updating the versions of reqwest dependencies.

After making a big update to reqwest via an updated fork, the vendored BUILD.reqwest.* files may need updating. To do that, comment native-tls from the features in rslib/Cargo.toml and run update.py, and copy the file in remote/ over the old vendored file. Then comment the other two deps out, add native-tls back, and repeat the process.