mirror of
https://github.com/WPMGPRoSToTeMa/SafeNameAndChat.git
synced 2025-02-12 06:48:49 +03:00
Migrated the CI/CD to GitHub Actions (#3)
Migrates the project's CI/CD to GitHub Actions from Travis CI. Adds CMake support along with the improved build script for Linux builds and adds `README.md` with build steps. Co-authored-by: Artem Golubikhin <wpmgprostotema@live.ru>
This commit is contained in:
parent
614a6496d7
commit
837c731ab4
105
.github/workflows/build.yml
vendored
Normal file
105
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
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-latest
|
||||
|
||||
env:
|
||||
solution: 'SafeNameAndChat.sln'
|
||||
buildPlatform: 'x86'
|
||||
buildRelease: 'Release'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- 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: Move files
|
||||
run: |
|
||||
mkdir publish\bin\win32
|
||||
move ${{ env.buildRelease }}\SafeNameAndChat.dll publish\bin\win32\SafeNameAndChat.dll
|
||||
|
||||
- name: Deploy artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: win32
|
||||
path: publish/*
|
||||
|
||||
linux:
|
||||
name: 'Linux'
|
||||
runs-on: ubuntu-latest
|
||||
container: s1lentq/linux86buildtools:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get install -y g++-8 g++-8-multilib
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
rm -rf build && CC=gcc-8 CXX=g++-8 cmake -B build -DUSE_STATIC_LIBSTDC=ON && cmake --build build -j8
|
||||
|
||||
- name: Move files
|
||||
run: |
|
||||
mkdir -p publish/bin/linux32
|
||||
mv build/SafeNameAndChat.so publish/bin/linux32/SafeNameAndChat.so
|
||||
|
||||
- name: Deploy artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
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@v2
|
||||
with:
|
||||
name: linux32
|
||||
|
||||
- name: Deploying windows artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: win32
|
||||
|
||||
- name: Publish artifacts
|
||||
uses: softprops/action-gh-release@v1
|
||||
id: publish-job
|
||||
if: |
|
||||
github.event_name == 'release' &&
|
||||
github.event.action == 'published' &&
|
||||
startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
bin/linux32/SafeNameAndChat.so
|
||||
bin/win32/SafeNameAndChat.dll
|
41
.travis.yml
41
.travis.yml
@ -1,41 +0,0 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
language: cpp
|
||||
os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- linux-libc-dev:i386
|
||||
- g++-8
|
||||
- g++-8-multilib
|
||||
- cmake
|
||||
- freebsd-buildutils
|
||||
before_install: eval "CC=gcc-8 && CXX=g++-8"
|
||||
script:
|
||||
# Why do we need -fno-gnu-unique?
|
||||
# These params disable "global unique objects" generated for currently compiled code
|
||||
#
|
||||
# -fuse-ld=gold -Wl,--no-gnu-unique
|
||||
# These params disable "global unique objects" for already compiled object files, so there will be no UNIQUE in result binary
|
||||
# You need to use these params if you're exporting symbols from object files not compiled with -fno-gnu-unique
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60348#c5
|
||||
# BTW -fuse-ld=gold always (sure?) produce binary with SVR4 brand, but we can change it by brandelf anyway
|
||||
# Also idk what also the gold linker affects in result binary, there is about 5KB diff
|
||||
#
|
||||
# TODO: -flto & its issues with hiding symbols
|
||||
# If static library is compiled with -flto, its exported symbols may be exported even if you have version script file
|
||||
# There is a command for linker fixes that issue, but I forgot it
|
||||
#
|
||||
# Also looks like I'm having some issues with -ldl importing, hmm... (IDA doesn't display required glibc version for imported functions)
|
||||
- ${CXX} Main.cpp -m32 -O3 -shared -std=c++14 -s -static-libgcc -static-libstdc++ -fvisibility=hidden -fpermissive -Ihlsdk/common -Ihlsdk/dlls -Ihlsdk/engine -Ihlsdk/pm_shared -Imetamod -ldl -o SafeNameAndChat.so -fdata-sections -ffunction-sections -Wl,--version-script=version_script.lds -Wl,--gc-sections -fno-gnu-unique
|
||||
- brandelf SafeNameAndChat.so -t SVR4
|
||||
deploy:
|
||||
provider: releases
|
||||
file: SafeNameAndChat.so
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
api_key: '$GITHUB_API_KEY'
|
||||
on:
|
||||
tags: true
|
114
CMakeLists.txt
Normal file
114
CMakeLists.txt
Normal file
@ -0,0 +1,114 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(snac 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 -rdynamic -fPIC options
|
||||
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||
|
||||
set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE")
|
||||
set(LINK_FLAGS "-m32")
|
||||
|
||||
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()
|
||||
|
||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} -msse2 -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections")
|
||||
|
||||
# Check Intel C++ compiler
|
||||
if ("$ENV{CXX}" MATCHES "icpc")
|
||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} \
|
||||
-fp-model=strict\
|
||||
-fasm-blocks\
|
||||
-fomit-frame-pointer\
|
||||
-Qoption,cpp,--treat_func_as_string_literal_cpp")
|
||||
|
||||
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} -fpermissive -fno-sized-deallocation")
|
||||
|
||||
# Check if not Clang compiler
|
||||
if (NOT "$ENV{CXX}" MATCHES "clang")
|
||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} -fno-gnu-unique")
|
||||
endif()
|
||||
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} \
|
||||
-s -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/version_script.lds\"")
|
||||
endif()
|
||||
|
||||
set(PROJECT_PUBLIC_DIR
|
||||
"${PROJECT_SOURCE_DIR}/hlsdk/common"
|
||||
"${PROJECT_SOURCE_DIR}/hlsdk/dlls"
|
||||
"${PROJECT_SOURCE_DIR}/hlsdk/engine"
|
||||
"${PROJECT_SOURCE_DIR}/hlsdk/pm_shared"
|
||||
"${PROJECT_SOURCE_DIR}/metamod"
|
||||
)
|
||||
|
||||
set(MAIN_SRCS
|
||||
"Main.cpp"
|
||||
)
|
||||
|
||||
add_library(snac SHARED)
|
||||
|
||||
target_include_directories(snac PRIVATE
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_PUBLIC_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(snac PRIVATE
|
||||
_LINUX
|
||||
LINUX
|
||||
NDEBUG
|
||||
_GLIBCXX_USE_CXX11_ABI=0
|
||||
)
|
||||
|
||||
target_sources(snac PRIVATE
|
||||
${MAIN_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(snac PRIVATE
|
||||
rt
|
||||
m
|
||||
dl
|
||||
)
|
||||
|
||||
if (USE_STATIC_LIBSTDC)
|
||||
target_compile_definitions(snac PRIVATE BUILD_STATIC_LIBSTDC)
|
||||
set(LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++")
|
||||
endif()
|
||||
|
||||
set_target_properties(snac PROPERTIES
|
||||
OUTPUT_NAME SafeNameAndChat
|
||||
PREFIX ""
|
||||
COMPILE_FLAGS ${COMPILE_FLAGS}
|
||||
LINK_FLAGS ${LINK_FLAGS}
|
||||
POSITION_INDEPENDENT_CODE OFF
|
||||
)
|
10
Compile.sh
10
Compile.sh
@ -1,10 +0,0 @@
|
||||
/opt/intel/bin/icpc \
|
||||
-O3 -m32 -shared \
|
||||
-fno-builtin -fno-rtti -Qoption,cpp,--treat_func_as_string_literal_cpp -no-intel-extensions -fno-stack-protector -std=c++14 \
|
||||
-ipo -s -static-libgcc -static-intel -static-libstdc++ \
|
||||
-msse2 -fp-model strict -fomit-frame-pointer -g0 \
|
||||
-fvisibility=hidden \
|
||||
-Ihlsdk/common -Ihlsdk/dlls -Ihlsdk/engine -Ihlsdk/pm_shared -Imetamod \
|
||||
Main.cpp \
|
||||
-lrt -ldl -lm \
|
||||
-o SafeNameAndChat.so
|
69
README.md
Normal file
69
README.md
Normal file
@ -0,0 +1,69 @@
|
||||
# SafeNameAndChat [![Download](https://camo.githubusercontent.com/1c836b9a3bc97bddd0d35f531833ce0eab6f1a82c69bc47987a3068b4d1197ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f57504d4750526f53546f54654d612f536166654e616d65416e64436861742e737667)](https://github.com/WPMGPRoSToTeMa/SafeNameAndChat/releases/latest) [![Downloads](https://camo.githubusercontent.com/d12eaaf6643e932e38e267852f633a581423216858bc1bb7ab7bfa9d1654f419/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f57504d4750526f53546f54654d612f536166654e616d65416e64436861742f746f74616c3f636f6c6f723d696d706f7274616e74)]() [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
|
||||
|
||||
## Build instructions
|
||||
### Checking requirements
|
||||
There are several software requirements for building SafeNameAndChat:
|
||||
|
||||
#### Windows
|
||||
<pre>
|
||||
Visual Studio 2015 (C++14 standard) and later
|
||||
</pre>
|
||||
|
||||
#### Linux
|
||||
<pre>
|
||||
git >= 1.8.5
|
||||
cmake >= 3.10
|
||||
GCC >= 4.9.2 (Optional)
|
||||
ICC >= 15.0.1 20141023 (Optional)
|
||||
LLVM (Clang) >= 6.0 (Optional)
|
||||
</pre>
|
||||
|
||||
### Building
|
||||
|
||||
#### Windows
|
||||
Use `Visual Studio` to build, open `SafeNameAndChat.sln` and just select from the solution configurations list `Release` or `Debug` and platform x86
|
||||
|
||||
#### Linux
|
||||
|
||||
* Optional options using `build.sh --compiler=[gcc] --jobs=[N] -D[option]=[ON or OFF]` (without square brackets)
|
||||
|
||||
<pre>
|
||||
-c=|--compiler=[icc|gcc|clang] - Select preferred C/C++ compiler to build
|
||||
-j=|--jobs=[N] - Specifies the number of jobs (commands) to run simultaneously (For faster building)
|
||||
|
||||
<sub>Definitions (-D)</sub>
|
||||
DEBUG - Enables debugging mode
|
||||
USE_STATIC_LIBSTDC - Enables static linking library libstdc++
|
||||
</pre>
|
||||
|
||||
* ICC <pre>./build.sh --compiler=intel</pre>
|
||||
* LLVM (Clang) <pre>./build.sh --compiler=clang</pre>
|
||||
* GCC <pre>./build.sh --compiler=gcc</pre>
|
||||
|
||||
##### Checking build environment (Debian / Ubuntu)
|
||||
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Installing required packages
|
||||
<pre>
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-multilib g++-multilib
|
||||
sudo apt-get install -y build-essential
|
||||
sudo apt-get install -y libc6-dev libc6-dev-i386
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Select the preferred C/C++ Compiler installation
|
||||
<pre>
|
||||
1) sudo apt-get install -y gcc g++
|
||||
2) sudo apt-get install -y clang
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</details>
|
60
build.sh
Executable file
60
build.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
main()
|
||||
{
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
|
||||
if [[ "$*" =~ "--help" ]]; then
|
||||
help
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
n=0
|
||||
args=()
|
||||
for i in "$@"
|
||||
do
|
||||
case $i in
|
||||
-j=*|--jobs=*)
|
||||
jobs="-j${i#*=}"
|
||||
shift
|
||||
;;
|
||||
-c=*|--compiler=*)
|
||||
C="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
args[$n]="$i"
|
||||
((++n))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$C" in
|
||||
("intel"|"icc") CC=icc CXX=icpc ;;
|
||||
("gcc"|"g++") CC=gcc CXX=g++ ;;
|
||||
("clang|llvm") CC=clang CXX=clang++ ;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
pushd build &> /dev/null
|
||||
CC=$CC CXX=$CXX cmake ${args[@]} ..
|
||||
make ${jobs}
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
printf "Usage: ./build.sh <options>\n\n"
|
||||
printf " -c= | --compiler=<icc|gcc|clang> - Select preferred C/C++ compiler to build\n"
|
||||
printf " -j= | --jobs=<N> - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
|
||||
}
|
||||
|
||||
# Initialize
|
||||
main $*
|
||||
|
||||
# Exit normally
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user