# Building on Windows

Install MSYS2 : https://www.msys2.org

Once installed hit start and look for and run `MSYS2 MinGW 64-bit`. This will open a command shell.
For visual studio code terminal integration see [VSCode terminal integration](#vsint)

In msys install all dependencies using the following command:

```
pacman --sync --noconfirm --needed git mingw-w64-x86_64-toolchain mingw-w64-x86_64-gtk3 mingw-w64-x86_64-meson mingw-w64-x86_64-libsamplerate mingw-w64-x86_64-fftw mingw-w64-x86_64-ffmpeg mingw-w64-x86_64-libyaml mingw-w64-x86_64-libsndfile mingw-w64-x86_64-rubberband mingw-w64-x86_64-dlfcn mingw-w64-x86_64-SDL2
```

Let it run until all packages are done installing.
The above will install git as well which is needed for the next step.

### Clone Zrythm

```
cd && mkdir git && cd git
git clone https://git.zrythm.org/git/zrythm && cd zrythm
```

### Build
Setup project files with meson
```
meson build -Denable_plugins=false -Denable_sdl=true
```

Compile and finalize
```
ninja -C build
ninja -C build install
```

### Run
The working directory must be the root of the zrythm repository, from there in msys run zrythm with:
```
/build/src/zrythm
```

### Debugging ( VSCode )
visual studio code:
In VSCode open the root folder of zrythm. Hit F5 and you will be prompted with a selection of environment options.
Select `C++(GDB/LLDB)`, this will create a new launch.json file with a configuration for gdb.

Edit the following options:

`"program":"${workspaceFolder}/build/src/zrythm.exe"`

`"externalConsole":true`

`"miDebuggerPath":"C:/msys64/mingw64/bin/gdb.exe"`

hit `F5` and the debugger should run.

### VSCode terminal integration
VSCode allows you to change the integrated terminal. With this we can make calls to msys directly from VSCode.

Changing terminal from powershell to bash:

Open settings using `File > Preferences > Settings` or `ctrl+,`
Select `Workspace`, this will make it so that these changes only apply to the current workspace.
Click the "Open settings" button top right (file with arrow icon). This will open the settings as an editable json file.

Add the following lines

```
 "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
 "terminal.integrated.shellArgs.windows": ["--login", "-i"],
 "terminal.integrated.env.windows": {
    "MSYSTEM": "MINGW64",
     "CHERE_INVOKING":"1"
  }
```

The above snippet assumes that msys64 was installed at the default location `C:/msys64`.
Make sure it matches with your installation path.

To open the terminal hit `ctrl`+`` ` ``

----

Copyright (C) 2020 Sidar Talei

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  This file is offered as-is,
without any warranty.
