Added support building using cmake

Added support clang compiler
Fixed some compiler warnings
Update README.md
This commit is contained in:
s1lent 2020-02-06 04:31:59 +07:00
parent 2eba3b1186
commit d8208f0884
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
18 changed files with 451 additions and 40 deletions

View File

@ -100,7 +100,7 @@ There are several software requirements for building Regamedll_CS:
<ol>
<li>Java Development Kit (JDK) 7+ (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)</li>
<li>For Windows: Visual Studio 2015 and later</li>
<li>For Linux: Intel C++ Compiler 15 and later</li>
<li>For Linux: GCC/Clang/Intel C++ Compiler 15 and later</li>
</ol>
### Checking requirements
@ -122,19 +122,25 @@ Help -> About
icc (ICC) 15.0.1 20141023
</pre>
### Building
On Windows:
### Building and run unit tests using gradle
#### On Windows:
<pre>gradlew --max-workers=1 clean buildRelease</pre>
* For faster building without unit tests use this:exclamation:
<pre>gradlew --max-workers=1 clean buildFixes</pre>
On Linux (ICC):
#### On Linux (ICC):
<pre>./gradlew --max-workers=1 clean buildRelease</pre>
* For faster building without unit tests use this:exclamation:
<pre>./gradlew --max-workers=1 clean buildFixes</pre>
On Linux (GCC):
#### On Linux (Clang):
<pre>./gradlew --max-workers=1 clean -PuseClang buildRelease</pre>
* For faster building without unit tests use this:exclamation:
<pre>./gradlew --max-workers=1 clean -PuseClang buildFixes</pre>
#### On Linux (GCC):
<pre>./gradlew --max-workers=1 clean -PuseGcc buildRelease</pre>
* For faster building without unit tests use this:exclamation:
@ -142,6 +148,20 @@ On Linux (GCC):
Compiled binaries will be placed in the build/binaries/ directory
### Simplified building using CMake 3.1 and later
#### On Windows:
<pre>Open solution msvc\ReGameDLL.sln and build it</pre>
#### On Linux:
* Run script `regamedll/compile.sh`
* Options using `regamedll/compile.sh -D[option]=[ON or OFF]` (without square brackets)
<pre>
DEBUG - Enables debugging mode
USE_INTEL_COMPILER - Switch main compiler to ICC
USE_CLANG_COMPILER - Switch main compiler to Clang
USE_STATIC_LIBSTDC - Enables static linking library libstdc++
</pre>
### Credits
Thanks to the project [ReHLDS](https://github.com/dreamstalker/rehlds) ( ReGameDLL_CS was created on the basis of ReHLDS )

148
regamedll/CMakeLists.txt Normal file
View File

@ -0,0 +1,148 @@
cmake_minimum_required(VERSION 3.1)
project(regamedll CXX)
option(DEBUG "Build debug application." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
if (USE_INTEL_COMPILER OR USE_CLANG_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fasm-blocks")
endif()
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -ggdb -O3 -Wall -ffunction-sections -fdata-sections")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-rtti -ffunction-sections -fdata-sections")
endif()
if (USE_INTEL_COMPILER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
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(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
-mtune=generic -msse3\
-Wno-write-strings -Wno-invalid-offsetof\
-Wno-unused-variable -Wno-unused-function\
-Wno-unused-result -Wno-invalid-offsetof\
-fpermissive -Wno-switch -Wno-enum-compare\
-Wno-unknown-pragmas -Wno-unused-value")
if (USE_CLANG_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
-Wno-unused-local-typedef\
-Wno-unused-private-field\
-fno-strict-vtable-pointers\
-Wno-overloaded-virtual")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
-Wno-unused-local-typedefs\
-Wno-sign-compare\
-Wno-strict-aliasing\
-Wno-unused-but-set-variable\
-fno-devirtualize")
endif()
endif()
if (NOT DEBUG AND USE_STATIC_LIBSTDC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-gc-sections -Wl,--version-script=${PROJECT_SOURCE_DIR}/../version_script.lds")
endif()
if (USE_STATIC_LIBSTDC)
add_definitions(-DBUILD_STATIC_LIBSTDC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
set(PROJECT_SRC_DIR
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/engine"
"${PROJECT_SOURCE_DIR}/common"
"${PROJECT_SOURCE_DIR}/dlls"
"${PROJECT_SOURCE_DIR}/game_shared"
"${PROJECT_SOURCE_DIR}/pm_shared"
"${PROJECT_SOURCE_DIR}/regamedll"
)
set(PROJECT_PUBLIC_DIR
"${PROJECT_SOURCE_DIR}/public"
"${PROJECT_SOURCE_DIR}/public/regamedll"
)
set(ENGINE_SRCS
"engine/unicode_strtools.cpp"
)
file(GLOB SHARED_SRCS
"game_shared/bot/*.cpp"
"game_shared/*.cpp"
"pm_shared/*.cpp"
"regamedll/*.cpp"
"public/FileSystem.cpp"
"public/interface.cpp"
"public/MemPool.cpp"
"version/version.cpp"
)
list(REMOVE_ITEM SHARED_SRCS EXCLUDE "${PROJECT_SOURCE_DIR}/regamedll/classes_dummy.cpp")
file(GLOB GAMEDLL_SRCS
"dlls/*.cpp"
"dlls/API/*.cpp"
"dlls/addons/*.cpp"
"dlls/wpn_shared/*.cpp"
"dlls/bot/*.cpp"
"dlls/bot/states/*.cpp"
"dlls/hostage/*.cpp"
"dlls/hostage/states/*.cpp"
)
include_directories(
${PROJECT_SRC_DIR}
${PROJECT_PUBLIC_DIR}
)
link_directories(${PROJECT_SOURCE_DIR}/lib/linux32)
add_definitions(
-DREGAMEDLL_FIXES
-DBUILD_LATEST
-DREGAMEDLL_ADD
-DREGAMEDLL_API
-DUNICODE_FIXES
-DCLIENT_WEAPONS
-DUSE_QSTRING
-DGNUC
-DPOSIX
-D_LINUX
-DLINUX
-D_stricmp=strcasecmp
-D_strnicmp=strncasecmp
-D_strdup=strdup
-D_unlink=unlink
-D_vsnprintf=vsnprintf
-D_write=write
-D_close=close
-D_access=access
-D_vsnwprintf=vswprintf
)
add_library(regamedll SHARED ${appversion.sh} ${GAMEDLL_SRCS} ${ENGINE_SRCS} ${SHARED_SRCS})
set_property(TARGET regamedll PROPERTY LIBRARY_OUTPUT_NAME cs)
add_custom_target(appversion COMMAND ${PROJECT_SOURCE_DIR}/version/appversion.sh ${PROJECT_SOURCE_DIR} regamedll)
set_target_properties(regamedll PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
target_link_libraries(regamedll dl aelf32)
add_dependencies(regamedll appversion)

View File

@ -92,6 +92,7 @@ void postEvaluate(NativeBinarySpec b) {
void setupToolchain(NativeBinarySpec b)
{
boolean useGcc = project.hasProperty("useGcc")
boolean useClang = project.hasProperty("useClang")
boolean unitTestExecutable = b.component.name.endsWith('_tests')
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
@ -121,7 +122,7 @@ void setupToolchain(NativeBinarySpec b)
cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED
}
else {
cfg.compilerOptions.args '/Oi', '/GF', '/GS-', '/GR-'
cfg.compilerOptions.args '/Oi', '/GF', '/GS', '/GR'
}
cfg.projectLibpath(project, '/lib')
@ -129,7 +130,7 @@ void setupToolchain(NativeBinarySpec b)
}
else if (cfg instanceof GccToolchainConfig)
{
if (!useGcc)
if (!useGcc && !useClang)
{
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
@ -150,10 +151,17 @@ void setupToolchain(NativeBinarySpec b)
'_access' : 'access'
])
if (useGcc) {
if (useGcc || useClang) {
// 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.
cfg.compilerOptions.args '-mtune=generic', '-msse3', '-Wno-write-strings', '-Wno-invalid-offsetof', '-fpermissive', '-fno-devirtualize'
cfg.compilerOptions.args '-mtune=generic', '-msse3', '-Wno-write-strings', '-Wno-invalid-offsetof', '-fpermissive', '-Wno-switch', '-Wno-unused-value', '-Wno-enum-compare'
if (useGcc) {
cfg.compilerOptions.args '-fno-devirtualize'
else {
cfg.compilerOptions.args '-fno-strict-vtable-pointers', '-Wno-overloaded-virtual'
}
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
@ -169,7 +177,7 @@ void setupToolchain(NativeBinarySpec b)
cfg.singleDefines 'BUILD_STATIC_LIBSTDC'
}
cfg.compilerOptions.args '-g0', '-fno-rtti', '-fno-exceptions'
cfg.compilerOptions.args '-g0', '-fno-exceptions'
cfg.projectLibpath(project, '/lib/linux32')
cfg.extraLibs 'dl', 'm', 'aelf32'
}
@ -276,7 +284,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
if (project.hasProperty("useGcc")) {
if (project.hasProperty("useClang")) {
clang(Clang)
}
else if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
@ -343,11 +354,18 @@ task buildFixes {
}
}
task buildDebug {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching {
SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'debug' && blib.flavor.name == 'regamedllFixes' && blib.component.name == 'regamedll_mp_gamedll'
}
}
buildFixes.finalizedBy(buildFinalize);
buildDebug.finalizedBy(buildFinalize);
buildRelease.finalizedBy(buildFinalize);
gradle.taskGraph.whenReady { graph ->
if (!graph.hasTask(buildFixes)) {
if (!graph.hasTask(buildFixes) && !graph.hasTask(buildDebug)) {
return;
}

7
regamedll/compile.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
rm -rf build
mkdir build
cd build
cmake ../ $*
make

View File

@ -397,7 +397,7 @@ void CBreakable::DamageSound()
int pitch;
float fvol;
char *rgpsz[6];
int i;
int i = 0;
int material = m_Material;
if (RANDOM_LONG(0, 2))

View File

@ -201,6 +201,7 @@ void CHostageImprov::MoveTowards(const Vector &pos, float deltaT)
switch (m_moveType)
{
case Stopped:
default:
accelRate = 0;
break;
case Walking:

View File

@ -2098,7 +2098,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
case 1:
{
UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT));
break;
}
case 2:
@ -2116,7 +2115,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
{
CBasePlayer* pObserver = UTIL_PlayerByIndex(i);
if (pObserver == this || pObserver && pObserver->IsObservingPlayer(this))
if (pObserver == this || (pObserver && pObserver->IsObservingPlayer(this)))
{
UTIL_ScreenFade(pObserver, Vector(0, 0, 0), 1, 4, 255, (FFADE_OUT));
}
@ -2677,9 +2676,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim)
animDesired = LookupActivity(ACT_DIE_BACKSHOT);
m_iThrowDirection = THROW_HITVEL;
break;
case 3:
animDesired = LookupActivity(ACT_DIESIMPLE);
break;
case 4:
animDesired = LookupActivity(ACT_DIEBACKWARD);
m_iThrowDirection = THROW_HITVEL;
@ -2698,6 +2694,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim)
animDesired = LookupActivity(ACT_DIE_HEADSHOT);
break;
default:
animDesired = LookupActivity(ACT_DIESIMPLE);
break;
}
break;
@ -2750,11 +2747,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(SetAnimation)(PLAYER_ANIM playerAnim)
break;
}
default:
{
animDesired = LookupActivity(ACT_DIESIMPLE);
break;
}
}
if (pev->flags & FL_DUCKING)
{
animDesired = LookupSequence("crouch_die");
@ -4349,7 +4345,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
#ifdef REGAMEDLL_FIXES
IsAlive() &&
#endif
m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f)
(m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f))
{
// check every 5 seconds
m_flIdleCheckTime = gpGlobals->time + 5.0;

View File

@ -282,8 +282,8 @@ extern "C"
{
inline unsigned _rotr(unsigned val, int shift)
{
register unsigned lobit;
register unsigned num = val;
unsigned lobit;
unsigned num = val;
shift &= 0x1f;

View File

@ -772,7 +772,7 @@ void CAmbientGeneric::KeyValue(KeyValueData *pkvd)
// lfotype
else if (FStrEq(pkvd->szKeyName, "lfotype"))
{
m_dpv.lfotype = (LowFreqOsc)Q_atoi(pkvd->szValue);
m_dpv.lfotype = Q_atoi(pkvd->szValue);
if (m_dpv.lfotype > 4)
m_dpv.lfotype = LFO_TRIANGLE;

View File

@ -38,7 +38,7 @@ const int MAX_SENTENCE_DPV_RESET = 27; // Max number of dynamic pitch volumes
const float MAX_ANNOUNCE_MINS = 2.25f;
const float MIN_ANNOUNCE_MINS = 0.25f;
enum LowFreqOsc : int
enum
{
LFO_OFF = 0,
LFO_SQUARE, // Square
@ -75,7 +75,7 @@ typedef struct dynpitchvol
int fadeout; // Volume fade out time 0 - 100
// Low Frequency Oscillator
LowFreqOsc lfotype; // 0) off 1) square 2) triangle 3) random
int lfotype; // 0) off 1) square 2) triangle 3) random
int lforate; // 0 - 1000, how fast lfo osciallates
int lfomodpitch; // 0-100 mod of current pitch. 0 is off.

View File

@ -238,7 +238,7 @@ void CSoundEnt::Initialize()
int CSoundEnt::ISoundsInList(int iListType)
{
int i;
int iThisSound;
int iThisSound = SOUNDLIST_EMPTY;
if (iListType == SOUNDLISTTYPE_FREE)
{
@ -251,6 +251,7 @@ int CSoundEnt::ISoundsInList(int iListType)
else
{
ALERT(at_console, "Unknown Sound List Type!\n");
iThisSound = iListType;
}
if (iThisSound == SOUNDLIST_EMPTY)

View File

@ -563,7 +563,7 @@ int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out)
if (uVal <= 0xFFFF)
{
pUTF8Out[0] = (unsigned char)(uVal >> 12) | 0xE0;
pUTF8Out[1] = (unsigned char)(uVal >> 6) & 0x3F | 0x80;
pUTF8Out[1] = (unsigned char)((uVal >> 6) & 0x3F) | 0x80;
pUTF8Out[2] = (unsigned char)(uVal & 0x3F) | 0x80;
return 3;
}

View File

@ -331,7 +331,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
// Load hiding spots
// load number of hiding spots
unsigned char hidingSpotCount;
unsigned char hidingSpotCount = 0;
file->Read(&hidingSpotCount, sizeof(unsigned char));
if (version == 1)
@ -366,7 +366,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
file->Read(&m_approachCount, sizeof(unsigned char));
// load approach area info (IDs)
unsigned char type;
unsigned char type = 0;
for (int a = 0; a < m_approachCount; a++)
{
file->Read(&m_approach[a].here.id, sizeof(unsigned int));
@ -398,7 +398,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
file->Read(&encounter.path.to.x, 3 * sizeof(float));
// read list of spots along this path
unsigned char spotCount;
unsigned char spotCount = 0;
file->Read(&spotCount, sizeof(unsigned char));
for (int s = 0; s < spotCount; s++)
@ -418,7 +418,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
file->Read(&encounter.from.id, sizeof(unsigned int));
unsigned char dir;
unsigned char dir = 0;
file->Read(&dir, sizeof(unsigned char));
encounter.fromDir = static_cast<NavDirType>(dir);
@ -428,7 +428,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
encounter.toDir = static_cast<NavDirType>(dir);
// read list of spots along this path
unsigned char spotCount;
unsigned char spotCount = 0;
file->Read(&spotCount, sizeof(unsigned char));
SpotOrder order;
@ -436,7 +436,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version)
{
file->Read(&order.id, sizeof(unsigned int));
unsigned char t;
unsigned char t = 0;
file->Read(&t, sizeof(unsigned char));
order.t = float(t) / 255.0f;
@ -733,7 +733,7 @@ void SanityCheckNavigationMap(const char *mapName)
navFile.Read(&saveBspSize, sizeof(unsigned int));
// verify size
if (!bspFilename)
if (saveBspSize == 0)
{
CONSOLE_ECHO("ERROR: No map corresponds to navigation file %s.\n", navFilename);
return;

View File

@ -235,11 +235,12 @@ protected:
// Constructor, Destructor
template <class T, class I, typename L, class M>
CUtlRBTree<T, I, L, M>::CUtlRBTree(int growSize, int initSize, LessFunc_t lessfunc) :
m_Elements(growSize, initSize),
m_LessFunc(lessfunc),
m_Elements(growSize, initSize),
m_Root(InvalidIndex()),
m_NumElements(0), m_TotalElements(0),
m_FirstFree(InvalidIndex())
m_NumElements(0),
m_FirstFree(InvalidIndex()),
m_TotalElements(0)
{
}

141
regamedll/version/appversion.sh Executable file
View File

@ -0,0 +1,141 @@
#!/bin/bash
init()
{
SOURCE_DIR=$1
VERSION_FILE=$SOURCE_DIR/../gradle.properties
APPVERSION_FILE=$SOURCE_DIR/version/appversion.h
if test -z "`git --version`"; then
echo "Please install git client"
echo "sudo apt-get install git"
exit 0
fi
# Read old version
if [ -e $APPVERSION_FILE ]; then
OLD_VERSION=$(cat $APPVERSION_FILE | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
if [ $? -ne 0 ]; then
OLD_VERSION=""
else
# Remove quotes
OLD_VERSION=$(echo $OLD_VERSION | xargs)
fi
fi
# Get major, minor and maintenance information from version.h
MAJOR=$(sed -nr -e '/majorVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
if [ $? -ne 0 -o "$MAJOR" = "" ]; then
MAJOR=0
fi
MINOR=$(sed -nr -e '/minorVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
if [ $? -ne 0 -o "$MINOR" = "" ]; then
MINOR=0
fi
MAINTENANCE=$(sed -nr -e '/maintenanceVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
MAINTENANCE=0
fi
BRANCH_NAME=$(git -C $SOURCE_DIR/../ rev-parse --abbrev-ref HEAD)
if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then
BRANCH_NAME=master
fi
COMMIT_COUNT=$(git -C $SOURCE_DIR/../ rev-list --count $BRANCH_NAME)
if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then
COMMIT_COUNT=0
fi
#
# Configure remote url repository
#
# Get remote name by current branch
BRANCH_REMOTE=$(git -C $SOURCE_DIR/../ config branch.$BRANCH_NAME.remote)
if [ $? -ne 0 -o "$BRANCH_REMOTE" = "" ]; then
BRANCH_REMOTE=origin
fi
# Get commit id
COMMIT_SHA=$(git -C $SOURCE_DIR/../ rev-parse --verify HEAD)
COMMIT_SHA=${COMMIT_SHA:0:7}
# Get remote url
COMMIT_URL=$(git -C $SOURCE_DIR/../ config remote.$BRANCH_REMOTE.url)
# Strip prefix 'git@'
COMMIT_URL=${COMMIT_URL#git@}
# Strip postfix '.git'
COMMIT_URL=${COMMIT_URL%.git}
# Replace ':' to '/'
COMMIT_URL=${COMMIT_URL/:/\/}
# Append extra string
if [ $? -ne 0 -o "$COMMIT_URL" = "${COMMIT_URL/bitbucket.org}" ]; then
COMMIT_URL=$(echo https://$COMMIT_URL/commits/)
else
COMMIT_URL=$(echo https://$COMMIT_URL/commit/)
fi
#
# Detect local modifications
#
if [ `git -C $SOURCE_DIR/../ ls-files -m | wc -l` = 0 ]; then
MODIFIED=
else
MODIFIED=+m
fi
NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT-dev$MODIFIED"
# Update appversion.h if version has changed or modifications/mixed revisions detected
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
update_appversion
fi
}
update_appversion()
{
day=$(date +%m)
year=$(date +%Y)
hours=$(date +%H:%M:%S)
month=$(LANG=en_us_88591; date +"%b")
# Write appversion.h
echo Updating appversion.h, new version is '"'$NEW_VERSION'"', the old one was $OLD_VERSION
echo -e "#ifndef __APPVERSION_H__\r">$APPVERSION_FILE
echo -e "#define __APPVERSION_H__\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "//\r">>$APPVERSION_FILE
echo -e "// This file is generated automatically.\r">>$APPVERSION_FILE
echo -e "// Don't edit it.\r">>$APPVERSION_FILE
echo -e "//\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "// Version defines\r">>$APPVERSION_FILE
echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>$APPVERSION_FILE
echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>$APPVERSION_FILE
echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>$APPVERSION_FILE
echo -e "#define APP_VERSION_FLAGS 0x0L\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>$APPVERSION_FILE
echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>$APPVERSION_FILE
echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "#endif //__APPVERSION_H__\r">>$APPVERSION_FILE
}
# Initialise
init $*
# Exit normally
exit 0

View File

@ -8,6 +8,7 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
apply from: 'shared_msvc.gradle'
apply from: 'shared_icc.gradle'
apply from: 'shared_clang.gradle'
apply from: 'shared_gcc.gradle'
rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
@ -38,6 +39,10 @@ rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
{
return rootProject.createIccConfig(releaseBuild, binaryKind)
}
else if (bin.toolChain instanceof Clang)
{
return rootProject.createClangConfig(releaseBuild, binaryKind)
}
else if (bin.toolChain instanceof Gcc)
{
return rootProject.createGccConfig(releaseBuild, binaryKind)

55
shared_clang.gradle Normal file
View File

@ -0,0 +1,55 @@
import org.doomedsociety.gradlecpp.cfg.BinaryKind
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
import org.doomedsociety.gradlecpp.gcc.OptimizationLevel
rootProject.ext.createClangConfig = { boolean release, BinaryKind binKind ->
GccToolchainConfig cfg
if (release) {
cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.LEVEL_3,
stackProtector: false,
noBuiltIn: true,
positionIndependentCode: false,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
} else {
// debug
cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true,
noBuiltIn: true,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
}
cfg.singleDefines('LINUX', '_LINUX')
return cfg
}

18
version_script.lds Normal file
View File

@ -0,0 +1,18 @@
REGAMEDLL_ABI_1.0 {
global:
*;
local:
_Zn*;
_Zd*;
extern "C++" {
*std::*;
*__cxxabi*::*;
*__gnu_cxx::*;
__cxa_*;
_txnal_*;
__dynamic_cast;
__gxx_personality_*;
__gcclibcxx_demangle_callback;
};
};