anki/cargo/README.md

61 lines
2.1 KiB
Markdown
Raw Normal View History

2020-11-03 00:03:00 +01:00
This folder integrates Rust crates.io fetching into Bazel.
V3 parent limits (#1638) * avoid repinning Rust deps by default * add id_tree dependency * Respect intermediate child limits in v3 * Test new behaviour of v3 counts * Rework v3 queue building to respect parent limits * Add missing did field to SQL query * Fix `LimitTreeMap::is_exhausted()` * Rework tree building logic https://github.com/ankitects/anki/pull/1638#discussion_r798328734 * Add timer for build_queues() * `is_exhausted()` -> `limit_reached()` * Move context and limits into `QueueBuilder` This allows for moving more logic into QueueBuilder, so less passing around of arguments. Unfortunately, some tests will require additional work to set up. * Fix stop condition in new_cards_by_position * Fix order gather order of new cards by deck * Add scheduler/queue/builder/burying.rs * Fix bad tree due to unsorted child decks * Fix comment * Fix `cap_new_to_review_rec()` * Add test for new card gathering * Always sort `child_decks()` * Fix deck removal in `cap_new_to_review_rec()` * Fix sibling ordering in new card gathering * Remove limits for deck total count with children * Add random gather order * Remove bad sibling order handling All routines ensure ascending order now. Also do some other minor refactoring. * Remove queue truncating All routines stop now as soon as the root limit is reached. * Move deck fetching into `QueueBuilder::new()` * Rework new card gather and sort options https://github.com/ankitects/anki/pull/1638#issuecomment-1032173013 * Disable new sort order choices ... depending on set gather order. * Use enum instead of numbers * Ensure valid sort order setting * Update new gather and sort order tooltips * Warn about random insertion order with v3 * Revert "Add timer for build_queues()" This reverts commit c9f5fc6ebe87953c17a0c842990b009b5596c69c. * Update rslib/src/storage/card/mod.rs (dae) * minor wording tweaks to the tooltips (dae) + move legacy strings to bottom + consistent capitalization (our leech action still needs fixing, but that will require introducing a new 'suspend card' string as the existing one is used elsewhere as well)
2022-02-10 00:55:43 +01:00
To add or update dependencies, ensure a local Rust environment is available
updates to the build process and binary bundles All platforms: - rename scripts/ to tools/: Bazelisk expects to find its wrapper script (used by the Mac changes below) in tools/. Rather than have a separate scripts/ and tools/, it's simpler to just move everything into tools/. - wheel outputs and binary bundles now go into .bazel/out/dist. While not technically Bazel build products, doing it this way ensures they get cleaned up when 'bazel clean' is run, and it keeps them out of the source folder. - update to the latest Bazel Windows changes: - bazel.bat has been removed, and tools\setup-env.bat has been added. Other scripts like .\run.bat will automatically call it to set up the environment. - because Bazel is now on the path, you can 'bazel test ...' from any folder, instead of having to do \anki\bazel. - the bat files can handle being called from any working directory, so things like running "\anki\tools\python" from c:\ will work. - build installer as part of bundling process Mac changes: - `arch -arch x86_64 bazel ...` will now automatically use a different build root, so that it is cheap to switch back and forth between archs on a new Mac. - tools/run-qt* will now automatically use Rosetta - disable jemalloc in Mac x86 build for now, as it won't build under Rosetta (perhaps due to its build scripts using $host_cpu instead of $target_cpu) - create app bundle as part of bundling process Linux changes: - remove arm64 orjson workaround in Linux bundle, as without a readily-available, relatively distro-agonstic PyQt/Qt build we can use, the arm64 Linux bundle is of very limited usefulness. - update Docker files for release build - include fcitx5 in both the qt5 and qt6 bundles - create tarballs as part of the bundling process
2022-01-30 01:50:14 +01:00
(eg `source tools/cargo-env`), then install cargo-raze:
2020-12-18 02:56:56 +01:00
```
cargo install cargo-raze --version 0.14.1
2021-03-27 05:56:51 +01:00
cargo install cargo-license
2020-12-18 02:56:56 +01:00
```
V3 parent limits (#1638) * avoid repinning Rust deps by default * add id_tree dependency * Respect intermediate child limits in v3 * Test new behaviour of v3 counts * Rework v3 queue building to respect parent limits * Add missing did field to SQL query * Fix `LimitTreeMap::is_exhausted()` * Rework tree building logic https://github.com/ankitects/anki/pull/1638#discussion_r798328734 * Add timer for build_queues() * `is_exhausted()` -> `limit_reached()` * Move context and limits into `QueueBuilder` This allows for moving more logic into QueueBuilder, so less passing around of arguments. Unfortunately, some tests will require additional work to set up. * Fix stop condition in new_cards_by_position * Fix order gather order of new cards by deck * Add scheduler/queue/builder/burying.rs * Fix bad tree due to unsorted child decks * Fix comment * Fix `cap_new_to_review_rec()` * Add test for new card gathering * Always sort `child_decks()` * Fix deck removal in `cap_new_to_review_rec()` * Fix sibling ordering in new card gathering * Remove limits for deck total count with children * Add random gather order * Remove bad sibling order handling All routines ensure ascending order now. Also do some other minor refactoring. * Remove queue truncating All routines stop now as soon as the root limit is reached. * Move deck fetching into `QueueBuilder::new()` * Rework new card gather and sort options https://github.com/ankitects/anki/pull/1638#issuecomment-1032173013 * Disable new sort order choices ... depending on set gather order. * Use enum instead of numbers * Ensure valid sort order setting * Update new gather and sort order tooltips * Warn about random insertion order with v3 * Revert "Add timer for build_queues()" This reverts commit c9f5fc6ebe87953c17a0c842990b009b5596c69c. * Update rslib/src/storage/card/mod.rs (dae) * minor wording tweaks to the tooltips (dae) + move legacy strings to bottom + consistent capitalization (our leech action still needs fixing, but that will require introducing a new 'suspend card' string as the existing one is used elsewhere as well)
2022-02-10 00:55:43 +01:00
After adding/updating dependencies in ../rslib/Cargo.toml, change to this
folder and run:
$ python update.py
or
$ REPIN=1 python update.py
The former will apply added crates and adjusted version numbers, while leaving
most crate versions alone. The latter will also update pinned dependencies to their
latest compatible versions.
2020-11-03 00:03:00 +01:00
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.
2020-11-03 00:03:00 +01:00
A couple of crates need extra work to build with Bazel, and are listed
2020-11-24 09:41:03 +01:00
in ../Cargo.toml. For example:
2020-11-03 00:03:00 +01:00
```toml
2020-11-24 09:41:03 +01:00
[package.metadata.raze.crates.pyo3.'*']
2020-12-15 11:28:10 +01:00
compile_data_attr = "glob([\"**\"])"
2020-11-03 00:03:00 +01:00
```
With minor version updates, you should not normally need to modify
the entries in that file.
2021-03-15 04:29:36 +01:00
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.