Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Rnote and Installer for Windows Arm64 #1211

Closed
wants to merge 13 commits into from
12 changes: 11 additions & 1 deletion build-aux/cargo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import os
import platform

project_build_root = sys.argv[1]
project_src_root = sys.argv[2]
Expand All @@ -22,7 +23,16 @@
output_file: {output_file}
""", file=sys.stderr)

cargo_call = f"env {cargo_env} {cargo_cmd} build {cargo_options}"
# Detecting architecture
if sys.platform == 'win32':
if platform.machine().lower() == 'arm64':
rustflags = '-C linker=clang'
else:
rustflags = ''
else:
rustflags = ''

cargo_call = f"env {cargo_env} RUSTFLAGS='{rustflags}' {cargo_cmd} build {cargo_options}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that this logic is in the meson build file, not in this script.

Copy link
Author

@OB0NE OB0NE Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback about moving the logic to the meson build file. I want to be transparent - I've been using AI to help me adjust the code as I have very limited knowledge about Rust and the app building process. This approach has proven to be quite inefficient, and despite multiple attempts, I haven't been able to successfully move the logic to the meson build file.

Rather than continue with AI-assisted code adjustments that might not meet the project's standards, I think I can be more helpful by offering to test any changes you implement on my ARM64 device (Surface Pro 11). This would ensure the changes work correctly on ARM64 Windows hardware, which might be valuable for the project.

So, please feel free to change what I have adjusted and let me know if you'd like me to test any changes you make, and I'll be happy to provide detailed feedback about how it works on ARM64.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a few changes.
I think this does what's intended, by moving the logic back into the meson file (and using an extra argument in the cargo_build.py file).
Feel free to check whether this builds or not on your side, though beware of #1228 (that should get fixed at some point)

cp_call = f"cp {bin_output} {output_file}"

print(cargo_call, file=sys.stderr)
Expand Down
6 changes: 3 additions & 3 deletions build-aux/rnote_inno.iss.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ DisableProgramGroupPage=yes
Compression=lzma2/ultra64
SolidCompression=yes
WizardStyle=modern
; Run in 64-bit mode, restrict to x64 architecture.
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
; Run in 64-bit mode, restrict to x64 and ARM64 architecture.
ArchitecturesAllowed=x64 arm64
ArchitecturesInstallIn64BitMode=x64 arm64

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ option(
'win-build-environment-path',
type: 'string',
value: 'C:\\msys64\\mingw64',
description: 'Only relevant for builds on Windows: the path of the installed msys/mingw64 environment.',
description: 'Only relevant for builds on Windows: the path of the installed msys/mingw64 (or msys/clangarm64) environment.',
)
96 changes: 96 additions & 0 deletions misc/building/rnote-windows-arm64-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Build Instructions for Windows arm64

## Prerequisites
### Clone the repository

```bash
git clone https://github.com/flxzt/rnote
git submodule update --init --recursive
```

### Install MSYS2
- Install MSYS2 (using CLANGARM64 environment)
- Update MSYS2:
```Bash
pacman -Suy
```
- Add MSYS2 binary directories `C:\msys64\clangarm64\bin` and `C:\msys64\usr\bin` to the system environment variable Path.

### (Optional) Install Inno Setup (for building the installer)

### Install Dependencies
Run the following command in the MSYS2 CLANGARM64 terminal to install necessary dependencies:

```bash
pacman -S mingw-w64-clang-aarch64-xz mingw-w64-clang-aarch64-pkgconf mingw-w64-clang-aarch64-clang \
mingw-w64-clang-aarch64-toolchain mingw-w64-clang-aarch64-autotools mingw-w64-clang-aarch64-make mingw-w64-clang-aarch64-cmake \
mingw-w64-clang-aarch64-meson mingw-w64-clang-aarch64-desktop-file-utils mingw-w64-clang-aarch64-appstream \
mingw-w64-clang-aarch64-gtk4 mingw-w64-clang-aarch64-libadwaita mingw-w64-clang-aarch64-poppler mingw-w64-clang-aarch64-poppler-data \
mingw-w64-clang-aarch64-angleproject
```
All the above packages are clang-aarch64 versions corresponding to x86_64 versions.
The mingw-w64-x86_64-diffutils package doesn't have a corresponding clang-aarch64 version, so install mingw-w64-x86_64-diffutils directly:

```bash
pacman -S mingw-w64-x86_64-diffutils
```

### Install Rust
Install Rust provided by MSYS2 (important)
```bash
pacman -S mingw-w64-clang-aarch64-rust
```

### Configuration

Add the following line to the end of the `C:\msys64\home\<user>\.bashrc` file to add the Rust binary directory to MSYS2's `PATH`:

```
export PATH=$PATH:/c/msys64/clangarm64/bin
```
If you have installed Inno Setup, add the following line to the end of the `C:\msys64\home\<user>\.bashrc` file:

```
export PATH=$PATH:/c/msys64/clangarm64/bin:/c/Program\ Files\ \(x86\)/Inno\ Setup\ 6
```
Apply the configuration:

```bash
source ~/.bashrc
```

# Compile Rnote

1. First, make sure you're in the correct directory:
```bash
cd /c/rnote
```

2. Clean previous build files:
```bash
rm -rf _mesonbuild
```

3. Reconfigure the project:
```bash
meson setup --prefix="C:/msys64/clangarm64" -Dwin-installer-name='windows_arm64_installer' -Dwin-build-environment-path='C:\\msys64\\clangarm64' _mesonbuild
```

4. Compile the project:
```bash
meson compile -C _mesonbuild
```

5. Install the project:
```bash
meson install -C _mesonbuild
```
# Build the installer

```bash
meson compile rnote-gmo -C _mesonbuild
```

```bash
meson compile build-installer -C _mesonbuild
```