mirror of
https://github.com/rehlds/rehlds.git
synced 2025-03-16 07:20:31 +03:00
Added GccToolchain config - could be used via -PuseGcc command line argument.
This commit is contained in:
parent
94c23428db
commit
c4c9829146
@ -2,6 +2,7 @@ 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
|
||||
@ -9,6 +10,7 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
|
||||
|
||||
apply plugin: 'c'
|
||||
apply plugin: IccCompilerPlugin
|
||||
apply plugin: GccCompilerPlugin
|
||||
|
||||
void setupToolchain(NativeBinarySpec b) {
|
||||
def cfg = rootProject.createToolchainConfig(b)
|
||||
@ -36,9 +38,11 @@ model {
|
||||
}
|
||||
|
||||
toolChains {
|
||||
visualCpp(VisualCpp) {
|
||||
}
|
||||
icc(Icc) {
|
||||
visualCpp(VisualCpp)
|
||||
if (project.hasProperty("useGcc")) {
|
||||
gcc(Gcc)
|
||||
} else {
|
||||
icc(Icc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,13 @@ 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
|
||||
|
||||
apply plugin: 'cpp'
|
||||
apply plugin: IccCompilerPlugin
|
||||
apply plugin: GccCompilerPlugin
|
||||
|
||||
void setupToolchain(NativeBinarySpec b) {
|
||||
def cfg = rootProject.createToolchainConfig(b)
|
||||
@ -27,9 +29,11 @@ model {
|
||||
}
|
||||
|
||||
toolChains {
|
||||
visualCpp(VisualCpp) {
|
||||
}
|
||||
icc(Icc) {
|
||||
visualCpp(VisualCpp)
|
||||
if (project.hasProperty("useGcc")) {
|
||||
gcc(Gcc)
|
||||
} else {
|
||||
icc(Icc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import org.apache.commons.io.FilenameUtils
|
||||
|
||||
apply plugin: 'cpp'
|
||||
apply plugin: IccCompilerPlugin
|
||||
apply plugin: GccCompilerPlugin
|
||||
apply plugin: RehldsPlayTestPlugin
|
||||
apply plugin: gradlecpp.CppUnitTestPlugin
|
||||
|
||||
@ -109,6 +110,7 @@ void postEvaluate(NativeBinarySpec b) {
|
||||
}
|
||||
|
||||
void setupToolchain(NativeBinarySpec b) {
|
||||
boolean useGcc = project.hasProperty("useGcc")
|
||||
boolean unitTestExecutable = b.component.name.endsWith('_tests')
|
||||
boolean swdsLib = b.name.toLowerCase().contains('swds')
|
||||
boolean rehldsFixes = b.flavor.name.contains('rehldsFixes')
|
||||
@ -145,10 +147,12 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
cfg.projectLibpath(project, '/lib')
|
||||
cfg.extraLibs 'steam_api.lib', 'psapi.lib', 'ws2_32.lib', 'kernel32.lib', 'user32.lib', 'advapi32.lib', 'libacof32.lib'
|
||||
} else if (cfg instanceof GccToolchainConfig) {
|
||||
if (!useGcc) {
|
||||
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
|
||||
enabled: true,
|
||||
pchSourceSet: 'rehlds_pch'
|
||||
)
|
||||
}
|
||||
cfg.compilerOptions.languageStandard = 'c++0x'
|
||||
cfg.defines([
|
||||
'_stricmp': 'strcasecmp',
|
||||
@ -157,7 +161,12 @@ void setupToolchain(NativeBinarySpec b) {
|
||||
'_unlink': 'unlink',
|
||||
'_vsnprintf': 'vsnprintf',
|
||||
])
|
||||
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'
|
||||
} else {
|
||||
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
|
||||
}
|
||||
cfg.projectLibpath(project, '/lib/linux32')
|
||||
cfg.extraLibs 'rt', 'dl', 'm', 'steam_api', 'aelf32'
|
||||
}
|
||||
@ -263,9 +272,11 @@ model {
|
||||
}
|
||||
|
||||
toolChains {
|
||||
visualCpp(VisualCpp) {
|
||||
}
|
||||
icc(Icc) {
|
||||
visualCpp(VisualCpp)
|
||||
if (project.hasProperty("useGcc")) {
|
||||
gcc(Gcc)
|
||||
} else {
|
||||
icc(Icc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
|
||||
|
||||
apply from: 'shared_msvc.gradle'
|
||||
apply from: 'shared_icc.gradle'
|
||||
apply from: 'shared_gcc.gradle'
|
||||
|
||||
rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
|
||||
BinaryKind binaryKind
|
||||
@ -27,6 +28,8 @@ rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
|
||||
return rootProject.createMsvcConfig(releaseBuild, binaryKind)
|
||||
} else if (bin.toolChain instanceof Icc) {
|
||||
return rootProject.createIccConfig(releaseBuild, binaryKind)
|
||||
} else if (bin.toolChain instanceof Gcc) {
|
||||
return rootProject.createGccConfig(releaseBuild, binaryKind)
|
||||
} else {
|
||||
throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}")
|
||||
}
|
||||
|
62
shared_gcc.gradle
Normal file
62
shared_gcc.gradle
Normal file
@ -0,0 +1,62 @@
|
||||
import org.doomedsociety.gradlecpp.cfg.BinaryKind
|
||||
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
|
||||
import org.doomedsociety.gradlecpp.gcc.OptimizationLevel
|
||||
|
||||
rootProject.ext.createGccConfig = { boolean release, BinaryKind binKind ->
|
||||
GccToolchainConfig cfg
|
||||
if (release) {
|
||||
cfg = new GccToolchainConfig(
|
||||
compilerOptions: new GccToolchainConfig.CompilerOptions(
|
||||
optimizationLevel: OptimizationLevel.LEVEL_3,
|
||||
stackProtector: false,
|
||||
//interProceduralOptimizations: true,
|
||||
|
||||
noBuiltIn: true,
|
||||
|
||||
//intelExtensions: false,
|
||||
//asmBlocks: true,
|
||||
|
||||
positionIndependentCode: false
|
||||
),
|
||||
|
||||
linkerOptions: new GccToolchainConfig.LinkerOptions(
|
||||
//interProceduralOptimizations: true,
|
||||
stripSymbolTable: true,
|
||||
staticLibGcc: true,
|
||||
//staticIntel: true,
|
||||
staticLibStdCpp: true,
|
||||
),
|
||||
|
||||
librarianOptions: new GccToolchainConfig.LibrarianOptions(
|
||||
|
||||
)
|
||||
)
|
||||
} else {
|
||||
//debug
|
||||
cfg = new GccToolchainConfig(
|
||||
compilerOptions: new GccToolchainConfig.CompilerOptions(
|
||||
optimizationLevel: OptimizationLevel.DISABLE,
|
||||
stackProtector: true,
|
||||
//interProceduralOptimizations: false,
|
||||
|
||||
noBuiltIn: true,
|
||||
//intelExtensions: false,
|
||||
//asmBlocks: true
|
||||
),
|
||||
|
||||
linkerOptions: new GccToolchainConfig.LinkerOptions(
|
||||
//interProceduralOptimizations: false,
|
||||
stripSymbolTable: false,
|
||||
staticLibGcc: true,
|
||||
//staticIntel: true,
|
||||
staticLibStdCpp: true,
|
||||
),
|
||||
|
||||
librarianOptions: new GccToolchainConfig.LibrarianOptions(
|
||||
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user