Skip to content

Commit

Permalink
Add workflows/build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Oct 10, 2023
1 parent c94d5df commit 33c4062
Show file tree
Hide file tree
Showing 16 changed files with 853 additions and 76 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: C/C++ CI

on:
push:
branches: [master]
paths-ignore:
- '**.md'

pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]

jobs:
windows:
name: 'Windows'
runs-on: windows-2019

env:
solution: 'msvc/resemiclip.sln'
buildPlatform: 'Win32'
buildRelease: 'Release'

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1.3
with:
vs-version: '16.8'

- name: Build
run: |
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
- name: Copy Binary files
run: |
mkdir publish\addons\resemiclip
move msvc\${{ env.buildRelease }}\resemiclip_mm.dll publish\addons\resemiclip\resemiclip_mm.dll
- name: Deploy artifacts
uses: actions/upload-artifact@v3.1.1
with:
name: win32
path: publish/*

linux:
name: 'Linux'
runs-on: ubuntu-latest
container: s1lentq/linux86buildtools:latest
outputs:
app-version: ${{ steps.app-version.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build using Intel C++ Compiler 19.0
run: |
rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8
- name: Reading appversion.h
id: app-version
run: |
if [ -e "version/appversion.h" ]; then
APP_VERSION=$(cat "version/appversion.h" | grep -wi '#define APP_VERSION_STRD' | sed -e 's/#define APP_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
if [ $? -ne 0 ]; then
APP_VERSION=""
else
# Remove quotes
APP_VERSION=$(echo $APP_VERSION | xargs)
fi
fi
echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Prepare Config files
run: |
mkdir -p publish/addons/resemiclip
rsync -a dist/ publish/addons/resemiclip/
- name: Copy Binary files
run: |
mv build/resemiclip_mm_i386.so publish/addons/resemiclip/resemiclip_mm_i386.so
- name: Deploy artifacts
uses: actions/upload-artifact@v3.1.1
id: upload-job
with:
name: linux32
path: publish/*

publish:
name: 'Publish'
runs-on: ubuntu-latest
needs: [windows, linux]

steps:
- name: Deploying linux artifacts
uses: actions/download-artifact@v3
with:
name: linux32

- name: Deploying windows artifacts
uses: actions/download-artifact@v3
with:
name: win32

- name: Packaging binaries
id: packaging-job
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
run: |
7z a -tzip resemiclip-${{ needs.linux.outputs.app-version }}.zip addons/
- name: Publish artifacts
uses: softprops/action-gh-release@v1
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging-job.outcome == 'success'
with:
files: |
*.zip
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
*.iml
/build
**/msvc/ipch
**/msvc/Debug*
**/msvc/Release*
Expand All @@ -13,3 +14,4 @@
**/msvc/*.txt
**/msvc/*.db
**/*.log
**/version/appversion.h
170 changes: 170 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#----------------------------------------
# 1. Preparing build:
# rm -rf build
# mkdir build && cd build
#
# 2. Select compiler and build it
# - Compile with Clang:
# CC="clang" CXX="clang++" cmake ..
# make
#
# - Compile with Intel C++ Compiler:
# CC="icc" CXX="icpc" cmake ..
# make
#
# - Compile with GCC Compiler:
# cmake ..
# make
#----------------------------------------

cmake_minimum_required(VERSION 3.1)
project(resemiclip CXX)

option(DEBUG "Build with debug information." OFF)
option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Avoid -fPIC option
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")

set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE")
set(LINK_FLAGS "-m32 -s")

set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-builtin -Wno-unknown-pragmas")

# Remove noxref code and data
set(COMPILE_FLAGS "${COMPILE_FLAGS} -ffunction-sections -fdata-sections")

if (DEBUG)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb")
else()
set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector")
endif()

# Check Intel C++ compiler
if ("$ENV{CXX}" MATCHES "icpc")
#
# -fp-model=precise
# ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations
# https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html#fp-model-fp_GUID-99936BBA-1508-4E9F-AC09-FA98613CE2F5
#
set(COMPILE_FLAGS "${COMPILE_FLAGS} \
-fp-model=precise\
-Qoption,cpp,--treat_func_as_string_literal_cpp\
-inline-forceinline\
-no-ansi-alias")

set(LINK_FLAGS "${LINK_FLAGS} \
-static-intel\
-no-intel-extensions")

if (NOT DEBUG)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo")
set(LINK_FLAGS "${LINK_FLAGS} -ipo")
endif()
else()
# Produce code optimized for the most common IA32/AMD64/EM64T processors.
# As new processors are deployed in the marketplace, the behavior of this option will change.
set(COMPILE_FLAGS "${COMPILE_FLAGS} \
-mtune=generic -msse3\
-Wno-write-strings\
-fno-sized-deallocation -Wno-strict-aliasing")
endif()

# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none")
endif()

if (NOT DEBUG)
set(LINK_FLAGS "${LINK_FLAGS} \
-Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/version_script.lds\"")
endif()

set(PROJECT_SRC_DIR
"${PROJECT_SOURCE_DIR}/"
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/version"
)

set(PROJECT_CSSDK_DIR
"${PROJECT_SOURCE_DIR}/cssdk/common"
"${PROJECT_SOURCE_DIR}/cssdk/dlls"
"${PROJECT_SOURCE_DIR}/cssdk/engine"
"${PROJECT_SOURCE_DIR}/cssdk/game_shared"
"${PROJECT_SOURCE_DIR}/cssdk/pm_shared"
"${PROJECT_SOURCE_DIR}/cssdk/public"
)

set(PROJECT_METAMOD_DIR
"${PROJECT_SOURCE_DIR}/metamod"
)

set(MAIN_SRCS
"src/precompiled.cpp"
"src/h_export.cpp"
"src/gamedll_api.cpp"
"src/engine_rehlds_api.cpp"
"src/meta_api.cpp"
"src/main.cpp"
"src/config.cpp"
)

set(PUBLIC_SRCS
"cssdk/public/interface.cpp"
)

add_library(resemiclip SHARED ${appversion.sh})

if (NOT TARGET appversion)
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}/")
endif()

add_dependencies(resemiclip appversion)

target_include_directories(resemiclip PRIVATE
${PROJECT_SRC_DIR}
${PROJECT_CSSDK_DIR}
${PROJECT_METAMOD_DIR}
)

target_compile_definitions(resemiclip PRIVATE
_LINUX
LINUX
NDEBUG
_GLIBCXX_USE_CXX11_ABI=0
HAVE_STRONG_TYPEDEF
_stricmp=strcasecmp
_strnicmp=strncasecmp
_vsnprintf=vsnprintf
_snprintf=snprintf
)

target_sources(resemiclip PRIVATE
${MAIN_SRCS}
${PUBLIC_SRCS}
)

target_link_libraries(resemiclip PRIVATE
dl
)

if (USE_STATIC_LIBSTDC)
target_compile_definitions(resemiclip PRIVATE BUILD_STATIC_LIBSTDC)
set(LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++")
endif()

set(LINK_FLAGS "${LINK_FLAGS} \
-Wl,-rpath,'$ORIGIN/.' \
-L${PROJECT_SOURCE_DIR}/lib/linux32")

set_target_properties(resemiclip PROPERTIES
OUTPUT_NAME resemiclip_mm_i386
PREFIX ""
COMPILE_FLAGS ${COMPILE_FLAGS}
LINK_FLAGS ${LINK_FLAGS}
POSITION_INDEPENDENT_CODE OFF
)
47 changes: 0 additions & 47 deletions Makefile

This file was deleted.

Loading

0 comments on commit 33c4062

Please sign in to comment.