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

Add GitHub Actions workflow #492

Merged
merged 4 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Build

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.platform.display_name }} ${{ matrix.preset_build_type.display_name }}

runs-on: ${{ matrix.platform.os }}

defaults:
run:
shell: bash

strategy:
fail-fast: false

matrix:
platform:
- { display_name: 'Linux Native Libraries', os: ubuntu-latest, preset_os: linux }
- { display_name: 'Windows Native Libraries', os: windows-latest, preset_os: windows }

preset_build_type:
- { display_name: 'Debug', name: debug }
- { display_name: 'Release', name: release }

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
run: |
preset_name="${{ matrix.platform.preset_os }}-${{ matrix.preset_build_type.name }}"
workspace_dir="${{ github.workspace }}"
source_dir=${workspace_dir//\\//}/mp/src
build_dir=${workspace_dir//\\//}/mp/src/build/$preset_name
install_dir=$build_dir/install
echo "source_dir=$source_dir" >> "$GITHUB_ENV"
echo "build_dir=$build_dir" >> "$GITHUB_ENV"
echo "install_dir=$install_dir" >> "$GITHUB_ENV"
echo "preset_name=$preset_name" >> "$GITHUB_ENV"

- name: Install packages
if: ${{ matrix.platform.os == 'ubuntu-latest' }}
run: |
sudo apt update
sudo apt install gcc-multilib g++-multilib ninja-build -y

- name: Install packages
if: ${{ matrix.platform.os == 'windows-latest' }}
run: choco install -y ninja

- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.platform.os == 'windows-latest' }}
with:
arch: x86

- name: Print PATH
if: ${{ matrix.platform.os == 'windows-latest' }}
run: |
echo "PATH: $PATH"

# Libraries

- name: CMake configure libraries build
working-directory: ${{ env.source_dir }}
run: >
cmake
--preset ${{ env.preset_name }}
-DCMAKE_INSTALL_PREFIX=${{ env.install_dir }}
-DNEO_CI_BUILD=ON
-DNEO_USE_CCACHE=OFF
-DNEO_COPY_LIBRARIES=OFF
-DNEO_USE_SEPARATE_BUILD_INFO=ON
-DNEO_INSTALL_LIBRARIES=ON
-DNEO_INSTALL_RESOURCES=OFF

- name: CMake libraries build
working-directory: ${{ env.source_dir }}
run: cmake --build --preset ${{ env.preset_name }} --parallel --verbose

- name: Install libraries
run: cmake --install ${{ env.build_dir }}

# Dedicated library

- name: CMake reconfigure dedicated library build
working-directory: ${{ env.source_dir }}
run: >
cmake
--preset ${{ env.preset_name }}
-DNEO_DEDICATED=ON

- name: CMake dedicated library build
working-directory: ${{ env.source_dir }}
run: cmake --build --preset ${{ env.preset_name }} --parallel --verbose

- name: Install dedicated library
run: cmake --install ${{ env.build_dir }}

# Artifacts

- name: Get artifact names
working-directory: ${{ env.install_dir }}
run: |
echo "libraries=$(find . -regex '\.\/neo-\w*-\w*-libraries-\w*-\w*' -printf '%f')" >> "$GITHUB_ENV"
echo "libraries_debuginfo=$(find . -regex '\.\/neo-\w*-\w*-libraries-debuginfo-\w*-\w*' -printf '%f')" >> "$GITHUB_ENV"
echo "dedicated=$(find . -regex '\.\/neo-\w*-\w*-dedicated-\w*-\w*' -printf '%f')" >> "$GITHUB_ENV"
echo "dedicated_debuginfo=$(find . -regex '\.\/neo-\w*-\w*-dedicated-debuginfo-\w*-\w*' -printf '%f')" >> "$GITHUB_ENV"

- name: Upload libraries
uses: actions/upload-artifact@v4
with:
name: ${{ env.libraries }}
path: ${{ env.install_dir }}/${{ env.libraries }}

- name: Upload libraries debug information
uses: actions/upload-artifact@v4
with:
name: ${{ env.libraries_debuginfo }}
path: ${{ env.install_dir }}/${{ env.libraries_debuginfo }}

- name: Upload dedicated library
uses: actions/upload-artifact@v4
with:
name: ${{ env.dedicated }}
path: ${{ env.install_dir }}/${{ env.dedicated }}

- name: Upload dedicated library debug information
uses: actions/upload-artifact@v4
with:
name: ${{ env.dedicated_debuginfo }}
path: ${{ env.install_dir }}/${{ env.dedicated_debuginfo }}

pack-resources:
name: Windows Native Resources

runs-on: windows-latest

defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
run: |
workspace_dir="${{ github.workspace }}"
source_dir=${workspace_dir//\\//}/mp/src
build_dir=${workspace_dir//\\//}/mp/src/build/windows-release
install_dir=$build_dir/install
echo "source_dir=$source_dir" >> "$GITHUB_ENV"
echo "build_dir=$build_dir" >> "$GITHUB_ENV"
echo "install_dir=$install_dir" >> "$GITHUB_ENV"

- name: Install packages
run: choco install -y ninja

- uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86

# Resources

- name: CMake configure resources build
working-directory: ${{ env.source_dir }}
run: >
cmake
--preset windows-release
-DCMAKE_INSTALL_PREFIX=${{ env.install_dir }}
-DNEO_USE_CCACHE=OFF
-DNEO_COPY_LIBRARIES=OFF
-DNEO_INSTALL_LIBRARIES=OFF
-DNEO_INSTALL_RESOURCES=ON

- name: Install resources
run: cmake --install ${{ env.build_dir }}

- name: Get artifact name
working-directory: ${{ env.install_dir }}
run: echo "resources=$(echo neo-*-*-resources)" >> "$GITHUB_ENV"

- name: Upload resources
uses: actions/upload-artifact@v4
with:
name: ${{ env.resources }}
path: ${{ env.install_dir }}/${{ env.resources }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,4 @@ mp/game/neo/cfg/sourcemod

# Auto-generated by CMake
mp/game/neo/resource/GameMenu.res
mp/src/game/shared/neo/neo_version_info.h
mp/src/game/shared/neo/neo_version_info.cpp
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Ochii's impressive [reverse engineering project](https://github.com/Ochii/neotok

### Current: CMake

This project currently use the [CMake](https://cmake.org/) build system to generate ninja/makefiles and is integrated with IDEs such as VS2022 and qtcreator. When modifying the project file structure, look into `CMakeLists.txt` and `cmake/*.cmake`.
This project currently use the [CMake](https://cmake.org/) build system to generate ninja/makefiles and is integrated with IDEs such as VS2022 and Qt Creator. When modifying the project file structure, look into `CMakeLists.txt` and `cmake/*.cmake`.

### Legacy: Solutions/makefiles

Expand Down
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ NT;RE can be built using [VS2022 IDE](#visual-studio-2022-windows), [Qt Creator
#### Visual Studio 2022 (Windows)
1. Open up VS2022 without a project, then go to: `File > Open > CMake...`
2. Open the `CMakeLists.txt` found in `mp\src`
3. In the top section, you may see "x64-Debug"/"x64-Release" as a selected profile. This needs to be changed to "x86-Debug"/"x86-Release" as this is a 32-bit project. To do so...
4. Click on the dropdown, go to: "Manage Configurations..."
5. Click the green plus button and select "x86-Debug" for debug or "x86-Release" for release mode and apply the configuration.
6. Then make sure to change it over to "x86-Debug" or "x86-Release".
7. In the "Solution Explorer", it'll be under the "Folder View". To switch to the CMake view, right-click and click on "Switch to CMake Targets View".
3. To switch to the CMake view, right-click and click on "Switch to CMake Targets View" in the "Solution Explorer", it'll be under the "Folder View".

After that, it should be able to compile. For debugger/run CMake configuration, refer to: [CONTRIBUTING.md - Debugging - VS2022 + CMake (Windows)](CONTRIBUTING.md#vs2022--cmake-windows).

#### Qt Creator (Linux)
1. On the "Welcome" screen, click on "Open Project..."
2. Open the `CMakeLists.txt` found in `mp/src`
3. It may ask about kit configuration, tick both Debug and Release configuration and set their build directories ending in "...build/debug" and "...build/release" respectively.
4. By default, the build is not done in parallel but rather sequentiality. Note, parallel builds at the default setting could deadlock the system or make it unresponsive during the process. Available since CMake 3.12, the amount of jobs can be tweaked using `--parallel <jobs>` where `<jobs>` is a number to specify parallel build level, or just simply don't apply it to turn it off. To turn on parallel builds in Qt Creator: On the "Projects" screen, in [YOUR KIT (under Build & Run)] > Build, go to "Build Steps" section, expand by clicking on "Details", and add `--parallel` to the CMake arguments.
3. By default, the build is not done in parallel but rather sequentiality. Note, parallel builds at the default setting could deadlock the system or make it unresponsive during the process. Available since CMake 3.12, the amount of jobs can be tweaked using `--parallel <jobs>` where `<jobs>` is a number to specify parallel build level, or just simply don't apply it to turn it off. To turn on parallel builds in Qt Creator: On the "Projects" screen, in [YOUR KIT (under Build & Run)] > Build, go to "Build Steps" section, expand by clicking on "Details", and add `--parallel` to the CMake arguments.

After that, it should be able to compile. For debugger/running configuration, refer to: [CONTRIBUTING.md - Debugging - Qt Creator (Linux)](CONTRIBUTING.md#qt-creator-linux)

Expand Down Expand Up @@ -83,16 +78,12 @@ Using with the ninja build system, to build NT;RE using the CLI can be done with

```
$ cd /PATH_TO_REPO/neo/mp/src

$ # To build in Release mode:
$ cmake -S . -B build/release -G Ninja -DCMAKE_BUILD_TYPE=Release
$ cmake --build build/release --parallel

$ # To build in Debug mode:
$ cmake -S . -B build/debug -G Ninja
$ cmake --build build/debug --parallel
$ cmake --preset PRESET_NAME
$ cmake --build --preset PRESET_NAME
```

Available PRESET_NAME values: `windows-debug`, `windows-release`, `linux-debug`, `linux-release`.

## Steam mod setup
To make it appear in Steam, the install files have to appear under the sourcemods directory or
be directed to it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
"13"
{
"label" "Build @BUILD_DATE@_@GIT_HASH@ (@OS_BUILD@)"
"label" "Build @BUILD_DATE_SHORT@_@GIT_HASH@ (@OS_BUILD@)"
"command" ""
}
}
Expand Down
Loading