2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-03-15 15:00:20 +03:00

Added GccToolchain config - could be used via -PuseGcc command line argument.

This commit is contained in:
Lev 2017-01-26 04:23:23 +05:00
parent 94c23428db
commit c4c9829146
11 changed files with 781 additions and 697 deletions

View File

@ -9,40 +9,40 @@ group = 'rehlds'
apply plugin: 'idea' apply plugin: 'idea'
idea { idea {
project { project {
languageLevel = 'JDK_1_7' languageLevel = 'JDK_1_7'
} }
} }
def gitInfo = GitVersioner.versionForDir(project.rootDir) def gitInfo = GitVersioner.versionForDir(project.rootDir)
RehldsVersionInfo versionInfo RehldsVersionInfo versionInfo
if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') { if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') {
def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
if (!m.find()) { if (!m.find()) {
throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}")
} }
versionInfo = new RehldsVersionInfo( versionInfo = new RehldsVersionInfo(
majorVersion: m.group(1) as int, majorVersion: m.group(1) as int,
minorVersion: m.group(2) as int, minorVersion: m.group(2) as int,
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null, maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
localChanges: gitInfo.localChanges, localChanges: gitInfo.localChanges,
commitDate: gitInfo.commitDate, commitDate: gitInfo.commitDate,
commitSHA: gitInfo.commitSHA, commitSHA: gitInfo.commitSHA,
commitURL: gitInfo.commitURL commitURL: gitInfo.commitURL
) )
} else { } else {
versionInfo = new RehldsVersionInfo( versionInfo = new RehldsVersionInfo(
majorVersion: project.majorVersion as int, majorVersion: project.majorVersion as int,
minorVersion: project.minorVersion as int, minorVersion: project.minorVersion as int,
maintenanceVersion: project.maintenanceVersion as int, maintenanceVersion: project.maintenanceVersion as int,
suffix: 'dev', suffix: 'dev',
localChanges: gitInfo ? gitInfo.localChanges : true, localChanges: gitInfo ? gitInfo.localChanges : true,
commitDate: gitInfo ? gitInfo.commitDate : new DateTime(), commitDate: gitInfo ? gitInfo.commitDate : new DateTime(),
commitSHA: gitInfo ? gitInfo.commitSHA : "", commitSHA: gitInfo ? gitInfo.commitSHA : "",
commitURL: gitInfo ? gitInfo.commitURL : "", commitURL: gitInfo ? gitInfo.commitURL : "",
commitCount: gitInfo ? (gitInfo.commitCount as int) : null commitCount: gitInfo ? (gitInfo.commitCount as int) : null
) )
} }
project.ext.rehldsVersionInfo = versionInfo project.ext.rehldsVersionInfo = versionInfo
@ -51,5 +51,5 @@ project.version = versionInfo.asMavenVersion()
apply from: 'publish.gradle' apply from: 'publish.gradle'
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '2.4' gradleVersion = '2.4'
} }

View File

@ -2,6 +2,7 @@ import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
import org.doomedsociety.gradlecpp.toolchain.icc.Icc import org.doomedsociety.gradlecpp.toolchain.icc.Icc
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
import org.gradle.nativeplatform.NativeBinarySpec import org.gradle.nativeplatform.NativeBinarySpec
import org.gradle.nativeplatform.NativeLibrarySpec import org.gradle.nativeplatform.NativeLibrarySpec
import org.gradle.nativeplatform.toolchain.VisualCpp import org.gradle.nativeplatform.toolchain.VisualCpp
@ -9,67 +10,70 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
apply plugin: 'c' apply plugin: 'c'
apply plugin: IccCompilerPlugin apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin
void setupToolchain(NativeBinarySpec b) { void setupToolchain(NativeBinarySpec b) {
def cfg = rootProject.createToolchainConfig(b) def cfg = rootProject.createToolchainConfig(b)
if (cfg instanceof MsvcToolchainConfig) { if (cfg instanceof MsvcToolchainConfig) {
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
enabled: true, enabled: true,
pchHeader: 'bzlib_private.h', pchHeader: 'bzlib_private.h',
pchSourceSet: 'bz2_pch' pchSourceSet: 'bz2_pch'
) )
} }
ToolchainConfigUtils.apply(project, cfg, b) ToolchainConfigUtils.apply(project, cfg, b)
} }
model { model {
buildTypes { buildTypes {
debug debug
release release
} }
platforms { platforms {
x86 { x86 {
architecture "x86" architecture "x86"
} }
} }
toolChains { toolChains {
visualCpp(VisualCpp) { visualCpp(VisualCpp)
} if (project.hasProperty("useGcc")) {
icc(Icc) { gcc(Gcc)
} } else {
} icc(Icc)
}
}
components { components {
bzip2(NativeLibrarySpec) { bzip2(NativeLibrarySpec) {
targetPlatform 'x86' targetPlatform 'x86'
sources { sources {
bz2_main(CSourceSet) { bz2_main(CSourceSet) {
source { source {
srcDir "src" srcDir "src"
include "**/*.c" include "**/*.c"
exclude "precompiled.c" exclude "precompiled.c"
} }
exportedHeaders { exportedHeaders {
srcDir "include" srcDir "include"
} }
} }
bz2_pch(CSourceSet) { bz2_pch(CSourceSet) {
source { source {
srcDir "src" srcDir "src"
include "precompiled.c" include "precompiled.c"
} }
exportedHeaders { exportedHeaders {
srcDir "include" srcDir "include"
} }
} }
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
} }
} }

View File

@ -2,38 +2,42 @@ import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
import org.doomedsociety.gradlecpp.toolchain.icc.Icc import org.doomedsociety.gradlecpp.toolchain.icc.Icc
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
import org.gradle.nativeplatform.NativeBinarySpec import org.gradle.nativeplatform.NativeBinarySpec
import org.gradle.nativeplatform.NativeLibrarySpec import org.gradle.nativeplatform.NativeLibrarySpec
apply plugin: 'cpp' apply plugin: 'cpp'
apply plugin: IccCompilerPlugin apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin
void setupToolchain(NativeBinarySpec b) { void setupToolchain(NativeBinarySpec b) {
def cfg = rootProject.createToolchainConfig(b) def cfg = rootProject.createToolchainConfig(b)
ToolchainConfigUtils.apply(project, cfg, b) ToolchainConfigUtils.apply(project, cfg, b)
} }
model { model {
buildTypes { buildTypes {
debug debug
release release
} }
platforms { platforms {
x86 { x86 {
architecture "x86" architecture "x86"
} }
} }
toolChains { toolChains {
visualCpp(VisualCpp) { visualCpp(VisualCpp)
} if (project.hasProperty("useGcc")) {
icc(Icc) { gcc(Gcc)
} } else {
} icc(Icc)
}
}
components { components {
cppunitlite(NativeLibrarySpec) { cppunitlite(NativeLibrarySpec) {
targetPlatform 'x86' targetPlatform 'x86'
@ -51,9 +55,9 @@ model {
} }
binaries.all { NativeBinarySpec b -> binaries.all { NativeBinarySpec b ->
project.setupToolchain(b) project.setupToolchain(b)
} }
} }
} }
} }

View File

@ -8,28 +8,28 @@ sourceCompatibility = '1.7'
targetCompatibility = '1.7' targetCompatibility = '1.7'
repositories { repositories {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
testCompile 'org.codehaus.groovy:groovy-all:2.4.5' testCompile 'org.codehaus.groovy:groovy-all:2.4.5'
testCompile "junit:junit:4.12" testCompile "junit:junit:4.12"
compile project(':flightrec/decoder_api') compile project(':flightrec/decoder_api')
} }
task uberjar(type: Jar, dependsOn: ['check', ':flightrec/decoder_api:build']) { task uberjar(type: Jar, dependsOn: ['check', ':flightrec/decoder_api:build']) {
from files(sourceSets.main.output.classesDir) from files(sourceSets.main.output.classesDir)
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
exclude('META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.LIST') //exclude all signing stuff exclude('META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.LIST') //exclude all signing stuff
manifest { manifest {
attributes 'Main-Class': 'org.rehlds.flightrec.main.FlightRecorder' attributes 'Main-Class': 'org.rehlds.flightrec.main.FlightRecorder'
attributes 'Implementation-Vendor': 'Sun Microsystems, Inc' attributes 'Implementation-Vendor': 'Sun Microsystems, Inc'
attributes 'Implementation-Title': 'Java Runtime Environment' attributes 'Implementation-Title': 'Java Runtime Environment'
attributes 'Implementation-Version': '1.7.0' attributes 'Implementation-Version': '1.7.0'
} }
} }
tasks.withType(AbstractCompile) { tasks.withType(AbstractCompile) {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }

View File

@ -8,67 +8,67 @@ sourceCompatibility = '1.7'
targetCompatibility = '1.7' targetCompatibility = '1.7'
repositories { repositories {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
testCompile "junit:junit:4.12" testCompile "junit:junit:4.12"
} }
publishing { publishing {
publications { publications {
maven(MavenPublication) { maven(MavenPublication) {
version project.version version project.version
artifactId 'decoder-api' artifactId 'decoder-api'
artifact jar artifact jar
pom.withXml { pom.withXml {
asNode().children().last() + { asNode().children().last() + {
resolveStrategy = DELEGATE_FIRST resolveStrategy = DELEGATE_FIRST
name 'decoder-api' name 'decoder-api'
description project.description description project.description
//url github //url github
//scm { //scm {
// url "${github}.git" // url "${github}.git"
// connection "scm:git:${github}.git" // connection "scm:git:${github}.git"
//} //}
/* /*
licenses { licenses {
license { license {
name 'The Apache Software License, Version 2.0' name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo' distribution 'repo'
} }
} }
developers { developers {
developer { developer {
id 'dreamstalker' id 'dreamstalker'
name 'dreamstalker' name 'dreamstalker'
} }
} }
*/ */
} }
} }
} }
} }
} }
publishing { publishing {
repositories { repositories {
maven { maven {
if (project.version.contains('dev')) { if (project.version.contains('dev')) {
url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/"
} else { } else {
url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/"
} }
credentials { credentials {
username rootProject.repoCreds.getProperty('username') username rootProject.repoCreds.getProperty('username')
password rootProject.repoCreds.getProperty('password') password rootProject.repoCreds.getProperty('password')
} }
} }
} }
} }
tasks.withType(AbstractCompile) { tasks.withType(AbstractCompile) {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }

View File

@ -2,154 +2,154 @@ import org.doomedsociety.gradlecpp.GradleCppUtils
import org.apache.commons.io.FilenameUtils import org.apache.commons.io.FilenameUtils
void _copyFileToDir(String from, String to) { void _copyFileToDir(String from, String to) {
def dst = new File(project.file(to), FilenameUtils.getName(from)) def dst = new File(project.file(to), FilenameUtils.getName(from))
GradleCppUtils.copyFile(project.file(from), dst, false) GradleCppUtils.copyFile(project.file(from), dst, false)
} }
void _copyFile(String from, String to) { void _copyFile(String from, String to) {
GradleCppUtils.copyFile(project.file(from), project.file(to), false) GradleCppUtils.copyFile(project.file(from), project.file(to), false)
} }
task publishPrepareFiles { task publishPrepareFiles {
dependsOn ':flightrec/decoder:uberjar' dependsOn ':flightrec/decoder:uberjar'
doLast { doLast {
def pubRootDir = project.file('publish/publishRoot') def pubRootDir = project.file('publish/publishRoot')
if (pubRootDir.exists()) { if (pubRootDir.exists()) {
if (!pubRootDir.deleteDir()) { if (!pubRootDir.deleteDir()) {
throw new RuntimeException("Failed to delete ${pubRootDir}") throw new RuntimeException("Failed to delete ${pubRootDir}")
} }
} }
pubRootDir.mkdirs() pubRootDir.mkdirs()
//bugfixed binaries //bugfixed binaries
project.file('publish/publishRoot/bin/bugfixed').mkdirs() project.file('publish/publishRoot/bin/bugfixed').mkdirs()
_copyFileToDir('publish/releaseRehldsFixes/swds.dll', 'publish/publishRoot/bin/bugfixed/') _copyFileToDir('publish/releaseRehldsFixes/swds.dll', 'publish/publishRoot/bin/bugfixed/')
_copyFileToDir('publish/releaseRehldsFixes/swds.pdb', 'publish/publishRoot/bin/bugfixed/') _copyFileToDir('publish/releaseRehldsFixes/swds.pdb', 'publish/publishRoot/bin/bugfixed/')
_copyFile('publish/releaseRehldsFixes/libengine_i486.so', 'publish/publishRoot/bin/bugfixed/engine_i486.so') _copyFile('publish/releaseRehldsFixes/libengine_i486.so', 'publish/publishRoot/bin/bugfixed/engine_i486.so')
//pure binaries //pure binaries
project.file('publish/publishRoot/bin/pure').mkdirs() project.file('publish/publishRoot/bin/pure').mkdirs()
_copyFileToDir('publish/releaseRehldsNofixes/swds.dll', 'publish/publishRoot/bin/pure/') _copyFileToDir('publish/releaseRehldsNofixes/swds.dll', 'publish/publishRoot/bin/pure/')
_copyFileToDir('publish/releaseRehldsNofixes/swds.pdb', 'publish/publishRoot/bin/pure/') _copyFileToDir('publish/releaseRehldsNofixes/swds.pdb', 'publish/publishRoot/bin/pure/')
_copyFile('publish/releaseRehldsNofixes/libengine_i486.so', 'publish/publishRoot/bin/pure/engine_i486.so') _copyFile('publish/releaseRehldsNofixes/libengine_i486.so', 'publish/publishRoot/bin/pure/engine_i486.so')
//hlsdk //hlsdk
project.file('publish/publishRoot/hlsdk').mkdirs() project.file('publish/publishRoot/hlsdk').mkdirs()
copy { copy {
from 'rehlds/common' from 'rehlds/common'
into 'publish/publishRoot/hlsdk/common' into 'publish/publishRoot/hlsdk/common'
} }
copy { copy {
from 'rehlds/dlls' from 'rehlds/dlls'
into 'publish/publishRoot/hlsdk/dlls' into 'publish/publishRoot/hlsdk/dlls'
} }
copy { copy {
from 'rehlds/pm_shared' from 'rehlds/pm_shared'
into 'publish/publishRoot/hlsdk/pm_shared' into 'publish/publishRoot/hlsdk/pm_shared'
} }
copy { copy {
from 'rehlds/public' from 'rehlds/public'
into 'publish/publishRoot/hlsdk/public' into 'publish/publishRoot/hlsdk/public'
exclude '**/rehlds/*', '**/tier0/*' exclude '**/rehlds/*', '**/tier0/*'
} }
copy { copy {
from 'rehlds/public/rehlds' from 'rehlds/public/rehlds'
into 'publish/publishRoot/hlsdk/engine' into 'publish/publishRoot/hlsdk/engine'
} }
//flightrecorder //flightrecorder
def flightRecJarTask = project(':flightrec/decoder').tasks.getByName('uberjar') def flightRecJarTask = project(':flightrec/decoder').tasks.getByName('uberjar')
println flightRecJarTask println flightRecJarTask
println flightRecJarTask.class.name println flightRecJarTask.class.name
File flightRecJarFile = flightRecJarTask.archivePath File flightRecJarFile = flightRecJarTask.archivePath
project.file('publish/publishRoot/flighrec').mkdirs() project.file('publish/publishRoot/flighrec').mkdirs()
GradleCppUtils.copyFile(flightRecJarFile, project.file('publish/publishRoot/flighrec/decoder.jar'), false) GradleCppUtils.copyFile(flightRecJarFile, project.file('publish/publishRoot/flighrec/decoder.jar'), false)
copy { copy {
from new File(project(':flightrec/decoder').projectDir, 'pub') from new File(project(':flightrec/decoder').projectDir, 'pub')
into 'publish/publishRoot/flighrec' into 'publish/publishRoot/flighrec'
} }
} }
} }
task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
baseName = "rehlds-dist-${project.version}" baseName = "rehlds-dist-${project.version}"
destinationDir file('publish') destinationDir file('publish')
from 'publish/publishRoot' from 'publish/publishRoot'
} }
publishing { publishing {
publications { publications {
maven(MavenPublication) { maven(MavenPublication) {
version project.version version project.version
artifact publishPackage artifact publishPackage
pom.withXml { pom.withXml {
asNode().children().last() + { asNode().children().last() + {
resolveStrategy = DELEGATE_FIRST resolveStrategy = DELEGATE_FIRST
name project.name name project.name
description project.description description project.description
properties { properties {
commitDate project.ext.rehldsVersionInfo.commitDate commitDate project.ext.rehldsVersionInfo.commitDate
commitSHA project.ext.rehldsVersionInfo.commitSHA commitSHA project.ext.rehldsVersionInfo.commitSHA
} }
//url github //url github
//scm { //scm {
// url "${github}.git" // url "${github}.git"
// connection "scm:git:${github}.git" // connection "scm:git:${github}.git"
//} //}
/* /*
licenses { licenses {
license { license {
name 'The Apache Software License, Version 2.0' name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt' url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo' distribution 'repo'
} }
} }
developers { developers {
developer { developer {
id 'dreamstalker' id 'dreamstalker'
name 'dreamstalker' name 'dreamstalker'
} }
} }
*/ */
} }
} }
} }
} }
} }
Properties repoCreds = new Properties() Properties repoCreds = new Properties()
project.ext.repoCreds = repoCreds project.ext.repoCreds = repoCreds
if (file('repo_creds.properties').exists()) { if (file('repo_creds.properties').exists()) {
println 'Loading maven repo credentials' println 'Loading maven repo credentials'
file('repo_creds.properties').withReader('UTF-8', { Reader r -> file('repo_creds.properties').withReader('UTF-8', { Reader r ->
repoCreds.load(r) repoCreds.load(r)
}) })
} }
publishing { publishing {
repositories { repositories {
maven { maven {
if (project.version.contains('dev')) { if (project.version.contains('dev')) {
url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/"
} else { } else {
url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/"
} }
credentials { credentials {
username repoCreds.getProperty('username') username repoCreds.getProperty('username')
password repoCreds.getProperty('password') password repoCreds.getProperty('password')
} }
} }
} }
} }
task doPublish { task doPublish {
dependsOn 'publishPackage' dependsOn 'publishPackage'
if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) { if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) {
dependsOn 'publish' dependsOn 'publish'
dependsOn ':flightrec/decoder_api:publish' dependsOn ':flightrec/decoder_api:publish'
} }
} }

View File

@ -23,6 +23,7 @@ import org.apache.commons.io.FilenameUtils
apply plugin: 'cpp' apply plugin: 'cpp'
apply plugin: IccCompilerPlugin apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin
apply plugin: RehldsPlayTestPlugin apply plugin: RehldsPlayTestPlugin
apply plugin: gradlecpp.CppUnitTestPlugin apply plugin: gradlecpp.CppUnitTestPlugin
@ -33,303 +34,313 @@ repositories {
} }
configurations { configurations {
rehlds_tests rehlds_tests
} }
dependencies { dependencies {
rehlds_tests 'rehlds.testdemos:hl-phys-single1:1.1' rehlds_tests 'rehlds.testdemos:hl-phys-single1:1.1'
rehlds_tests 'rehlds.testdemos:crossfire-1-multiplayer-1:1.1' rehlds_tests 'rehlds.testdemos:crossfire-1-multiplayer-1:1.1'
rehlds_tests 'rehlds.testdemos:cstrike-muliplayer-1:1.1' rehlds_tests 'rehlds.testdemos:cstrike-muliplayer-1:1.1'
rehlds_tests 'rehlds.testdemos:shooting-hl-1:1.1' rehlds_tests 'rehlds.testdemos:shooting-hl-1:1.1'
} }
project.ext.dep_bzip2 = project(':dep/bzip2') project.ext.dep_bzip2 = project(':dep/bzip2')
project.ext.dep_cppunitlite = project(':dep/cppunitlite') project.ext.dep_cppunitlite = project(':dep/cppunitlite')
void createIntergrationTestTask(NativeBinarySpec b) { void createIntergrationTestTask(NativeBinarySpec b) {
boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') boolean rehldsFixes = b.flavor.name.contains('rehldsFixes')
if (!(b instanceof SharedLibraryBinarySpec)) return if (!(b instanceof SharedLibraryBinarySpec)) return
if (!GradleCppUtils.windows) return if (!GradleCppUtils.windows) return
if (rehldsFixes) return if (rehldsFixes) return
def libLinkTask = GradleCppUtils.getLinkTask(b) def libLinkTask = GradleCppUtils.getLinkTask(b)
String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null
def depFiles = [] def depFiles = []
depFiles.addAll(libLinkTask.outputs.files.files) depFiles.addAll(libLinkTask.outputs.files.files)
def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RehldsPlayTestTask) def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RehldsPlayTestTask)
demoItgTestTask.with { demoItgTestTask.with {
rehldsImageRoot = new File(project.projectDir, '_rehldsTestImg') rehldsImageRoot = new File(project.projectDir, '_rehldsTestImg')
rehldsTestLogs = new File(this.project.buildDir, "_rehldsTestLogs/${b.name}") rehldsTestLogs = new File(this.project.buildDir, "_rehldsTestLogs/${b.name}")
testDemos = project.configurations.rehlds_tests testDemos = project.configurations.rehlds_tests
testFor = b testFor = b
//inputs/outputs for up-to-date check //inputs/outputs for up-to-date check
inputs.files depFiles inputs.files depFiles
inputs.files testDemos.files inputs.files testDemos.files
outputs.dir rehldsTestLogs outputs.dir rehldsTestLogs
//dependencies on library and test executable //dependencies on library and test executable
dependsOn libLinkTask dependsOn libLinkTask
if (unitTestTask) { if (unitTestTask) {
dependsOn unitTestTask dependsOn unitTestTask
} }
postExtractAction { postExtractAction {
def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b) def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b)
GradleCppUtils.copyFile(binaryOutFile, new File(rehldsImageRoot, binaryOutFile.name), true) GradleCppUtils.copyFile(binaryOutFile, new File(rehldsImageRoot, binaryOutFile.name), true)
} }
} }
b.buildTask.dependsOn demoItgTestTask b.buildTask.dependsOn demoItgTestTask
} }
void setupUnitTests(NativeBinarySpec bin) { void setupUnitTests(NativeBinarySpec bin) {
boolean unitTestExecutable = bin.component.name.endsWith('_tests') boolean unitTestExecutable = bin.component.name.endsWith('_tests')
if (!unitTestExecutable) return if (!unitTestExecutable) return
GradleCppUtils.getLinkTask(bin).doLast { GradleCppUtils.getLinkTask(bin).doLast {
String srcPath = '' + projectDir + (GradleCppUtils.windows ? '/lib/steam_api.dll' : '/lib/linux32/libsteam_api.so') String srcPath = '' + projectDir + (GradleCppUtils.windows ? '/lib/steam_api.dll' : '/lib/linux32/libsteam_api.so')
String dstPath = bin.executableFile.parent + (GradleCppUtils.windows ? '/steam_api.dll' : '/libsteam_api.so') String dstPath = bin.executableFile.parent + (GradleCppUtils.windows ? '/steam_api.dll' : '/libsteam_api.so')
GradleCppUtils.copyFile(srcPath, dstPath, true) GradleCppUtils.copyFile(srcPath, dstPath, true)
} }
} }
void postEvaluate(NativeBinarySpec b) { void postEvaluate(NativeBinarySpec b) {
// attach generateAppVersion task to all 'compile source' tasks // attach generateAppVersion task to all 'compile source' tasks
GradleCppUtils.getCompileTasks(b).each { Task t -> GradleCppUtils.getCompileTasks(b).each { Task t ->
t.dependsOn project.generateAppVersion t.dependsOn project.generateAppVersion
} }
setupUnitTests(b) setupUnitTests(b)
createIntergrationTestTask(b) createIntergrationTestTask(b)
} }
void setupToolchain(NativeBinarySpec b) { void setupToolchain(NativeBinarySpec b) {
boolean unitTestExecutable = b.component.name.endsWith('_tests') boolean useGcc = project.hasProperty("useGcc")
boolean swdsLib = b.name.toLowerCase().contains('swds') boolean unitTestExecutable = b.component.name.endsWith('_tests')
boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') boolean swdsLib = b.name.toLowerCase().contains('swds')
boolean rehldsFixes = b.flavor.name.contains('rehldsFixes')
ToolchainConfig cfg = rootProject.createToolchainConfig(b) ToolchainConfig cfg = rootProject.createToolchainConfig(b)
cfg.projectInclude(project, '', '/public/rehlds', '/engine', '/common', '/pm_shared', '/rehlds', '/testsuite', '/hookers', '/public') cfg.projectInclude(project, '', '/public/rehlds', '/engine', '/common', '/pm_shared', '/rehlds', '/testsuite', '/hookers', '/public')
cfg.projectInclude(dep_bzip2, '/include') cfg.projectInclude(dep_bzip2, '/include')
if (unitTestExecutable) { if (unitTestExecutable) {
cfg.projectInclude(dep_cppunitlite, '/include') cfg.projectInclude(dep_cppunitlite, '/include')
b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true) b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true)
} }
b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true) b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true)
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'SWDS', 'REHLDS_SELF', 'REHLDS_OPT_PEDANTIC', 'REHLDS_FLIGHT_REC' cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'SWDS', 'REHLDS_SELF', 'REHLDS_OPT_PEDANTIC', 'REHLDS_FLIGHT_REC'
if (cfg instanceof MsvcToolchainConfig) { if (cfg instanceof MsvcToolchainConfig) {
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
enabled: true, enabled: true,
pchHeader: 'precompiled.h', pchHeader: 'precompiled.h',
pchSourceSet: 'rehlds_pch' pchSourceSet: 'rehlds_pch'
) )
cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') cfg.singleDefines('_CRT_SECURE_NO_WARNINGS')
if (!rehldsFixes) { if (!rehldsFixes) {
cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE
cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED
} else { } else {
cfg.compilerOptions.args '/Oi', '/GF', '/GR-', '/GS-' cfg.compilerOptions.args '/Oi', '/GF', '/GR-', '/GS-'
} }
if (swdsLib) { if (swdsLib) {
cfg.linkerOptions.randomizedBaseAddress = false cfg.linkerOptions.randomizedBaseAddress = false
cfg.linkerOptions.baseAddress = '0x4970000' cfg.linkerOptions.baseAddress = '0x4970000'
} }
cfg.projectLibpath(project, '/lib') cfg.projectLibpath(project, '/lib')
cfg.extraLibs 'steam_api.lib', 'psapi.lib', 'ws2_32.lib', 'kernel32.lib', 'user32.lib', 'advapi32.lib', 'libacof32.lib' cfg.extraLibs 'steam_api.lib', 'psapi.lib', 'ws2_32.lib', 'kernel32.lib', 'user32.lib', 'advapi32.lib', 'libacof32.lib'
} else if (cfg instanceof GccToolchainConfig) { } else if (cfg instanceof GccToolchainConfig) {
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( if (!useGcc) {
enabled: true, cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
pchSourceSet: 'rehlds_pch' enabled: true,
) pchSourceSet: 'rehlds_pch'
cfg.compilerOptions.languageStandard = 'c++0x' )
cfg.defines([ }
'_stricmp': 'strcasecmp', cfg.compilerOptions.languageStandard = 'c++0x'
'_strnicmp': 'strncasecmp', cfg.defines([
'_strdup': 'strdup', '_stricmp': 'strcasecmp',
'_unlink': 'unlink', '_strnicmp': 'strncasecmp',
'_vsnprintf': 'vsnprintf', '_strdup': 'strdup',
]) '_unlink': 'unlink',
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti' '_vsnprintf': 'vsnprintf',
cfg.projectLibpath(project, '/lib/linux32') ])
cfg.extraLibs 'rt', 'dl', 'm', 'steam_api', 'aelf32' 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'
}
if (!unitTestExecutable && !swdsLib) { if (!unitTestExecutable && !swdsLib) {
cfg.singleDefines 'HOOK_ENGINE' cfg.singleDefines 'HOOK_ENGINE'
} }
if (unitTestExecutable) { if (unitTestExecutable) {
cfg.singleDefines 'REHLDS_UNIT_TESTS' cfg.singleDefines 'REHLDS_UNIT_TESTS'
} }
if (rehldsFixes) { if (rehldsFixes) {
cfg.singleDefines 'REHLDS_FIXES', 'REHLDS_CHECKS' cfg.singleDefines 'REHLDS_FIXES', 'REHLDS_CHECKS'
} }
ToolchainConfigUtils.apply(project, cfg, b) ToolchainConfigUtils.apply(project, cfg, b)
GradleCppUtils.onTasksCreated(project, 'postEvaluate', { GradleCppUtils.onTasksCreated(project, 'postEvaluate', {
postEvaluate(b) postEvaluate(b)
}) })
} }
class RehldsSrc { class RehldsSrc {
static void rehlds_src(def h) { static void rehlds_src(def h) {
h.rehlds_src(CppSourceSet) { h.rehlds_src(CppSourceSet) {
source { source {
srcDirs "engine", "rehlds", "public", "version" srcDirs "engine", "rehlds", "public", "version"
if (GradleCppUtils.windows) srcDirs "testsuite" if (GradleCppUtils.windows) srcDirs "testsuite"
include "**/*.cpp" include "**/*.cpp"
exclude "precompiled.cpp" exclude "precompiled.cpp"
exclude GradleCppUtils.windows ? "tier0/platform_linux.cpp" : "tier0/platform_win32.cpp" exclude GradleCppUtils.windows ? "tier0/platform_linux.cpp" : "tier0/platform_win32.cpp"
exclude "interface.cpp", "rehlds/crc32c.cpp", "rehlds/sys_shared.cpp" exclude "interface.cpp", "rehlds/crc32c.cpp", "rehlds/sys_shared.cpp"
} }
source { source {
srcDirs "hookers" srcDirs "hookers"
include "**/*.cpp" include "**/*.cpp"
exclude "6132_hooker.cpp", "hooker.cpp", "main.cpp", "main_swds.cpp" exclude "6132_hooker.cpp", "hooker.cpp", "main.cpp", "main_swds.cpp"
if (!GradleCppUtils.windows) exclude "rehlds_debug.cpp" if (!GradleCppUtils.windows) exclude "rehlds_debug.cpp"
} }
} }
} }
static void rehlds_pch(def h) { static void rehlds_pch(def h) {
h.rehlds_pch(CppSourceSet) { h.rehlds_pch(CppSourceSet) {
source { source {
srcDirs "rehlds" srcDirs "rehlds"
include "precompiled.cpp" include "precompiled.cpp"
} }
} }
} }
static void rehlds_hooker_src(def h) { static void rehlds_hooker_src(def h) {
h.rehlds_hooker_src(CppSourceSet) { h.rehlds_hooker_src(CppSourceSet) {
source { source {
srcDirs "hookers" srcDirs "hookers"
include "6132_hooker.cpp", "hooker.cpp" include "6132_hooker.cpp", "hooker.cpp"
} }
} }
} }
static void rehlds_hooker_main_src(def h) { static void rehlds_hooker_main_src(def h) {
h.rehlds_hooker_main_src(CppSourceSet) { h.rehlds_hooker_main_src(CppSourceSet) {
source { source {
srcDirs "hookers" srcDirs "hookers"
include "main.cpp" include "main.cpp"
} }
} }
} }
static void rehlds_swds_main_src(def h) { static void rehlds_swds_main_src(def h) {
h.rehlds_swds_main_src(CppSourceSet) { h.rehlds_swds_main_src(CppSourceSet) {
source { source {
srcDirs "hookers" srcDirs "hookers"
include "main_swds.cpp" include "main_swds.cpp"
} }
} }
} }
static void rehlds_tests_src(def h) { static void rehlds_tests_src(def h) {
h.rehlds_tests_src(CppSourceSet) { h.rehlds_tests_src(CppSourceSet) {
source { source {
srcDir "unittests" srcDir "unittests"
include "**/*.cpp" include "**/*.cpp"
} }
} }
} }
} }
model { model {
buildTypes { buildTypes {
debug debug
release release
} }
platforms { platforms {
x86 { x86 {
architecture "x86" architecture "x86"
} }
} }
toolChains { toolChains {
visualCpp(VisualCpp) { visualCpp(VisualCpp)
} if (project.hasProperty("useGcc")) {
icc(Icc) { gcc(Gcc)
} } else {
} icc(Icc)
}
}
flavors { flavors {
rehldsNofixes rehldsNofixes
rehldsFixes rehldsFixes
} }
components { components {
rehlds_hooker_engine(NativeLibrarySpec) { rehlds_hooker_engine(NativeLibrarySpec) {
targetPlatform 'x86' targetPlatform 'x86'
baseName 'FileSystem_Stdio' baseName 'FileSystem_Stdio'
sources { sources {
RehldsSrc.rehlds_pch(it) RehldsSrc.rehlds_pch(it)
RehldsSrc.rehlds_src(it) RehldsSrc.rehlds_src(it)
RehldsSrc.rehlds_hooker_src(it) RehldsSrc.rehlds_hooker_src(it)
RehldsSrc.rehlds_hooker_main_src(it) RehldsSrc.rehlds_hooker_main_src(it)
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
rehlds_swds_engine(NativeLibrarySpec) { rehlds_swds_engine(NativeLibrarySpec) {
targetPlatform 'x86' targetPlatform 'x86'
baseName GradleCppUtils.windows ? 'swds' : 'engine_i486' baseName GradleCppUtils.windows ? 'swds' : 'engine_i486'
sources { sources {
RehldsSrc.rehlds_pch(it) RehldsSrc.rehlds_pch(it)
RehldsSrc.rehlds_src(it) RehldsSrc.rehlds_src(it)
RehldsSrc.rehlds_swds_main_src(it) RehldsSrc.rehlds_swds_main_src(it)
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
rehlds_hooker_engine_tests(NativeExecutableSpec) { rehlds_hooker_engine_tests(NativeExecutableSpec) {
targetPlatform 'x86' targetPlatform 'x86'
sources { sources {
RehldsSrc.rehlds_pch(it) RehldsSrc.rehlds_pch(it)
RehldsSrc.rehlds_src(it) RehldsSrc.rehlds_src(it)
RehldsSrc.rehlds_tests_src(it) RehldsSrc.rehlds_tests_src(it)
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
rehlds_swds_engine_tests(NativeExecutableSpec) { rehlds_swds_engine_tests(NativeExecutableSpec) {
targetPlatform 'x86' targetPlatform 'x86'
sources { sources {
RehldsSrc.rehlds_pch(it) RehldsSrc.rehlds_pch(it)
RehldsSrc.rehlds_src(it) RehldsSrc.rehlds_src(it)
RehldsSrc.rehlds_tests_src(it) RehldsSrc.rehlds_tests_src(it)
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
} }
} }
task buildRelease { task buildRelease {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
blib.buildable && blib.buildType.name == 'release' && !blib.name.contains('Rehlds_hooker_engine') blib.buildable && blib.buildType.name == 'release' && !blib.name.contains('Rehlds_hooker_engine')
} }
} }
task buildFixes { task buildFixes {
@ -351,21 +362,21 @@ gradle.taskGraph.whenReady { graph ->
} }
task prepareDevEnvTests { task prepareDevEnvTests {
def rehldsTests = new File(project.projectDir, '_dev/testDemos') def rehldsTests = new File(project.projectDir, '_dev/testDemos')
inputs.files configurations.rehlds_tests.files inputs.files configurations.rehlds_tests.files
outputs.dir rehldsTests outputs.dir rehldsTests
doLast { doLast {
rehldsTests.mkdirs() rehldsTests.mkdirs()
configurations.rehlds_tests.files.each { File f -> configurations.rehlds_tests.files.each { File f ->
def t = zipTree(f) def t = zipTree(f)
copy { copy {
into new File(rehldsTests, FilenameUtils.getBaseName(f.absolutePath)) into new File(rehldsTests, FilenameUtils.getBaseName(f.absolutePath))
from t from t
} }
} }
} }
} }
task prepareDevEnvEngine << { task prepareDevEnvEngine << {
@ -378,40 +389,40 @@ task prepareDevEnvEngine << {
} }
task prepareDevEnv { task prepareDevEnv {
dependsOn prepareDevEnvEngine, prepareDevEnvTests dependsOn prepareDevEnvEngine, prepareDevEnvTests
} }
tasks.clean.doLast { tasks.clean.doLast {
project.file('version/appversion.h').delete() project.file('version/appversion.h').delete()
} }
task generateAppVersion { task generateAppVersion {
RehldsVersionInfo verInfo = (RehldsVersionInfo) rootProject.rehldsVersionInfo RehldsVersionInfo verInfo = (RehldsVersionInfo) rootProject.rehldsVersionInfo
def tplFile = project.file('version/appversion.vm') def tplFile = project.file('version/appversion.vm')
def renderedFile = project.file('version/appversion.h') def renderedFile = project.file('version/appversion.h')
// check to up-to-date // check to up-to-date
inputs.file tplFile inputs.file tplFile
inputs.file project.file('gradle.properties') inputs.file project.file('gradle.properties')
outputs.file renderedFile outputs.file renderedFile
// this will ensure that this task is redone when the versions change // this will ensure that this task is redone when the versions change
inputs.property('version', rootProject.version) inputs.property('version', rootProject.version)
inputs.property('commitDate', verInfo.asCommitDate()) inputs.property('commitDate', verInfo.asCommitDate())
println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']"; println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']";
doLast { doLast {
def templateCtx = [ def templateCtx = [
verInfo : verInfo verInfo : verInfo
] ]
def content = VelocityUtils.renderTemplate(tplFile, templateCtx) def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
renderedFile.delete() renderedFile.delete()
renderedFile.write(content, 'utf-8') renderedFile.write(content, 'utf-8')
println 'The current ReHLDS maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')'; println 'The current ReHLDS maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
} }
} }

View File

@ -8,26 +8,29 @@ import org.gradle.nativeplatform.toolchain.VisualCpp
apply from: 'shared_msvc.gradle' apply from: 'shared_msvc.gradle'
apply from: 'shared_icc.gradle' apply from: 'shared_icc.gradle'
apply from: 'shared_gcc.gradle'
rootProject.ext.createToolchainConfig = { NativeBinarySpec bin -> rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
BinaryKind binaryKind BinaryKind binaryKind
if (bin instanceof NativeExecutableBinarySpec) { if (bin instanceof NativeExecutableBinarySpec) {
binaryKind = BinaryKind.EXECUTABLE binaryKind = BinaryKind.EXECUTABLE
} else if (bin instanceof SharedLibraryBinarySpec) { } else if (bin instanceof SharedLibraryBinarySpec) {
binaryKind = BinaryKind.SHARED_LIBRARY binaryKind = BinaryKind.SHARED_LIBRARY
} else if (bin instanceof StaticLibraryBinarySpec) { } else if (bin instanceof StaticLibraryBinarySpec) {
binaryKind = BinaryKind.STATIC_LIBRARY binaryKind = BinaryKind.STATIC_LIBRARY
} else { } else {
throw new RuntimeException("Unknown executable kind ${bin.class.name}") throw new RuntimeException("Unknown executable kind ${bin.class.name}")
} }
boolean releaseBuild = bin.buildType.name.toLowerCase() == 'release' boolean releaseBuild = bin.buildType.name.toLowerCase() == 'release'
if (bin.toolChain instanceof VisualCpp) { if (bin.toolChain instanceof VisualCpp) {
return rootProject.createMsvcConfig(releaseBuild, binaryKind) return rootProject.createMsvcConfig(releaseBuild, binaryKind)
} else if (bin.toolChain instanceof Icc) { } else if (bin.toolChain instanceof Icc) {
return rootProject.createIccConfig(releaseBuild, binaryKind) return rootProject.createIccConfig(releaseBuild, binaryKind)
} else { } else if (bin.toolChain instanceof Gcc) {
throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}") return rootProject.createGccConfig(releaseBuild, binaryKind)
} } else {
throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}")
}
} }

62
shared_gcc.gradle Normal file
View 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
}

View File

@ -3,60 +3,60 @@ import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
import org.doomedsociety.gradlecpp.gcc.OptimizationLevel import org.doomedsociety.gradlecpp.gcc.OptimizationLevel
rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind -> rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
GccToolchainConfig cfg GccToolchainConfig cfg
if (release) { if (release) {
cfg = new GccToolchainConfig( cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions( compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.LEVEL_3, optimizationLevel: OptimizationLevel.LEVEL_3,
stackProtector: false, stackProtector: false,
interProceduralOptimizations: true, interProceduralOptimizations: true,
noBuiltIn: true, noBuiltIn: true,
intelExtensions: false, intelExtensions: false,
asmBlocks: true, asmBlocks: true,
positionIndependentCode: false positionIndependentCode: false
), ),
linkerOptions: new GccToolchainConfig.LinkerOptions( linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: true, interProceduralOptimizations: true,
stripSymbolTable: true, stripSymbolTable: true,
staticLibGcc: true, staticLibGcc: true,
staticIntel: true, staticIntel: true,
staticLibStdCpp: true, staticLibStdCpp: true,
), ),
librarianOptions: new GccToolchainConfig.LibrarianOptions( librarianOptions: new GccToolchainConfig.LibrarianOptions(
) )
) )
} else { } else {
//debug //debug
cfg = new GccToolchainConfig( cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions( compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.DISABLE, optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true, stackProtector: true,
interProceduralOptimizations: false, interProceduralOptimizations: false,
noBuiltIn: true, noBuiltIn: true,
intelExtensions: false, intelExtensions: false,
asmBlocks: true asmBlocks: true
), ),
linkerOptions: new GccToolchainConfig.LinkerOptions( linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: false, interProceduralOptimizations: false,
stripSymbolTable: false, stripSymbolTable: false,
staticLibGcc: true, staticLibGcc: true,
staticIntel: true, staticIntel: true,
staticLibStdCpp: true, staticLibStdCpp: true,
), ),
librarianOptions: new GccToolchainConfig.LibrarianOptions( librarianOptions: new GccToolchainConfig.LibrarianOptions(
) )
) )
} }
return cfg return cfg
} }

View File

@ -13,111 +13,111 @@ import org.doomedsociety.gradlecpp.msvc.RuntimeChecks
import org.doomedsociety.gradlecpp.msvc.WarningLevel import org.doomedsociety.gradlecpp.msvc.WarningLevel
rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind -> rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
MsvcToolchainConfig cfg MsvcToolchainConfig cfg
if (release) { if (release) {
cfg = new MsvcToolchainConfig( cfg = new MsvcToolchainConfig(
compilerOptions: new MsvcToolchainConfig.CompilerOptions( compilerOptions: new MsvcToolchainConfig.CompilerOptions(
codeGeneration: CodeGenerationKind.MULTITHREADED, codeGeneration: CodeGenerationKind.MULTITHREADED,
optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION, optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION,
debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
runtimeChecks: RuntimeChecks.DEFAULT, runtimeChecks: RuntimeChecks.DEFAULT,
cppExceptions: CppExceptions.ENABLED_WITH_SEH, cppExceptions: CppExceptions.ENABLED_WITH_SEH,
warningLevel: WarningLevel.LEVEL_3, warningLevel: WarningLevel.LEVEL_3,
callingConvention: CallingConvention.CDECL, callingConvention: CallingConvention.CDECL,
enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
floatingPointModel: FloatingPointModel.FAST, floatingPointModel: FloatingPointModel.FAST,
enableMinimalRebuild: false, enableMinimalRebuild: false,
omitFramePointers: false, omitFramePointers: false,
wholeProgramOptimization: true, wholeProgramOptimization: true,
enabledFunctionLevelLinking: true, enabledFunctionLevelLinking: true,
enableSecurityCheck: true, enableSecurityCheck: true,
analyzeCode: false, analyzeCode: false,
sdlChecks: false, sdlChecks: false,
treatWarningsAsErrors: false, treatWarningsAsErrors: false,
treatWchartAsBuiltin: true, treatWchartAsBuiltin: true,
forceConformanceInForLoopScope: true, forceConformanceInForLoopScope: true,
extraDefines: [ extraDefines: [
'WIN32': null, 'WIN32': null,
'_MBCS': null, '_MBCS': null,
'NDEBUG': null, 'NDEBUG': null,
] ]
), ),
linkerOptions: new MsvcToolchainConfig.LinkerOptions( linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG, linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT, errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
enableIncrementalLinking: false, enableIncrementalLinking: false,
eliminateUnusedRefs: true, eliminateUnusedRefs: true,
enableCOMDATFolding: true, enableCOMDATFolding: true,
generateDebugInfo: true, generateDebugInfo: true,
dataExecutionPrevention: true, dataExecutionPrevention: true,
randomizedBaseAddress: true randomizedBaseAddress: true
), ),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions( librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
), ),
generatePdb: true generatePdb: true
) )
} else { } else {
//debug //debug
cfg = new MsvcToolchainConfig( cfg = new MsvcToolchainConfig(
compilerOptions: new MsvcToolchainConfig.CompilerOptions( compilerOptions: new MsvcToolchainConfig.CompilerOptions(
codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG, codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG,
optimizationLevel: OptimizationLevel.DISABLED, optimizationLevel: OptimizationLevel.DISABLED,
debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
runtimeChecks: RuntimeChecks.DEFAULT, runtimeChecks: RuntimeChecks.DEFAULT,
cppExceptions: CppExceptions.ENABLED_WITH_SEH, cppExceptions: CppExceptions.ENABLED_WITH_SEH,
warningLevel: WarningLevel.LEVEL_3, warningLevel: WarningLevel.LEVEL_3,
callingConvention: CallingConvention.CDECL, callingConvention: CallingConvention.CDECL,
enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
floatingPointModel: FloatingPointModel.FAST, floatingPointModel: FloatingPointModel.FAST,
enableMinimalRebuild: true, enableMinimalRebuild: true,
omitFramePointers: false, omitFramePointers: false,
wholeProgramOptimization: false, wholeProgramOptimization: false,
enabledFunctionLevelLinking: true, enabledFunctionLevelLinking: true,
enableSecurityCheck: true, enableSecurityCheck: true,
analyzeCode: false, analyzeCode: false,
sdlChecks: false, sdlChecks: false,
treatWarningsAsErrors: false, treatWarningsAsErrors: false,
treatWchartAsBuiltin: true, treatWchartAsBuiltin: true,
forceConformanceInForLoopScope: true, forceConformanceInForLoopScope: true,
extraDefines: [ extraDefines: [
'WIN32': null, 'WIN32': null,
'_MBCS': null, '_MBCS': null,
'_DEBUG': null, '_DEBUG': null,
] ]
), ),
linkerOptions: new MsvcToolchainConfig.LinkerOptions( linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT, linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT, errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
enableIncrementalLinking: true, enableIncrementalLinking: true,
eliminateUnusedRefs: false, eliminateUnusedRefs: false,
enableCOMDATFolding: false, enableCOMDATFolding: false,
generateDebugInfo: true, generateDebugInfo: true,
dataExecutionPrevention: true, dataExecutionPrevention: true,
randomizedBaseAddress: true randomizedBaseAddress: true
), ),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions( librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
), ),
generatePdb: true generatePdb: true
) )
if (binKind == BinaryKind.STATIC_LIBRARY) { if (binKind == BinaryKind.STATIC_LIBRARY) {
cfg.compilerConfig.extraDefines['_LIB'] = null cfg.compilerConfig.extraDefines['_LIB'] = null
} }
} }
return cfg return cfg
} }