Skip to content

Commit

Permalink
feat: sync 1.44
Browse files Browse the repository at this point in the history
fix: no longer q3lcc
  • Loading branch information
alphagocc committed Dec 16, 2024
1 parent 67aa1b1 commit 1a657f2
Show file tree
Hide file tree
Showing 112 changed files with 7,412 additions and 3,451 deletions.
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] Short title describing issue"
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment(please complete the following information):**
- Operation System: [e.g. Windows, Linux, ...]
- Processor Architecture: [e.g. x86, x86_64, arm7, ...]
- MVDSV Version: [e.g. 0.31, 0.32, custom or specific commit build reference]
- KTX Version: [e.g. 1.37, 1.38, custom or specific commit build reference]

**Additional context**
Add any other context about the problem here.
251 changes: 251 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: main

on:
push:
# Only build branches on push, tags will be handled by 'release' job.
branches:
- '**'
pull_request:
workflow_dispatch:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target: [ linux-amd64, linux-i686, linux-armhf, linux-aarch64, windows-x64, windows-x86, qvm ]
include:
- target: linux-amd64
os: linux
arch: amd64
ext: ".so"
packages: [ ]
- target: linux-i686
os: linux
arch: i686
ext: ".so"
packages: [ "gcc-i686-linux-gnu" ]
- target: linux-armhf
os: linux
arch: armhf
ext: ".so"
packages: [ "gcc-arm-linux-gnueabihf", "libc6-dev-armhf-cross" ]
- target: linux-aarch64
os: linux
arch: aarch64
ext: ".so"
packages: [ "gcc-aarch64-linux-gnu", "libc6-dev-arm64-cross" ]
- target: windows-x64
os: windows
arch: x64
ext: ".dll"
packages: [ "gcc-mingw-w64-x86-64" ]
- target: windows-x86
os: windows
arch: x86
ext: ".dll"
packages: [ "gcc-mingw-w64-i686" ]
- target: qvm
os: linux
arch: qvm
ext: ".qvm"
packages: [ ]
container:
image: "debian:stable"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ktx

- name: Prepare Build Environemnt
run: |
apt-get -qq update
apt-get -qq install build-essential cmake ninja-build ${{ join(matrix.packages, ' ') }}
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
if: matrix.target == 'qvm'

- uses: ammaraskar/gcc-problem-matcher@0.3.0
if: matrix.target != 'qvm'

- name: Checkout q3lcc
uses: actions/checkout@v4
with:
repository: ec-/q3lcc
path: q3lcc
if: matrix.target == 'qvm'

- name: Build q3lcc
run: |
make -j ${{ steps.cpu-cores.outputs.count }} PLATFORM=$(uname -s) ARCH=$(uname -m)
mv build*/q3lcc build*/q3rcc build*/q3cpp /usr/local/bin
working-directory: q3lcc
if: matrix.target == 'qvm'

- name: Build
run: |
./build_cmake.sh ${{ matrix.target }}
mv build/*/qwprogs.* ..
working-directory: ktx

- uses: actions/upload-artifact@v4
with:
name: qwprogs-${{ matrix.target }}
path: |
qwprogs.*
compression-level: 9

verify-macos:
runs-on: macos-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: ammaraskar/gcc-problem-matcher@0.3.0

- name: Build
run: |
cmake -B builddir -S . -G Xcode -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
cmake --build builddir --config Release --parallel
verify-msvc:
runs-on: windows-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: ammaraskar/msvc-problem-matcher@0.3.0

- name: Build
run: |
cmake -B builddir -S . -G "Visual Studio 17 2022"
cmake --build builddir --config Release --parallel
upload:
needs: build
timeout-minutes: 10
runs-on: ubuntu-latest
if: github.repository == 'QW-Group/ktx' && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ktx

- name: Get release date
run: |
RELEASE_DATE=$(git log -1 --format=%cI "${{ github.ref_name }}")
echo "RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV
working-directory: ktx

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Collect GitHub release artifacts
run: |
dist_dir=$(pwd)/dist
mkdir $dist_dir
find qwprogs* -type f -exec sha256sum {} \; > "${dist_dir}/checksums.txt"
# Reset timestamp to time of tag
find qwprogs* -print0 | xargs -0r touch --date="${RELEASE_DATE}"
touch --date="${RELEASE_DATE}" "${dist_dir}/checksums.txt"
for target in qwprogs*; do
(cd $target; zip -o -9 "${dist_dir}/${target}.zip" *)
done
echo "GITHUB_ARTIFACTS=$dist_dir" >> $GITHUB_ENV
if: github.event_name == 'release'

- name: Attach artifacts to GitHub release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.GITHUB_ARTIFACTS }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release'

- name: Prepare Upload Environemnt
run: |
sudo apt-get -qq update
sudo apt-get -qq --no-install-recommends install openssh-client
- name: Setup SSH
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
shell: bash
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
- name: Prepare upload to builds.quakeworld.nu
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
shell: bash
run: |
# Build file structure for uploading
# snapshots:
# upload/snapshots/latest/$os/$arch/$filename
# upload/snapshots/$os/$arch/$prefix_$filename
# releases:
# upload/releases/latest/$os/$arch/$filename
# upload/releases/$tag/$os/$arch/$filename
upload_dir="$(pwd)/upload"
if [[ $GITHUB_REF == refs/tags/* ]]; then
main_dir="${upload_dir}/releases/${{ github.ref_name }}"
latest_dir="${upload_dir}/releases/latest"
prefix=""
else
main_dir="${upload_dir}/snapshots"
latest_dir="${upload_dir}/snapshots/latest"
date=$(TZ="Europe/Amsterdam" date "+%Y%m%d-%H%M%S")
prefix="${date}_${GITHUB_SHA::7}_"
fi
for target in qwprogs*; do
os_arch="${target#qwprogs-}"
os_arch_dir="${os_arch//-//}"
main_target_dir="${main_dir}/${os_arch_dir}"
latest_target_dir="${latest_dir}/${os_arch_dir}"
mkdir -p "${main_target_dir}" "${latest_target_dir}"
for src in $(find "${target}" -type f); do
filename=$(basename "${src}")
cp "${src}" "${main_target_dir}/${prefix}${filename}"
cp "${src}" "${latest_target_dir}/${filename}"
done
(cd "${main_target_dir}" && md5sum * > "${prefix}qwprogs.md5")
(cd "${latest_target_dir}" && md5sum * > "qwprogs.md5")
done
# Reset timestamp to time of tag
find "${upload_dir}" -print0 | xargs -0r touch --date="${RELEASE_DATE}"
echo "Artifacts to upload:"
find upload
echo
- name: Upload to builds.quakeworld.nu/ktx/snapshots
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
shell: bash
run: |
sftp -rp -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' -P ${{ secrets.SFTP_PORT }} ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/snapshots <<< $'put -rp upload/snapshots/*'
if: github.event_name == 'push'

- name: Upload to builds.quakeworld.nu/ktx/releases
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
shell: bash
run: |
sftp -rp -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' -P ${{ secrets.SFTP_PORT }} ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/releases <<< $'put -rp upload/releases/*'
if: github.event_name == 'release'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ x64/*
*.vspx
*.suobackup
*.VC.db
/.cache
42 changes: 37 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 3.9.0)
# Set project name and languge.
project(qwprogs C)

include(CheckCCompilerFlag)

set(CMAKE_COLOR_DIAGNOSTICS ON)

# CMake option for bot support, we check it below and add C preprocessor directive if required.
option(BOT_SUPPORT "Build with bot support" ON)
# Option for FTE extensions. We also have some basic support for FTE which does not controlled by this setting.
Expand Down Expand Up @@ -64,13 +68,17 @@ set(SRC_COMMON
"${DIR_SRC}/doors.c"
"${DIR_SRC}/fb_globals.c"
"${DIR_SRC}/files.c"
"${DIR_SRC}/func_bob.c"
"${DIR_SRC}/func_laser.c"
"${DIR_SRC}/g_cmd.c"
"${DIR_SRC}/globals.c"
"${DIR_SRC}/g_mem.c"
"${DIR_SRC}/grapple.c"
"${DIR_SRC}/g_spawn.c"
"${DIR_SRC}/g_userinfo.c"
"${DIR_SRC}/g_utils.c"
"${DIR_SRC}/g_syscalls_extra.c"
"${DIR_SRC}/hiprot.c"
"${DIR_SRC}/hoonymode.c"
"${DIR_SRC}/items.c"
"${DIR_SRC}/logs.c"
Expand All @@ -90,6 +98,9 @@ set(SRC_COMMON
"${DIR_SRC}/player.c"
"${DIR_SRC}/q_shared.c"
"${DIR_SRC}/race.c"
"${DIR_SRC}/rng.c"
"${DIR_SRC}/rng_gen_impl.c"
"${DIR_SRC}/rng_seed_impl.c"
"${DIR_SRC}/route_calc.c"
"${DIR_SRC}/route_fields.c"
"${DIR_SRC}/route_lookup.c"
Expand Down Expand Up @@ -142,18 +153,37 @@ if(FTESV)
endif()
# If not Miscrosoft compilator - then set additional options for linker.
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
# 4100 - unused parameter
# 4210 - using extern keyword in functions
# 4456 - shadowing locals, broadly used
# 4459 - shadowing globals, broadly used
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /wd4100 /wd4210 /wd4456 /wd4459)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--no-undefined") # Do not allow undefined symbols while linking.

check_c_compiler_flag("-Wstrict-prototypes" HAS_CFLAG_STRICT_PROTOTYPES)
if (HAS_CFLAG_STRICT_PROTOTYPES)
target_compile_options(${PROJECT_NAME} PRIVATE -Werror=strict-prototypes)
endif()

check_c_compiler_flag("-Wstrlcpy-strlcat-size" HAS_STRLCPY_STRLCAT_SIZE)
if (HAS_STRLCPY_STRLCAT_SIZE)
target_compile_options(${PROJECT_NAME} PRIVATE -Werror=strlcpy-strlcat-size)
endif()

# Do not allow undefined symbols while linking.
if(APPLE)
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,-undefined,error")
else()
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--no-undefined")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE m) # Link with libm.
endif()


# Build QVM tools.
# EXCLUDE_FROM_ALL tells to not build tools if they does not required, for example if you build native library only.
add_subdirectory(tools/q3asm EXCLUDE_FROM_ALL)
add_subdirectory(tools/q3lcc EXCLUDE_FROM_ALL)

# Set up vars for QVM library.
set(VM_DIR "vm")
Expand All @@ -166,7 +196,7 @@ set(QVM_C_FLAGS -DQ3_VM -S -Wf-target=bytecode -Wf-g)
if(BOT_SUPPORT)
set(QVM_C_FLAGS ${QVM_C_FLAGS} -DBOT_SUPPORT=1)
endif()
set(QVM_INCFLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/include)
set(QVM_INCDIR "${CMAKE_CURRENT_SOURCE_DIR}/include")

# Write first chunk of QVM_LIST_FILE.
set(QVM_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/game.q3asm")
Expand All @@ -178,9 +208,11 @@ foreach(file ${SRC_COMMON} ${SRC_VM})
string(CONCAT file_asm ${file_asm} ".asm") # Add asm extension.
list(APPEND SRC_ASM ${file_asm}) # Fill in SRC_ASM list.
file(APPEND ${QVM_LIST_FILE} "${VM_DIR}/${file_asm}\n") # Continue generate QVM_LIST_FILE.
get_filename_component(src_dir ${file} DIRECTORY)
file(RELATIVE_PATH QVM_RELINCDIR "${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}" "${QVM_INCDIR}")
# Add command to compile c to asm.
add_custom_target(${file_asm}
COMMAND ${QVM_COMPILER} ${QVM_C_FLAGS} ${QVM_INCFLAGS} "${CMAKE_CURRENT_SOURCE_DIR}/${file}" -o "${VM_DIR}/${file_asm}"
COMMAND ${QVM_COMPILER} ${QVM_C_FLAGS} -I${QVM_RELINCDIR} "${CMAKE_CURRENT_SOURCE_DIR}/${file}" -o "${VM_DIR}/${file_asm}"
DEPENDS vmdir
SOURCES ${file}
)
Expand Down
Loading

0 comments on commit 1a657f2

Please sign in to comment.