2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

HLTV: Support GCC

This commit is contained in:
s1lent 2017-09-27 04:00:01 +07:00
parent 3c036eda31
commit a444ce046b
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
9 changed files with 124 additions and 44 deletions

View File

@ -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?

View File

@ -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'
@ -38,12 +39,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "user32.lib"
}
else if (cfg instanceof GccToolchainConfig) {
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',
@ -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'
}
@ -73,7 +85,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

View File

@ -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')
@ -32,12 +33,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "ws2_32.lib", "psapi.lib"
}
else if (cfg instanceof GccToolchainConfig) {
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',
@ -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);
@ -66,7 +77,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

View File

@ -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'
@ -28,12 +29,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "psapi.lib"
}
else if (cfg instanceof GccToolchainConfig) {
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',
@ -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);
@ -62,7 +73,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

View File

@ -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'
@ -27,10 +28,12 @@ void setupToolchain(NativeBinarySpec b) {
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF'
}
else if (cfg instanceof GccToolchainConfig) {
if (!useGcc) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'director_pch'
);
}
cfg.compilerOptions.languageStandard = 'c++0x'
cfg.defines([
@ -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);
@ -61,7 +72,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

View File

@ -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')
@ -33,12 +34,14 @@ void setupToolchain(NativeBinarySpec b) {
cfg.extraLibs "steam_api.lib", "psapi.lib", "ws2_32.lib"
}
else if (cfg instanceof GccToolchainConfig) {
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',
@ -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"
}
@ -69,7 +80,10 @@ model {
toolChains {
visualCpp(VisualCpp) {
}
icc(Icc) {
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}

View File

@ -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));
@ -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.");

View File

@ -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'
}
@ -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;
}

View File

@ -47,7 +47,7 @@ void setupToolchain(NativeBinarySpec b) {
pchSourceSet: 'dedicated_pch'
);
}
cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_strdup': 'strdup',
'_stricmp': 'strcasecmp',
@ -55,14 +55,16 @@ void setupToolchain(NativeBinarySpec b) {
'_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'
}