Skip to content

Commit

Permalink
Merge latest OpenJK PR (JACoders#1173)
Browse files Browse the repository at this point in the history
* Fix up some context usage and normalise cmake options

* parallelise builds, split EternalJK steps on windows

* looks like the python shell is v2 with no f-strings

* alternative per-platform methods for obtaining the processor count

* Add UseInternalLibs cmake option to default all libs to internal

* remove unnecessary game path from create-latest step

* allow changes to CMake project files to trigger builds

(cherry picked from commit 137f55a)
  • Loading branch information
Razish authored and taysta committed Oct 10, 2023
1 parent 980da23 commit e744100
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 74 deletions.
110 changes: 51 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- beta
paths-ignore:
- "**.md"
- "*.txt"
- ".gitignore"
- "docs/*"
pull_request:
Expand All @@ -17,7 +16,6 @@ on:
- beta
paths-ignore:
- "**.md"
- "*.txt"
- ".gitignore"
- "docs/*"
release:
Expand Down Expand Up @@ -48,35 +46,36 @@ jobs:
uses: microsoft/[email protected]

- name: Create Build Environment
run: cmake -E make_directory ${{ runner.workspace }}/build
run: cmake -E make_directory ${{ github.workspace }}/build

- name: Configure CMake
shell: bash
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
run: |
OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin"
if [ "${{ matrix.portable }}" == "Portable" ]; then
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin"
OPTIONS+=" -DBuildPortableVersion=ON"
else
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin"
OPTIONS+=" -DBuildPortableVersion=OFF"
fi
cmake $GITHUB_WORKSPACE -A ${{ matrix.platform }} $OPTIONS
- name: Build
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build . --config ${{ matrix.build_type }}
run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS

- name: Install
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/build
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --install . --config ${{ matrix.build_type }}

- uses: actions/upload-artifact@v3
if: ${{ matrix.build_type == 'Release' }}
if: ${{ matrix.build_type == 'Release' }}
with:
name: TaystJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}
path: ${{ runner.workspace }}/build/bin
path: ${{ github.workspace }}/build/bin/JediAcademy
if-no-files-found: error

msvcxp:
Expand Down Expand Up @@ -114,36 +113,36 @@ jobs:
uses: microsoft/[email protected]

- name: Create Build Environment
run: cmake -E make_directory ${{ runner.workspace }}/build
run: cmake -E make_directory ${{ github.workspace }}/build

- name: Configure CMake
shell: bash
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
run: |
OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin"
if [ "${{ matrix.portable }}" == "Portable" ]; then
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin"
OPTIONS+=" -DBuildPortableVersion=ON"
else
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin"
OPTIONS+=" -DBuildPortableVersion=OFF"
fi
cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS
- name: Build
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build . --config ${{ matrix.build_type }}
run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS

- name: Install
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: |
cmake --install . --config ${{ matrix.build_type }}
run: cmake --install . --config ${{ matrix.build_type }}

- uses: actions/upload-artifact@v3
if: ${{ matrix.build_type == 'Release' }}
if: ${{ matrix.build_type == 'Release' }}
with:
name: TaystJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}
path: ${{ runner.workspace }}/build/bin
path: ${{ github.workspace }}/build/bin/JediAcademy
if-no-files-found: error

ubuntu:
Expand Down Expand Up @@ -172,52 +171,44 @@ jobs:
sudo apt-get -qq update
sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev
fi
cmake -E make_directory ${{ runner.workspace }}/build
cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
shell: bash
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
run: |
OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install"
if [ "${{ matrix.portable }}" == "Portable" ]; then
OPTIONS="-DUseInternalLibs=ON -DBuildPortableVersion=ON -DBuildDiscordRichPresence=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install"
OPTIONS+=" -DUseInternalLibs=ON -DBuildPortableVersion=ON"
else
OPTIONS="-DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DBuildDiscordRichPresence=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install"
OPTIONS+=" -DUseInternalLibs=OFF -DBuildPortableVersion=OFF"
fi
if [ ${{ matrix.arch }} == "x86" ]; then
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake
else
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS
OPTIONS+=" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake"
fi
cmake $GITHUB_WORKSPACE $OPTIONS
- name: Build
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build .
run: cmake --build . -j $(nproc)

- name: Install
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --install .

- name: Create binary archive
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/install/JediAcademy
working-directory: ${{ github.workspace }}/install/JediAcademy
shell: bash
run: |
if [ ${{ matrix.arch }} == "x86" ]; then
chmod +x eternaljk.i386
else
chmod +x eternaljk.${{ matrix.arch }}
fi
tar -zcvf TaystJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz *
run: tar -czvf TaystJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz *

- uses: actions/upload-artifact@v3
if: ${{ matrix.build_type == 'Release' }}
with:
name: TaystJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}
path: ${{runner.workspace}}/install/JediAcademy/TaystJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz
path: ${{github.workspace}}/install/JediAcademy/TaystJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz
if-no-files-found: error

macos:
Expand All @@ -236,43 +227,44 @@ jobs:
- name: Create Build Environment
run: |
brew install zlib libjpeg libpng sdl2
cmake -E make_directory ${{ runner.workspace }}/build
cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
shell: bash
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
run: |
OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install"
if [ "${{ matrix.portable }}" == "Portable" ]; then
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=ON -DBuildPortableVersion=ON -DBuildDiscordRichPresence=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install"
OPTIONS+=" -DUseInternalLibs=ON -DBuildPortableVersion=ON"
else
OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DBuildDiscordRichPresence=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install"
OPTIONS+=" -DUseInternalLibs=OFF -DBuildPortableVersion=OFF"
fi
cmake $GITHUB_WORKSPACE $OPTIONS
- name: Build
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build .
run: cmake --build . -j $(getconf _NPROCESSORS_ONLN)

- name: Install
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --install .

- name: Create binary archive
if: ${{ matrix.build_type == 'Release' }}
working-directory: ${{ runner.workspace }}/install/JediAcademy
working-directory: ${{ github.workspace }}/install/JediAcademy
shell: bash
run: |
chmod +x eternaljk.x86_64.app/Contents/MacOS/eternaljk.x86_64
tar -zcvf TaystJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz *
tar -czvf TaystJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz *
- uses: actions/upload-artifact@v3
if: ${{ matrix.build_type == 'Release' }}
with:
name: TaystJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}
path: ${{ runner.workspace }}/install/JediAcademy/TaystJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz
path: ${{ github.workspace }}/install/JediAcademy/TaystJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz
if-no-files-found: error

create-latest:
Expand All @@ -289,11 +281,11 @@ jobs:

- name: Create binary archives
run: |
7z a -r TaystJK-windows-x86.zip ./TaystJK-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*'
7z a -r TaystJK-windows-x86_64.zip ./TaystJK-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*'
mv ./TaystJK-linux-x86-Release-Non-Portable/* TaystJK-linux-x86.tar.gz
mv ./TaystJK-linux-x86_64-Release-Non-Portable/* TaystJK-linux-x86_64.tar.gz
mv ./TaystJK-macos-x86_64-Release-Non-Portable/* TaystJK-macos-x86_64.tar.gz
7z a -r TaystJK-windows-x86.zip ./TaystJK-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*'
7z a -r TaystJK-windows-x86_64.zip ./TaystJK-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*'
mv ./TaystJK-linux-x86-Release-Non-Portable/* TaystJK-linux-x86.tar.gz
mv ./TaystJK-linux-x86_64-Release-Non-Portable/* TaystJK-linux-x86_64.tar.gz
mv ./TaystJK-macos-x86_64-Release-Non-Portable/* TaystJK-macos-x86_64.tar.gz
- name: Create latest build
uses: ModeSevenIndustrialSolutions/action-automatic-releases@latest
Expand Down
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#============================================================================
# Copyright (C) 2013 - 2018, OpenJK contributors
#
#
# This file is part of the OpenJK source code.
#
#
# OpenJK is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#============================================================================
Expand Down Expand Up @@ -61,7 +61,7 @@ set(UseInternalPNGDefault OFF)
set(UseInternalJPEGDefault OFF)
set(UseInternalSDL2Default OFF)

if(WIN32)
if(UseInternalLibs OR WIN32)
set(UseInternalOpenALDefault ON)
set(UseInternalZlibDefault ON)
set(UseInternalPNGDefault ON)
Expand All @@ -70,9 +70,7 @@ if(WIN32)
endif()

if(APPLE)
set(UseInternalJPEGDefault ON)
set(UseInternalOpenALDefault ON)
set(UseInternalPNGDefault ON)
set(UseInternalJPEGDefault ON)
endif()

option(UseInternalOpenAL "If set, use bundled OpenAL." ${UseInternalOpenALDefault})
Expand Down Expand Up @@ -145,6 +143,8 @@ endif()
#=============================================================================
#
# Binary names
#
#=============================================================================
set(MPEngine "eternaljk.${Architecture}")
set(MPVanillaRenderer "rd-eternaljk_${Architecture}")
set(MPVulkanRenderer "rd-vulkan_${Architecture}")
Expand Down Expand Up @@ -200,7 +200,8 @@ if(MSVC)
set(SharedDefines ${SharedDefines} "_SCL_SECURE_NO_WARNINGS")
set(SharedDefines ${SharedDefines} "_CRT_NONSTDC_NO_DEPRECATE")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHsc /arch:SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHsc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")

Expand Down Expand Up @@ -242,7 +243,7 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M

# enable somewhat modern C++
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# enable support for multithreading
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

Expand Down
10 changes: 5 additions & 5 deletions cmake/Modules/InstallConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#============================================================================
# Copyright (C) 2015, OpenJK contributors
#
#
# This file is part of the OpenJK source code.
#
#
# OpenJK is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#============================================================================
Expand Down Expand Up @@ -55,7 +55,7 @@ if(WIN32)
set(CPACK_NSIS_PACKAGE_NAME "OpenJK")
set(CPACK_NSIS_MUI_ICON "${SharedDir}/icons/icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${SharedDir}/icons/icon.ico")
set(CPACK_NSIS_URL_INFO_ABOUT "http://openjk.org")
set(CPACK_NSIS_URL_INFO_ABOUT "https://openjk.org")

set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
Expand Down

0 comments on commit e744100

Please sign in to comment.