mirror of
https://github.com/rehlds/rehlds.git
synced 2025-03-31 22:59:06 +03:00
171 lines
4.1 KiB
Groovy
171 lines
4.1 KiB
Groovy
import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
|
|
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
|
|
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.Icc
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
|
|
import org.doomedsociety.gradlecpp.GradleCppUtils
|
|
import org.gradle.nativeplatform.NativeExecutableSpec
|
|
import org.gradle.nativeplatform.NativeExecutableBinarySpec
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'windows-resources'
|
|
apply plugin: IccCompilerPlugin
|
|
apply plugin: GccCompilerPlugin
|
|
|
|
List<Task> getRcCompileTasks(NativeBinarySpec binary)
|
|
{
|
|
def linkTask = GradleCppUtils.getLinkTask(binary)
|
|
def res = linkTask.taskDependencies.getDependencies(linkTask).findAll { Task t -> t instanceof WindowsResourceCompile }
|
|
return res as List
|
|
}
|
|
|
|
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'
|
|
|
|
if (cfg instanceof MsvcToolchainConfig) {
|
|
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
|
|
enabled: true,
|
|
pchHeader: 'precompiled.h',
|
|
pchSourceSet: 'hltv_pch'
|
|
);
|
|
|
|
cfg.singleDefines('_CRT_SECURE_NO_WARNINGS');
|
|
|
|
cfg.linkerOptions.args('/SUBSYSTEM:WINDOWS,5.01');
|
|
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF', '/GR-'
|
|
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++11'
|
|
cfg.defines([
|
|
'_strdup': 'strdup',
|
|
'_stricmp': 'strcasecmp',
|
|
'_strnicmp': 'strncasecmp',
|
|
'_vsnprintf': 'vsnprintf',
|
|
'_snprintf': 'snprintf',
|
|
]);
|
|
|
|
|
|
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'
|
|
}
|
|
|
|
ToolchainConfigUtils.apply(project, cfg, b);
|
|
}
|
|
|
|
model {
|
|
buildTypes {
|
|
release
|
|
}
|
|
|
|
platforms {
|
|
x86 {
|
|
architecture "x86"
|
|
}
|
|
}
|
|
|
|
toolChains {
|
|
visualCpp(VisualCpp) {
|
|
}
|
|
if (project.hasProperty("useGcc")) {
|
|
gcc(Gcc)
|
|
} else {
|
|
icc(Icc)
|
|
}
|
|
}
|
|
|
|
components {
|
|
hltv(NativeExecutableSpec) {
|
|
targetPlatform 'x86'
|
|
baseName 'hltv'
|
|
|
|
sources {
|
|
hltv_main(CppSourceSet) {
|
|
source {
|
|
srcDir "src"
|
|
include "**/*.cpp"
|
|
exclude "precompiled.cpp"
|
|
}
|
|
}
|
|
hltv_common(CppSourceSet) {
|
|
source {
|
|
srcDirs "../../common", "../common"
|
|
|
|
// common
|
|
include "BaseSystemModule.cpp"
|
|
include "ObjectList.cpp"
|
|
include "TokenLine.cpp"
|
|
include "textconsole.cpp"
|
|
if (GradleCppUtils.windows) {
|
|
include "TextConsoleWin32.cpp"
|
|
}
|
|
else {
|
|
include "TextConsoleUnix.cpp"
|
|
}
|
|
|
|
// HLTV common
|
|
include "random.cpp"
|
|
include "common.cpp"
|
|
}
|
|
}
|
|
hltv_engine(CppSourceSet) {
|
|
source {
|
|
srcDir "../../engine"
|
|
include "mem.cpp"
|
|
}
|
|
}
|
|
hltv_pch(CppSourceSet) {
|
|
source {
|
|
srcDir "src"
|
|
include "precompiled.cpp"
|
|
}
|
|
}
|
|
|
|
rc {
|
|
source {
|
|
srcDir "msvc"
|
|
include "hltv.rc"
|
|
}
|
|
exportedHeaders {
|
|
srcDirs "msvc"
|
|
}
|
|
}
|
|
}
|
|
|
|
binaries.all {
|
|
NativeExecutableBinarySpec b -> project.setupToolchain(b)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task buildFixes {
|
|
dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib ->
|
|
blib.buildable && blib.buildType.name == 'release'
|
|
}
|
|
}
|
|
|
|
task buildRelease {
|
|
dependsOn binaries.withType(NativeExecutableBinarySpec).matching { NativeExecutableBinarySpec blib ->
|
|
blib.buildable && blib.buildType.name == 'release'
|
|
}
|
|
}
|