d55f080733
* 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)
170 lines
4.4 KiB
Python
170 lines
4.4 KiB
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
|
|
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
|
|
load(":rustfmt.bzl", "rustfmt_fix", "rustfmt_test")
|
|
load("//ts/sql_format:defs.bzl", "sql_format")
|
|
|
|
# Build script
|
|
#######################
|
|
|
|
cargo_build_script(
|
|
name = "build_script",
|
|
srcs = glob(["build/*.rs"]),
|
|
build_script_env = {
|
|
"PROTO_TOP": "$(location //proto:.top_level)",
|
|
"PROTOC": "$(location @com_google_protobuf//:protoc)",
|
|
"RSLIB_FTL_ROOT": "$(location @rslib_ftl//:l10n.toml)",
|
|
"EXTRA_FTL_ROOT": "$(location @extra_ftl//:l10n.toml)",
|
|
"BAZEL": "1",
|
|
},
|
|
crate_root = "build/main.rs",
|
|
data = [
|
|
"//ftl",
|
|
"//proto",
|
|
"@com_google_protobuf//:protoc",
|
|
# bazel requires us to list these out separately
|
|
"//proto:.top_level",
|
|
"@rslib_ftl//:l10n.toml",
|
|
"@extra_ftl//:l10n.toml",
|
|
],
|
|
deps = [
|
|
"//rslib/cargo:prost_build",
|
|
],
|
|
)
|
|
|
|
# Library
|
|
#######################
|
|
|
|
_anki_compile_data = glob([
|
|
"src/**/*.sql",
|
|
"src/**/*.html",
|
|
"src/**/*.css",
|
|
"src/**/*.tex",
|
|
]) + [
|
|
"Cargo.toml", # prevents a warning about num_enum
|
|
"//:buildinfo.txt",
|
|
]
|
|
|
|
_anki_features = [
|
|
"translations",
|
|
]
|
|
|
|
_anki_rustc_env = {
|
|
"BUILDINFO": "$(location //:buildinfo.txt)",
|
|
}
|
|
|
|
rust_library(
|
|
name = "anki",
|
|
srcs = glob([
|
|
"src/**/*.rs",
|
|
]),
|
|
compile_data = _anki_compile_data,
|
|
crate_features = _anki_features,
|
|
proc_macro_deps = [
|
|
"//rslib/cargo:async_trait",
|
|
"//rslib/cargo:serde_derive",
|
|
"//rslib/cargo:serde_repr",
|
|
],
|
|
rustc_env = _anki_rustc_env,
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":build_script",
|
|
"//rslib/cargo:ammonia",
|
|
"//rslib/cargo:blake3",
|
|
"//rslib/cargo:bytes",
|
|
"//rslib/cargo:chrono",
|
|
"//rslib/cargo:coarsetime",
|
|
"//rslib/cargo:flate2",
|
|
"//rslib/cargo:fluent",
|
|
"//rslib/cargo:fnv",
|
|
"//rslib/cargo:futures",
|
|
"//rslib/cargo:hex",
|
|
"//rslib/cargo:htmlescape",
|
|
"//rslib/cargo:id_tree",
|
|
"//rslib/cargo:intl_memoizer",
|
|
"//rslib/cargo:itertools",
|
|
"//rslib/cargo:lazy_static",
|
|
"//rslib/cargo:nom",
|
|
"//rslib/cargo:num_enum",
|
|
"//rslib/cargo:num_integer",
|
|
"//rslib/cargo:once_cell",
|
|
"//rslib/cargo:pin_project",
|
|
"//rslib/cargo:prost",
|
|
"//rslib/cargo:pulldown_cmark",
|
|
"//rslib/cargo:rand",
|
|
"//rslib/cargo:regex",
|
|
"//rslib/cargo:rusqlite",
|
|
"//rslib/cargo:scopeguard",
|
|
"//rslib/cargo:serde",
|
|
"//rslib/cargo:serde_aux",
|
|
"//rslib/cargo:serde_json",
|
|
"//rslib/cargo:serde_tuple",
|
|
"//rslib/cargo:sha1",
|
|
"//rslib/cargo:slog",
|
|
"//rslib/cargo:slog_async",
|
|
"//rslib/cargo:slog_envlogger",
|
|
"//rslib/cargo:slog_term",
|
|
"//rslib/cargo:strum",
|
|
"//rslib/cargo:tempfile",
|
|
"//rslib/cargo:tokio",
|
|
"//rslib/cargo:tokio_util",
|
|
"//rslib/cargo:unic_langid",
|
|
"//rslib/cargo:unicase",
|
|
"//rslib/cargo:unicode_normalization",
|
|
"//rslib/cargo:unic_ucd_category",
|
|
"//rslib/cargo:utime",
|
|
"//rslib/cargo:zip",
|
|
"//rslib/cargo:pct_str",
|
|
"//rslib/i18n:anki_i18n",
|
|
] + select({
|
|
# rustls on Linux
|
|
"//platforms:linux_x86_64": ["@reqwest_rustls//:reqwest"],
|
|
"//platforms:linux_arm64": ["@reqwest_rustls//:reqwest"],
|
|
# native tls on other platforms
|
|
"//conditions:default": ["//rslib/cargo:reqwest"],
|
|
}),
|
|
)
|
|
|
|
# Tests
|
|
#######################
|
|
|
|
rust_test(
|
|
name = "anki_tests",
|
|
compile_data = _anki_compile_data,
|
|
crate = ":anki",
|
|
crate_features = _anki_features,
|
|
data = glob([
|
|
"tests/support/**",
|
|
]),
|
|
rustc_env = _anki_rustc_env,
|
|
rustc_flags = [
|
|
"-Dclippy::dbg_macro",
|
|
],
|
|
deps = [
|
|
"//rslib/cargo:env_logger",
|
|
"//rslib/cargo:linkcheck",
|
|
"//rslib/cargo:utime",
|
|
],
|
|
)
|
|
|
|
rustfmt_test(
|
|
name = "format_check",
|
|
srcs = glob([
|
|
"**/*.rs",
|
|
]),
|
|
)
|
|
|
|
rustfmt_fix(
|
|
name = "format",
|
|
srcs = glob([
|
|
"**/*.rs",
|
|
]),
|
|
)
|
|
|
|
sql_format(
|
|
name = "sql_format",
|
|
srcs = glob(["**/*.sql"]),
|
|
)
|