mirror of
https://github.com/rehlds/rehlds.git
synced 2025-04-10 03:20:05 +03:00
154 lines
3.7 KiB
Groovy
154 lines
3.7 KiB
Groovy
import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
|
|
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.Icc
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
|
|
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
|
|
import org.gradle.nativeplatform.NativeBinarySpec
|
|
import org.gradle.nativeplatform.NativeLibrarySpec
|
|
import org.gradle.nativeplatform.toolchain.VisualCpp
|
|
|
|
apply plugin: 'cpp'
|
|
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'
|
|
|
|
if (cfg instanceof MsvcToolchainConfig) {
|
|
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
|
|
enabled: true,
|
|
pchHeader: 'precompiled.h',
|
|
pchSourceSet: 'director_pch'
|
|
);
|
|
|
|
cfg.singleDefines('_CRT_SECURE_NO_WARNINGS')
|
|
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([
|
|
'_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-exceptions'
|
|
}
|
|
|
|
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 {
|
|
director(NativeLibrarySpec) {
|
|
targetPlatform 'x86'
|
|
baseName 'director'
|
|
|
|
sources {
|
|
director_main(CppSourceSet) {
|
|
source {
|
|
srcDir "src"
|
|
include "**/*.cpp"
|
|
exclude "precompiled.cpp"
|
|
}
|
|
}
|
|
|
|
director_common(CppSourceSet) {
|
|
source {
|
|
srcDirs "../../common", "../common"
|
|
|
|
// common
|
|
include "BaseSystemModule.cpp"
|
|
include "ObjectDictionary.cpp"
|
|
include "ObjectList.cpp"
|
|
include "TokenLine.cpp"
|
|
|
|
// HLTV common
|
|
include "BitBuffer.cpp"
|
|
include "byteorder.cpp"
|
|
include "common.cpp"
|
|
include "DirectorCmd.cpp"
|
|
include "mathlib.cpp"
|
|
include "random.cpp"
|
|
}
|
|
}
|
|
|
|
director_engine(CppSourceSet) {
|
|
source {
|
|
srcDir "../../engine"
|
|
include "mem.cpp"
|
|
}
|
|
}
|
|
|
|
director_pch(CppSourceSet) {
|
|
source {
|
|
srcDir "src"
|
|
include "precompiled.cpp"
|
|
}
|
|
}
|
|
}
|
|
|
|
binaries.all {
|
|
NativeBinarySpec b -> project.setupToolchain(b)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task buildFixes {
|
|
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
|
|
blib.buildable && blib.buildType.name == 'release'
|
|
}
|
|
}
|
|
|
|
task buildRelease {
|
|
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
|
|
blib.buildable && blib.buildType.name == 'release'
|
|
}
|
|
}
|
|
|
|
// prevent static lib building
|
|
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
|
buildable = false
|
|
}
|