mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
minor tweak to new-platforms.md, and run prettier on docs
This commit is contained in:
parent
ee644e08a3
commit
3b8b71b815
8 changed files with 68 additions and 58 deletions
4
docs/BUILD.bazel
Normal file
4
docs/BUILD.bazel
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
load("//ts:prettier.bzl", "prettier_test")
|
||||||
|
|
||||||
|
# formatting of the .md files
|
||||||
|
prettier_test()
|
|
@ -21,7 +21,7 @@ pylib contains a private Python module called rsbridge (`pylib/rsbridge/`) that
|
||||||
|
|
||||||
### GUI
|
### GUI
|
||||||
|
|
||||||
Anki's *GUI* is a mix of Qt (via the PyQt Python bindings for Qt), and
|
Anki's _GUI_ is a mix of Qt (via the PyQt Python bindings for Qt), and
|
||||||
TypeScript/HTML/CSS. The Qt code lives in `qt/aqt/`, and is importable in Python
|
TypeScript/HTML/CSS. The Qt code lives in `qt/aqt/`, and is importable in Python
|
||||||
with "import aqt". The web code is split between `qt/aqt/data/web/` and `ts/`,
|
with "import aqt". The web code is split between `qt/aqt/data/web/` and `ts/`,
|
||||||
with the majority of new code being placed in the latter, and copied into the
|
with the majority of new code being placed in the latter, and copied into the
|
||||||
|
@ -39,4 +39,4 @@ type-safe manner between the different languages.
|
||||||
At the moment, the protobuf is not considered public API. Some pylib methods
|
At the moment, the protobuf is not considered public API. Some pylib methods
|
||||||
expose a protobuf object directly to callers, but when they do so, they use a
|
expose a protobuf object directly to callers, but when they do so, they use a
|
||||||
type alias, so callers outside pylib should never need to import a generated
|
type alias, so callers outside pylib should never need to import a generated
|
||||||
_pb2.py file.
|
\_pb2.py file.
|
||||||
|
|
|
@ -179,9 +179,9 @@ expand proc macros and build scripts, and run cargo check on startup. Adding
|
||||||
of `use` statements.
|
of `use` statements.
|
||||||
|
|
||||||
The Bazel build products will make RA start up slowly out of the box. For a much
|
The Bazel build products will make RA start up slowly out of the box. For a much
|
||||||
nicer experience, add each of the bazel-* folders to Rust Analyzer's excludeDirs
|
nicer experience, add each of the `bazel-*` folders to Rust Analyzer's excludeDirs
|
||||||
settings, and node_modules. Wildcards don't work unfortunately. Then adjust
|
settings, and node*modules. Wildcards don't work unfortunately. Then adjust
|
||||||
VS Code's "watcher exclude", and add `**/bazel-*`.
|
VS Code's "watcher exclude", and add `\*\*/bazel-*`.
|
||||||
|
|
||||||
After running 'code' from the project root, it may take a minute or two to be
|
After running 'code' from the project root, it may take a minute or two to be
|
||||||
ready.
|
ready.
|
||||||
|
|
|
@ -59,7 +59,7 @@ docker run --rm -it \
|
||||||
|
|
||||||
Here is a breakdown of some of the arguments:
|
Here is a breakdown of some of the arguments:
|
||||||
|
|
||||||
- Mount the current user's `~/.local/share` directory onto the container. Anki saves things
|
- Mount the current user's `~/.local/share` directory onto the container. Anki saves things
|
||||||
into this directory, and if we don't mount it, we will lose any changes once the
|
into this directory, and if we don't mount it, we will lose any changes once the
|
||||||
container exits. We mount this as read-write (`rw`) because we want to make changes here.
|
container exits. We mount this as read-write (`rw`) because we want to make changes here.
|
||||||
|
|
||||||
|
@ -67,26 +67,26 @@ Here is a breakdown of some of the arguments:
|
||||||
--volume $HOME/.local/share:$HOME/.local/share:rw
|
--volume $HOME/.local/share:$HOME/.local/share:rw
|
||||||
```
|
```
|
||||||
|
|
||||||
- Mount `/etc/passwd` so we can enter the container as ourselves. We mount this as
|
- Mount `/etc/passwd` so we can enter the container as ourselves. We mount this as
|
||||||
read-only because we definitely do not want to modify this.
|
read-only because we definitely do not want to modify this.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--volume /etc/passwd:/etc/passwd:ro
|
--volume /etc/passwd:/etc/passwd:ro
|
||||||
```
|
```
|
||||||
|
|
||||||
- Enter the container with our user ID and group ID, so we stay as ourselves.
|
- Enter the container with our user ID and group ID, so we stay as ourselves.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--user $(id -u):$(id -g)
|
--user $(id -u):$(id -g)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Mount the X11 directory that allows us to open displays.
|
- Mount the X11 directory that allows us to open displays.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--volume /tmp/.X11-unix:/tmp/.X11-unix:rw
|
--volume /tmp/.X11-unix:/tmp/.X11-unix:rw
|
||||||
```
|
```
|
||||||
|
|
||||||
- Pass the `DISPLAY` variable to the container, so it knows where to display graphics.
|
- Pass the `DISPLAY` variable to the container, so it knows where to display graphics.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--env DISPLAY=$DISPLAY
|
--env DISPLAY=$DISPLAY
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
## Upstream prerequisites
|
## Upstream prerequisites
|
||||||
|
|
||||||
- A recent Qt, PyQt5 and PyQtWebEngine must work on your platform. Chances are wheels
|
- A recent Qt, PyQt5 and PyQtWebEngine must work on your platform. Chances are wheels
|
||||||
for your platform are not available on PyPI, so you will need to have a working
|
for your platform are not available on PyPI, so you will need to have a working
|
||||||
version installed already, either from your Linux distro's archives, or by building
|
version installed already, either from your Linux distro's archives, or by building
|
||||||
from source.
|
from source.
|
||||||
- Rust and Node must support your platform.
|
- Rust and Node must support your platform.
|
||||||
- If the Bazel Rust and Node rules do not support your platform, extra work may be required.
|
- If the Bazel Rust and Node rules do not support your platform, extra work may be required.
|
||||||
|
|
||||||
## 32 bit builds
|
## 32 bit builds
|
||||||
|
|
||||||
|
@ -17,47 +17,47 @@ tried, and it will likely not work out of the box.
|
||||||
|
|
||||||
## Protobuf & Python
|
## Protobuf & Python
|
||||||
|
|
||||||
- Edit /platforms/BUILD.bzl and add the new platform. Available platforms
|
- Edit /platforms/BUILD.bzl and add the new platform. Available platforms
|
||||||
and CPUs can be found here: https://github.com/bazelbuild/platforms
|
and CPUs can be found here: https://github.com/bazelbuild/platforms
|
||||||
- Edit /protobuf.bzl and add the new platform and a link to a protoc binary.
|
- Edit /protobuf.bzl and add the new platform and a link to a protoc binary.
|
||||||
- Edit /pylib/anki/BUILD.bazel and add the new platform and the relevant
|
- Edit /pylib/anki/BUILD.bazel and add the new platform and the relevant
|
||||||
Python wheel name for your platform.
|
Python wheel name for your platform.
|
||||||
|
|
||||||
Example of the above changes:
|
Example of the above changes:
|
||||||
https://github.com/ankitects/anki/commit/db3308e788f20b188e84add40d6a1dce5bf726a0
|
https://github.com/ankitects/anki/commit/db3308e788f20b188e84add40d6a1dce5bf726a0
|
||||||
|
|
||||||
- We need to tell the build process to use your local PyQt5 install, instead of
|
- We need to tell the build process to use your local PyQt5 install, instead of
|
||||||
fetching it from PyPI. Locate your Python site-packages folder where the PyQt5
|
fetching it from PyPI. Locate your Python site-packages folder where the PyQt5
|
||||||
folder is, and add the following to user.bazelrc in the project folder root:
|
folder is, and add the following to user.bazelrc in the project folder root:
|
||||||
|
|
||||||
```
|
```
|
||||||
build --action_env=PYTHON_SITE_PACKAGES=/path/to/site-packages
|
build --action_env=PYTHON_SITE_PACKAGES=/path/to/site-packages/
|
||||||
```
|
```
|
||||||
|
|
||||||
- Anki uses the Python 'orjson' module to speed up DB access. If you're on a
|
- Anki uses the Python 'orjson' module to speed up DB access. If you're on a
|
||||||
platform that can not build orjson, you can remove it from
|
platform that can not build orjson, you can remove it from
|
||||||
pip/requirements.txt to skip it during running/building, but DB operations
|
python/requirements.txt to skip it during running/building, but DB operations
|
||||||
will be slower.
|
will be slower.
|
||||||
|
|
||||||
The py_wheel() rule in pylib/anki/BUILD.bazel adds an orjson requirement to
|
The py_wheel() rule in pylib/anki/BUILD.bazel adds an orjson requirement to
|
||||||
the generated Anki wheel on x86_64. If you have removed orjson, you'll want to
|
the generated Anki wheel. If you have removed orjson, you'll want to
|
||||||
remove that line. If you have successfully built orjson for another platform,
|
remove that line. If you have successfully built orjson for another platform,
|
||||||
you'll want to adjust that line to include your platform.
|
you'll want to adjust that line to include your platform.
|
||||||
|
|
||||||
## Rust
|
## Rust
|
||||||
|
|
||||||
- Ensure you have Rust installed (eg via rustup)
|
- Ensure you have Rust installed (eg via rustup)
|
||||||
- Edit /Cargo.toml in this project, and add your platform
|
- Edit /Cargo.toml in this project, and add your platform
|
||||||
to the targets. Check that the platform [is supported](https://github.com/bazelbuild/rules_rust/blob/master/rust/platform/platform.bzl) by rules_rust; if it is not, you'll
|
to the targets. Check that the platform [is supported](https://github.com/bazelbuild/rules_rust/blob/master/rust/platform/platform.bzl) by rules_rust; if it is not, you'll
|
||||||
need to send a PR to them adding it. You can test your change locally by modifying
|
need to send a PR to them adding it. You can test your change locally by modifying
|
||||||
/repos.bzl in this project to point to a local rules_rust checkout.
|
/repos.bzl in this project to point to a local rules_rust checkout.
|
||||||
- Edit /cargo/BUILD.request.bazel and add the new platform.
|
- Edit /cargo/BUILD.request.bazel and add the new platform.
|
||||||
- Run update.py in the /cargo folder.
|
- Run update.py in the /cargo folder.
|
||||||
|
|
||||||
Examples of the required changes:
|
Examples of the required changes:
|
||||||
|
|
||||||
- https://github.com/ankitects/anki/commit/eca27b371000e77b68cb4c790b44848507ca3883
|
- https://github.com/ankitects/anki/commit/eca27b371000e77b68cb4c790b44848507ca3883
|
||||||
- https://github.com/ankitects/anki/commit/3f3f4b5c3640a7d1f4eec02f326fda93214ec34b
|
- https://github.com/ankitects/anki/commit/3f3f4b5c3640a7d1f4eec02f326fda93214ec34b
|
||||||
|
|
||||||
## NodeJS
|
## NodeJS
|
||||||
|
|
||||||
|
|
|
@ -5,21 +5,21 @@ use AnkiWeb, you can run the server on a machine on your local network.
|
||||||
|
|
||||||
Things to be aware of:
|
Things to be aware of:
|
||||||
|
|
||||||
- Media syncing is not currently supported. You will either need to disable
|
- Media syncing is not currently supported. You will either need to disable
|
||||||
syncing of sounds and images in the preferences screen, sync your media via
|
syncing of sounds and images in the preferences screen, sync your media via
|
||||||
AnkiWeb, or use some other solution.
|
AnkiWeb, or use some other solution.
|
||||||
- AnkiMobile does not yet provide an option for using a local sync server,
|
- AnkiMobile does not yet provide an option for using a local sync server,
|
||||||
so for now this will only be usable with the computer version of Anki, and
|
so for now this will only be usable with the computer version of Anki, and
|
||||||
AnkiDroid.
|
AnkiDroid.
|
||||||
- This code is partly new, and while it has had some testing, it's possible
|
- This code is partly new, and while it has had some testing, it's possible
|
||||||
something has been missed. Please make backups, and report any bugs you run
|
something has been missed. Please make backups, and report any bugs you run
|
||||||
into.
|
into.
|
||||||
- The server runs over an unencrypted HTTP connection and does not require
|
- The server runs over an unencrypted HTTP connection and does not require
|
||||||
authentication, so it is only suitable for use on a private network.
|
authentication, so it is only suitable for use on a private network.
|
||||||
- This is an advanced feature, targeted at users who are comfortable with
|
- This is an advanced feature, targeted at users who are comfortable with
|
||||||
networking and the command line. If you use this, the expectation is you
|
networking and the command line. If you use this, the expectation is you
|
||||||
can resolve any setup/network/firewall issues you run into yourself, and
|
can resolve any setup/network/firewall issues you run into yourself, and
|
||||||
use of this is entirely at your own risk.
|
use of this is entirely at your own risk.
|
||||||
|
|
||||||
## From source
|
## From source
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
# this is a hack to invoke prettier directly from Bazel
|
# this is a hack to invoke prettier directly from Bazel
|
||||||
(cd "${BUILD_WORKSPACE_DIRECTORY}" && node_modules/.bin/prettier --config .prettierrc --write ts qt/aqt/data/web/js)
|
(cd "${BUILD_WORKSPACE_DIRECTORY}" && node_modules/.bin/prettier \
|
||||||
|
--config .prettierrc --write \
|
||||||
|
ts \
|
||||||
|
qt/aqt/data/web/js \
|
||||||
|
docs \
|
||||||
|
)
|
||||||
|
|
|
@ -9,6 +9,7 @@ def prettier_test(name = "format_check", srcs = None, exclude = [], **kwargs):
|
||||||
"*.ts",
|
"*.ts",
|
||||||
"*.js",
|
"*.js",
|
||||||
"*.svelte",
|
"*.svelte",
|
||||||
|
"*.md",
|
||||||
], exclude = exclude)
|
], exclude = exclude)
|
||||||
|
|
||||||
_prettier_test(
|
_prettier_test(
|
||||||
|
|
Loading…
Reference in a new issue