Skip to content

Commit 0817367

Browse files
committed
HLTV: Support GCC
1 parent 3c036ed commit 0817367

File tree

9 files changed

+125
-45
lines changed

9 files changed

+125
-45
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Help -> About
8282
<pre>$ icc --version
8383
icc (ICC) 15.0.1 20141023
8484
</pre>
85-
85+
<>
8686
#### GCC
8787
<pre>$ gcc --version
8888
gcc (Debian 4.9.2-10) 4.9.2
@@ -105,6 +105,7 @@ On Linux (GCC):
105105
* For faster building without unit tests use this:exclamation:
106106
<pre>./gradlew --max-workers=1 -PuseGcc clean buildFixes</pre>
107107

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

110111
## How can I help the project?

rehlds/HLTV/Console/build.gradle

+22-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ List<Task> getRcCompileTasks(NativeBinarySpec binary)
2020
}
2121

2222
void setupToolchain(NativeBinarySpec b) {
23+
boolean useGcc = project.hasProperty("useGcc")
2324
def cfg = rootProject.createToolchainConfig(b);
2425
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds');
2526
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', '_CONSOLE'
@@ -38,12 +39,14 @@ void setupToolchain(NativeBinarySpec b) {
3839
cfg.extraLibs "user32.lib"
3940
}
4041
else if (cfg instanceof GccToolchainConfig) {
41-
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
42-
enabled: true,
43-
pchSourceSet: 'hltv_pch'
44-
);
42+
if (!useGcc) {
43+
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
44+
enabled: true,
45+
pchSourceSet: 'hltv_pch'
46+
);
47+
}
4548

46-
cfg.compilerOptions.languageStandard = 'c++0x'
49+
cfg.compilerOptions.languageStandard = 'c++11'
4750
cfg.defines([
4851
'_strdup': 'strdup',
4952
'_stricmp': 'strcasecmp',
@@ -52,7 +55,16 @@ void setupToolchain(NativeBinarySpec b) {
5255
'_snprintf': 'snprintf',
5356
]);
5457

55-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti', '-fno-exceptions'
58+
59+
if (useGcc) {
60+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
61+
// As new processors are deployed in the marketplace, the behavior of this option will change.
62+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
63+
} else {
64+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
65+
}
66+
67+
cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
5668
cfg.extraLibs 'dl'
5769
}
5870

@@ -73,7 +85,10 @@ model {
7385
toolChains {
7486
visualCpp(VisualCpp) {
7587
}
76-
icc(Icc) {
88+
if (project.hasProperty("useGcc")) {
89+
gcc(Gcc)
90+
} else {
91+
icc(Icc)
7792
}
7893
}
7994

rehlds/HLTV/Core/build.gradle

+21-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ apply plugin: GccCompilerPlugin
1414
project.ext.dep_bzip2 = project(':dep/bzip2')
1515

1616
void setupToolchain(NativeBinarySpec b) {
17+
boolean useGcc = project.hasProperty("useGcc")
1718
def cfg = rootProject.createToolchainConfig(b);
1819
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
1920
cfg.projectInclude(dep_bzip2, '/include')
@@ -32,12 +33,14 @@ void setupToolchain(NativeBinarySpec b) {
3233
cfg.extraLibs "ws2_32.lib", "psapi.lib"
3334
}
3435
else if (cfg instanceof GccToolchainConfig) {
35-
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
36-
enabled: true,
37-
pchSourceSet: 'core_pch'
38-
);
36+
if (!useGcc) {
37+
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
38+
enabled: true,
39+
pchSourceSet: 'core_pch'
40+
);
41+
}
3942

40-
cfg.compilerOptions.languageStandard = 'c++0x'
43+
cfg.compilerOptions.languageStandard = 'c++11'
4144
cfg.defines([
4245
'_strdup': 'strdup',
4346
'_stricmp': 'strcasecmp',
@@ -46,7 +49,15 @@ void setupToolchain(NativeBinarySpec b) {
4649
'_snprintf': 'snprintf',
4750
]);
4851

49-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
52+
if (useGcc) {
53+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
54+
// As new processors are deployed in the marketplace, the behavior of this option will change.
55+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
56+
} else {
57+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
58+
}
59+
60+
cfg.compilerOptions.args '-fno-exceptions'
5061
}
5162

5263
ToolchainConfigUtils.apply(project, cfg, b);
@@ -66,7 +77,10 @@ model {
6677
toolChains {
6778
visualCpp(VisualCpp) {
6879
}
69-
icc(Icc) {
80+
if (project.hasProperty("useGcc")) {
81+
gcc(Gcc)
82+
} else {
83+
icc(Icc)
7084
}
7185
}
7286

rehlds/HLTV/DemoPlayer/build.gradle

+21-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ apply plugin: IccCompilerPlugin
1212
apply plugin: GccCompilerPlugin
1313

1414
void setupToolchain(NativeBinarySpec b) {
15+
boolean useGcc = project.hasProperty("useGcc")
1516
def cfg = rootProject.createToolchainConfig(b);
1617
cfg.projectInclude(project, '/..', '/../..', '/src', '/../common', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
1718
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'DEMOPLAYER_MODULE'
@@ -28,12 +29,14 @@ void setupToolchain(NativeBinarySpec b) {
2829
cfg.extraLibs "psapi.lib"
2930
}
3031
else if (cfg instanceof GccToolchainConfig) {
31-
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
32-
enabled: true,
33-
pchSourceSet: 'demoplayer_pch'
34-
);
32+
if (!useGcc) {
33+
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
34+
enabled: true,
35+
pchSourceSet: 'demoplayer_pch'
36+
);
37+
}
3538

36-
cfg.compilerOptions.languageStandard = 'c++0x'
39+
cfg.compilerOptions.languageStandard = 'c++11'
3740
cfg.defines([
3841
'_strdup': 'strdup',
3942
'_stricmp': 'strcasecmp',
@@ -42,7 +45,15 @@ void setupToolchain(NativeBinarySpec b) {
4245
'_snprintf': 'snprintf',
4346
]);
4447

45-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
48+
if (useGcc) {
49+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
50+
// As new processors are deployed in the marketplace, the behavior of this option will change.
51+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
52+
} else {
53+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
54+
}
55+
56+
cfg.compilerOptions.args '-fno-exceptions'
4657
}
4758

4859
ToolchainConfigUtils.apply(project, cfg, b);
@@ -62,7 +73,10 @@ model {
6273
toolChains {
6374
visualCpp(VisualCpp) {
6475
}
65-
icc(Icc) {
76+
if (project.hasProperty("useGcc")) {
77+
gcc(Gcc)
78+
} else {
79+
icc(Icc)
6680
}
6781
}
6882

rehlds/HLTV/Director/build.gradle

+20-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ apply plugin: IccCompilerPlugin
1212
apply plugin: GccCompilerPlugin
1313

1414
void setupToolchain(NativeBinarySpec b) {
15+
boolean useGcc = project.hasProperty("useGcc")
1516
def cfg = rootProject.createToolchainConfig(b);
1617
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
1718
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'DIRECTOR_MODULE'
@@ -27,10 +28,12 @@ void setupToolchain(NativeBinarySpec b) {
2728
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF'
2829
}
2930
else if (cfg instanceof GccToolchainConfig) {
30-
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
31-
enabled: true,
32-
pchSourceSet: 'director_pch'
33-
);
31+
if (!useGcc) {
32+
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
33+
enabled: true,
34+
pchSourceSet: 'director_pch'
35+
);
36+
}
3437

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

44-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
47+
if (useGcc) {
48+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
49+
// As new processors are deployed in the marketplace, the behavior of this option will change.
50+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
51+
} else {
52+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
53+
}
54+
55+
cfg.compilerOptions.args '-fno-exceptions'
4556
}
4657

4758
ToolchainConfigUtils.apply(project, cfg, b);
@@ -61,7 +72,10 @@ model {
6172
toolChains {
6273
visualCpp(VisualCpp) {
6374
}
64-
icc(Icc) {
75+
if (project.hasProperty("useGcc")) {
76+
gcc(Gcc)
77+
} else {
78+
icc(Icc)
6579
}
6680
}
6781

rehlds/HLTV/Proxy/build.gradle

+21-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ apply plugin: GccCompilerPlugin
1414
project.ext.dep_bzip2 = project(':dep/bzip2')
1515

1616
void setupToolchain(NativeBinarySpec b) {
17+
boolean useGcc = project.hasProperty("useGcc")
1718
def cfg = rootProject.createToolchainConfig(b);
1819
cfg.projectInclude(project, '/..', '/../..', '/src', '/../Director/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds', '/../../pm_shared');
1920
cfg.projectInclude(dep_bzip2, '/include')
@@ -33,12 +34,14 @@ void setupToolchain(NativeBinarySpec b) {
3334
cfg.extraLibs "steam_api.lib", "psapi.lib", "ws2_32.lib"
3435
}
3536
else if (cfg instanceof GccToolchainConfig) {
36-
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
37-
enabled: true,
38-
pchSourceSet: 'proxy_pch'
39-
);
37+
if (!useGcc) {
38+
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
39+
enabled: true,
40+
pchSourceSet: 'proxy_pch'
41+
);
42+
}
4043

41-
cfg.compilerOptions.languageStandard = 'c++0x'
44+
cfg.compilerOptions.languageStandard = 'c++11'
4245
cfg.defines([
4346
'_strdup': 'strdup',
4447
'_stricmp': 'strcasecmp',
@@ -47,7 +50,15 @@ void setupToolchain(NativeBinarySpec b) {
4750
'_snprintf': 'snprintf',
4851
]);
4952

50-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-exceptions'
53+
if (useGcc) {
54+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
55+
// As new processors are deployed in the marketplace, the behavior of this option will change.
56+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
57+
} else {
58+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
59+
}
60+
61+
cfg.compilerOptions.args '-fno-exceptions'
5162
cfg.projectLibpath(project, '/../../lib/linux32')
5263
cfg.extraLibs "steam_api"
5364
}
@@ -69,7 +80,10 @@ model {
6980
toolChains {
7081
visualCpp(VisualCpp) {
7182
}
72-
icc(Icc) {
83+
if (project.hasProperty("useGcc")) {
84+
gcc(Gcc)
85+
} else {
86+
icc(Icc)
7387
}
7488
}
7589

rehlds/HLTV/Proxy/src/Proxy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool Proxy::Init(IBaseSystem *system, int serial, char *name)
222222
-1.f, -1.f, // x, y
223223
0.5f, 2.f, // fadein, fadeout
224224
5.f, 0.f, // holdtime, fxtime
225-
"" // text
225+
{} // text
226226
};
227227

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

239239
Q_strlcpy(m_OffLineText, "Game is delayed. Please try again later.");

rehlds/build.gradle

+9-3
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ void setupToolchain(NativeBinarySpec b) {
168168
// As new processors are deployed in the marketplace, the behavior of this option will change.
169169
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3'
170170
} else {
171-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
171+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
172172
}
173173

174-
cfg.compilerOptions.args '-fno-exceptions'
174+
cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
175175
cfg.projectLibpath(project, '/lib/linux32')
176176
cfg.extraLibs 'rt', 'dl', 'm', 'steam_api', 'aelf32'
177177
}
@@ -364,8 +364,14 @@ task buildFixes {
364364
}
365365
}
366366

367+
task buildEngine {
368+
dependsOn binaries.withType(SharedLibraryBinarySpec).matching {
369+
SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'rehldsFixes' && blib.component.name == 'rehlds_swds_engine'
370+
}
371+
}
372+
367373
gradle.taskGraph.whenReady { graph ->
368-
if (!graph.hasTask(buildFixes)) {
374+
if (!graph.hasTask(buildFixes) && !graph.hasTask(buildEngine)) {
369375
return;
370376
}
371377

rehlds/dedicated/build.gradle

+7-5
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,24 @@ void setupToolchain(NativeBinarySpec b) {
4747
pchSourceSet: 'dedicated_pch'
4848
);
4949
}
50-
cfg.compilerOptions.languageStandard = 'c++0x'
50+
cfg.compilerOptions.languageStandard = 'c++11'
5151
cfg.defines([
5252
'_strdup': 'strdup',
5353
'_stricmp': 'strcasecmp',
5454
'_strnicmp': 'strncasecmp',
5555
'_vsnprintf': 'vsnprintf',
5656
'_snprintf': 'snprintf',
5757
]);
58+
5859
if (useGcc) {
59-
// MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AES and PCLMUL instruction set support.
60-
cfg.compilerOptions.args '-march=sandybridge', '-Wno-write-strings'
60+
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
61+
// As new processors are deployed in the marketplace, the behavior of this option will change.
62+
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3', '-flto'
6163
} else {
62-
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
64+
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
6365
}
6466

65-
cfg.compilerOptions.args '-fno-exceptions'
67+
cfg.compilerOptions.args '-fno-rtti', '-fno-exceptions'
6668
cfg.extraLibs 'dl'
6769
}
6870

0 commit comments

Comments
 (0)