Skip to content

Commit

Permalink
HLTV: Support GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Sep 26, 2017
1 parent 3c036ed commit 0817367
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 45 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Help -> About
<pre>$ icc --version
icc (ICC) 15.0.1 20141023
</pre>

<>
#### GCC
<pre>$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Expand All @@ -105,6 +105,7 @@ On Linux (GCC):
* For faster building without unit tests use this:exclamation:
<pre>./gradlew --max-workers=1 -PuseGcc clean buildFixes</pre>

Also there is a task `buildEngine`, it builds only a part of the engine.<br />
Compiled binaries will be placed in the rehlds/build/binaries/ directory

## How can I help the project?
Expand Down
29 changes: 22 additions & 7 deletions rehlds/HLTV/Console/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ List<Task> getRcCompileTasks(NativeBinarySpec binary)
}

void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds');
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', '_CONSOLE'
Expand All @@ -38,12 +39,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "user32.lib"
}
else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'hltv_pch'
);
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'hltv_pch'
);
}

cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
Expand All @@ -52,7 +55,16 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf',
]);

cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti', '-fno-exceptions'

if (useGcc) {
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
cfg.extraLibs 'dl'
}

Expand All @@ -73,7 +85,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

Expand Down
28 changes: 21 additions & 7 deletions rehlds/HLTV/Core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apply plugin: GccCompilerPlugin
project.ext.dep_bzip2 = project(':dep/bzip2')

void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
cfg.projectInclude(dep_bzip2, '/include')
Expand All @@ -32,12 +33,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "ws2_32.lib", "psapi.lib"
}
else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'core_pch'
);
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'core_pch'
);
}

cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
Expand All @@ -46,7 +49,15 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf',
]);

cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
if (useGcc) {
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
}

ToolchainConfigUtils.apply(project, cfg, b);
Expand All @@ -66,7 +77,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

Expand Down
28 changes: 21 additions & 7 deletions rehlds/HLTV/DemoPlayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin

void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../common', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'DEMOPLAYER_MODULE'
Expand All @@ -28,12 +29,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "psapi.lib"
}
else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'demoplayer_pch'
);
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'demoplayer_pch'
);
}

cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
Expand All @@ -42,7 +45,15 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf',
]);

cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
if (useGcc) {
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
}

ToolchainConfigUtils.apply(project, cfg, b);
Expand All @@ -62,7 +73,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

Expand Down
26 changes: 20 additions & 6 deletions rehlds/HLTV/Director/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin

void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'DIRECTOR_MODULE'
Expand All @@ -27,10 +28,12 @@ void setupToolchain(NativeBinarySpec b) {
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF'
}
else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'director_pch'
);
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'director_pch'
);
}

cfg.compilerOptions.languageStandard = 'c++0x'
cfg.defines([
Expand All @@ -41,7 +44,15 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf',
]);

cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
if (useGcc) {
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
}

ToolchainConfigUtils.apply(project, cfg, b);
Expand All @@ -61,7 +72,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

Expand Down
28 changes: 21 additions & 7 deletions rehlds/HLTV/Proxy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apply plugin: GccCompilerPlugin
project.ext.dep_bzip2 = project(':dep/bzip2')

void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../Director/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
cfg.projectInclude(dep_bzip2, '/include')
Expand All @@ -33,12 +34,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "steam_api.lib", "psapi.lib", "ws2_32.lib"
}
else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'proxy_pch'
);
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'proxy_pch'
);
}

cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
Expand All @@ -47,7 +50,15 @@ void setupToolchain(NativeBinarySpec b) {
'_snprintf': 'snprintf',
]);

cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
if (useGcc) {
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
cfg.projectLibpath(project, '/../../lib/linux32')
cfg.extraLibs "steam_api"
}
Expand All @@ -69,7 +80,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

Expand Down
4 changes: 2 additions & 2 deletions rehlds/HLTV/Proxy/src/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool Proxy::Init(IBaseSystem *system, int serial, char *name)
-1.f, -1.f, // x, y
0.5f, 2.f, // fadein, fadeout
5.f, 0.f, // holdtime, fxtime
"" // text
{} // text
};

Q_memset(&m_CommentatorMessage, 0, sizeof(m_CommentatorMessage));
Expand All @@ -233,7 +233,7 @@ bool Proxy::Init(IBaseSystem *system, int serial, char *name)
-1.f, -1.f, // x, y
0.3f, 1.f, // fadein, fadeout
5.f, 0.f, // holdtime, fxtime
"" // text
{} // text
};

Q_strlcpy(m_OffLineText, "Game is delayed. Please try again later.");
Expand Down
12 changes: 9 additions & 3 deletions rehlds/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ void setupToolchain(NativeBinarySpec b) {
// As new processors are deployed in the marketplace, the behavior of this option will change.
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
cfg.projectLibpath(project, '/lib/linux32')
cfg.extraLibs 'rt', 'dl', 'm', 'steam_api', 'aelf32'
}
Expand Down Expand Up @@ -364,8 +364,14 @@ task buildFixes {
}
}

task buildEngine {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching {
SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'rehldsFixes' && blib.component.name == 'rehlds_swds_engine'
}
}

gradle.taskGraph.whenReady { graph ->
if (!graph.hasTask(buildFixes)) {
if (!graph.hasTask(buildFixes) && !graph.hasTask(buildEngine)) {
return;
}

Expand Down
12 changes: 7 additions & 5 deletions rehlds/dedicated/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,24 @@ void setupToolchain(NativeBinarySpec b) {
pchSourceSet: 'dedicated_pch'
);
}
cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
'_strnicmp': 'strncasecmp',
'_vsnprintf': 'vsnprintf',
'_snprintf': 'snprintf',
]);

if (useGcc) {
// MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AES and PCLMUL instruction set support.
cfg.compilerOptions.args '-march=sandybridge', '-Wno-write-strings'
// 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', '-Wno-write-strings', '-msse3', '-flto'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
}

cfg.compilerOptions.args '-fno-exceptions'
cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
cfg.extraLibs 'dl'
}

Expand Down

0 comments on commit 0817367

Please sign in to comment.