chore(build): add WOW and SC1 flavors

This commit is contained in:
fallenoak 2025-08-31 14:59:26 -05:00
parent 222e3ec624
commit 62121bef6f
4 changed files with 54 additions and 18 deletions

View file

@ -4,34 +4,43 @@ on: pull_request
jobs: jobs:
build: build:
name: ${{ matrix.config.name }} name: ${{ matrix.flavor.name }} / ${{ matrix.build.os_name }} (${{ matrix.build.compiler_name }})
runs-on: ${{ matrix.config.os }} runs-on: ${{ matrix.build.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
config: build:
- name: Ubuntu Latest (GCC) - os_name: Ubuntu Latest
compiler_name: GCC
os: ubuntu-latest os: ubuntu-latest
build_type: Release build_type: Release
test_path: StormTest test_path: StormTest
cc: gcc cc: gcc
cxx: g++ cxx: g++
- name: macOS Latest (Clang) - os_name: macOS Latest
compiler_name: Clang
os: macos-latest os: macos-latest
build_type: Release build_type: Release
test_path: StormTest test_path: StormTest
cc: clang cc: clang
cxx: clang++ cxx: clang++
- name: Windows Latest (MSVC) - os_name: Windows Latest
compiler_name: MSVC
os: windows-latest os: windows-latest
build_type: Release build_type: Release
test_path: Release/StormTest test_path: Release/StormTest
cc: cl cc: cl
cxx: cl cxx: cl
flavor:
- name: WoW
define: WOW
- name: SC1
define: SC1
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -41,10 +50,10 @@ jobs:
run: mkdir build run: mkdir build
- name: Configure - name: Configure
run: cd build && cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} run: cd build && cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build.build_type }} -DWHOA_STORM_FLAVOR=${{ matrix.flavor.define}}
- name: Build - name: Build
run: cmake --build build --config ${{ matrix.config.build_type }} run: cmake --build build --config ${{ matrix.build.build_type }}
- name: Test - name: Test
run: ./build/test/${{ matrix.config.test_path }} run: ./build/test/${{ matrix.build.test_path }}

View file

@ -7,34 +7,43 @@ on:
jobs: jobs:
build: build:
name: ${{ matrix.config.name }} name: ${{ matrix.flavor.name }} / ${{ matrix.build.os_name }} (${{ matrix.build.compiler_name }})
runs-on: ${{ matrix.config.os }} runs-on: ${{ matrix.build.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
config: build:
- name: Ubuntu Latest (GCC) - os_name: Ubuntu Latest
compiler_name: GCC
os: ubuntu-latest os: ubuntu-latest
build_type: Release build_type: Release
test_path: StormTest test_path: StormTest
cc: gcc cc: gcc
cxx: g++ cxx: g++
- name: macOS Latest (Clang) - os_name: macOS Latest
compiler_name: Clang
os: macos-latest os: macos-latest
build_type: Release build_type: Release
test_path: StormTest test_path: StormTest
cc: clang cc: clang
cxx: clang++ cxx: clang++
- name: Windows Latest (MSVC) - os_name: Windows Latest
compiler_name: MSVC
os: windows-latest os: windows-latest
build_type: Release build_type: Release
test_path: Release/StormTest test_path: Release/StormTest
cc: cl cc: cl
cxx: cl cxx: cl
flavor:
- name: WoW
define: WOW
- name: SC1
define: SC1
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -44,10 +53,10 @@ jobs:
run: mkdir build run: mkdir build
- name: Configure - name: Configure
run: cd build && cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} run: cd build && cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build.build_type }} -DWHOA_STORM_FLAVOR=${{ matrix.flavor.define}}
- name: Build - name: Build
run: cmake --build build --config ${{ matrix.config.build_type }} run: cmake --build build --config ${{ matrix.build.build_type }}
- name: Test - name: Test
run: ./build/test/${{ matrix.config.test_path }} run: ./build/test/${{ matrix.build.test_path }}

View file

@ -25,6 +25,17 @@ list(APPEND CMAKE_MODULE_PATH
include(system) include(system)
# Storm flavors
if(WHOA_STORM_FLAVOR STREQUAL "SC1")
message(STATUS "Building Storm with StarCraft flavoring")
add_definitions(-DWHOA_STORM_C_CRIT_SECT_RECURSIVE)
elseif(WHOA_STORM_FLAVOR STREQUAL "WOW")
message(STATUS "Building Storm with World of Warcraft flavoring")
else()
message(STATUS "Building Storm with default flavoring")
endif()
# OS defines # OS defines
if(WHOA_SYSTEM_WIN) if(WHOA_SYSTEM_WIN)
# Avoid win32 header hell # Avoid win32 header hell

View file

@ -6,11 +6,18 @@ CCritSect::CCritSect() {
#endif #endif
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX) #if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
#if defined(WHOA_STORM_C_CRIT_SECT_RECURSIVE)
// Use of SRgnDuplicate on systems with pthreads needs recursive locking (inside s_rgntable) to prevent deadlocks.
// This behavior doesn't appear to have carried forward to World of Warcraft, probably because SCritSect was
// preferred.
pthread_mutexattr_t mutex_attr; pthread_mutexattr_t mutex_attr;
pthread_mutexattr_init(&mutex_attr); pthread_mutexattr_init(&mutex_attr);
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&this->m_critsect, &mutex_attr); pthread_mutex_init(&this->m_critsect, &mutex_attr);
#else
pthread_mutex_init(&this->m_critsect, nullptr);
#endif
#endif #endif
} }