Skip to content

Commit

Permalink
Add MSYS2 setup/build docs
Browse files Browse the repository at this point in the history
ep-tpstevens committed Nov 2, 2024
1 parent 2e09f40 commit ca13b3a
Showing 1 changed file with 142 additions and 0 deletions.
142 changes: 142 additions & 0 deletions Documentation/getting-started-eyepop.md
Original file line number Diff line number Diff line change
@@ -135,5 +135,147 @@ sudo apt install ../nnstreamer*.deb

See `eyepop-ml-dev`'s README.

## Notes on MSYS2 build for Windows on ARM

These instructions are experimental, subject to change, and will eventually be integrated with the
setup instructions above after testing and verification.

Note: MSYS2 uses your entire Windows username for `$HOME`, which may include spaces. To work around
this, I actually used `/home/tyler/workspace/install` as the base of the install path. Change paths
below as desired, but using the paths below will work since the MSYS2 environment apparently doesn't
have strict permissions. Need to investigate further.

Note: on my machine, running a `pacman` command often resulted in two instances. It was necessary to
kill the one with (usually) lower memory through the Windows task manager and/or run the command
again (ignoring errors from the first run). After running a command successfully, check the Task
Manager (or run `ps -e | grep 'pacman'`) for any processes to kill.

### Initial setup

* Install MSYS2: https://github.com/msys2/msys2-installer/releases/tag/2024-07-27
* Run the `MSYS2 CLANGARM64` application (`"C:\msys64\clangarm64.exe"`, if installed to the default
path)

Update and install build tools (run this twice -- will close the window once for a system upgrade):

```sh
pacman -S \
mingw-w64-clang-aarch64-clang \
mingw-w64-clang-aarch64-cmake \
mingw-w64-clang-aarch64-gtest \
mingw-w64-clang-aarch64-make \
mingw-w64-clang-aarch64-pkgconf \
mingw-w64-clang-aarch64-python3.12
```

Install dependencies for nnstreamer (can be combined with above instructions -- just separating for
tracking):

```sh
pacman -S \
mingw-w64-clang-aarch64-glib2 \
mingw-w64-clang-aarch64-libffi
```

### Build gstreamer

Clone `gstreamer` from https://gitlab.freedesktop.org/gstreamer/gstreamer and check out the latest
tag (1.24.9).

Set up a Python virtual environment to install necessary tools. Note: installing CMake through `pip`
did not work for me, hence the system package above.

```sh
python3.12 -m venv .venv
pip3 install meson ninja
```

To build and install `gstreamer` (note the GST-specific install directory to keep it separate from
the experimental `nnstreamer` build):

```sh
meson setup builddir \
--prefix=/home/tyler/workspace/install/gst \
-Dauto_features=disabled -Dgstreamer:tools=enabled -Dgood=enabled -Ddevtools=enabled -Dgstreamer:check=enabled
```

```sh
meson compile -C builddir
```

```sh
meson install -C builddir
```

### tflite2 notes

My preference would have been to build tflite from `eyepop-ml-dev`, but compilation is currently
blocked by this MSYS2 package issue: https://github.com/msys2/MINGW-packages/issues/22160

### Install onnxruntime

Download v.1.19.2 of the CPU-accelerated ONNX runtime from
https://github.com/microsoft/onnxruntime/releases/tag/v1.19.2

Unpack it to your desired install directory (in my case, `/home/tyler/workspace/install/onnx`).
There should be `lib/` and `include/` directories with no subdirectories, just files.

Create a `pkgconfig/` directory in the `lib/` folder and add the following `libonnxruntime.pc` file.
Again, adjust paths as necessary.

```
prefix=C:/msys64/home/tyler/workspace/install/onnx
includedir=${prefix}/include
libdir=${prefix}/lib
Name: ONNX runtime
Description: ONNX runtime libraries and headers
Version: 1.19.2
Libs: -L${libdir} -lonnxruntime -lonnxruntime_providers_shared
Cflags: -I${includedir}
```

### Build nnstreamer

Clone `eyepop-nnstreamer` from https://github.com/eyepop-ai/eyepop-nnstreamer and check out the
`tyler/msys2` branch.

Again, set up a Python virtual environment to install necessary tools. Note: installing CMake
through `pip` did not work for me, hence the system package above.

```sh
python3.12 -m venv .venv
pip3 install meson ninja
```

To build `nnstreamer` (which should pick up the ONNX runtime):

```sh
meson setup builddir \
--prefix=/home/tyler/workspace/install/nnstreamer \
-Dwerror=false -Denable-test=false -Denable-nnstreamer-check=false \
-Dpkg_config_path=/home/tyler/workspace/install/gst/lib/pkgconfig:/home/tyler/workspace/install/onnx/lib/pkgconfig
```

```sh
ninja -C builddir
```

### Next steps

* Build `eyepop-pipeline`
* Run an ONNX model
* Fix all the warnings I introduced (e.g. duplicate definitions of `NNS_API`)
* Add proper error handling for `char*` to `wchar_t*` conversions
* Properly handle conditional build options for Linux and Windows (where I've just overwritten the
defaults to hack together the Windows build)
* Make `nnstreamer` tests work
* Make this work in CI
* Figure out the weird `pacman` behavior
* Properly document the Windows build process and current status

It's likely that at this point, we'll discover several runtime issues with the nnstreamer build
and/or environment setup. But the build works on my machine! (for now)

[docker-setup]: https://app.gitbook.com/o/lp5TZAZIwu5jXdzZth9T/s/0fWYYHCrIOcShgRMiWhf/readme/howtos/running-as-docker-container
[dockerfiles]: https://github.com/eyepop-ai/eyepop-docker-images

0 comments on commit ca13b3a

Please sign in to comment.