R2Northstar / NorthstarLauncher

Launcher used to modify Titanfall 2 to allow mods to be loaded
MIT License
281 stars 126 forks source link

Figure out building Northstar on Linux #212

Closed GeckoEidechse closed 1 year ago

GeckoEidechse commented 2 years ago

We use msbuild, which is Windows only?

We should figure out how to compile on Linux to make developing on Linux easier.

Note that this means still creating a Windows executable. As Titanfall2 is a Windows only game there's no point in creating a Linux-native version of Northstar as that version would have to interface with Wine/Proton instead and hook functions there which require a complete rewrite just for Linux. Given that Northstar works fine running under Wine/Proton, there's no point in putting in the huge amount of effort required for working Linux native builds.

p0358 commented 2 years ago

Highly suggesting the last one (it defaults to VS2022 contrary to what readme says). Is the most painless since it downloads files automatically without requiring Vagrant Windows image to presetup.

The only other option is to use a different Linux-native compiler, which I don't really recommend due to possible ABI incompatibilities that will not necessarily be nice to debug for people trying this approach, though @pg9182 disagreed with my opinion on this before...

pg9182 commented 2 years ago

I am planning to open a series of PRs based on my own configs:

The end goal will be to have everything in Northstar compiled with llvm-mingw-msvcrt (instead of msvc) using meson build scripts (instead of msbuild), with all CI being done on Linux.

Benefits:

Costs:

apophis42 commented 1 year ago

If your goal is cross-platform development, I'd recommend adding support for building through CMake over Meson, since it's the defacto standard build system for C++at this point and is very good for cross-platform. It also has native integrations with multiple IDEs, including Visual Studio, meaning it should be just as easy for anyone using VS to use the CMake file as it is to use the solution file.

I've made a commit that's able to successfully build through CMake through MSVC and I'm using it to look at what's required for building with mingw. Let me know if you'd like a PR.

GeckoEidechse commented 1 year ago

I've made a commit that's able to successfully build through CMake through MSVC and I'm using it to look at what's required for building with mingw. Let me know if you'd like a PR.

PR would always be appreciated <3

apophis42 commented 1 year ago

My friend and I managed to make the changes required for a successful mingw build, so I can PR that once the previous is accepted.

Jan200101 commented 1 year ago

elek on Discord got NorthstarLauncher to compile under msvc-wine.

This has been tested on at least Arch and Fedora but is likely to work on more distros.

Instructions copied straight from Discord (message):

Arch Linux instructions

Create a folder for msvc installation but don't enter it (e.g. ~/msvc) Clone msvc-wine and enter folder. (git clone https://github.com/mstorsjo/msvc-wine) ./vsdownload.py --dest <folder for msvc installation> (e.g. ~/msvc) Accept Licence Agreement ./install.sh <folder of the msvc installation>

export PATH=<path to msvc installation>/bin/x64:$PATH

Clone NorthstarLauncher and switch into clone repo CC=cl CXX=cl cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja"

cmake --build .

pg9182 commented 1 year ago

Furthermore, you can also add -DCMAKE_EXPORT_COMPILE_COMMANDS=1 to make it work well with the vscode-clangd extension (along with clang-cl).

GeckoEidechse commented 1 year ago

This is basically solved with #501

We only need to add the instructions to documentation ^^