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:
hobyst
2021-06-15 11:54:44 +02:00
committed by Sunho Kim
parent 1c37f70273
commit b807ddc78e
7 changed files with 97 additions and 117 deletions
+3 -2
View File
@@ -38,12 +38,13 @@ jobs:
include: include:
- os: macos-latest - os: macos-latest
cache_path: ~/Library/Caches/ccache cache_path: ~/Library/Caches/ccache
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake
- os: ubuntu-latest - os: ubuntu-latest
cache_path: ~/.ccache 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 - os: windows-latest
cache_path: ~\AppData\Local\Mozilla\sccache 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: steps:
- name: Set up build environment (macos-latest) - name: Set up build environment (macos-latest)
+1 -1
View File
@@ -60,7 +60,7 @@ jobs:
- name: Build - name: Build
run: | 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 }} cmake --build build --config ${{ matrix.config }}
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

+87 -46
View File
@@ -1,37 +1,69 @@
# Build Vita3K # 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. - 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). - Install `git` to `clone` the project. Download and install `git` from [here](https://git-scm.com).
- Clone this repo. - Clone this repo.
```cmd ```cmd
git clone --recursive https://github.com/Vita3K/Vita3K git clone --recursive https://github.com/Vita3K/Vita3K
cd 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 - Clone the repository:
.\gen-windows ```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) ## macOS (Xcode)
@@ -41,28 +73,32 @@ Example for Visual Studio 2019:
- Install dependencies with `brew`. - Install dependencies with `brew`.
```sh ```sh
brew install git cmake brew install git cmake
``` ```
- Clone this repo. - Clone this repo.
```sh ```sh
git clone --recursive https://github.com/Vita3K/Vita3K git clone --recursive https://github.com/Vita3K/Vita3K
cd Vita3K cd Vita3K
``` ```
- Generate Xcode project. - 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. - 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. - 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 ## Linux
@@ -70,34 +106,39 @@ cd Vita3K
- Install dependencies. - Install dependencies.
```sh ```sh
sudo apt install git cmake ninja-build libsdl2-dev pkg-config libgtk-3-dev clang sudo apt install git cmake ninja-build libsdl2-dev pkg-config libgtk-3-dev clang
``` ```
- Clone this repo. - Clone this repo.
```sh ```sh
git clone --recursive https://github.com/Vita3K/Vita3K git clone --recursive https://github.com/Vita3K/Vita3K
cd Vita3K cd Vita3K
``` ```
- Build the project. - Generate the project.
```sh ```sh
./gen-linux.sh cmake -S . -B build-linux -G Ninja -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake
cd build-linux ```
ninja 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 ## Note
- After cloning or checking out a branch, you should always update submodules. - After cloning or checking out a branch, you should always update submodules.
```sh
`git submodule update --init --recursive` `git submodule update --init --recursive`
```
- If `boost` failed to build, you can opt out for system `boost` package (Linux and macOS only). - If `boost` failed to build, you can opt out for system `boost` package (Linux and macOS only).
```sh ```sh
brew install boost # for macOS brew install boost # for macOS
sudo apt install libboost-all-dev # for Ubuntu/Debian sudo apt install libboost-all-dev # for Ubuntu/Debian
``` ```
+2 -26
View File
@@ -1,29 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
cmake_args= # Generate project files for Ninja
CLANG= cmake -S . -B build-linux -G Ninja -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/linux-x64.cmake
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}
+2 -18
View File
@@ -1,21 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
# CI uses pre-built Boost # Generate project files for Xcode
if [[ -z "${CI}" ]]; then cmake -S . -B build-macos -G Xcode -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/macos-x64.cmake
# 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 ..
+2 -24
View File
@@ -1,26 +1,4 @@
@echo off @echo off
REM CI uses pre-built Boost REM Generate project files for Visual Studio 2019
IF "%CI%"=="" IF NOT EXIST external\boost-build ( call cmake -S . -B build-windows -G "Visual Studio 2019 16" -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain/windows-x64.cmake
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