2015-06-30 12:46:07 +03:00
|
|
|
import gradlecpp.RegamedllPlayTestPlugin
|
|
|
|
import gradlecpp.RegamedllPlayTestTask
|
|
|
|
import gradlecpp.VelocityUtils
|
2016-12-09 17:07:34 +03:00
|
|
|
|
2015-06-30 12:46:07 +03:00
|
|
|
import org.doomedsociety.gradlecpp.GradleCppUtils
|
|
|
|
import org.doomedsociety.gradlecpp.LazyNativeDepSet
|
|
|
|
import org.doomedsociety.gradlecpp.cfg.ToolchainConfig
|
|
|
|
import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
|
|
|
|
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
|
|
|
|
import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet
|
|
|
|
import org.doomedsociety.gradlecpp.msvc.FloatingPointModel
|
|
|
|
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
|
|
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.Icc
|
|
|
|
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
|
|
|
|
import org.gradle.language.cpp.CppSourceSet
|
|
|
|
import org.gradle.nativeplatform.NativeBinarySpec
|
|
|
|
import org.gradle.nativeplatform.NativeExecutableSpec
|
|
|
|
import org.gradle.nativeplatform.NativeLibrarySpec
|
|
|
|
import org.gradle.nativeplatform.SharedLibraryBinarySpec
|
|
|
|
import regamedll.testdemo.RegamedllDemoRunner
|
|
|
|
import versioning.RegamedllVersionInfo
|
|
|
|
import org.apache.commons.io.FilenameUtils
|
2015-07-05 14:05:26 +03:00
|
|
|
import org.apache.commons.compress.archivers.ArchiveInputStream
|
2015-06-30 12:46:07 +03:00
|
|
|
|
|
|
|
apply plugin: 'cpp'
|
|
|
|
apply plugin: IccCompilerPlugin
|
|
|
|
apply plugin: RegamedllPlayTestPlugin
|
|
|
|
apply plugin: gradlecpp.CppUnitTestPlugin
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-releases/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
2015-12-05 22:40:30 +03:00
|
|
|
regamedll_tests
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2016-02-23 22:54:07 +03:00
|
|
|
regamedll_tests 'regamedll.testdemos:cstrike-basic:1.0'
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
project.ext.dep_cppunitlite = project(':dep/cppunitlite')
|
|
|
|
|
|
|
|
void createIntergrationTestTask(NativeBinarySpec b) {
|
2015-12-05 22:40:30 +03:00
|
|
|
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
|
|
|
|
|
|
|
|
if (!(b instanceof SharedLibraryBinarySpec)) return
|
|
|
|
if (!GradleCppUtils.windows) return
|
|
|
|
if (regamedllFixes) return
|
|
|
|
|
|
|
|
String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null
|
|
|
|
|
|
|
|
def demoItgTestTask = project.tasks.create(b.namingScheme.getTaskName('demoItgTest'), RegamedllPlayTestTask)
|
|
|
|
demoItgTestTask.with {
|
|
|
|
regamedllImageRoot = new File(project.projectDir, '_regamedllTestImg')
|
|
|
|
regamedllTestLogs = new File(this.project.buildDir, "_regamedllTestLogs/${b.name}")
|
|
|
|
testDemos = project.configurations.regamedll_tests
|
|
|
|
testFor = b
|
|
|
|
|
2016-02-23 22:54:07 +03:00
|
|
|
//inputs/outputs for up-to-date check
|
|
|
|
inputs.files testDemos.files
|
|
|
|
outputs.dir regamedllTestLogs
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2016-02-23 22:54:07 +03:00
|
|
|
//dependencies on test executable
|
|
|
|
if (unitTestTask) {
|
|
|
|
dependsOn unitTestTask
|
|
|
|
}
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2016-02-23 22:54:07 +03:00
|
|
|
postExtractAction {
|
|
|
|
def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b)
|
|
|
|
def binaryOutDir = new File(project.projectDir, '/_regamedllTestImg/cstrike/dlls')
|
|
|
|
GradleCppUtils.copyFile(binaryOutFile, new File(binaryOutDir, binaryOutFile.name), true)
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
b.buildTask.dependsOn demoItgTestTask
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void postEvaluate(NativeBinarySpec b) {
|
|
|
|
|
2015-12-05 22:40:30 +03:00
|
|
|
// attach generateAppVersion task to all 'compile source' tasks
|
|
|
|
GradleCppUtils.getCompileTasks(b).each { Task t ->
|
|
|
|
t.dependsOn project.generateAppVersion
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
|
2015-12-05 22:40:30 +03:00
|
|
|
createIntergrationTestTask(b)
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2015-12-05 22:40:30 +03:00
|
|
|
void setupToolchain(NativeBinarySpec b)
|
|
|
|
{
|
|
|
|
boolean unitTestExecutable = b.component.name.endsWith('_tests')
|
|
|
|
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
|
|
|
|
|
|
|
|
ToolchainConfig cfg = rootProject.createToolchainConfig(b)
|
2017-10-19 20:12:02 +03:00
|
|
|
cfg.projectInclude(project, '', '/engine', '/common', '/dlls', '/game_shared', '/pm_shared', '/regamedll', '/public', '/public/regamedll')
|
2015-12-05 22:40:30 +03:00
|
|
|
|
|
|
|
if (unitTestExecutable)
|
|
|
|
{
|
|
|
|
cfg.projectInclude(dep_cppunitlite, '/include')
|
|
|
|
b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true)
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:29:22 +03:00
|
|
|
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS', 'USE_QSTRING'
|
2015-12-05 22:40:30 +03:00
|
|
|
|
|
|
|
if (cfg instanceof MsvcToolchainConfig)
|
|
|
|
{
|
|
|
|
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
|
|
|
|
enabled: true,
|
|
|
|
pchHeader: 'precompiled.h',
|
|
|
|
pchSourceSet: 'regamedll_pch'
|
|
|
|
);
|
|
|
|
|
|
|
|
cfg.singleDefines('_CRT_SECURE_NO_WARNINGS')
|
|
|
|
if (!regamedllFixes)
|
|
|
|
{
|
|
|
|
cfg.compilerOptions.floatingPointModel = FloatingPointModel.PRECISE
|
|
|
|
cfg.compilerOptions.enhancedInstructionsSet = EnhancedInstructionsSet.DISABLED
|
|
|
|
}
|
2016-04-24 16:52:16 +03:00
|
|
|
else {
|
2018-02-14 12:02:00 +03:00
|
|
|
cfg.compilerOptions.args '/Oi', '/GF', '/GS-'
|
2016-04-24 16:52:16 +03:00
|
|
|
}
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2016-12-24 15:09:50 +03:00
|
|
|
cfg.projectLibpath(project, '/lib')
|
|
|
|
cfg.extraLibs 'libacof32.lib'
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
2016-02-04 03:18:26 +03:00
|
|
|
else if (cfg instanceof GccToolchainConfig)
|
|
|
|
{
|
2015-12-05 22:40:30 +03:00
|
|
|
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
|
|
|
|
enabled: true,
|
|
|
|
pchSourceSet: 'regamedll_pch'
|
|
|
|
);
|
|
|
|
|
2017-10-12 17:50:56 +03:00
|
|
|
cfg.compilerOptions.languageStandard = 'c++14'
|
2015-12-05 22:40:30 +03:00
|
|
|
cfg.defines([
|
|
|
|
'_stricmp': 'strcasecmp',
|
|
|
|
'_strnicmp': 'strncasecmp',
|
|
|
|
'_strdup': 'strdup',
|
|
|
|
'_unlink': 'unlink',
|
|
|
|
'_vsnprintf': 'vsnprintf',
|
|
|
|
'_write' : 'write',
|
|
|
|
'_close' : 'close',
|
2016-04-07 23:20:45 +03:00
|
|
|
'_vsnwprintf' : 'vswprintf',
|
|
|
|
'_access' : 'access'
|
2015-12-05 22:40:30 +03:00
|
|
|
])
|
|
|
|
|
2015-12-06 22:02:16 +03:00
|
|
|
cfg.linkerOptions.args '-no-opt-class-analysis'
|
2017-07-01 23:40:10 +03:00
|
|
|
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-g0', '-fno-rtti', '-fno-exceptions'
|
2016-12-24 15:09:50 +03:00
|
|
|
cfg.projectLibpath(project, '/lib/linux32')
|
|
|
|
cfg.extraLibs 'dl', 'm', 'stdc++', 'aelf32'
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
|
|
|
|
2017-10-19 20:12:02 +03:00
|
|
|
if (GradleCppUtils.windows && !unitTestExecutable) {
|
2015-12-05 22:40:30 +03:00
|
|
|
cfg.linkerOptions.definitionFile = "${projectDir}\\msvc\\mp.def";
|
|
|
|
}
|
|
|
|
|
2016-02-23 22:54:07 +03:00
|
|
|
if (unitTestExecutable) {
|
2015-12-05 22:40:30 +03:00
|
|
|
cfg.singleDefines 'REGAMEDLL_UNIT_TESTS'
|
|
|
|
}
|
|
|
|
|
2016-02-23 22:54:07 +03:00
|
|
|
if (regamedllFixes) {
|
2017-10-31 00:29:22 +03:00
|
|
|
cfg.singleDefines 'REGAMEDLL_FIXES', 'REGAMEDLL_CHECKS', 'REGAMEDLL_ADD', 'UNICODE_FIXES', 'NDEBUG'
|
2016-02-23 22:54:07 +03:00
|
|
|
} else {
|
|
|
|
cfg.singleDefines 'PLAY_GAMEDLL'
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ToolchainConfigUtils.apply(project, cfg, b)
|
|
|
|
GradleCppUtils.onTasksCreated(project, 'postEvaluate', {
|
|
|
|
postEvaluate(b)
|
|
|
|
})
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class RegamedllSrc {
|
2015-12-05 22:40:30 +03:00
|
|
|
static void regamedll_src(def h) {
|
2017-10-31 00:29:22 +03:00
|
|
|
h.engine_src(CppSourceSet) {
|
|
|
|
source {
|
|
|
|
srcDir "engine"
|
|
|
|
include "unicode_strtools.cpp"
|
|
|
|
}
|
|
|
|
}
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2017-10-31 00:29:22 +03:00
|
|
|
h.shared_src(CppSourceSet) {
|
2015-12-05 22:40:30 +03:00
|
|
|
source {
|
2017-10-31 00:29:22 +03:00
|
|
|
srcDirs "game_shared", "pm_shared", "regamedll", "public", "version"
|
2015-12-05 22:40:30 +03:00
|
|
|
|
|
|
|
include "**/*.cpp"
|
2017-10-31 00:29:22 +03:00
|
|
|
|
2015-12-05 22:40:30 +03:00
|
|
|
exclude "precompiled.cpp"
|
2016-02-04 03:18:26 +03:00
|
|
|
exclude "tier0/dbg.cpp", "utlsymbol.cpp", "utlbuffer.cpp"
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2016-02-23 02:13:52 +03:00
|
|
|
if (GradleCppUtils.windows)
|
|
|
|
{
|
2015-12-05 22:40:30 +03:00
|
|
|
exclude "tier0/platform_linux.cpp"
|
2016-02-23 02:13:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-05 22:40:30 +03:00
|
|
|
exclude "tier0/platform_win32.cpp"
|
2016-01-29 16:46:52 +03:00
|
|
|
exclude "classes_dummy.cpp"
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-31 00:29:22 +03:00
|
|
|
|
|
|
|
h.gamedll_src(CppSourceSet) {
|
|
|
|
source {
|
|
|
|
srcDirs "dlls", "dlls/API", "dlls/addons"
|
|
|
|
include "**/*.cpp"
|
|
|
|
}
|
|
|
|
}
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
|
2015-12-05 22:40:30 +03:00
|
|
|
static void regamedll_pch(def h) {
|
|
|
|
h.regamedll_pch(CppSourceSet) {
|
|
|
|
source {
|
2017-10-31 00:29:22 +03:00
|
|
|
srcDir "regamedll"
|
2015-12-05 22:40:30 +03:00
|
|
|
include "precompiled.cpp"
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void regamedll_tests_src(def h) {
|
|
|
|
h.regamedll_tests_src(CppSourceSet) {
|
|
|
|
source {
|
|
|
|
srcDir "unittests"
|
|
|
|
include "**/*.cpp"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
model {
|
2015-12-05 22:40:30 +03:00
|
|
|
buildTypes {
|
|
|
|
debug
|
|
|
|
release
|
|
|
|
}
|
|
|
|
|
|
|
|
platforms {
|
|
|
|
x86 {
|
|
|
|
architecture "x86"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toolChains {
|
|
|
|
visualCpp(VisualCpp) {
|
|
|
|
}
|
|
|
|
icc(Icc) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flavors {
|
|
|
|
regamedllNofixes
|
|
|
|
regamedllFixes
|
|
|
|
}
|
|
|
|
|
|
|
|
components {
|
|
|
|
|
|
|
|
regamedll_mp_gamedll(NativeLibrarySpec) {
|
|
|
|
targetPlatform 'x86'
|
|
|
|
baseName GradleCppUtils.windows ? 'mp' : 'cs'
|
|
|
|
sources {
|
|
|
|
RegamedllSrc.regamedll_pch(it)
|
|
|
|
RegamedllSrc.regamedll_src(it)
|
|
|
|
}
|
|
|
|
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
|
|
|
|
}
|
|
|
|
|
|
|
|
regamedll_mp_gamedll_tests(NativeExecutableSpec) {
|
|
|
|
targetPlatform 'x86'
|
|
|
|
sources {
|
|
|
|
RegamedllSrc.regamedll_pch(it)
|
|
|
|
RegamedllSrc.regamedll_src(it)
|
|
|
|
RegamedllSrc.regamedll_tests_src(it)
|
|
|
|
}
|
|
|
|
|
|
|
|
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
|
|
|
|
}
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task buildRelease {
|
2015-12-05 22:40:30 +03:00
|
|
|
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
|
2017-10-19 20:12:02 +03:00
|
|
|
blib.buildable && blib.buildType.name == 'release'
|
2015-12-05 22:40:30 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-07-18 00:09:31 +03:00
|
|
|
task buildFixes {
|
|
|
|
dependsOn binaries.withType(SharedLibraryBinarySpec).matching {
|
|
|
|
SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'regamedllFixes' && blib.component.name == 'regamedll_mp_gamedll'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gradle.taskGraph.whenReady { graph ->
|
|
|
|
if (!graph.hasTask(buildFixes)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip all tasks with the matched substrings in the name like "test"
|
|
|
|
def tasks = graph.getAllTasks();
|
|
|
|
tasks.findAll { it.name.toLowerCase().contains("test") }.each { task ->
|
|
|
|
task.enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-30 12:46:07 +03:00
|
|
|
task prepareDevEnvTests {
|
2015-12-05 22:40:30 +03:00
|
|
|
def regamedllTests = new File(project.projectDir, '_dev/testDemos')
|
|
|
|
|
|
|
|
inputs.files configurations.regamedll_tests.files
|
|
|
|
outputs.dir regamedllTests
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
regamedllTests.mkdirs()
|
|
|
|
configurations.regamedll_tests.files.each { File f ->
|
|
|
|
def t = zipTree(f)
|
|
|
|
copy {
|
|
|
|
into new File(regamedllTests, FilenameUtils.getBaseName(f.absolutePath))
|
|
|
|
from t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task prepareDevEnvGamedll << {
|
|
|
|
['_dev/regamedll', '_dev/regamedll_mp'].each { gamedllDir ->
|
|
|
|
def regamedllImage = new File(project.projectDir, gamedllDir)
|
|
|
|
regamedllImage.mkdirs()
|
|
|
|
def demoRunner = new RegamedllDemoRunner(project.configurations.regamedll_playtest_image.getFiles(), regamedllImage, null)
|
2015-07-05 14:05:26 +03:00
|
|
|
demoRunner.prepareEngine()
|
|
|
|
//demoRunner.prepareDemo()
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task prepareDevEnv {
|
2015-12-05 22:40:30 +03:00
|
|
|
dependsOn prepareDevEnvGamedll, prepareDevEnvTests
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.clean.doLast {
|
2015-12-05 22:40:30 +03:00
|
|
|
project.file('version/appversion.h').delete()
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task generateAppVersion {
|
|
|
|
|
|
|
|
RegamedllVersionInfo verInfo = (RegamedllVersionInfo) rootProject.regamedllVersionInfo
|
|
|
|
def tplFile = project.file('version/appversion.vm')
|
|
|
|
def renderedFile = project.file('version/appversion.h')
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2016-12-09 17:07:34 +03:00
|
|
|
// check to up-to-date
|
2015-06-30 12:46:07 +03:00
|
|
|
inputs.file tplFile
|
|
|
|
inputs.file project.file('gradle.properties')
|
|
|
|
outputs.file renderedFile
|
2016-12-09 17:07:34 +03:00
|
|
|
|
|
|
|
// this will ensure that this task is redone when the versions change
|
|
|
|
inputs.property('version', rootProject.version)
|
|
|
|
inputs.property('commitDate', verInfo.asCommitDate())
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2017-01-14 17:07:12 +03:00
|
|
|
println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']";
|
|
|
|
|
2015-06-30 12:46:07 +03:00
|
|
|
doLast {
|
|
|
|
def templateCtx = [
|
|
|
|
verInfo: verInfo
|
|
|
|
]
|
2015-12-05 22:40:30 +03:00
|
|
|
|
2015-06-30 12:46:07 +03:00
|
|
|
def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
|
|
|
|
renderedFile.delete()
|
|
|
|
renderedFile.write(content, 'utf-8')
|
2016-02-01 13:46:31 +03:00
|
|
|
|
2016-12-09 17:07:34 +03:00
|
|
|
println 'The current ReGameDLL maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
}
|