mirror of
https://github.com/Vita3K/Vita3K.git
synced 2024-05-16 03:40:38 -04:00
Removes old build method
- Updates GitHub workflows to use the CMake toolchain files - Updates building.md to reflect the new build method - Updates old build scripts to just use the CMake project generation command
This commit is contained in:
parent
1c37f70273
commit
b807ddc78e
5
.github/workflows/c-cpp.yml
vendored
5
.github/workflows/c-cpp.yml
vendored
|
@ -38,12 +38,13 @@ jobs:
|
|||
include:
|
||||
- os: macos-latest
|
||||
cache_path: ~/Library/Caches/ccache
|
||||
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake
|
||||
- os: ubuntu-latest
|
||||
cache_path: ~/.ccache
|
||||
extra_cmake_args: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_DISCORD_RICH_PRESENCE=OFF
|
||||
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake -DUSE_DISCORD_RICH_PRESENCE=OFF
|
||||
- os: windows-latest
|
||||
cache_path: ~\AppData\Local\Mozilla\sccache
|
||||
extra_cmake_args: -DBOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
|
||||
extra_cmake_args: -DBOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64 -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/windows-x64.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
|
||||
|
||||
steps:
|
||||
- name: Set up build environment (macos-latest)
|
||||
|
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
|
@ -60,7 +60,7 @@ jobs:
|
|||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -B build -DCI=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_DISCORD_RICH_PRESENCE=OFF -G Ninja
|
||||
cmake -B build -DCI=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake -DUSE_DISCORD_RICH_PRESENCE=OFF -G Ninja
|
||||
cmake --build build --config ${{ matrix.config }}
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
|
|
BIN
_building/vs-cmd-prompt.png
Executable file
BIN
_building/vs-cmd-prompt.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
133
building.md
133
building.md
|
@ -1,37 +1,69 @@
|
|||
# Build Vita3K
|
||||
|
||||
## Windows (Visual Studio)
|
||||
Vita3K uses CMake for its project configuration and generation and should in theory be compatible with any project generator supported by CMake, C++17 compatible compiler and IDE with CMake support. However, the following settings are recommended to be used when compiling or developing:
|
||||
|
||||
Target OS | Host OS | [Project generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) (`-G`) | C/C++ Compiler (`-DCMAKE_C_COMPILER` and `-DCMAKE_CXX_COMPILER`)
|
||||
--- | --- | --- | ---
|
||||
Windows | Windows | Visual Studio / MSBuild | `cl` a.k.a Microsoft Visual C/C++ Compiler (included as a part of the [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) and the ` Dekstop development with C++` Visual Studio workload)
|
||||
macOS | macOS | Xcode | Clang (`clang` and `clang++`)
|
||||
Linux | Linux | Ninja | Clang (`clang` and `clang++`)
|
||||
|
||||
Vita3K also comes bundled with CMake toolchain files found in `./cmake/toolchain` for each target platform that automatically set up platform-specific variables such as the C/C++ compiler to the values shown in table above and must always be used when generating projects using CMake. Despite this, if needed the set values can be overwritten at project generation as well via CMake `-D` arguments and the project generator will be either the default one for the host OS platform or the one the person building the emulator decides to use.
|
||||
|
||||
**Note: Vita3K doesn't support compilation for 32-bit/x86/i386 platforms.**
|
||||
|
||||
For convenience, the following building instructions are given as examples based on the information from the table:
|
||||
|
||||
## Windows
|
||||
|
||||
### Visual Studio 2019
|
||||
- Install Visual Studio 2019 and choose to install `Desktop development with C++`. You will get compiler and `cmake` required for building.
|
||||
|
||||
Example for Visual Studio 2019:
|
||||
Example for Visual Studio 2019:
|
||||
|
||||
![Required tools for VS 2019](https://i.imgur.com/bkY15Oh.png)
|
||||
![Required tools for VS 2019](https://i.imgur.com/bkY15Oh.png)
|
||||
|
||||
- Install `git` to `clone` the project. Download and install `git` from [here](https://git-scm.com).
|
||||
|
||||
- Clone this repo.
|
||||
|
||||
```cmd
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
```cmd
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
|
||||
- Open `Developer Command Prompt` for your respective Visual Studio version. `cmake` and other `C/C++` toolchain only available on `Developer Command Prompt`.
|
||||
- Run Visual Studio 2019. On the project selection window open the local clone of the repository as a folder. Thanks to the integration between Visual Studio and CMake, Visual Studio will automatically setup the project for you.
|
||||
- Use the [CMake Settings Editor](https://docs.microsoft.com/en-us/cpp/build/customize-cmake-settings?view=msvc-160) to set "CMake toolchain file" to `./cmake/toolchain/windows-x64.cmake`. If asked to do so, delete and re-generate the CMake cache.
|
||||
|
||||
Example for Visual Studio 2019:
|
||||
From there, the project will be ready to build right from the Visual Studio UI.
|
||||
|
||||
![Developer Command Prompt for VS 2019](https://i.imgur.com/w6Umx1S.png)
|
||||
|
||||
- Run `gen-windows.bat` to create Visual Studio project in `build-windows` directory.
|
||||
### Build using terminal
|
||||
- Install:
|
||||
- [Git](https://git-scm.com)
|
||||
- [CMake](https://cmake.org/download/)
|
||||
- Either the [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) or Visual Studio 2019 with the ` Dekstop development with C++` workload.
|
||||
- On the Start Menu, open the `x64 Native Tools Command Prompt for Visual Studio 2019`.
|
||||
<p align="center">
|
||||
<img src="./_building/vs-cmd-prompt.png">
|
||||
</p>
|
||||
|
||||
```cmd
|
||||
.\gen-windows
|
||||
```
|
||||
- Clone the repository:
|
||||
```cmd
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
|
||||
- Open the project generated in the `build-windows` directory.
|
||||
- Generate the project:
|
||||
```cmd
|
||||
cmake -S . -B build-windows -G "Visual Studio 2019 16" -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/windows-x64.cmake
|
||||
```
|
||||
The line above will generate a Visual Studio 2019 project inside a folder called `build-windows`.
|
||||
|
||||
- Build and run it.
|
||||
- Build the project:
|
||||
```cmd
|
||||
cmake --build build-windows
|
||||
```
|
||||
|
||||
## macOS (Xcode)
|
||||
|
||||
|
@ -41,28 +73,32 @@ Example for Visual Studio 2019:
|
|||
|
||||
- Install dependencies with `brew`.
|
||||
|
||||
```sh
|
||||
brew install git cmake
|
||||
```
|
||||
```sh
|
||||
brew install git cmake
|
||||
```
|
||||
|
||||
- Clone this repo.
|
||||
|
||||
```sh
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
```sh
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
|
||||
- Generate Xcode project.
|
||||
|
||||
```
|
||||
./gen-macos.sh
|
||||
```
|
||||
```
|
||||
cmake -S . -B build-macos -G Xcode -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake
|
||||
```
|
||||
This example will generate a Xcode project inside a folder called `build-macos`.
|
||||
|
||||
- Open Xcode project `vita3k.xcodeproj` generated in `build-macos` directory.
|
||||
|
||||
- When prompted to create schemes, create one for the `vita3k` target only. The project builds many targets, so it will make your life easier if you create schemes as needed.
|
||||
|
||||
- Build.
|
||||
- Build the project using the Xcode UI. If needed, the build process can be invoked as well the same way as with the other platforms using a terminal:
|
||||
```sh
|
||||
cmake --build build-macos
|
||||
```
|
||||
|
||||
## Linux
|
||||
|
||||
|
@ -70,34 +106,39 @@ cd Vita3K
|
|||
|
||||
- Install dependencies.
|
||||
|
||||
```sh
|
||||
sudo apt install git cmake ninja-build libsdl2-dev pkg-config libgtk-3-dev clang
|
||||
```
|
||||
```sh
|
||||
sudo apt install git cmake ninja-build libsdl2-dev pkg-config libgtk-3-dev clang
|
||||
```
|
||||
|
||||
- Clone this repo.
|
||||
|
||||
```sh
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
```sh
|
||||
git clone --recursive https://github.com/Vita3K/Vita3K
|
||||
cd Vita3K
|
||||
```
|
||||
|
||||
- Build the project.
|
||||
- Generate the project.
|
||||
|
||||
```sh
|
||||
./gen-linux.sh
|
||||
cd build-linux
|
||||
ninja
|
||||
```
|
||||
```sh
|
||||
cmake -S . -B build-linux -G Ninja -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake
|
||||
```
|
||||
This example will generate a Ninja (`ninja-build`) project instead of a Make (`make`, the default project generator for Linux) one inside a folder called `build-linux`.
|
||||
|
||||
- Build the project:
|
||||
```sh
|
||||
cmake --build build-linux
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
- After cloning or checking out a branch, you should always update submodules.
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
```sh
|
||||
`git submodule update --init --recursive`
|
||||
```
|
||||
|
||||
- If `boost` failed to build, you can opt out for system `boost` package (Linux and macOS only).
|
||||
|
||||
```sh
|
||||
brew install boost # for macOS
|
||||
sudo apt install libboost-all-dev # for Ubuntu/Debian
|
||||
```
|
||||
```sh
|
||||
brew install boost # for macOS
|
||||
sudo apt install libboost-all-dev # for Ubuntu/Debian
|
||||
```
|
||||
|
|
28
gen-linux.sh
28
gen-linux.sh
|
@ -1,29 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
cmake_args=
|
||||
CLANG=
|
||||
command -v clang > /dev/null && CLANG=1
|
||||
|
||||
# CI uses pre-built Boost
|
||||
if [[ -z "${CI}" ]]; then
|
||||
# Create build dir
|
||||
mkdir -p external/boost-build
|
||||
cd external/boost
|
||||
|
||||
chmod +x tools/build/src/engine/build.sh
|
||||
sh bootstrap.sh
|
||||
|
||||
# Build our Boost subset
|
||||
./b2 --ignore-site-config -j$(nproc) --build-dir=../boost-build --stagedir=../boost-build stage
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
if [ "$CLANG" ]; then
|
||||
cmake_args="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
|
||||
fi
|
||||
|
||||
# Generate project files
|
||||
mkdir -p build-linux
|
||||
cd build-linux
|
||||
cmake .. -GNinja ${cmake_args}
|
||||
# Generate project files for Ninja
|
||||
cmake -S . -B build-linux -G Ninja -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake
|
||||
|
|
20
gen-macos.sh
20
gen-macos.sh
|
@ -1,21 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
# CI uses pre-built Boost
|
||||
if [[ -z "${CI}" ]]; then
|
||||
# Create build dir
|
||||
mkdir -p external/boost-build
|
||||
cd external/boost
|
||||
|
||||
chmod +x tools/build/src/engine/build.sh
|
||||
sh bootstrap.sh
|
||||
|
||||
# Build our Boost subset
|
||||
./b2 -j$(sysctl -n hw.logicalcpu) --build-dir=../boost-build --stagedir=../boost-build stage
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
# Generate project files
|
||||
mkdir -p build-macos
|
||||
cd build-macos
|
||||
cmake -G Xcode ..
|
||||
# Generate project files for Xcode
|
||||
cmake -S . -B build-macos -G Xcode -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake
|
||||
|
|
|
@ -1,26 +1,4 @@
|
|||
@echo off
|
||||
|
||||
REM CI uses pre-built Boost
|
||||
IF "%CI%"=="" IF NOT EXIST external\boost-build (
|
||||
REM Create build dir
|
||||
mkdir external\boost-build
|
||||
cd external\boost
|
||||
|
||||
call bootstrap.bat
|
||||
|
||||
REM Build our Boost subset
|
||||
call b2 -j%NUMBER_OF_PROCESSORS% --build-dir=../boost-build --stagedir=../boost-build toolset=msvc stage
|
||||
cd ../..
|
||||
)
|
||||
|
||||
REM Create build folder
|
||||
mkdir build-windows
|
||||
pushd build-windows
|
||||
|
||||
REM Generate project files
|
||||
IF "%CI%"=="" (
|
||||
call cmake -G "Visual Studio 16 2019" ..
|
||||
) ELSE (
|
||||
call cmake -G "Visual Studio 16 2019" -DCI:BOOL=ON -DCMAKE_CONFIGURATION_TYPES=%CONFIGURATION% ..
|
||||
)
|
||||
popd
|
||||
REM Generate project files for Visual Studio 2019
|
||||
call cmake -S . -B build-windows -G "Visual Studio 2019 16" -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/windows-x64.cmake
|
||||
|
|
Loading…
Reference in a new issue