anki/docs/windows.md

119 lines
3.4 KiB
Markdown
Raw Normal View History

# Windows
## Requirements
**Windows**:
You must be running 64 bit Windows 10, version 1703 or newer.
The build system requires [Developer Mode](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) to be enabled.
**Visual Studio**:
2021-11-28 10:07:27 +01:00
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)".
2020-11-05 11:12:18 +01:00
2021-11-28 10:07:27 +01:00
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**:
2020-11-05 11:12:18 +01:00
Install [msys2](https://www.msys2.org/) into the default folder location.
2020-11-05 11:12:18 +01:00
After installation completes, run msys2, and run the following command:
```
2020-11-18 04:22:51 +01:00
$ pacman -S git
```
If you have native Windows apps relying on Git, e.g. the PowerShell extension
[posh-git](https://github.com/dahlbyk/posh-git), you may want to install
[Git for Windows](https://gitforwindows.org/) and put it on the path instead,
as msys Git may cause issues with them.
**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.
2020-12-08 00:08:51 +01:00
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:
```
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
.\tools\runopt
```
## Stale TS Files
The build process may break when .ts files are removed or renamed on Windows. If you're
tracking Anki's development and you run into a TS build error, try the following:
```
bazel run tools:cleanup_js
```
2020-11-04 05:01:14 +01:00
## More
For info on running tests, building wheels and so on, please see
[Development](./development.md).
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
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.
However, this will not work in PowerShell, as .bat files are executed in a subprocess.
To invoke bazel scripts, you will have to adjust your session path manually.
One option is to create a script that sets up your Anki development environment for you.
Here is an example:
```powershell
# put bazel and msys on path
$env:PATH = "c:\bazel;c:\msys64\usr\bin;$env:PATH"
# change working directory to anki root
Set-Location C:\code\anki
# open VSC
code .
# open powershell 7
pwsh
```