diff --git a/build.gradle b/build.gradle index de12d30..4ac20c5 100644 --- a/build.gradle +++ b/build.gradle @@ -9,40 +9,40 @@ group = 'rehlds' apply plugin: 'idea' idea { - project { - languageLevel = 'JDK_1_7' - } + project { + languageLevel = 'JDK_1_7' + } } def gitInfo = GitVersioner.versionForDir(project.rootDir) RehldsVersionInfo versionInfo if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') { - def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ - if (!m.find()) { - throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") - } + def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ + if (!m.find()) { + throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") + } - versionInfo = new RehldsVersionInfo( - majorVersion: m.group(1) as int, - minorVersion: m.group(2) as int, - maintenanceVersion: m.group(4) ? (m.group(4) as int) : null, - localChanges: gitInfo.localChanges, - commitDate: gitInfo.commitDate, - commitSHA: gitInfo.commitSHA, - commitURL: gitInfo.commitURL - ) + versionInfo = new RehldsVersionInfo( + majorVersion: m.group(1) as int, + minorVersion: m.group(2) as int, + maintenanceVersion: m.group(4) ? (m.group(4) as int) : null, + localChanges: gitInfo.localChanges, + commitDate: gitInfo.commitDate, + commitSHA: gitInfo.commitSHA, + commitURL: gitInfo.commitURL + ) } else { - versionInfo = new RehldsVersionInfo( - majorVersion: project.majorVersion as int, - minorVersion: project.minorVersion as int, - maintenanceVersion: project.maintenanceVersion as int, - suffix: 'dev', - localChanges: gitInfo ? gitInfo.localChanges : true, - commitDate: gitInfo ? gitInfo.commitDate : new DateTime(), - commitSHA: gitInfo ? gitInfo.commitSHA : "", - commitURL: gitInfo ? gitInfo.commitURL : "", - commitCount: gitInfo ? (gitInfo.commitCount as int) : null - ) + versionInfo = new RehldsVersionInfo( + majorVersion: project.majorVersion as int, + minorVersion: project.minorVersion as int, + maintenanceVersion: project.maintenanceVersion as int, + suffix: 'dev', + localChanges: gitInfo ? gitInfo.localChanges : true, + commitDate: gitInfo ? gitInfo.commitDate : new DateTime(), + commitSHA: gitInfo ? gitInfo.commitSHA : "", + commitURL: gitInfo ? gitInfo.commitURL : "", + commitCount: gitInfo ? (gitInfo.commitCount as int) : null + ) } project.ext.rehldsVersionInfo = versionInfo @@ -51,5 +51,5 @@ project.version = versionInfo.asMavenVersion() apply from: 'publish.gradle' task wrapper(type: Wrapper) { - gradleVersion = '2.4' + gradleVersion = '2.4' } diff --git a/dep/bzip2/build.gradle b/dep/bzip2/build.gradle index 649ea6d..09fef5a 100644 --- a/dep/bzip2/build.gradle +++ b/dep/bzip2/build.gradle @@ -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,67 +10,70 @@ import org.gradle.nativeplatform.toolchain.VisualCpp apply plugin: 'c' apply plugin: IccCompilerPlugin +apply plugin: GccCompilerPlugin void setupToolchain(NativeBinarySpec b) { - def cfg = rootProject.createToolchainConfig(b) - if (cfg instanceof MsvcToolchainConfig) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'bzlib_private.h', - pchSourceSet: 'bz2_pch' - ) - } + def cfg = rootProject.createToolchainConfig(b) + if (cfg instanceof MsvcToolchainConfig) { + cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( + enabled: true, + pchHeader: 'bzlib_private.h', + pchSourceSet: 'bz2_pch' + ) + } - ToolchainConfigUtils.apply(project, cfg, b) + ToolchainConfigUtils.apply(project, cfg, b) } model { - buildTypes { - debug - release - } + buildTypes { + debug + release + } - platforms { - x86 { - architecture "x86" - } - } + platforms { + x86 { + architecture "x86" + } + } - toolChains { - visualCpp(VisualCpp) { - } - icc(Icc) { - } - } + toolChains { + visualCpp(VisualCpp) + if (project.hasProperty("useGcc")) { + gcc(Gcc) + } else { + icc(Icc) + } + } - components { - bzip2(NativeLibrarySpec) { - targetPlatform 'x86' + components { + bzip2(NativeLibrarySpec) { + targetPlatform 'x86' - sources { - bz2_main(CSourceSet) { - source { - srcDir "src" - include "**/*.c" - exclude "precompiled.c" - } - exportedHeaders { - srcDir "include" - } - } + sources { + bz2_main(CSourceSet) { + source { + srcDir "src" + include "**/*.c" + exclude "precompiled.c" + } + exportedHeaders { + srcDir "include" + } + } - bz2_pch(CSourceSet) { - source { - srcDir "src" - include "precompiled.c" - } - exportedHeaders { - srcDir "include" - } - } - } + bz2_pch(CSourceSet) { + source { + srcDir "src" + include "precompiled.c" + } + exportedHeaders { + srcDir "include" + } + } + } - binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } - } - } + binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } + } + } } diff --git a/dep/cppunitlite/build.gradle b/dep/cppunitlite/build.gradle index 6fc4523..bae46b8 100644 --- a/dep/cppunitlite/build.gradle +++ b/dep/cppunitlite/build.gradle @@ -2,38 +2,42 @@ 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) + def cfg = rootProject.createToolchainConfig(b) - ToolchainConfigUtils.apply(project, cfg, b) + ToolchainConfigUtils.apply(project, cfg, b) } model { - buildTypes { - debug - release - } + buildTypes { + debug + release + } - platforms { - x86 { - architecture "x86" - } - } + platforms { + x86 { + architecture "x86" + } + } - toolChains { - visualCpp(VisualCpp) { - } - icc(Icc) { - } - } + toolChains { + visualCpp(VisualCpp) + if (project.hasProperty("useGcc")) { + gcc(Gcc) + } else { + icc(Icc) + } + } - components { + components { cppunitlite(NativeLibrarySpec) { targetPlatform 'x86' @@ -51,9 +55,9 @@ model { } - binaries.all { NativeBinarySpec b -> - project.setupToolchain(b) - } + binaries.all { NativeBinarySpec b -> + project.setupToolchain(b) + } } } } diff --git a/flightrec/decoder/build.gradle b/flightrec/decoder/build.gradle index d658f5d..707f713 100644 --- a/flightrec/decoder/build.gradle +++ b/flightrec/decoder/build.gradle @@ -8,28 +8,28 @@ sourceCompatibility = '1.7' targetCompatibility = '1.7' repositories { - mavenCentral() + mavenCentral() } dependencies { - testCompile 'org.codehaus.groovy:groovy-all:2.4.5' - testCompile "junit:junit:4.12" - compile project(':flightrec/decoder_api') + testCompile 'org.codehaus.groovy:groovy-all:2.4.5' + testCompile "junit:junit:4.12" + compile project(':flightrec/decoder_api') } task uberjar(type: Jar, dependsOn: ['check', ':flightrec/decoder_api:build']) { - from files(sourceSets.main.output.classesDir) - 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 + from files(sourceSets.main.output.classesDir) + 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 - manifest { - attributes 'Main-Class': 'org.rehlds.flightrec.main.FlightRecorder' - attributes 'Implementation-Vendor': 'Sun Microsystems, Inc' - attributes 'Implementation-Title': 'Java Runtime Environment' - attributes 'Implementation-Version': '1.7.0' - } + manifest { + attributes 'Main-Class': 'org.rehlds.flightrec.main.FlightRecorder' + attributes 'Implementation-Vendor': 'Sun Microsystems, Inc' + attributes 'Implementation-Title': 'Java Runtime Environment' + attributes 'Implementation-Version': '1.7.0' + } } tasks.withType(AbstractCompile) { - options.encoding = 'UTF-8' + options.encoding = 'UTF-8' } diff --git a/flightrec/decoder_api/build.gradle b/flightrec/decoder_api/build.gradle index deff67b..3ec5e22 100644 --- a/flightrec/decoder_api/build.gradle +++ b/flightrec/decoder_api/build.gradle @@ -8,67 +8,67 @@ sourceCompatibility = '1.7' targetCompatibility = '1.7' repositories { - mavenCentral() + mavenCentral() } dependencies { - testCompile "junit:junit:4.12" + testCompile "junit:junit:4.12" } publishing { - publications { - maven(MavenPublication) { - version project.version - artifactId 'decoder-api' - artifact jar + publications { + maven(MavenPublication) { + version project.version + artifactId 'decoder-api' + artifact jar - pom.withXml { - asNode().children().last() + { - resolveStrategy = DELEGATE_FIRST - name 'decoder-api' - description project.description - //url github - //scm { - // url "${github}.git" - // connection "scm:git:${github}.git" - //} - /* - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - developers { - developer { - id 'dreamstalker' - name 'dreamstalker' - } - } - */ - } - } - } - } + pom.withXml { + asNode().children().last() + { + resolveStrategy = DELEGATE_FIRST + name 'decoder-api' + description project.description + //url github + //scm { + // url "${github}.git" + // connection "scm:git:${github}.git" + //} + /* + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' + } + } + developers { + developer { + id 'dreamstalker' + name 'dreamstalker' + } + } + */ + } + } + } + } } publishing { - repositories { - maven { - if (project.version.contains('dev')) { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" - } else { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" - } - credentials { - username rootProject.repoCreds.getProperty('username') - password rootProject.repoCreds.getProperty('password') - } - } - } + repositories { + maven { + if (project.version.contains('dev')) { + url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" + } else { + url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" + } + credentials { + username rootProject.repoCreds.getProperty('username') + password rootProject.repoCreds.getProperty('password') + } + } + } } tasks.withType(AbstractCompile) { - options.encoding = 'UTF-8' + options.encoding = 'UTF-8' } diff --git a/publish.gradle b/publish.gradle index d5fbdf3..ee6d0bd 100644 --- a/publish.gradle +++ b/publish.gradle @@ -2,154 +2,154 @@ import org.doomedsociety.gradlecpp.GradleCppUtils import org.apache.commons.io.FilenameUtils void _copyFileToDir(String from, String to) { - def dst = new File(project.file(to), FilenameUtils.getName(from)) - GradleCppUtils.copyFile(project.file(from), dst, false) + def dst = new File(project.file(to), FilenameUtils.getName(from)) + GradleCppUtils.copyFile(project.file(from), dst, false) } 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 { - dependsOn ':flightrec/decoder:uberjar' - doLast { - def pubRootDir = project.file('publish/publishRoot') - if (pubRootDir.exists()) { - if (!pubRootDir.deleteDir()) { - throw new RuntimeException("Failed to delete ${pubRootDir}") - } - } + dependsOn ':flightrec/decoder:uberjar' + doLast { + def pubRootDir = project.file('publish/publishRoot') + if (pubRootDir.exists()) { + if (!pubRootDir.deleteDir()) { + throw new RuntimeException("Failed to delete ${pubRootDir}") + } + } - pubRootDir.mkdirs() + pubRootDir.mkdirs() - //bugfixed binaries - project.file('publish/publishRoot/bin/bugfixed').mkdirs() - _copyFileToDir('publish/releaseRehldsFixes/swds.dll', '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') + //bugfixed binaries + project.file('publish/publishRoot/bin/bugfixed').mkdirs() + _copyFileToDir('publish/releaseRehldsFixes/swds.dll', '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') - //pure binaries - project.file('publish/publishRoot/bin/pure').mkdirs() - _copyFileToDir('publish/releaseRehldsNofixes/swds.dll', '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') + //pure binaries + project.file('publish/publishRoot/bin/pure').mkdirs() + _copyFileToDir('publish/releaseRehldsNofixes/swds.dll', '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') - //hlsdk - project.file('publish/publishRoot/hlsdk').mkdirs() - copy { - from 'rehlds/common' - into 'publish/publishRoot/hlsdk/common' - } - copy { - from 'rehlds/dlls' - into 'publish/publishRoot/hlsdk/dlls' - } - copy { - from 'rehlds/pm_shared' - into 'publish/publishRoot/hlsdk/pm_shared' - } - copy { - from 'rehlds/public' - into 'publish/publishRoot/hlsdk/public' - exclude '**/rehlds/*', '**/tier0/*' - } - copy { - from 'rehlds/public/rehlds' - into 'publish/publishRoot/hlsdk/engine' - } + //hlsdk + project.file('publish/publishRoot/hlsdk').mkdirs() + copy { + from 'rehlds/common' + into 'publish/publishRoot/hlsdk/common' + } + copy { + from 'rehlds/dlls' + into 'publish/publishRoot/hlsdk/dlls' + } + copy { + from 'rehlds/pm_shared' + into 'publish/publishRoot/hlsdk/pm_shared' + } + copy { + from 'rehlds/public' + into 'publish/publishRoot/hlsdk/public' + exclude '**/rehlds/*', '**/tier0/*' + } + copy { + from 'rehlds/public/rehlds' + into 'publish/publishRoot/hlsdk/engine' + } - //flightrecorder + //flightrecorder - def flightRecJarTask = project(':flightrec/decoder').tasks.getByName('uberjar') - println flightRecJarTask - println flightRecJarTask.class.name - File flightRecJarFile = flightRecJarTask.archivePath - project.file('publish/publishRoot/flighrec').mkdirs() - GradleCppUtils.copyFile(flightRecJarFile, project.file('publish/publishRoot/flighrec/decoder.jar'), false) - copy { - from new File(project(':flightrec/decoder').projectDir, 'pub') - into 'publish/publishRoot/flighrec' - } - } + def flightRecJarTask = project(':flightrec/decoder').tasks.getByName('uberjar') + println flightRecJarTask + println flightRecJarTask.class.name + File flightRecJarFile = flightRecJarTask.archivePath + project.file('publish/publishRoot/flighrec').mkdirs() + GradleCppUtils.copyFile(flightRecJarFile, project.file('publish/publishRoot/flighrec/decoder.jar'), false) + copy { + from new File(project(':flightrec/decoder').projectDir, 'pub') + into 'publish/publishRoot/flighrec' + } + } } task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { - baseName = "rehlds-dist-${project.version}" - destinationDir file('publish') - from 'publish/publishRoot' + baseName = "rehlds-dist-${project.version}" + destinationDir file('publish') + from 'publish/publishRoot' } publishing { - publications { - maven(MavenPublication) { - version project.version - artifact publishPackage + publications { + maven(MavenPublication) { + version project.version + artifact publishPackage - pom.withXml { - asNode().children().last() + { - resolveStrategy = DELEGATE_FIRST - name project.name - description project.description - properties { - commitDate project.ext.rehldsVersionInfo.commitDate - commitSHA project.ext.rehldsVersionInfo.commitSHA - } + pom.withXml { + asNode().children().last() + { + resolveStrategy = DELEGATE_FIRST + name project.name + description project.description + properties { + commitDate project.ext.rehldsVersionInfo.commitDate + commitSHA project.ext.rehldsVersionInfo.commitSHA + } - //url github - //scm { - // url "${github}.git" - // connection "scm:git:${github}.git" - //} - /* - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - developers { - developer { - id 'dreamstalker' - name 'dreamstalker' - } - } - */ - } - } - } - } + //url github + //scm { + // url "${github}.git" + // connection "scm:git:${github}.git" + //} + /* + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' + } + } + developers { + developer { + id 'dreamstalker' + name 'dreamstalker' + } + } + */ + } + } + } + } } Properties repoCreds = new Properties() project.ext.repoCreds = repoCreds if (file('repo_creds.properties').exists()) { - println 'Loading maven repo credentials' - file('repo_creds.properties').withReader('UTF-8', { Reader r -> - repoCreds.load(r) - }) + println 'Loading maven repo credentials' + file('repo_creds.properties').withReader('UTF-8', { Reader r -> + repoCreds.load(r) + }) } publishing { - repositories { - maven { - if (project.version.contains('dev')) { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" - } else { - url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" - } - credentials { - username repoCreds.getProperty('username') - password repoCreds.getProperty('password') - } - } - } + repositories { + maven { + if (project.version.contains('dev')) { + url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-dev/" + } else { + url "http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/" + } + credentials { + username repoCreds.getProperty('username') + password repoCreds.getProperty('password') + } + } + } } task doPublish { - dependsOn 'publishPackage' - if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) { - dependsOn 'publish' - dependsOn ':flightrec/decoder_api:publish' - } + dependsOn 'publishPackage' + if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) { + dependsOn 'publish' + dependsOn ':flightrec/decoder_api:publish' + } } diff --git a/rehlds/build.gradle b/rehlds/build.gradle index 53f977c..ec8bff9 100644 --- a/rehlds/build.gradle +++ b/rehlds/build.gradle @@ -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 @@ -33,303 +34,313 @@ repositories { } configurations { - rehlds_tests + rehlds_tests } dependencies { - rehlds_tests 'rehlds.testdemos:hl-phys-single1: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:shooting-hl-1: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:cstrike-muliplayer-1:1.1' + rehlds_tests 'rehlds.testdemos:shooting-hl-1:1.1' } project.ext.dep_bzip2 = project(':dep/bzip2') project.ext.dep_cppunitlite = project(':dep/cppunitlite') void createIntergrationTestTask(NativeBinarySpec b) { - boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') + boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') - if (!(b instanceof SharedLibraryBinarySpec)) return - if (!GradleCppUtils.windows) return - if (rehldsFixes) return + if (!(b instanceof SharedLibraryBinarySpec)) return + if (!GradleCppUtils.windows) return + if (rehldsFixes) return - def libLinkTask = GradleCppUtils.getLinkTask(b) - String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null + def libLinkTask = GradleCppUtils.getLinkTask(b) + String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null - def depFiles = [] - depFiles.addAll(libLinkTask.outputs.files.files) + def depFiles = [] + depFiles.addAll(libLinkTask.outputs.files.files) - def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RehldsPlayTestTask) - demoItgTestTask.with { - rehldsImageRoot = new File(project.projectDir, '_rehldsTestImg') - rehldsTestLogs = new File(this.project.buildDir, "_rehldsTestLogs/${b.name}") - testDemos = project.configurations.rehlds_tests - testFor = b + def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RehldsPlayTestTask) + demoItgTestTask.with { + rehldsImageRoot = new File(project.projectDir, '_rehldsTestImg') + rehldsTestLogs = new File(this.project.buildDir, "_rehldsTestLogs/${b.name}") + testDemos = project.configurations.rehlds_tests + testFor = b - //inputs/outputs for up-to-date check - inputs.files depFiles - inputs.files testDemos.files - outputs.dir rehldsTestLogs + //inputs/outputs for up-to-date check + inputs.files depFiles + inputs.files testDemos.files + outputs.dir rehldsTestLogs - //dependencies on library and test executable - dependsOn libLinkTask - if (unitTestTask) { - dependsOn unitTestTask - } + //dependencies on library and test executable + dependsOn libLinkTask + if (unitTestTask) { + dependsOn unitTestTask + } - postExtractAction { - def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b) - GradleCppUtils.copyFile(binaryOutFile, new File(rehldsImageRoot, binaryOutFile.name), true) - } - } + postExtractAction { + def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b) + GradleCppUtils.copyFile(binaryOutFile, new File(rehldsImageRoot, binaryOutFile.name), true) + } + } - b.buildTask.dependsOn demoItgTestTask + b.buildTask.dependsOn demoItgTestTask } void setupUnitTests(NativeBinarySpec bin) { - boolean unitTestExecutable = bin.component.name.endsWith('_tests') - if (!unitTestExecutable) return + boolean unitTestExecutable = bin.component.name.endsWith('_tests') + if (!unitTestExecutable) return - GradleCppUtils.getLinkTask(bin).doLast { - 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') - GradleCppUtils.copyFile(srcPath, dstPath, true) - } + GradleCppUtils.getLinkTask(bin).doLast { + 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') + GradleCppUtils.copyFile(srcPath, dstPath, true) + } } void postEvaluate(NativeBinarySpec b) { - // attach generateAppVersion task to all 'compile source' tasks - GradleCppUtils.getCompileTasks(b).each { Task t -> - t.dependsOn project.generateAppVersion - } + // attach generateAppVersion task to all 'compile source' tasks + GradleCppUtils.getCompileTasks(b).each { Task t -> + t.dependsOn project.generateAppVersion + } - setupUnitTests(b) - createIntergrationTestTask(b) + setupUnitTests(b) + createIntergrationTestTask(b) } void setupToolchain(NativeBinarySpec b) { - boolean unitTestExecutable = b.component.name.endsWith('_tests') - boolean swdsLib = b.name.toLowerCase().contains('swds') - boolean rehldsFixes = b.flavor.name.contains('rehldsFixes') + 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') - ToolchainConfig cfg = rootProject.createToolchainConfig(b) - cfg.projectInclude(project, '', '/public/rehlds', '/engine', '/common', '/pm_shared', '/rehlds', '/testsuite', '/hookers', '/public') - cfg.projectInclude(dep_bzip2, '/include') + ToolchainConfig cfg = rootProject.createToolchainConfig(b) + cfg.projectInclude(project, '', '/public/rehlds', '/engine', '/common', '/pm_shared', '/rehlds', '/testsuite', '/hookers', '/public') + cfg.projectInclude(dep_bzip2, '/include') - if (unitTestExecutable) { - cfg.projectInclude(dep_cppunitlite, '/include') - b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true) - } - b.lib LazyNativeDepSet.create(dep_bzip2, 'bzip2', b.buildType.name, true) + if (unitTestExecutable) { + cfg.projectInclude(dep_cppunitlite, '/include') + b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', 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) { - cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( - enabled: true, - pchHeader: 'precompiled.h', - pchSourceSet: 'rehlds_pch' - ) - cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') - if (!rehldsFixes) { - cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE - cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED - } else { + if (cfg instanceof MsvcToolchainConfig) { + cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( + enabled: true, + pchHeader: 'precompiled.h', + pchSourceSet: 'rehlds_pch' + ) + cfg.singleDefines('_CRT_SECURE_NO_WARNINGS') + if (!rehldsFixes) { + cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE + cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED + } else { cfg.compilerOptions.args '/Oi', '/GF', '/GR-', '/GS-' } - if (swdsLib) { - cfg.linkerOptions.randomizedBaseAddress = false - cfg.linkerOptions.baseAddress = '0x4970000' - } - 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) { - cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions( - enabled: true, - pchSourceSet: 'rehlds_pch' - ) - cfg.compilerOptions.languageStandard = 'c++0x' - cfg.defines([ - '_stricmp': 'strcasecmp', - '_strnicmp': 'strncasecmp', - '_strdup': 'strdup', - '_unlink': 'unlink', - '_vsnprintf': 'vsnprintf', - ]) - 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 (swdsLib) { + cfg.linkerOptions.randomizedBaseAddress = false + cfg.linkerOptions.baseAddress = '0x4970000' + } + 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', + '_strnicmp': 'strncasecmp', + '_strdup': 'strdup', + '_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' + } - if (!unitTestExecutable && !swdsLib) { - cfg.singleDefines 'HOOK_ENGINE' - } + if (!unitTestExecutable && !swdsLib) { + cfg.singleDefines 'HOOK_ENGINE' + } if (unitTestExecutable) { cfg.singleDefines 'REHLDS_UNIT_TESTS' } - if (rehldsFixes) { - cfg.singleDefines 'REHLDS_FIXES', 'REHLDS_CHECKS' - } + if (rehldsFixes) { + cfg.singleDefines 'REHLDS_FIXES', 'REHLDS_CHECKS' + } - ToolchainConfigUtils.apply(project, cfg, b) + ToolchainConfigUtils.apply(project, cfg, b) - GradleCppUtils.onTasksCreated(project, 'postEvaluate', { - postEvaluate(b) - }) + GradleCppUtils.onTasksCreated(project, 'postEvaluate', { + postEvaluate(b) + }) } class RehldsSrc { - static void rehlds_src(def h) { - h.rehlds_src(CppSourceSet) { - source { - srcDirs "engine", "rehlds", "public", "version" - if (GradleCppUtils.windows) srcDirs "testsuite" + static void rehlds_src(def h) { + h.rehlds_src(CppSourceSet) { + source { + srcDirs "engine", "rehlds", "public", "version" + if (GradleCppUtils.windows) srcDirs "testsuite" - include "**/*.cpp" - exclude "precompiled.cpp" - exclude GradleCppUtils.windows ? "tier0/platform_linux.cpp" : "tier0/platform_win32.cpp" + include "**/*.cpp" + exclude "precompiled.cpp" + exclude GradleCppUtils.windows ? "tier0/platform_linux.cpp" : "tier0/platform_win32.cpp" exclude "interface.cpp", "rehlds/crc32c.cpp", "rehlds/sys_shared.cpp" - } + } - source { - srcDirs "hookers" - include "**/*.cpp" - exclude "6132_hooker.cpp", "hooker.cpp", "main.cpp", "main_swds.cpp" - if (!GradleCppUtils.windows) exclude "rehlds_debug.cpp" - } - } - } + source { + srcDirs "hookers" + include "**/*.cpp" + exclude "6132_hooker.cpp", "hooker.cpp", "main.cpp", "main_swds.cpp" + if (!GradleCppUtils.windows) exclude "rehlds_debug.cpp" + } + } + } - static void rehlds_pch(def h) { - h.rehlds_pch(CppSourceSet) { - source { - srcDirs "rehlds" - include "precompiled.cpp" - } - } - } + static void rehlds_pch(def h) { + h.rehlds_pch(CppSourceSet) { + source { + srcDirs "rehlds" + include "precompiled.cpp" + } + } + } - static void rehlds_hooker_src(def h) { - h.rehlds_hooker_src(CppSourceSet) { - source { - srcDirs "hookers" - include "6132_hooker.cpp", "hooker.cpp" - } - } - } + static void rehlds_hooker_src(def h) { + h.rehlds_hooker_src(CppSourceSet) { + source { + srcDirs "hookers" + include "6132_hooker.cpp", "hooker.cpp" + } + } + } - static void rehlds_hooker_main_src(def h) { - h.rehlds_hooker_main_src(CppSourceSet) { - source { - srcDirs "hookers" - include "main.cpp" - } - } - } + static void rehlds_hooker_main_src(def h) { + h.rehlds_hooker_main_src(CppSourceSet) { + source { + srcDirs "hookers" + include "main.cpp" + } + } + } - static void rehlds_swds_main_src(def h) { - h.rehlds_swds_main_src(CppSourceSet) { - source { - srcDirs "hookers" - include "main_swds.cpp" - } - } - } + static void rehlds_swds_main_src(def h) { + h.rehlds_swds_main_src(CppSourceSet) { + source { + srcDirs "hookers" + include "main_swds.cpp" + } + } + } - static void rehlds_tests_src(def h) { - h.rehlds_tests_src(CppSourceSet) { - source { - srcDir "unittests" - include "**/*.cpp" - } - } - } + static void rehlds_tests_src(def h) { + h.rehlds_tests_src(CppSourceSet) { + source { + srcDir "unittests" + include "**/*.cpp" + } + } + } } model { - buildTypes { - debug - release - } + buildTypes { + debug + release + } - platforms { - x86 { - architecture "x86" - } - } + platforms { + x86 { + architecture "x86" + } + } - toolChains { - visualCpp(VisualCpp) { - } - icc(Icc) { - } - } + toolChains { + visualCpp(VisualCpp) + if (project.hasProperty("useGcc")) { + gcc(Gcc) + } else { + icc(Icc) + } + } - flavors { - rehldsNofixes - rehldsFixes - } + flavors { + rehldsNofixes + rehldsFixes + } - components { - rehlds_hooker_engine(NativeLibrarySpec) { - targetPlatform 'x86' - baseName 'FileSystem_Stdio' + components { + rehlds_hooker_engine(NativeLibrarySpec) { + targetPlatform 'x86' + baseName 'FileSystem_Stdio' - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_hooker_src(it) - RehldsSrc.rehlds_hooker_main_src(it) - } + sources { + RehldsSrc.rehlds_pch(it) + RehldsSrc.rehlds_src(it) + RehldsSrc.rehlds_hooker_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) { - targetPlatform 'x86' - baseName GradleCppUtils.windows ? 'swds' : 'engine_i486' + rehlds_swds_engine(NativeLibrarySpec) { + targetPlatform 'x86' + baseName GradleCppUtils.windows ? 'swds' : 'engine_i486' - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_swds_main_src(it) - } + sources { + RehldsSrc.rehlds_pch(it) + RehldsSrc.rehlds_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) { - targetPlatform 'x86' - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_tests_src(it) - } + rehlds_hooker_engine_tests(NativeExecutableSpec) { + targetPlatform 'x86' + sources { + RehldsSrc.rehlds_pch(it) + RehldsSrc.rehlds_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) { - targetPlatform 'x86' - sources { - RehldsSrc.rehlds_pch(it) - RehldsSrc.rehlds_src(it) - RehldsSrc.rehlds_tests_src(it) - } + rehlds_swds_engine_tests(NativeExecutableSpec) { + targetPlatform 'x86' + sources { + RehldsSrc.rehlds_pch(it) + RehldsSrc.rehlds_src(it) + RehldsSrc.rehlds_tests_src(it) + } - binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } - } - } + binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } + } + } } 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') - } + } } task buildFixes { @@ -351,21 +362,21 @@ gradle.taskGraph.whenReady { graph -> } task prepareDevEnvTests { - def rehldsTests = new File(project.projectDir, '_dev/testDemos') + def rehldsTests = new File(project.projectDir, '_dev/testDemos') - inputs.files configurations.rehlds_tests.files - outputs.dir rehldsTests + inputs.files configurations.rehlds_tests.files + outputs.dir rehldsTests - doLast { - rehldsTests.mkdirs() - configurations.rehlds_tests.files.each { File f -> - def t = zipTree(f) - copy { - into new File(rehldsTests, FilenameUtils.getBaseName(f.absolutePath)) - from t - } - } - } + doLast { + rehldsTests.mkdirs() + configurations.rehlds_tests.files.each { File f -> + def t = zipTree(f) + copy { + into new File(rehldsTests, FilenameUtils.getBaseName(f.absolutePath)) + from t + } + } + } } task prepareDevEnvEngine << { @@ -378,40 +389,40 @@ task prepareDevEnvEngine << { } task prepareDevEnv { - dependsOn prepareDevEnvEngine, prepareDevEnvTests + dependsOn prepareDevEnvEngine, prepareDevEnvTests } tasks.clean.doLast { - project.file('version/appversion.h').delete() + project.file('version/appversion.h').delete() } task generateAppVersion { - RehldsVersionInfo verInfo = (RehldsVersionInfo) rootProject.rehldsVersionInfo + RehldsVersionInfo verInfo = (RehldsVersionInfo) rootProject.rehldsVersionInfo - def tplFile = project.file('version/appversion.vm') - def renderedFile = project.file('version/appversion.h') + def tplFile = project.file('version/appversion.vm') + def renderedFile = project.file('version/appversion.h') - // check to up-to-date - inputs.file tplFile - inputs.file project.file('gradle.properties') - outputs.file renderedFile + // check to up-to-date + inputs.file tplFile + inputs.file project.file('gradle.properties') + outputs.file renderedFile - // this will ensure that this task is redone when the versions change - inputs.property('version', rootProject.version) - inputs.property('commitDate', verInfo.asCommitDate()) + // this will ensure that this task is redone when the versions change + inputs.property('version', rootProject.version) + inputs.property('commitDate', verInfo.asCommitDate()) - println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']"; + println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']"; - doLast { + doLast { - def templateCtx = [ - verInfo : verInfo - ] + def templateCtx = [ + verInfo : verInfo + ] - def content = VelocityUtils.renderTemplate(tplFile, templateCtx) - renderedFile.delete() - renderedFile.write(content, 'utf-8') + def content = VelocityUtils.renderTemplate(tplFile, templateCtx) + renderedFile.delete() + 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 + ')'; + } } diff --git a/shared.gradle b/shared.gradle index b251219..ec81f33 100644 --- a/shared.gradle +++ b/shared.gradle @@ -8,26 +8,29 @@ 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 - if (bin instanceof NativeExecutableBinarySpec) { - binaryKind = BinaryKind.EXECUTABLE - } else if (bin instanceof SharedLibraryBinarySpec) { - binaryKind = BinaryKind.SHARED_LIBRARY - } else if (bin instanceof StaticLibraryBinarySpec) { - binaryKind = BinaryKind.STATIC_LIBRARY - } else { - throw new RuntimeException("Unknown executable kind ${bin.class.name}") - } + BinaryKind binaryKind + if (bin instanceof NativeExecutableBinarySpec) { + binaryKind = BinaryKind.EXECUTABLE + } else if (bin instanceof SharedLibraryBinarySpec) { + binaryKind = BinaryKind.SHARED_LIBRARY + } else if (bin instanceof StaticLibraryBinarySpec) { + binaryKind = BinaryKind.STATIC_LIBRARY + } else { + 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) { - return rootProject.createMsvcConfig(releaseBuild, binaryKind) - } else if (bin.toolChain instanceof Icc) { - return rootProject.createIccConfig(releaseBuild, binaryKind) - } else { - throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}") - } + if (bin.toolChain instanceof VisualCpp) { + 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}") + } } diff --git a/shared_gcc.gradle b/shared_gcc.gradle new file mode 100644 index 0000000..44d767f --- /dev/null +++ b/shared_gcc.gradle @@ -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 +} diff --git a/shared_icc.gradle b/shared_icc.gradle index d812348..084902b 100644 --- a/shared_icc.gradle +++ b/shared_icc.gradle @@ -3,60 +3,60 @@ import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig import org.doomedsociety.gradlecpp.gcc.OptimizationLevel rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind -> - GccToolchainConfig cfg - if (release) { - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.LEVEL_3, - stackProtector: false, - interProceduralOptimizations: true, + GccToolchainConfig cfg + if (release) { + cfg = new GccToolchainConfig( + compilerOptions: new GccToolchainConfig.CompilerOptions( + optimizationLevel: OptimizationLevel.LEVEL_3, + stackProtector: false, + interProceduralOptimizations: true, - noBuiltIn: true, + noBuiltIn: true, - intelExtensions: false, - asmBlocks: true, + intelExtensions: false, + asmBlocks: true, - positionIndependentCode: false - ), + positionIndependentCode: false + ), - linkerOptions: new GccToolchainConfig.LinkerOptions( - interProceduralOptimizations: true, - stripSymbolTable: true, - staticLibGcc: true, - staticIntel: true, - staticLibStdCpp: true, - ), + linkerOptions: new GccToolchainConfig.LinkerOptions( + interProceduralOptimizations: true, + stripSymbolTable: true, + staticLibGcc: true, + staticIntel: true, + staticLibStdCpp: true, + ), - librarianOptions: new GccToolchainConfig.LibrarianOptions( + librarianOptions: new GccToolchainConfig.LibrarianOptions( - ) - ) - } else { - //debug - cfg = new GccToolchainConfig( - compilerOptions: new GccToolchainConfig.CompilerOptions( - optimizationLevel: OptimizationLevel.DISABLE, - stackProtector: true, - interProceduralOptimizations: false, + ) + ) + } else { + //debug + cfg = new GccToolchainConfig( + compilerOptions: new GccToolchainConfig.CompilerOptions( + optimizationLevel: OptimizationLevel.DISABLE, + stackProtector: true, + interProceduralOptimizations: false, - noBuiltIn: true, - intelExtensions: false, - asmBlocks: true - ), + noBuiltIn: true, + intelExtensions: false, + asmBlocks: true + ), - linkerOptions: new GccToolchainConfig.LinkerOptions( - interProceduralOptimizations: false, - stripSymbolTable: false, - staticLibGcc: true, - staticIntel: true, - staticLibStdCpp: true, - ), + linkerOptions: new GccToolchainConfig.LinkerOptions( + interProceduralOptimizations: false, + stripSymbolTable: false, + staticLibGcc: true, + staticIntel: true, + staticLibStdCpp: true, + ), - librarianOptions: new GccToolchainConfig.LibrarianOptions( + librarianOptions: new GccToolchainConfig.LibrarianOptions( - ) - ) - } + ) + ) + } - return cfg + return cfg } diff --git a/shared_msvc.gradle b/shared_msvc.gradle index 5b69f4c..04017fb 100644 --- a/shared_msvc.gradle +++ b/shared_msvc.gradle @@ -13,111 +13,111 @@ import org.doomedsociety.gradlecpp.msvc.RuntimeChecks import org.doomedsociety.gradlecpp.msvc.WarningLevel rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind -> - MsvcToolchainConfig cfg - if (release) { - cfg = new MsvcToolchainConfig( - compilerOptions: new MsvcToolchainConfig.CompilerOptions( - codeGeneration: CodeGenerationKind.MULTITHREADED, - optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION, - debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, - runtimeChecks: RuntimeChecks.DEFAULT, - cppExceptions: CppExceptions.ENABLED_WITH_SEH, - warningLevel: WarningLevel.LEVEL_3, - callingConvention: CallingConvention.CDECL, - enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, - floatingPointModel: FloatingPointModel.FAST, + MsvcToolchainConfig cfg + if (release) { + cfg = new MsvcToolchainConfig( + compilerOptions: new MsvcToolchainConfig.CompilerOptions( + codeGeneration: CodeGenerationKind.MULTITHREADED, + optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION, + debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, + runtimeChecks: RuntimeChecks.DEFAULT, + cppExceptions: CppExceptions.ENABLED_WITH_SEH, + warningLevel: WarningLevel.LEVEL_3, + callingConvention: CallingConvention.CDECL, + enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, + floatingPointModel: FloatingPointModel.FAST, - enableMinimalRebuild: false, - omitFramePointers: false, - wholeProgramOptimization: true, - enabledFunctionLevelLinking: true, - enableSecurityCheck: true, - analyzeCode: false, - sdlChecks: false, - treatWarningsAsErrors: false, - treatWchartAsBuiltin: true, - forceConformanceInForLoopScope: true, + enableMinimalRebuild: false, + omitFramePointers: false, + wholeProgramOptimization: true, + enabledFunctionLevelLinking: true, + enableSecurityCheck: true, + analyzeCode: false, + sdlChecks: false, + treatWarningsAsErrors: false, + treatWchartAsBuiltin: true, + forceConformanceInForLoopScope: true, - extraDefines: [ - 'WIN32': null, - '_MBCS': null, - 'NDEBUG': null, - ] - ), + extraDefines: [ + 'WIN32': null, + '_MBCS': null, + 'NDEBUG': null, + ] + ), - linkerOptions: new MsvcToolchainConfig.LinkerOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG, - errorReportingMode: ErrorReporting.NO_ERROR_REPORT, + linkerOptions: new MsvcToolchainConfig.LinkerOptions( + linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG, + errorReportingMode: ErrorReporting.NO_ERROR_REPORT, - enableIncrementalLinking: false, - eliminateUnusedRefs: true, - enableCOMDATFolding: true, - generateDebugInfo: true, - dataExecutionPrevention: true, - randomizedBaseAddress: true - ), + enableIncrementalLinking: false, + eliminateUnusedRefs: true, + enableCOMDATFolding: true, + generateDebugInfo: true, + dataExecutionPrevention: true, + randomizedBaseAddress: true + ), - librarianOptions: new MsvcToolchainConfig.LibrarianOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG - ), + librarianOptions: new MsvcToolchainConfig.LibrarianOptions( + linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG + ), - generatePdb: true - ) - } else { - //debug - cfg = new MsvcToolchainConfig( - compilerOptions: new MsvcToolchainConfig.CompilerOptions( - codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG, - optimizationLevel: OptimizationLevel.DISABLED, - debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, - runtimeChecks: RuntimeChecks.DEFAULT, - cppExceptions: CppExceptions.ENABLED_WITH_SEH, - warningLevel: WarningLevel.LEVEL_3, - callingConvention: CallingConvention.CDECL, - enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, - floatingPointModel: FloatingPointModel.FAST, + generatePdb: true + ) + } else { + //debug + cfg = new MsvcToolchainConfig( + compilerOptions: new MsvcToolchainConfig.CompilerOptions( + codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG, + optimizationLevel: OptimizationLevel.DISABLED, + debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE, + runtimeChecks: RuntimeChecks.DEFAULT, + cppExceptions: CppExceptions.ENABLED_WITH_SEH, + warningLevel: WarningLevel.LEVEL_3, + callingConvention: CallingConvention.CDECL, + enhancedInstructionsSet: EnhancedInstructionsSet.SSE2, + floatingPointModel: FloatingPointModel.FAST, - enableMinimalRebuild: true, - omitFramePointers: false, - wholeProgramOptimization: false, - enabledFunctionLevelLinking: true, - enableSecurityCheck: true, - analyzeCode: false, - sdlChecks: false, - treatWarningsAsErrors: false, - treatWchartAsBuiltin: true, - forceConformanceInForLoopScope: true, + enableMinimalRebuild: true, + omitFramePointers: false, + wholeProgramOptimization: false, + enabledFunctionLevelLinking: true, + enableSecurityCheck: true, + analyzeCode: false, + sdlChecks: false, + treatWarningsAsErrors: false, + treatWchartAsBuiltin: true, + forceConformanceInForLoopScope: true, - extraDefines: [ - 'WIN32': null, - '_MBCS': null, - '_DEBUG': null, - ] - ), + extraDefines: [ + 'WIN32': null, + '_MBCS': null, + '_DEBUG': null, + ] + ), - linkerOptions: new MsvcToolchainConfig.LinkerOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT, - errorReportingMode: ErrorReporting.NO_ERROR_REPORT, + linkerOptions: new MsvcToolchainConfig.LinkerOptions( + linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT, + errorReportingMode: ErrorReporting.NO_ERROR_REPORT, - enableIncrementalLinking: true, - eliminateUnusedRefs: false, - enableCOMDATFolding: false, - generateDebugInfo: true, - dataExecutionPrevention: true, - randomizedBaseAddress: true - ), + enableIncrementalLinking: true, + eliminateUnusedRefs: false, + enableCOMDATFolding: false, + generateDebugInfo: true, + dataExecutionPrevention: true, + randomizedBaseAddress: true + ), - librarianOptions: new MsvcToolchainConfig.LibrarianOptions( - linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG - ), + librarianOptions: new MsvcToolchainConfig.LibrarianOptions( + linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG + ), - generatePdb: true - ) + generatePdb: true + ) - if (binKind == BinaryKind.STATIC_LIBRARY) { - cfg.compilerConfig.extraDefines['_LIB'] = null - } - } + if (binKind == BinaryKind.STATIC_LIBRARY) { + cfg.compilerConfig.extraDefines['_LIB'] = null + } + } - return cfg -} \ No newline at end of file + return cfg +}