From 1464adf1dec84a0d4b816715ab96a4dcc2c9ce77 Mon Sep 17 00:00:00 2001 From: cypress Date: Tue, 21 Nov 2023 15:14:50 -0500 Subject: [PATCH] Enable compilation via MINGW, upload all artifacts --- .github/workflows/.github.yml | 89 +++++++++++++++++++++++------------ Makefile | 68 +++++++++++++++++++------- README.md | 2 +- common/cmdlib.h | 2 + common/threads.cpp | 5 +- 5 files changed, 119 insertions(+), 47 deletions(-) diff --git a/.github/workflows/.github.yml b/.github/workflows/.github.yml index 0835983..2e3c25f 100644 --- a/.github/workflows/.github.yml +++ b/.github/workflows/.github.yml @@ -3,40 +3,71 @@ name: build on: [push, pull_request] jobs: - linux_builds: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - cxx: [g++, clang++] + linux_build: + runs-on: ubuntu-latest env: - CXX: ${{ matrix.cxx }} + CXX: g++ + steps: + - name: Install 32-bit libraries + run: | + sudo apt update && sudo apt install -y g++-multilib + - name: Checkout + uses: actions/checkout@v3 + - name: Build 64 bit + run: | + make -j8 + - name: Archive vhlt Linux64 tools + uses: actions/upload-artifact@v3 + with: + name: vhlt-linux64-tools + path: ./bin/* + - name: Build 32 bit + run: | + make clean + make -j8 USER_FLAGS="-m32" + - name: Archive vhlt Linux32 tools + uses: actions/upload-artifact@v3 + with: + name: vhlt-linux32-tools + path: ./bin/* + + macos_build: + runs-on: macos-latest + env: + CXX: clang++ steps: - name: Checkout uses: actions/checkout@v3 - name: Build run: | - make - - windows_build: - runs-on: windows-latest - - env: - SOLUTION_FILE_PATH: . - BUILD_CONFIGURATION: Release - - steps: - - uses: actions/checkout@v3 - - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1.1 - - - name: Build vhlt Windows tools - working-directory: ${{env.GITHUB_WORKSPACE}} - run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} - - - name: Archive vhlt Windows tools + make -j8 + - name: Archive vhlt macOS tools uses: actions/upload-artifact@v3 with: - name: vhlt-windows-tools - path: D:\a\vhlt\bin\* + name: vhlt-macos-tools + path: ./bin/* + + windows_build: + runs-on: ubuntu-latest + steps: + - name: Install mingw64 + run: | + sudo apt update && sudo apt install -y build-essential g++-multilib mingw-w64 + - name: Checkout + uses: actions/checkout@v3 + - name: Build 32 bit + run: | + make -j8 CXX="i686-w64-mingw32-g++" USER_FLAGS="-w -static" + - name: Archive vhlt Windows32 tools + uses: actions/upload-artifact@v3 + with: + name: vhlt-windows32-tools + path: ./bin/* + - name: Build 64 bit + run: | + make clean && make -j8 CXX="x86_64-w64-mingw32-g++" USER_FLAGS="-w -static" + - name: Archive vhlt Windows64 tools + uses: actions/upload-artifact@v3 + with: + name: vhlt-windows64-tools + path: ./bin/* \ No newline at end of file diff --git a/Makefile b/Makefile index 7ad7fe0..d2b3f89 100644 --- a/Makefile +++ b/Makefile @@ -75,17 +75,53 @@ COMMON_INCLUDEFILES = \ common/win32fix.h \ common/winding.h \ -COMMON_DEFINITIONS = \ - VERSION_LINUX \ - SYSTEM_POSIX \ - NDEBUG \ - STDC_HEADERS \ - HAVE_FCNTL_H \ - HAVE_PTHREAD_H \ - HAVE_SYS_RESOURCE_H \ - HAVE_SYS_STAT_H \ - HAVE_SYS_TIME_H \ - HAVE_UNISTD_H \ +ifeq ($(CXX),x86_64-w64-mingw32-g++) + HLCSG_NAME = hlcsg.exe + HLBSP_NAME = hlbsp.exe + HLRAD_NAME = hlrad.exe + HLVIS_NAME = hlvis.exe + RIPENT_NAME = ripent.exe + + COMMON_DEFINITIONS = \ + VERSION_64BIT \ + NDEBUG \ + WIN32 \ + _CONSOLE \ + SYSTEM_WIN32 \ + STDC_HEADERS +else ifeq ($(CXX),i686-w64-mingw32-g++) + HLCSG_NAME = hlcsg.exe + HLBSP_NAME = hlbsp.exe + HLRAD_NAME = hlrad.exe + HLVIS_NAME = hlvis.exe + RIPENT_NAME = ripent.exe + + COMMON_DEFINITIONS = \ + VERSION_32BIT \ + NDEBUG \ + WIN32 \ + _CONSOLE \ + SYSTEM_WIN32 \ + STDC_HEADERS +else + HLCSG_NAME = hlcsg + HLBSP_NAME = hlbsp + HLRAD_NAME = hlrad + HLVIS_NAME = hlvis + RIPENT_NAME = ripent + + COMMON_DEFINITIONS = \ + VERSION_LINUX \ + SYSTEM_POSIX \ + NDEBUG \ + STDC_HEADERS \ + HAVE_FCNTL_H \ + HAVE_PTHREAD_H \ + HAVE_SYS_RESOURCE_H \ + HAVE_SYS_STAT_H \ + HAVE_SYS_TIME_H \ + HAVE_UNISTD_H +endif COMMON_FLAGS = -Wall -Wno-deprecated-declarations -O2 -fno-strict-aliasing -pthread -pipe $(USER_FLAGS) @@ -246,7 +282,7 @@ bin/hlcsg : $(HLCSG_CPPFILES:%.cpp=hlcsg/release/%.o) printusage mkdir -p hlcsg/release/bin $(CXX) $(COMMON_FLAGS) -o hlcsg/release/bin/hlcsg $(addprefix -I,$(HLCSG_INCLUDEDIRS)) $(addprefix -D,$(HLCSG_DEFINITIONS)) $(HLCSG_CPPFILES:%.cpp=hlcsg/release/%.o) mkdir -p bin - cp hlcsg/release/bin/hlcsg bin/hlcsg + cp hlcsg/release/bin/$(HLCSG_NAME) bin/$(HLCSG_NAME) $(HLCSG_CPPFILES:%.cpp=hlcsg/release/%.o) : hlcsg/release/%.o : %.cpp $(HLCSG_INCLUDEFILES) printusage @echo ======== hlcsg : compiling $< ======== @@ -258,7 +294,7 @@ bin/hlbsp : $(HLBSP_CPPFILES:%.cpp=hlbsp/release/%.o) printusage mkdir -p hlbsp/release/bin $(CXX) $(COMMON_FLAGS) -o hlbsp/release/bin/hlbsp $(addprefix -I,$(HLBSP_INCLUDEDIRS)) $(addprefix -D,$(HLBSP_DEFINITIONS)) $(HLBSP_CPPFILES:%.cpp=hlbsp/release/%.o) mkdir -p bin - cp hlbsp/release/bin/hlbsp bin/hlbsp + cp hlbsp/release/bin/$(HLBSP_NAME) bin/$(HLBSP_NAME) $(HLBSP_CPPFILES:%.cpp=hlbsp/release/%.o) : hlbsp/release/%.o : %.cpp $(HLBSP_INCLUDEFILES) printusage @echo ======== hlbsp : compiling $< ======== @@ -270,7 +306,7 @@ bin/hlvis : $(HLVIS_CPPFILES:%.cpp=hlvis/release/%.o) printusage mkdir -p hlvis/release/bin $(CXX) $(COMMON_FLAGS) -o hlvis/release/bin/hlvis $(addprefix -I,$(HLVIS_INCLUDEDIRS)) $(addprefix -D,$(HLVIS_DEFINITIONS)) $(HLVIS_CPPFILES:%.cpp=hlvis/release/%.o) mkdir -p bin - cp hlvis/release/bin/hlvis bin/hlvis + cp hlvis/release/bin/$(HLVIS_NAME) bin/$(HLVIS_NAME) $(HLVIS_CPPFILES:%.cpp=hlvis/release/%.o) : hlvis/release/%.o : %.cpp $(HLVIS_INCLUDEFILES) printusage @echo ======== hlvis : compiling $< ======== @@ -282,7 +318,7 @@ bin/hlrad : $(HLRAD_CPPFILES:%.cpp=hlrad/release/%.o) printusage mkdir -p hlrad/release/bin $(CXX) $(COMMON_FLAGS) -o hlrad/release/bin/hlrad $(addprefix -I,$(HLRAD_INCLUDEDIRS)) $(addprefix -D,$(HLRAD_DEFINITIONS)) $(HLRAD_CPPFILES:%.cpp=hlrad/release/%.o) mkdir -p bin - cp hlrad/release/bin/hlrad bin/hlrad + cp hlrad/release/bin/$(HLRAD_NAME) bin/$(HLRAD_NAME) $(HLRAD_CPPFILES:%.cpp=hlrad/release/%.o) : hlrad/release/%.o : %.cpp $(HLRAD_INCLUDEFILES) printusage @echo ======== hlrad : compiling $< ======== @@ -294,7 +330,7 @@ bin/ripent : $(RIPENT_CPPFILES:%.cpp=ripent/release/%.o) printusage mkdir -p ripent/release/bin $(CXX) $(COMMON_FLAGS) -o ripent/release/bin/ripent $(addprefix -I,$(RIPENT_INCLUDEDIRS)) $(addprefix -D,$(RIPENT_DEFINITIONS)) $(RIPENT_CPPFILES:%.cpp=ripent/release/%.o) mkdir -p bin - cp ripent/release/bin/ripent bin/ripent + cp ripent/release/bin/$(RIPENT_NAME) bin/$(RIPENT_NAME) $(RIPENT_CPPFILES:%.cpp=ripent/release/%.o) : ripent/release/%.o : %.cpp $(RIPENT_INCLUDEFILES) printusage @echo ======== ripent : compiling $< ======== diff --git a/README.md b/README.md index ebf9533..5a962f4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Custom Zoner's Half-Life Tools created by vluzacn. This is not my project, I jus If you want to pass additional flags to make: - make USER_FLAGS="your flags" + make USER_FLAGS="your-flags" Example: diff --git a/common/cmdlib.h b/common/cmdlib.h index 2e1513d..b61f312 100644 --- a/common/cmdlib.h +++ b/common/cmdlib.h @@ -600,6 +600,7 @@ #endif //===================================================================== +#ifndef __MINGW32__ #if _MSC_VER <1400 #define strcpy_s strcpy //--vluzacn #define sprintf_s sprintf //--vluzacn @@ -607,6 +608,7 @@ #if _MSC_VER >= 1400 #pragma warning(disable: 4996) #endif +#endif //--cypress #ifdef __MINGW32__ #include diff --git a/common/threads.cpp b/common/threads.cpp index 22d1a6a..4b14e67 100644 --- a/common/threads.cpp +++ b/common/threads.cpp @@ -27,6 +27,9 @@ #endif #endif +// --cypress +#include + #include "hlassert.h" q_threadpriority g_threadpriority = DEFAULT_THREAD_PRIORITY; @@ -349,7 +352,7 @@ q_threadfunction q_entry; static DWORD WINAPI ThreadEntryStub(LPVOID pParam) { - q_entry((int)pParam); + q_entry((intptr_t)pParam); return 0; }