anki/docs/windows.md
Damien Elmes 95dbf30fb9 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-02-10 19:23:07 +10:00

2.5 KiB

Windows

Requirements

Windows:

You must be running 64 bit Windows 10, version 1703 or newer.

The build system requires Developer Mode to be enabled.

Visual Studio:

Visual Studio 2022 was released in Nov 2021. Anki does not support it yet. You will need to download 2019 instead. Microsoft will push you towards 2022 on the Visual Studio website; you'll need to locate "older downloads", then log in with a free Microsoft account and search for "Build Tools for Visual Studio 2019 (version 16.11)".

Once you've downloaded the installer, open it, and select "Desktop Development with C++" on the left, leaving the options shown on the right as is.

MSYS:

Install msys2 into the default folder location.

After installation completes, run msys2, and run the following command:

$ pacman -S git

Bazel:

Use Start>Run to open PowerShell. Create a folder to store Bazel and its working data. Anki's build scripts expect to find it in \bazel on the same drive as the source folder.

PS> mkdir \bazel
PS> cd \bazel

Then grab Bazelisk:

PS> \msys64\usr\bin\curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.10.1/bazelisk-windows-amd64.exe -o bazel.exe

Source folder:

Anki's source files do not need to be in a specific location other than on the same drive as \bazel, but it's best to avoid long paths, as they can cause problems.

Running Anki during development

Open PowerShell and change to the top level of Anki's source folder, then run

.\run

This will build Anki and run it in place.

The first build will take a while, as it downloads and builds a bunch of dependencies. When the build is complete, Anki will automatically start.

To play and record audio, mpv.exe and lame.exe must be on the path.

Optimized builds

The .\run command will create a non-optimized build by default. This is faster to compile, but will mean Anki will run considerably slower.

To run Anki in optimized mode, use:

.\tools\runopt

More

For info on running tests, building wheels and so on, please see Development.

When you run a script like .\run, MSYS and bazel will automatically be added to the path, and Bazel will be configured to output build products into \bazel\anki. If you want to directly invoke bazel before having run any of the .bat files in this repo, please run tools\setup-env first.