Remove gradle build system & Cleanup

This commit is contained in:
s1lentq 2021-04-12 21:51:51 +07:00
parent fc52871739
commit 9736437cb8
77 changed files with 218 additions and 3198 deletions

4
.gitattributes vendored
View File

@ -16,14 +16,10 @@
# Scripts
*.sh text eol=lf
gradlew text eol=lf
*.bat text eol=crlf
*.gradle text eol=crlf
*.groovy text eol=crlf
*.def text eol=crlf
*.fgd text eol=crlf
*.cfg text eol=crlf
*.properties text eol=crlf
*.vm text eol=crlf
# Compiled Object files

6
.gitignore vendored
View File

@ -1,7 +1,4 @@
**/build
**/.gradle
.idea
*.iml
*.bat
*.log
*.lnk
@ -15,12 +12,11 @@
**/msvc/*.db
**/msvc/*.opendb
**/msvc/*.txt
**/msvc/*.aps
**/msvc/*.amplxeproj
**/msvc/.vs
**/msvc/ipch
regamedll/version/appversion.h
regamedll/msvc/PublishPath*.txt
regamedll/_regamedllTestImg
regamedll/_dev
publish

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "regamedll/extra/cssdk"]
path = regamedll/extra/cssdk
url = https://github.com/s1lentq/CSSDK.git

View File

@ -1,60 +0,0 @@
import versioning.GitVersioner
import versioning.RegamedllVersionInfo
import org.joda.time.DateTime
apply plugin: 'maven-publish'
apply from: 'shared.gradle'
group = 'regamedll'
apply plugin: 'idea'
idea {
project {
languageLevel = 'JDK_1_7'
}
}
def gitInfo = GitVersioner.versionForDir(project.rootDir)
RegamedllVersionInfo 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}")
}
versionInfo = new RegamedllVersionInfo(
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 {
if (!gitInfo) {
System.err.println "WARNING! couldn't get gitInfo";
}
versionInfo = new RegamedllVersionInfo(
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.regamedllVersionInfo = versionInfo
project.version = versionInfo.asMavenVersion()
apply from: 'publish.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}

View File

@ -1,33 +0,0 @@
apply plugin: 'groovy'
repositories {
//mavenLocal()
mavenCentral()
maven {
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-releases/'
}
maven {
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-snapshots/'
}
maven {
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-dev/'
}
}
dependencies {
compile gradleApi()
compile localGroovy()
compile 'commons-io:commons-io:2.4'
compile 'commons-lang:commons-lang:2.6'
compile 'joda-time:joda-time:2.7'
compile 'org.doomedsociety.gradlecpp:gradle-cpp-plugin:1.2'
compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r'
compile 'org.apache.commons:commons-compress:1.9'
compile 'org.apache.ant:ant-compress:1.2'
compile 'org.apache.ant:ant:1.9.6'
compile 'org.apache.velocity:velocity:1.7'
}

View File

@ -1,58 +0,0 @@
package dirsync.builder
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
import groovy.transform.CompileStatic
class FileSystemTreeBuilder {
@CompileStatic
private static FileNode<File> buildNodeForFile(File file, DirectoryNode<File> parent) {
if (parent.getChildren(file.name)) {
throw new RuntimeException("Parent dir ${parent.name} already contains child node ${file.name}");
}
return new FileNode(
name: file.name,
lastModifiedDate: file.lastModified(),
data: file,
parent: parent,
size: file.size()
);
}
@CompileStatic
private static DirectoryNode<File> buildNodeForDirectoryRecursive(File dir, DirectoryNode<File> parent) {
if (!dir.isDirectory()) {
throw new RuntimeException("File ${dir.absolutePath} is not a directory")
}
if (parent != null && parent.getChildren(dir.name)) {
throw new RuntimeException("Parent dir ${parent.name} already contains child node ${dir.name}");
}
DirectoryNode<File> thisNode = new DirectoryNode(
name: dir.name,
lastModifiedDate: dir.lastModified(),
data: dir,
parent: parent
);
dir.eachFile { File f ->
if (f.isDirectory()) {
thisNode.childNodes[f.name] = buildNodeForDirectoryRecursive(f, thisNode)
} else {
thisNode.childNodes[f.name] = buildNodeForFile(f, thisNode)
}
}
return thisNode;
}
static DirectoryNode<File> buildFileSystemTree(File rootDir) {
def root = buildNodeForDirectoryRecursive(rootDir, null);
PostBuildPass.doPostBuild(root)
return root
}
}

View File

@ -1,60 +0,0 @@
package dirsync.builder
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
class FileTreeMerger {
private static <T> void mergeContentsRecursive(DirectoryNode<T> newParent, DirectoryNode<T> toMerge) {
toMerge.childNodes.each { cn ->
def node = cn.value
def existingNode = newParent.childNodes[node.name]
if (existingNode) {
if (!(existingNode instanceof DirectoryNode) || !(node instanceof DirectoryNode))
throw new RuntimeException("Failed to merge non-directory nodes ${node.fullPath}")
def existingDirNode = existingNode as DirectoryNode<T>
def dirNode = node as DirectoryNode<T>
existingDirNode.lastModifiedDate = Math.max(existingDirNode.lastModifiedDate, dirNode.lastModifiedDate)
mergeContentsRecursive(existingDirNode, dirNode)
} else {
if (node instanceof DirectoryNode) {
def dirNode = node as DirectoryNode<T>
def newNode = new DirectoryNode<T>(
name: dirNode.name,
data: dirNode.data,
parent: newParent,
lastModifiedDate: dirNode.lastModifiedDate
)
newParent.childNodes[node.name] = newNode
mergeContentsRecursive(newNode, dirNode)
} else {
FileNode<T> fileNode = node as FileNode<T>
FileNode<T> newNode = new FileNode<T>(
name: fileNode.name,
data: fileNode.data,
parent: newParent,
lastModifiedDate: fileNode.lastModifiedDate,
size: fileNode.size
)
newParent.childNodes[node.name] = newNode
}
}
}
}
public static <T> DirectoryNode<T> mergeTrees(DirectoryNode<T> tree1, DirectoryNode<T> tree2) {
DirectoryNode<T> newRoot = new DirectoryNode<T>(
name: tree1.name ?: tree2.name
)
mergeContentsRecursive(newRoot, tree1)
mergeContentsRecursive(newRoot, tree2)
PostBuildPass.doPostBuild(newRoot)
return newRoot
}
}

View File

@ -1,22 +0,0 @@
package dirsync.builder
import dirsync.model.tree.DirectoryNode
class PostBuildPass {
private static <T> void postProcessRecursive(DirectoryNode<T> dir) {
dir.childNodes.each { cne ->
def childNode = cne.value
childNode.fullPath = dir.fullPath ? dir.fullPath + '/' + childNode.name : childNode.name
if (childNode instanceof DirectoryNode) {
def childDirNode = childNode as DirectoryNode<T>
postProcessRecursive(childDirNode)
}
}
}
static <T> void doPostBuild(DirectoryNode<T> root) {
root.fullPath = ''
postProcessRecursive(root)
}
}

View File

@ -1,53 +0,0 @@
package dirsync.builder
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
import dirsync.model.tree.ZipData
import java.util.zip.ZipFile
class ZipTreeBuilder {
static DirectoryNode<ZipData> buildForZipArchive(String zipArchive, ZipFile zf) {
DirectoryNode<ZipData> root = new DirectoryNode<>()
zf.entries().each { ze ->
def path = ze.name.replace('\\', '/')
if (path.endsWith('/'))
path = path.substring(0, path.length() - 1)
def parentPath = path.contains('/') ? path.substring(0, path.lastIndexOf('/')) : ''
def childPath = path.contains('/') ? path.substring(path.lastIndexOf('/') + 1) : path
def parentNode = (DirectoryNode<ZipData>) root.getByPath(parentPath)
if (parentNode == null)
throw new RuntimeException("Error reading ${zipArchive}: could not find parent path ${parentPath} for path ${path}")
def childNode = parentNode.getChildren(childPath)
if (childNode)
throw new RuntimeException("Error reading ${zipArchive}: duplicate path ${path}")
if (ze.directory) {
childNode = new DirectoryNode<ZipData>(
name: childPath,
lastModifiedDate: ze.time,
data: new ZipData(zipEntryName: ze.name, zipArchiveName: zipArchive),
parent: parentNode
);
} else {
childNode = new FileNode<ZipData>(
name: childPath,
lastModifiedDate: ze.time,
data: new ZipData(zipEntryName: ze.name, zipArchiveName: zipArchive),
parent: parentNode,
size: ze.size
);
}
parentNode.childNodes[childPath] = childNode
//println '' + ze.directory + ' ' + ze.name + ' ' + parentPath + ' ' + childPath
}
PostBuildPass.doPostBuild(root)
return root
}
}

View File

@ -1,97 +0,0 @@
package dirsync.merger
import dirsync.model.synccmd.AbstractSyncCmd
import dirsync.model.synccmd.CopyDirCmd
import dirsync.model.synccmd.CopyFileCmd
import dirsync.model.synccmd.DeleteDirCmd
import dirsync.model.synccmd.DeleteFileCmd
import dirsync.model.synccmd.ReplaceFileCmd
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
import groovy.transform.TypeChecked
@TypeChecked
class FileTreeComparator {
private static <T, U> void mergeDirsRecursive(DirectoryNode<T> left, DirectoryNode<U> right, List<AbstractSyncCmd<T, U>> diffs) {
// left => right
left.childNodes.each { le ->
def leftNode = le.value
def rightNode = right.childNodes[leftNode.name]
if (rightNode == null) {
switch (leftNode) {
case DirectoryNode:
def leftDirNode = leftNode as DirectoryNode<T>
diffs << new CopyDirCmd<>(src: leftDirNode, dstParentDir: right)
break
case FileNode:
def leftFileNode = leftNode as FileNode<T>
diffs << new CopyFileCmd<>(src: leftFileNode, dstDir: right)
break
default:
throw new RuntimeException("Invalid node class ${leftNode.class.name}")
}
return
}
if (rightNode.class != leftNode.class) {
throw new RuntimeException("node classes mismatch: ${leftNode.class.name} != ${rightNode.class.name}")
}
switch (rightNode) {
case DirectoryNode:
def leftDirNode = leftNode as DirectoryNode<T>
def rightDirNode = rightNode as DirectoryNode<U>
mergeDirsRecursive(leftDirNode, rightDirNode, diffs)
break
case FileNode:
def leftFileNode = leftNode as FileNode<T>
def rightFileNode = rightNode as FileNode<T>
if (leftFileNode.size != rightFileNode.size || leftFileNode.lastModifiedDate != rightFileNode.lastModifiedDate) {
diffs << new ReplaceFileCmd<>(src: leftFileNode, dst: rightFileNode)
}
break
default:
throw new RuntimeException("Invalid node class ${rightNode.class.name}")
}
} // ~left => right
//right => left
right.childNodes.each { re ->
def rightNode = re.value
def leftNode = left.childNodes[rightNode.name]
if (leftNode != null) {
return //already processed in left => right
}
switch (rightNode) {
case DirectoryNode:
def rightDirNode = rightNode as DirectoryNode<U>
diffs << new DeleteDirCmd<>(dirNode: rightDirNode)
break
case FileNode:
def rightFileNode = rightNode as FileNode<T>
diffs << new DeleteFileCmd<>(node: rightFileNode)
break
default:
throw new RuntimeException("Invalid node class ${rightNode.class.name}")
}
} // ~right => left
}
static <T, U> List<AbstractSyncCmd<T, U>> mergeTrees(DirectoryNode<T> leftRoot, DirectoryNode<U> rightRoot) {
List<AbstractSyncCmd<T, U>> res = []
mergeDirsRecursive(leftRoot, rightRoot, res)
return res
}
}

View File

@ -1,103 +0,0 @@
package dirsync.merger
import dirsync.model.synccmd.AbstractSyncCmd
import dirsync.model.synccmd.CopyDirCmd
import dirsync.model.synccmd.CopyFileCmd
import dirsync.model.synccmd.DeleteDirCmd
import dirsync.model.synccmd.DeleteFileCmd
import dirsync.model.synccmd.ReplaceFileCmd
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
import dirsync.model.tree.TreePhysMapper
import groovy.transform.TypeChecked
import org.apache.commons.io.IOUtils
@TypeChecked
public class FileTreeDiffApplier {
static <T, U> void copyDirRecursive(DirectoryNode<T> src, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
dstMapper.createDirectory(src.fullPath)
src.childNodes.each { ce ->
def childNode = ce.value
def childPath = childNode.fullPath
switch (childNode) {
case FileNode:
srcMapper.fileContent(childNode.data).withStream { InputStream inStream ->
dstMapper.createFile(childPath).withStream { OutputStream outStream ->
IOUtils.copy(inStream, outStream)
}
dstMapper.setFileLastUpdatedDate(childPath, childNode.lastModifiedDate)
}
break;
case DirectoryNode:
copyDirRecursive(childNode as DirectoryNode<T>, srcMapper, dstMapper)
break;
default:
throw new RuntimeException("Invalid node class: ${childNode.class.name}")
}
}
}
static <T, U> void handleCopyFile(CopyFileCmd<T, U> fileCopy, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
def dstPath = fileCopy.dstDir.fullPath ? fileCopy.dstDir.fullPath + '/' + fileCopy.src.name : fileCopy.src.name
srcMapper.fileContent(fileCopy.src.data).withStream { InputStream inStream ->
dstMapper.createFile(dstPath).withStream { OutputStream outStream ->
IOUtils.copy(inStream, outStream)
}
dstMapper.setFileLastUpdatedDate(dstPath, fileCopy.src.lastModifiedDate)
}
}
static <T, U> void handleDeleteDir(DeleteDirCmd<T, U> delDir, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
dstMapper.removeDirectory(delDir.dirNode.fullPath)
}
static <T, U> void handleDeleteFile(DeleteFileCmd<T, U> delFile, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
dstMapper.removeFile(delFile.node.fullPath)
}
static <T, U> void handleReplaceFile(ReplaceFileCmd<T, U> replaceFile, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
dstMapper.removeFile(replaceFile.dst.fullPath)
srcMapper.fileContent(replaceFile.src.data).withStream { InputStream inStream ->
dstMapper.createFile(replaceFile.dst.fullPath).withStream { OutputStream outStream ->
IOUtils.copy(inStream, outStream)
}
dstMapper.setFileLastUpdatedDate(replaceFile.dst.fullPath, replaceFile.src.lastModifiedDate)
}
}
static <T, U> void applyDiffs(List<AbstractSyncCmd<T, U>> diffs, TreePhysMapper<T> srcMapper, TreePhysMapper<U> dstMapper) {
diffs.each { diff ->
switch (diff) {
case CopyDirCmd:
def copyDir = diff as CopyDirCmd<T, U>
copyDirRecursive(copyDir.src, srcMapper, dstMapper)
break
case CopyFileCmd:
handleCopyFile(diff as CopyFileCmd<T, U>, srcMapper, dstMapper)
break
case DeleteDirCmd:
handleDeleteDir(diff as DeleteDirCmd<T, U>, srcMapper, dstMapper)
break
case DeleteFileCmd:
handleDeleteFile(diff as DeleteFileCmd<T, U>, srcMapper, dstMapper)
break
case ReplaceFileCmd:
handleReplaceFile(diff as ReplaceFileCmd<T, U>, srcMapper, dstMapper)
break
default:
throw new RuntimeException("Invalid diff command ${diff.class.name}")
}
}
}
}

View File

@ -1,4 +0,0 @@
package dirsync.model.synccmd
class AbstractSyncCmd<T, U> {
}

View File

@ -1,8 +0,0 @@
package dirsync.model.synccmd
import dirsync.model.tree.DirectoryNode
class CopyDirCmd<T, U> extends AbstractSyncCmd<T, U> {
DirectoryNode<T> src
DirectoryNode<U> dstParentDir
}

View File

@ -1,9 +0,0 @@
package dirsync.model.synccmd
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FileNode
class CopyFileCmd<T, U> extends AbstractSyncCmd<T, U> {
FileNode<T> src
DirectoryNode<U> dstDir
}

View File

@ -1,7 +0,0 @@
package dirsync.model.synccmd
import dirsync.model.tree.DirectoryNode
class DeleteDirCmd<T, U> extends AbstractSyncCmd<T, U> {
DirectoryNode<U> dirNode
}

View File

@ -1,7 +0,0 @@
package dirsync.model.synccmd
import dirsync.model.tree.FileNode
class DeleteFileCmd<T, U> extends AbstractSyncCmd<T, U> {
FileNode<U> node
}

View File

@ -1,8 +0,0 @@
package dirsync.model.synccmd
import dirsync.model.tree.FileNode
class ReplaceFileCmd<T, U> extends AbstractSyncCmd<T, U> {
FileNode<T> src
FileNode<U> dst
}

View File

@ -1,27 +0,0 @@
package dirsync.model.tree
import groovy.transform.CompileStatic
@CompileStatic
abstract class AbstractFileTreeNode<T> {
DirectoryNode<T> parent
String name
String fullPath
long lastModifiedDate
T data
boolean equals(o) {
if (this.is(o)) return true
if (getClass() != o.class) return false
AbstractFileTreeNode that = (AbstractFileTreeNode) o
if (name != that.name) return false
return true
}
int hashCode() {
return (name != null ? name.hashCode() : 0)
}
}

View File

@ -1,42 +0,0 @@
package dirsync.model.tree
import groovy.transform.CompileStatic
@CompileStatic
class DirectoryNode<T> extends AbstractFileTreeNode<T> {
Map<String, AbstractFileTreeNode<T>> childNodes = new HashMap<>()
AbstractFileTreeNode<T> getChildren(String name) {
return childNodes[name];
}
AbstractFileTreeNode<T> getChildren(String[] names, int idx) {
if (idx == names.length)
return this
AbstractFileTreeNode<T> c = childNodes[names[idx]]
if (c == null)
return null
if (c instanceof DirectoryNode) {
def d = (DirectoryNode<T>) c;
return d.getChildren(names, idx + 1)
}
return null;
}
AbstractFileTreeNode<T> getByPath(String path) {
path = path.replace('\\', '/')
if (path.endsWith('/'))
path = path.substring(0, path.length() - 1)
if (path.empty) {
return this
}
String[] components = path.split('/')
return getChildren(components, 0)
}
}

View File

@ -1,50 +0,0 @@
package dirsync.model.tree
class FSMapper extends TreePhysMapper<File> {
final File root
FSMapper(File root) {
this.root = root
}
@Override
InputStream fileContent(File file) {
return file.newDataInputStream()
}
@Override
void createDirectory(String dir) {
def target = new File(root, dir)
if (!target.mkdirs()) {
throw new RuntimeException("Failed to create directory ${target.absolutePath}")
}
}
@Override
void removeDirectory(String dir) {
def target = new File(root, dir)
if (!target.deleteDir()) {
throw new RuntimeException("Failed to delete directory ${target.absolutePath}")
}
}
@Override
void removeFile(String path) {
def target = new File(root, path)
if (!target.delete()) {
throw new RuntimeException("Failed to delete file ${target.absolutePath}")
}
}
@Override
OutputStream createFile(String path) {
def target = new File(root, path)
return target.newOutputStream()
}
@Override
void setFileLastUpdatedDate(String path, long date) {
def target = new File(root, path)
target.setLastModified(date)
}
}

View File

@ -1,8 +0,0 @@
package dirsync.model.tree
import groovy.transform.CompileStatic
@CompileStatic
class FileNode<T> extends AbstractFileTreeNode<T> {
long size
}

View File

@ -1,11 +0,0 @@
package dirsync.model.tree
abstract class TreePhysMapper<T> {
abstract InputStream fileContent(T file)
abstract void createDirectory(String dir)
abstract void removeDirectory(String dir)
abstract void removeFile(String path)
abstract OutputStream createFile(String path)
abstract void setFileLastUpdatedDate(String path, long date)
}

View File

@ -1,9 +0,0 @@
package dirsync.model.tree
import groovy.transform.CompileStatic
@CompileStatic
class ZipData {
String zipEntryName
String zipArchiveName
}

View File

@ -1,72 +0,0 @@
package dirsync.model.tree
import dirsync.builder.FileTreeMerger
import dirsync.builder.ZipTreeBuilder
import sun.reflect.generics.reflectiveObjects.NotImplementedException
import java.util.zip.ZipFile
public class ZipTreeMapper extends TreePhysMapper<ZipData> implements Closeable {
Map<String, ZipFile> zipArchives = [:]
void addZipArchive(String zipArchive) {
zipArchives[zipArchive] = new ZipFile(zipArchive)
}
DirectoryNode<ZipData> buildFileTree() {
def root = new DirectoryNode<ZipData>()
zipArchives.each { ze ->
def zipTree = ZipTreeBuilder.buildForZipArchive(ze.key, ze.value)
root = FileTreeMerger.mergeTrees(root, zipTree)
}
return root
}
@Override
void close() throws IOException {
zipArchives.each { ze ->
try { ze.value.close() } catch (Exception ignored) { }
}
}
@Override
InputStream fileContent(ZipData file) {
def archive = zipArchives[file.zipArchiveName]
if (!archive) {
throw new RuntimeException("Archive ${file.zipArchiveName} is not loaded");
}
def zipEntry = archive.getEntry(file.zipEntryName)
if (!zipEntry) {
throw new RuntimeException("File ${file.zipEntryName} not found in archive ${file.zipArchiveName}");
}
return archive.getInputStream(zipEntry)
}
@Override
void createDirectory(String dir) {
throw new NotImplementedException()
}
@Override
void removeDirectory(String dir) {
throw new NotImplementedException()
}
@Override
void removeFile(String path) {
throw new NotImplementedException()
}
@Override
OutputStream createFile(String path) {
throw new NotImplementedException()
}
@Override
void setFileLastUpdatedDate(String path, long date) {
throw new NotImplementedException()
}
}

View File

@ -1,19 +0,0 @@
package gradlecpp
import org.gradle.api.Project
import org.gradle.nativeplatform.NativeBinarySpec
class CppUnitTestExtension {
Project _project
CppUnitTestExtension(Project p) {
_project = p
}
void eachTestExecutable(Closure action) {
_project.binaries.each { NativeBinarySpec bin ->
if (!bin.hasProperty('cppUnitTestsExecutable')) return
action(bin)
}
}
}

View File

@ -1,242 +0,0 @@
package gradlecpp
import gradlecpp.teamcity.TeamCityIntegration
import org.gradle.api.Action
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.internal.project.AbstractProject
import org.gradle.model.internal.core.DirectNodeModelAction
import org.gradle.model.internal.core.ModelActionRole
import org.gradle.model.internal.core.ModelPath
import org.gradle.model.internal.core.ModelReference
import org.gradle.model.internal.core.MutableModelNode
import org.gradle.model.internal.core.rule.describe.ModelRuleDescriptor
import org.gradle.model.internal.core.rule.describe.SimpleModelRuleDescriptor
import org.gradle.model.internal.registry.ModelRegistry
import org.gradle.nativeplatform.NativeBinarySpec
import org.gradle.nativeplatform.NativeLibrarySpec
import org.gradle.nativeplatform.internal.AbstractNativeBinarySpec
import org.doomedsociety.gradlecpp.GradleCppUtils
class CppUnitTestPlugin implements Plugin<Project> {
private static class TestExecStatus {
boolean successful
int exitCode
String output
long durationMsec
String cmdLine
String execDir
}
static void onBinariesCreated(Project p, String desc, Closure action) {
ModelRegistry mr = (p as AbstractProject).getModelRegistry()
def modelPath = ModelPath.path("binaries")
ModelRuleDescriptor ruleDescriptor = new SimpleModelRuleDescriptor(desc);
mr.configure(ModelActionRole.Finalize, DirectNodeModelAction.of(ModelReference.of(modelPath), ruleDescriptor, new Action<MutableModelNode>() {
@Override
void execute(MutableModelNode node) {
action()
}
}))
}
@Override
void apply(Project project) {
project.extensions.create('cppUnitTest', CppUnitTestExtension, project)
onBinariesCreated(project, 'CppUnitTestPlugin::AttachUnitTest', {
processCppUnitTests(project)
})
}
/**
* Attaches test tasks to C/C++ libraries build tasks
*/
static void processCppUnitTests(Project p) {
//println "processCppUnitTests::afterEvaluate on ${p.name}: project type is ${p.projectType}"
p.binaries.all { NativeBinarySpec bin ->
if (!(bin.component instanceof NativeLibrarySpec)) {
return
}
def testComponentName = bin.component.name + '_tests'
Collection<NativeBinarySpec> testCandidates = p.binaries.matching { it.component.name == testComponentName && bin.buildType == it.buildType && bin.flavor == it.flavor }
if (testCandidates.size() > 1) {
throw new GradleException("Found >1 test candidates for library ${bin.component.name} in project ${p}: ${testCandidates}")
} else if (!testCandidates.empty) {
def testBinary = testCandidates.first()
GradleCppUtils.onTasksCreated(p, 'CppUnitTestPlugin::AttachUnitTestTask', {
attachTestTaskToCppLibrary(bin, testBinary)
})
String testTaskName = bin.namingScheme.getTaskName('unitTest')
bin.ext.cppUnitTestTask = testTaskName
} else {
throw new GradleException("No tests found for library ${bin.component.name} in project ${p}")
}
}
}
static TestExecStatus runTestExecutable(NativeBinarySpec testSubject, String executable, List<String> params, String phase, int timeout) {
def execFile = new File(executable)
def outDir = new File(testSubject.buildTask.project.buildDir, "tests/${testSubject.name}/run")
outDir.mkdirs()
def outPath = new File(outDir, "${phase}.log")
def cmdParams = [];
cmdParams << execFile.absolutePath
cmdParams.addAll(params)
def execDir = execFile.parentFile
def pb = new ProcessBuilder(cmdParams).redirectErrorStream(true).directory(execDir)
if (!GradleCppUtils.windows) {
pb.environment().put('LD_LIBRARY_PATH', '.')
}
def sout = new StringBuffer()
long startTime = System.currentTimeMillis()
def p = pb.start()
p.consumeProcessOutput(sout, sout)
p.waitForOrKill(timeout * 1000)
long endTime = System.currentTimeMillis()
int exitVal = p.exitValue()
outPath.withWriter('UTF-8') { writer ->
writer.write(sout.toString())
}
return new TestExecStatus(
exitCode: exitVal,
successful: (exitVal == 0),
output: sout.toString(),
durationMsec: endTime - startTime,
cmdLine: cmdParams.join(' '),
execDir: execDir.absolutePath
)
}
static void dumpTestExecStatus(TestExecStatus stat) {
if (!stat) {
println "Execution of test executable failed"
}
println "Test executable command: ${stat.cmdLine}"
println "Test executable run directury: ${stat.execDir}"
println "Test executable exit code: ${stat.exitCode}"
println "Test executable output BEGIN"
println stat.output
println "Test executable output END"
}
static void attachTestTaskToCppLibrary(NativeBinarySpec libBin, NativeBinarySpec testExecBin) {
Project p = libBin.buildTask.project
def libBinImpl = libBin as AbstractNativeBinarySpec
def libLinkTask = GradleCppUtils.getLinkTask(libBin)
def testExecLinkTask = GradleCppUtils.getLinkTask(testExecBin)
// collect all output files from library and test executable
def depFiles = []
depFiles.addAll(libLinkTask.outputs.files.files)
depFiles.addAll(testExecLinkTask.outputs.files.files)
//create 'tests' task
def testTaskName = libBinImpl.namingScheme.getTaskName('unitTest')
def testTask = p.task(testTaskName, { Task testTask ->
//output dir
def testResDir = new File(p.buildDir, "tests/${libBin.name}")
//inputs/outputs for up-to-date check
testTask.outputs.dir testResDir
testTask.inputs.files depFiles
//dependencies on library and test executable
testTask.dependsOn libLinkTask
testTask.dependsOn testExecLinkTask
// binary build depends on unit test
libBin.buildTask.dependsOn testTask
// extra project-specific dependencies
def testDepsTask = p.tasks.findByName('testDeps')
if (testDepsTask != null) {
testTask.dependsOn testDepsTask
}
// task actions
testTask.doLast {
//temporary file that store info about all tests (XML)
File allTests = File.createTempFile('j4s-testinfo', 'data')
allTests.deleteOnExit()
//fill file with test info
print "Fetching test info..."
def getTestsStatus = runTestExecutable(libBin, testExecBin.executableFile.absolutePath, ['-writeTestInfo', allTests.absolutePath], '__getTests', 5000)
if (!getTestsStatus.successful) {
println " Failed"
dumpTestExecStatus(getTestsStatus)
throw new GradleException("Unable to fetch test names")
}
println " OK"
getTestsStatus = null // allow GC to collect it
// parse the test info file
def root = new XmlSlurper().parse(allTests)
// run all tests
println "Running ${root.test.size()} tests..."
TeamCityIntegration.suiteStarted("unitTests.${libBin.name}")
int failCount = 0;
root.test.list().each { testInfo ->
def testName = '' + testInfo.@name.text()
def testGroup = '' + testInfo.@group.text()
def testTimeout = ('' + testInfo.@timeout.text()) as int
if (!TeamCityIntegration.writeOutput) {
print " ${testGroup}-${testName}..."
System.out.flush()
}
TeamCityIntegration.testStarted("${testGroup}-${testName}")
def testExecStatus = runTestExecutable(libBin, testExecBin.executableFile.absolutePath, ['-runTest', testGroup, testName], "${testGroup}-${testName}", testTimeout)
if (!testExecStatus.successful) {
if (!TeamCityIntegration.writeOutput) {
println " Failed"
}
TeamCityIntegration.testFailed("${testGroup}-${testName}", "test executable return code is ${testExecStatus.exitCode}", "test executable return code is ${testExecStatus.exitCode}")
dumpTestExecStatus(testExecStatus)
failCount++
} else {
if (!TeamCityIntegration.writeOutput) {
println " OK"
}
}
TeamCityIntegration.testStdOut("${testGroup}-${testName}", testExecStatus.output)
TeamCityIntegration.testFinished("${testGroup}-${testName}", testExecStatus.durationMsec)
}
TeamCityIntegration.suiteFinished("unitTests.${libBin.name}")
if (failCount) {
throw new GradleException("CPP unit tests: ${failCount} tests failed");
}
}
})
}
}

View File

@ -1,17 +0,0 @@
package gradlecpp
import org.gradle.api.Plugin
import org.gradle.api.Project
class RegamedllPlayTestPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.configurations {
regamedll_playtest_image
}
project.dependencies {
regamedll_playtest_image 'regamedll.testimg:testimg:2.0'
}
}
}

View File

@ -1,86 +0,0 @@
package gradlecpp
import gradlecpp.teamcity.TeamCityIntegration
import org.apache.commons.lang.SystemUtils
import org.gradle.api.DefaultTask
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.TaskAction
import org.gradle.nativeplatform.NativeBinarySpec
import regamedll.testdemo.RegamedllDemoRunner
import regamedll.testdemo.RegamedllTestParser
class RegamedllPlayTestTask extends DefaultTask {
def FileCollection testDemos
def Closure postExtractAction
def File regamedllImageRoot
def File regamedllTestLogs
def NativeBinarySpec testFor
@TaskAction
def doPlay() {
if (!SystemUtils.IS_OS_WINDOWS) {
return
}
if (!testDemos) {
println 'RegamedllPlayTestTask: no demos attached to the testDemos property'
}
regamedllImageRoot.mkdirs()
regamedllTestLogs.mkdirs()
def demoRunner = new RegamedllDemoRunner(this.project.configurations.regamedll_playtest_image.getFiles(), regamedllImageRoot, postExtractAction)
println "Preparing engine..."
demoRunner.prepareEngine()
println "Running ${testDemos.getFiles().size()} ReGameDLL_CS test demos..."
TeamCityIntegration.suiteStarted("regamedllDemo.${testFor.name}")
int failCount = 0;
testDemos.getFiles().each { f ->
demoRunner.prepareEngine();
def testInfo = RegamedllTestParser.parseTestInfo(f)
TeamCityIntegration.testStarted(testInfo.testName)
if (!TeamCityIntegration.writeOutput) {
println "Running ReGameDLL_CS test demo ${testInfo.testName} "
System.out.flush()
}
println "Preparing files for test demo ${testInfo.testName} "
demoRunner.prepareDemo(f)
def testRes = demoRunner.runTest(testInfo, regamedllTestLogs)
if (testRes.success) {
if (!TeamCityIntegration.writeOutput) {
println ' OK'
}
} else {
TeamCityIntegration.testFailed(testInfo.testName, "Exit code: ${testRes.returnCode}", "Exit code: ${testRes.returnCode}")
if (!TeamCityIntegration.writeOutput) {
println ' Failed'
println "ReGameDLL_CS testdemo ${testInfo.testName} playback failed. Exit status is ${testRes.returnCode}."
println "Dumping console output:"
println testRes.hldsConsoleOutput
}
failCount++
}
TeamCityIntegration.testStdOut(testInfo.testName, testRes.hldsConsoleOutput)
TeamCityIntegration.testFinished(testInfo.testName, testRes.duration)
}
TeamCityIntegration.suiteFinished("regamedllDemo.${testFor.name}")
if (failCount) {
throw new RuntimeException("ReGameDLL_CS testdemos: failed ${failCount} tests")
}
}
}

View File

@ -1,38 +0,0 @@
package gradlecpp
import org.apache.velocity.Template
import org.apache.velocity.VelocityContext
import org.apache.velocity.app.Velocity
import org.joda.time.format.DateTimeFormat
class VelocityUtils {
static {
Properties p = new Properties();
p.setProperty("resource.loader", "class");
p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
p.setProperty("class.resource.loader.path", "");
p.setProperty("input.encoding", "UTF-8");
p.setProperty("output.encoding", "UTF-8");
Velocity.init(p);
}
static String renderTemplate(File tplFile, Map<String, ? extends Object> ctx) {
Template tpl = Velocity.getTemplate(tplFile.absolutePath)
if (!tpl) {
throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found")
}
def velocityContext = new VelocityContext(ctx)
velocityContext.put("_DateTimeFormat", DateTimeFormat)
def sw = new StringWriter()
tpl.merge(velocityContext, sw)
return sw.toString()
}
}

View File

@ -1,84 +0,0 @@
package gradlecpp.teamcity
import groovy.transform.CompileStatic
class TeamCityIntegration {
static final String flowId = System.getenv('TEAMCITY_PROCESS_FLOW_ID')
static final boolean underTeamcity = System.getenv('TEAMCITY_PROJECT_NAME')
static boolean writeOutput = underTeamcity
@CompileStatic
private static String escape(String s) {
StringBuilder sb = new StringBuilder((int)(s.length() * 1.2));
for (char c in s.chars) {
switch (c) {
case '\n': sb.append('|n'); break;
case '\r': sb.append('|r'); break;
case '\'': sb.append('|\''); break;
case '|': sb.append('||'); break;
case ']': sb.append('|]'); break;
default: sb.append(c);
}
}
return sb.toString()
}
@CompileStatic
static void writeMessage(String name, Map params) {
if (!writeOutput) return
StringBuilder sb = new StringBuilder()
sb.append('##teamcity[').append(name)
params.each { e ->
if (e.value != null) {
sb.append(' ').append('' + e.key).append('=\'').append(escape('' + e.value)).append('\'')
}
}
sb.append(']')
println sb.toString()
}
static void suiteStarted(String suiteName) {
writeMessage('testSuiteStarted', [name: suiteName, flowId: flowId ?: null])
}
static void suiteFinished(String suiteName) {
writeMessage('testSuiteFinished', [name: suiteName, flowId: flowId ?: null])
}
static void testStarted(String testName) {
writeMessage('testStarted', [name: testName, flowId: flowId ?: null])
}
static void testStdOut(String testName, String output) {
writeMessage('testStdOut', [name: testName, out: output, flowId: flowId ?: null])
}
static void testFinished(String testName, long durationMs) {
writeMessage('testFinished', [
name: testName,
flowId: flowId ?: null,
duration: (durationMs >= 0) ? durationMs : null
])
}
static void testFailed(String testName, String message, String details) {
writeMessage('testFailed', [
name: testName,
flowId: flowId ?: null,
message: message,
details: details
])
}
static void testIgnored(String testName, String message) {
writeMessage('testIgnored', [
name: testName,
flowId: flowId ?: null,
message: message,
])
}
}

View File

@ -1,106 +0,0 @@
package regamedll.testdemo
import dirsync.builder.FileSystemTreeBuilder
import dirsync.merger.FileTreeComparator
import dirsync.merger.FileTreeDiffApplier
import dirsync.model.tree.DirectoryNode
import dirsync.model.tree.FSMapper
import dirsync.model.tree.ZipData
import dirsync.model.tree.ZipTreeMapper
import org.apache.ant.compress.taskdefs.Unzip
import org.apache.tools.ant.types.PatternSet;
class RegamedllDemoRunner {
ZipTreeMapper regamedllImage = new ZipTreeMapper()
File rootDir
DirectoryNode<ZipData> engineImageTree
Closure postExtract
static class TestResult {
boolean success
int returnCode
String hldsConsoleOutput
long duration
}
RegamedllDemoRunner(Collection<File> engineImageZips, File rootDir, Closure postExtract) {
this.rootDir = rootDir
engineImageZips.each { f ->
regamedllImage.addZipArchive(f.absolutePath)
}
engineImageTree = regamedllImage.buildFileTree()
this.postExtract = postExtract
}
void prepareDemo(File demoArchive) {
if (demoArchive == null) {
throw new RuntimeException("ReGameDLL_CS testdemos: file is null")
}
PatternSet patt = new PatternSet();
patt.setExcludes("**/*.bin");
patt.setExcludes("**/*.xml");
//patt.setIncludes("**/cstrike/*");
//patt.setIncludes("**/czero/*");
//patt.setIncludes("**/valve/*");
Unzip unzipper = new Unzip();
unzipper.setDest( rootDir ); // directory unzipped
unzipper.setSrc( demoArchive ); // zip file
unzipper.addPatternset( patt );
unzipper.execute();
}
void prepareEngine() {
def existingTree = FileSystemTreeBuilder.buildFileSystemTree(rootDir)
def cmds = FileTreeComparator.mergeTrees(engineImageTree, existingTree)
FSMapper fsMapper = new FSMapper(rootDir)
FileTreeDiffApplier.applyDiffs(cmds, regamedllImage, fsMapper)
if (postExtract != null) {
postExtract.run()
}
}
TestResult runTest(RegamedllTestInfo info, File testLogDir) {
long startTime = System.currentTimeMillis()
//prepareEngine()
def outPath = new File(testLogDir, "${info.testName}_run.log")
def cmdParams = []
cmdParams << new File(rootDir, 'hlds.exe').absolutePath
cmdParams.addAll(info.hldsArgs)
if (info.regamedllExtraArgs) {
cmdParams.addAll(info.regamedllExtraArgs)
}
cmdParams << '--rehlds-test-play' << info.testBinFile.absolutePath
def pb = new ProcessBuilder(cmdParams).redirectErrorStream(true).directory(rootDir)
def sout = new StringBuffer()
def p = pb.start()
p.consumeProcessOutput(sout, sout)
p.waitForOrKill(info.timeoutSeconds * 1000)
int exitVal = p.exitValue()
outPath.withWriter('UTF-8') { writer ->
writer.write(sout.toString())
}
long endTime = System.currentTimeMillis()
return new TestResult(
success: (exitVal == 777),
returnCode: exitVal,
hldsConsoleOutput: sout.toString(),
duration: endTime - startTime
)
}
}

View File

@ -1,9 +0,0 @@
package regamedll.testdemo
class RegamedllTestInfo {
String testName
List<String> hldsArgs
String regamedllExtraArgs
int timeoutSeconds
File testBinFile
}

View File

@ -1,63 +0,0 @@
package regamedll.testdemo
import groovy.util.slurpersupport.GPathResult
import org.apache.commons.io.IOUtils
import java.util.zip.ZipFile
class RegamedllTestParser {
static final String REGAMEDLL_TEST_METAINFO_FILE = 'regamedll_test_metainfo.xml'
static RegamedllTestInfo parseTestInfo(File testArchive) {
def zf = new ZipFile(testArchive);
try {
def metaInfoEntry = zf.getEntry(REGAMEDLL_TEST_METAINFO_FILE)
if (metaInfoEntry == null) {
throw new RuntimeException("Unable to open ${REGAMEDLL_TEST_METAINFO_FILE} in ${testArchive.absolutePath}")
}
GPathResult metaInfo = null
zf.getInputStream(metaInfoEntry).withStream { InputStream ins ->
metaInfo = new XmlSlurper().parse(ins)
}
RegamedllTestInfo testInfo = new RegamedllTestInfo(
testName: metaInfo.name.text(),
hldsArgs: metaInfo.runArgs.arg.list().collect { it.text().trim() },
timeoutSeconds: metaInfo.timeout.text() as int
)
//validate testInfo
if (!testInfo.testName) {
throw new RuntimeException("Error parsing ${testArchive.absolutePath}: test name is not specified")
}
if (!testInfo.hldsArgs) {
throw new RuntimeException("Error parsing ${testArchive.absolutePath}: run arguments are not specified")
}
if (testInfo.timeoutSeconds <= 0) {
throw new RuntimeException("Error parsing ${testArchive.absolutePath}: bad timeout")
}
def testBinName = testInfo.testName + '.bin'
def testBinEntry = zf.getEntry(testBinName)
if (testBinEntry == null) {
throw new RuntimeException("Error parsing ${testArchive.absolutePath}: test binary ${testBinName} not found inside archive")
}
testInfo.testBinFile = File.createTempFile(testBinName, 'regamedll')
testInfo.testBinFile.deleteOnExit()
zf.getInputStream(testBinEntry).withStream { InputStream ins ->
testInfo.testBinFile.withOutputStream { OutputStream os ->
IOUtils.copy(ins, os)
}
}
return testInfo
} finally {
try { zf.close() } catch (Exception ignored) { }
}
}
}

View File

@ -1,16 +0,0 @@
package versioning
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.joda.time.DateTime
@CompileStatic @TypeChecked
class GitInfo {
boolean localChanges
DateTime commitDate
String branch
String tag
String commitSHA
String commitURL
Integer commitCount
}

View File

@ -1,140 +0,0 @@
package versioning
import java.util.Set;
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.StoredConfig
import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.revwalk.RevWalk
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
@CompileStatic @TypeChecked
class GitVersioner {
static GitInfo versionForDir(String dir) {
versionForDir(new File(dir))
}
static int getCountCommit(Repository repo) {
Iterable<RevCommit> commits = Git.wrap(repo).log().call()
int count = 0;
commits.each {
count++;
}
return count;
}
static String prepareUrlToCommits(String url) {
if (url == null) {
// default remote url
return "https://github.com/s1lentq/ReGameDLL_CS/commit/";
}
StringBuilder sb = new StringBuilder();
String childPath;
int pos = url.indexOf('@');
if (pos != -1) {
childPath = url.substring(pos + 1, url.lastIndexOf('.git')).replace(':', '/');
sb.append('https://');
} else {
pos = url.lastIndexOf('.git');
childPath = (pos == -1) ? url : url.substring(0, pos);
}
// support for different links to history of commits
if (url.indexOf('bitbucket.org') != -1) {
sb.append(childPath).append('/commits/');
} else {
sb.append(childPath).append('/commit/');
}
return sb.toString();
}
// check uncommited changes
static boolean getUncommittedChanges(Repository repo) {
Git git = new Git(repo);
Status status = git.status().setIgnoreSubmodules(SubmoduleWalk.IgnoreSubmoduleMode.ALL).call();
Set<String> uncommittedChanges = status.getUncommittedChanges();
System.err.println ' UncommittedChanges: ' + uncommittedChanges
if (!uncommittedChanges.isEmpty()) {
System.err.println 'getUncommittedChanges details'
System.err.println ' Added: ' + status.getAdded()
System.err.println ' Changed: ' + status.getChanged()
System.err.println ' Removed: ' + status.getRemoved()
System.err.println ' Missing: ' + status.getMissing()
System.err.println ' Modified: ' + status.getModified()
System.err.println ' Conflicting: ' + status.getConflicting()
System.err.println ' ConflictingStageState: ' + status.getConflictingStageState()
System.err.println ' IgnoredNotInIndex: ' + status.getIgnoredNotInIndex()
System.err.println ' Untracked: ' + status.getUntracked()
System.err.println ' UntrackedFolders: ' + status.getUntrackedFolders()
return true;
}
return false;
}
static GitInfo versionForDir(File dir) {
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repo = builder.setWorkTree(dir)
.findGitDir()
.build()
ObjectId head = repo.resolve('HEAD');
if (!head) {
return null
}
final StoredConfig cfg = repo.getConfig();
def commit = new RevWalk(repo).parseCommit(head);
if (!commit) {
throw new RuntimeException("Can't find last commit.");
}
def localChanges = getUncommittedChanges(repo);
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC);
if (localChanges) {
commitDate = new DateTime();
}
def branch = repo.getBranch();
String url = null;
String remote_name = cfg.getString("branch", branch, "remote");
if (remote_name == null) {
for (String remotes : cfg.getSubsections("remote")) {
if (url != null) {
println 'Found a second remote: (' + remotes + '), url: (' + cfg.getString("remote", remotes, "url") + ')'
continue;
}
url = cfg.getString("remote", remotes, "url");
}
} else {
url = cfg.getString("remote", remote_name, "url");
}
String commitURL = prepareUrlToCommits(url);
String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key
String commitSHA = commit.getId().abbreviate(7).name();
return new GitInfo(
localChanges: localChanges,
commitDate: commitDate,
branch: branch,
tag: tag,
commitSHA: commitSHA,
commitURL: commitURL,
commitCount: getCountCommit(repo)
)
}
}

View File

@ -1,58 +0,0 @@
package versioning
import groovy.transform.CompileStatic
import groovy.transform.ToString
import groovy.transform.TypeChecked
import org.joda.time.format.DateTimeFormat
import org.joda.time.DateTime
@CompileStatic @TypeChecked
@ToString(includeNames = true)
class RegamedllVersionInfo {
Integer majorVersion
Integer minorVersion
Integer maintenanceVersion
String suffix
boolean localChanges
DateTime commitDate
String commitSHA
String commitURL
Integer commitCount
String asMavenVersion(boolean extra = true) {
StringBuilder sb = new StringBuilder()
sb.append(majorVersion).append('.' + minorVersion);
if (maintenanceVersion != null) {
sb.append('.' + maintenanceVersion);
}
if (commitCount != null) {
sb.append('.' + commitCount)
}
if (extra && suffix) {
sb.append('-' + suffix)
}
// do mark for this build like a modified version
if (extra && localChanges) {
sb.append('+m');
}
return sb.toString()
}
String asCommitDate(String pattern = null) {
if (pattern == null) {
pattern = "MMM d yyyy";
if (commitDate.getDayOfMonth() >= 10) {
pattern = "MMM d yyyy";
}
}
return DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH).print(commitDate);
}
String asCommitTime() {
return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate);
}
}

View File

@ -1,44 +0,0 @@
package dirsync.builder
import org.junit.Test
import java.io.File
import dirsync.builder.ZipTreeBuilder
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream;
import static org.junit.Assert.*;
class ZipTreeBuilderTest {
@Test
void test1() {
File zipFile = File.createTempFile('ZipTreeBuilderTest', 'zip')
zipFile.deleteOnExit()
new ZipOutputStream(zipFile.newDataOutputStream()).withStream { ZipOutputStream zos ->
zos.putNextEntry(new ZipEntry('aRootFile1.txt'))
zos.write(65) //'A'
zos.putNextEntry(new ZipEntry('dir1/'))
zos.putNextEntry(new ZipEntry('dir1/dir2/'))
zos.putNextEntry(new ZipEntry('dir1/dir2/d1d2f1.txt'))
zos.write(65); zos.write(66) //'AB'
zos.putNextEntry(new ZipEntry('dir1/d1f1.txt'))
zos.write(65); zos.write(66); zos.write(67) //'ABC'
zos.putNextEntry(new ZipEntry('zRootFile2.txt'))
zos.write(65); zos.write(66); zos.write(67); zos.write(68) //'ABCD'
}
ZipFile zf = new ZipFile(zipFile.absolutePath)
def tree = ZipTreeBuilder.buildForZipArchive(zipFile.absolutePath, zf)
assert tree.childNodes.size() == 3
}
}

View File

@ -1,62 +0,0 @@
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)
ToolchainConfigUtils.apply(project, cfg, b)
}
model {
buildTypes {
debug
release
}
platforms {
x86 {
architecture "x86"
}
}
toolChains {
visualCpp(VisualCpp)
if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
icc(Icc)
}
}
components {
cppunitlite(NativeLibrarySpec) {
targetPlatform 'x86'
sources {
cppul_main(CppSourceSet) {
source {
srcDir "src"
include "**/*.cpp"
}
exportedHeaders {
srcDir "include"
}
}
}
binaries.all { NativeBinarySpec b ->
project.setupToolchain(b)
}
}
}
}

View File

@ -7,8 +7,8 @@ public:
static void StringEquals(std::string message, std::string expected, std::string actual, const char* fileName, long lineNumber);
static void StringEquals(std::string message, const char* expected, const char* actual, const char* fileName, long lineNumber);
static void ConditionFailed(std::string message, std::string condition, const char* fileName, long lineNumber);
static void ConditionFailed(std::string message, std::string condition, const char* fileName, long lineNumber, bool onlyWarning = false);
static void LongEquals(std::string message, long expected, long actual, const char* fileName, long lineNumber);

View File

@ -6,12 +6,13 @@
class TestFailException : public std::exception {
public:
TestFailException(std::string message, std::string fileName, long lineNumber) {
TestFailException(std::string message, std::string fileName, long lineNumber, bool onlyWarning = false) {
std::stringstream ss;
ss << message << " at " << fileName << " line " << lineNumber;
this->message = ss.str();
this->fileName = fileName;
this->lineNumber = lineNumber;
this->warning = onlyWarning;
}
virtual ~TestFailException() throw() {
@ -21,6 +22,7 @@ public:
std::string message;
std::string fileName;
long lineNumber;
bool warning;
virtual const char * what() const throw() {
return message.c_str();
@ -35,6 +37,7 @@ public:
this->message = e.message;
this->fileName = e.fileName;
this->lineNumber = e.lineNumber;
this->warning = e.warning;
}
Failure (std::string message, std::string testName) {
@ -48,6 +51,7 @@ public:
std::string message;
std::string fileName;
long lineNumber;
bool warning;
};

View File

@ -1,6 +1,6 @@
#pragma once
class GradleAdapter {
class MainAdapter {
public:
int writeAllTestsInfoToFile(const char* fname);
int runTest(const char* groupName, const char* testName);

View File

@ -20,7 +20,7 @@ public:
void setNext(Test *test);
Test *getNext () const;
void run(TestResult& result);
const char* getName() {
return name_.c_str();
}
@ -28,7 +28,7 @@ public:
const char* getGroup() {
return group_.c_str();
}
int getTimeout() {
return timeout_;
}
@ -47,7 +47,7 @@ protected:
{ public: testGroup##testName##Test () : Test (#testName , #testGroup , testTimeout) {} \
void runInternal (); } \
testGroup##testName##Instance; \
void testGroup##testName##Test::runInternal()
void testGroup##testName##Test::runInternal()
@ -55,6 +55,9 @@ protected:
} \
}
#define CHECK_WARNING_OUT(msg, condition) { if (!(condition)) { Assertions::ConditionFailed(msg,#condition, __FILE__, __LINE__, true); return; \
} \
}
#define ZSTR_EQUAL(msg,expected,actual) { \
Assertions::StringEquals((msg), (expected), (actual), __FILE__, __LINE__); \

View File

@ -13,6 +13,10 @@ public:
int getFailureCount() {
return failureCount;
}
int getWarningCount() {
return warningCount;
}
private:
int failureCount;
int warningCount;
};

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -13,7 +13,7 @@
<ItemGroup>
<ClInclude Include="..\include\cppunitlite\Assertions.h" />
<ClInclude Include="..\include\cppunitlite\Failure.h" />
<ClInclude Include="..\include\cppunitlite\GradleAdapter.h" />
<ClInclude Include="..\include\cppunitlite\MainAdapter.h" />
<ClInclude Include="..\include\cppunitlite\Test.h" />
<ClInclude Include="..\include\cppunitlite\TestHarness.h" />
<ClInclude Include="..\include\cppunitlite\TestRegistry.h" />
@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\Assertions.cpp" />
<ClCompile Include="..\src\GradleAdapter.cpp" />
<ClCompile Include="..\src\MainAdapter.cpp" />
<ClCompile Include="..\src\Test.cpp" />
<ClCompile Include="..\src\TestRegistry.cpp" />
<ClCompile Include="..\src\TestResult.cpp" />
@ -30,7 +30,7 @@
<ProjectGuid>{CEB94F7C-E459-4673-AABB-36E2074396C0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>cppunitlite</RootNamespace>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -42,15 +42,6 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Nav|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
@ -78,7 +69,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(ProjectDir)..\include\</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>

View File

@ -27,7 +27,7 @@
<ClInclude Include="..\include\cppunitlite\TestResult.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\include\cppunitlite\GradleAdapter.h">
<ClInclude Include="..\include\cppunitlite\MainAdapter.h">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
@ -44,7 +44,7 @@
<ClCompile Include="..\src\TestResult.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\GradleAdapter.cpp">
<ClCompile Include="..\src\MainAdapter.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>

View File

@ -27,13 +27,13 @@ void Assertions::StringEquals(std::string message, const char *expected, const c
}
}
void Assertions::ConditionFailed(std::string message, std::string condition, const char *fileName, long lineNumber) {
void Assertions::ConditionFailed(std::string message, std::string condition, const char *fileName, long lineNumber, bool onlyWarning) {
std::stringstream ss;
ss << message << " (condition failed: " << condition << ")";
throw TestFailException(ss.str(), std::string(fileName), lineNumber);
throw TestFailException(ss.str(), std::string(fileName), lineNumber, onlyWarning);
}
void Assertions::LongEquals(std::string message, long expected, long actual, const char *fileName, long lineNumber) {
void Assertions::LongEquals(std::string message, long expected, long actual, const char* fileName, long lineNumber) {
if (expected != actual) {
std::stringstream ss;
ss << message << " (expected '" << expected << "', got '" << actual << "')";
@ -41,7 +41,7 @@ void Assertions::LongEquals(std::string message, long expected, long actual, con
}
}
void Assertions::UInt32Equals(std::string message, unsigned int expected, unsigned int actual, const char *fileName, long lineNumber) {
void Assertions::UInt32Equals(std::string message, unsigned int expected, unsigned int actual, const char* fileName, long lineNumber) {
if (expected != actual) {
std::stringstream ss;
ss << message << " (expected '" << expected << "', got '" << actual << "')";
@ -49,7 +49,7 @@ void Assertions::UInt32Equals(std::string message, unsigned int expected, unsign
}
}
void Assertions::CharEquals(std::string message, char expected, char actual, const char *fileName, long lineNumber) {
void Assertions::CharEquals(std::string message, char expected, char actual, const char* fileName, long lineNumber) {
if (expected != actual) {
std::stringstream ss;
ss << message << " (expected '" << expected << "', got '" << actual << "')";
@ -57,15 +57,15 @@ void Assertions::CharEquals(std::string message, char expected, char actual, con
}
}
void Assertions::DoubleEquals(std::string message, double expected, double actual, double epsilon, const char *fileName, long lineNumber) {
if (std::abs(expected - actual) > epsilon) {
void Assertions::DoubleEquals(std::string message, double expected, double actual, double epsilon, const char* fileName, long lineNumber) {
if (std::fabs(expected - actual) > epsilon) {
std::stringstream ss;
ss << message << " (expected '" << expected << "', got '" << actual << "')";
throw TestFailException(ss.str(), std::string(fileName), lineNumber);
}
}
void Assertions::MemoryEquals(std::string message, void *expected, void *actual, int size, const char *fileName, long lineNumber) {
void Assertions::MemoryEquals(std::string message, void* expected, void* actual, int size, const char* fileName, long lineNumber) {
if (memcmp(expected, actual, size)) {
std::stringstream ss;
ss << message << " (expected '";

View File

@ -2,11 +2,11 @@
#include <stdlib.h>
#include <string.h>
#include "cppunitlite/GradleAdapter.h"
#include "cppunitlite/MainAdapter.h"
#include "cppunitlite/Test.h"
#include "cppunitlite/TestRegistry.h"
int GradleAdapter::writeAllTestsInfoToFile(const char *fname) {
int MainAdapter::writeAllTestsInfoToFile(const char *fname) {
FILE *outFile = fopen(fname, "w");
if (!outFile) {
return 1;
@ -32,7 +32,7 @@ int GradleAdapter::writeAllTestsInfoToFile(const char *fname) {
return 0;
}
int GradleAdapter::runTest(const char *groupName, const char *testName) {
int MainAdapter::runTest(const char *groupName, const char *testName) {
Test *curTest = TestRegistry::getFirstTest();
while (curTest) {
if (!strcmp(groupName, curTest->getGroup()) && !strcmp(testName, curTest->getName())) {
@ -52,14 +52,18 @@ int GradleAdapter::runTest(const char *groupName, const char *testName) {
if (result.getFailureCount()) {
return 1;
}
else if (result.getWarningCount()) {
return 3;
}
else {
return 0;
}
}
int GradleAdapter::runGroup(const char *groupName) {
int MainAdapter::runGroup(const char *groupName) {
Test *curTest = TestRegistry::getFirstTest();
int ranTests = 0;
int warnTest = 0;
while (curTest) {
if (strcmp(groupName, curTest->getGroup())) {
curTest = curTest->getNext();
@ -74,6 +78,10 @@ int GradleAdapter::runGroup(const char *groupName) {
return 1;
}
if (result.getWarningCount()) {
warnTest++;
}
curTest = curTest->getNext();
}
@ -82,13 +90,19 @@ int GradleAdapter::runGroup(const char *groupName) {
return 2;
}
if (warnTest > 0) {
printf("There were no test failures, but with warnings: %d; Tests executed: %d\n", warnTest, ranTests);
return 3;
}
printf("There were no test failures; Tests executed: %d\n", ranTests);
return 0;
}
int GradleAdapter::runAllTests() {
int MainAdapter::runAllTests() {
Test *curTest = TestRegistry::getFirstTest();
int ranTests = 0;
int warnTest = 0;
while (curTest) {
TestResult result;
curTest->run(result);
@ -98,14 +112,23 @@ int GradleAdapter::runAllTests() {
return 1;
}
if (result.getWarningCount()) {
warnTest++;
}
curTest = curTest->getNext();
}
if (warnTest > 0) {
printf("There were no test failures, but with warnings: %d; Tests executed: %d\n", warnTest, ranTests);
return 3;
}
printf("There were no test failures; Tests executed: %d\n", ranTests);
return 0;
}
int GradleAdapter::testsEntryPoint(int argc, char *argv[]) {
int MainAdapter::testsEntryPoint(int argc, char *argv[]) {
if (argc < 2 || !strcmp(argv[1], "-all")) {
return runAllTests();
}

View File

@ -3,9 +3,10 @@
#include "cppunitlite/Failure.h"
#include <exception>
#include <iostream>
#include <sstream>
Test::Test (const char* testName, const char* testGroup, int timeout)
Test::Test(const char *testName, const char *testGroup, int timeout)
: name_ (testName), group_ (testGroup), timeout_(timeout)
{
next_ = nullptr;
@ -18,15 +19,17 @@ Test *Test::getNext() const
}
void Test::setNext(Test *test)
{
{
next_ = test;
}
void Test::run(TestResult &result) {
void Test::run(TestResult &result)
{
try {
runInternal();
} catch (TestFailException *e) {
result.addFailure(Failure(*e, name_));
std::cout << "Test::run() > " << group_ << "::" << name_ << " Passed" << std::endl;
} catch (TestFailException &e) {
result.addFailure(Failure(e, name_));
} catch (std::exception &e) {
std::stringstream ss;
ss << "unexpected exception " << e.what();

View File

@ -1,50 +1,44 @@
#include "cppunitlite/Test.h"
#include "cppunitlite/TestResult.h"
#include "cppunitlite/TestRegistry.h"
void TestRegistry::addTest (Test *test)
void TestRegistry::addTest(Test *test)
{
instance ().add (test);
instance().add(test);
}
void TestRegistry::runAllTests (TestResult& result)
void TestRegistry::runAllTests(TestResult &result)
{
instance ().run (result);
instance().run(result);
}
Test* TestRegistry::getFirstTest() {
Test *TestRegistry::getFirstTest() {
return instance().tests;
}
TestRegistry& TestRegistry::instance ()
TestRegistry& TestRegistry::instance()
{
static TestRegistry registry;
return registry;
}
void TestRegistry::add (Test *test)
void TestRegistry::add(Test *test)
{
if (tests == 0) {
tests = test;
return;
}
test->setNext (tests);
test->setNext(tests);
tests = test;
}
void TestRegistry::run (TestResult& result)
void TestRegistry::run(TestResult &result)
{
result.testsStarted ();
result.testsStarted();
for (Test *test = tests; test != 0; test = test->getNext ())
test->run (result);
result.testsEnded ();
for (Test *test = tests; test; test = test->getNext())
test->run(result);
result.testsEnded();
}

View File

@ -1,38 +1,48 @@
#include "cppunitlite/TestResult.h"
#include "cppunitlite/Failure.h"
#include <sstream>
#include <iostream>
TestResult::TestResult ()
: failureCount (0)
TestResult::TestResult()
: failureCount(0), warningCount(0)
{
}
void TestResult::testsStarted ()
void TestResult::testsStarted()
{
}
void TestResult::addFailure (const Failure& failure) {
void TestResult::addFailure(const Failure& failure)
{
std::stringstream ss;
ss << "Failure in test '" << failure.testName << "' :" << failure.message;
ss << (failure.warning ? "Warning in test '" : "Failure in test '") << failure.testName << "' :" << failure.message;
std::cout << ss.str() << std::endl;
std::cout.flush();
failureCount++;
if (failure.warning) {
warningCount++;
}
else
failureCount++;
}
void TestResult::testsEnded () {
void TestResult::testsEnded()
{
std::stringstream ss;
if (failureCount > 0) {
ss << "There were " << failureCount << " failures";
} else {
if (warningCount > 0) {
ss << ", and " << warningCount << " warnings";
}
}
else if (warningCount > 0) {
ss << "There were " << warningCount << " warnings";
}
else {
ss << "There were no test failures";
}
std::cout << ss.str() << std::endl;
std::cout.flush();
}

View File

@ -1,19 +0,0 @@
@echo off
if defined VS150COMNTOOLS (
if not exist "%VS150COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS
call "%VS150COMNTOOLS%vcvarsqueryregistry.bat"
goto :run
) else if defined VS140COMNTOOLS (
if not exist "%VS140COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS
call "%VS140COMNTOOLS%vcvarsqueryregistry.bat"
goto :run
)
:NoVS
echo Error: Visual Studio 2015 or 2017 required.
exit /b 1
:run
echo %UniversalCRTSdkDir%
echo %UCRTVersion%

View File

@ -1,3 +0,0 @@
majorVersion=5
minorVersion=20
maintenanceVersion=0

Binary file not shown.

View File

@ -1,6 +0,0 @@
#Sat Jun 06 16:31:05 BRT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

164
gradlew vendored
View File

@ -1,164 +0,0 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored
View File

@ -1,90 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReGameDLL", "..\regamedll\msvc\ReGameDLL.vcxproj", "{70A2B904-B7DB-4C48-8DE0-AF567360D572}"
ProjectSection(ProjectDependencies) = postProject
@ -10,14 +10,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReGameDLL", "..\regamedll\m
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppunitlite", "..\dep\cppunitlite\msvc\cppunitlite.vcxproj", "{CEB94F7C-E459-4673-AABB-36E2074396C0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gradle", "gradle", "{DB570330-2FEE-4C39-971B-340019B6E661}"
ProjectSection(SolutionItems) = preProject
..\build.gradle = ..\build.gradle
..\gradle.properties = ..\gradle.properties
..\settings.gradle = ..\settings.gradle
..\shared.gradle = ..\shared.gradle
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Play|Win32 = Debug Play|Win32
@ -51,4 +43,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E442B676-1D5A-48D0-BFCC-D5D3BAD32ECF}
EndGlobalSection
EndGlobal

View File

@ -1,142 +0,0 @@
import org.doomedsociety.gradlecpp.GradleCppUtils
import org.apache.commons.io.FilenameUtils
void _copyFileToDir(String from, String to) {
if (!project.file(from).exists()) {
println 'WARNING: Could not find: ' + from;
return;
}
if (!project.file(to).exists()) {
project.file(to).mkdirs();
}
def dst = new File(project.file(to), FilenameUtils.getName(from))
GradleCppUtils.copyFile(project.file(from), dst, false)
}
void _copyFile(String from, String to) {
if (!project.file(from).exists()) {
println 'WARNING: Could not find: ' + from;
return;
}
GradleCppUtils.copyFile(project.file(from), project.file(to), false)
}
task publishPrepareFiles {
doLast {
def pubRootDir = project.file('publish/publishRoot')
if (pubRootDir.exists()) {
if (!pubRootDir.deleteDir()) {
throw new RuntimeException("Failed to delete ${pubRootDir}")
}
}
pubRootDir.mkdirs()
project.file('publish/publishRoot/bin/win32/cstrike/dlls').mkdirs()
project.file('publish/publishRoot/bin/linux32/cstrike/dlls').mkdirs()
// bugfixed binaries
_copyFile('publish/releaseRegamedllFixes/mp.dll', 'publish/publishRoot/bin/win32/cstrike/dlls/mp.dll')
_copyFile('publish/releaseRegamedllFixes/cs.so', 'publish/publishRoot/bin/linux32/cstrike/dlls/cs.so')
// copy files from folder dist
copy {
from('dist')
into 'publish/publishRoot/bin/win32/cstrike'
}
copy {
from('dist')
into 'publish/publishRoot/bin/linux32/cstrike'
}
// cssdk
project.file('publish/publishRoot/cssdk').mkdirs()
copy {
from 'regamedll/extra/cssdk'
into 'publish/publishRoot/cssdk'
}
}
}
task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
baseName = "regamedll-dist-${project.version}"
destinationDir file('publish')
from 'publish/publishRoot'
}
publishing {
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.regamedllVersionInfo.commitDate
commitSHA project.ext.regamedllVersionInfo.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'
}
}
*/
}
}
}
}
}
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)
})
}
publishing {
repositories {
maven {
if (project.version.contains('dev')) {
url "http://nexus.rehlds.org/nexus/content/repositories/regamedll-dev/"
} else {
url "http://nexus.rehlds.org/nexus/content/repositories/regamedll-releases/"
}
credentials {
username repoCreds.getProperty('username')
password repoCreds.getProperty('password')
}
}
}
}
task doPublish {
dependsOn 'publishPackage'
if (repoCreds.getProperty('username') && repoCreds.getProperty('password')) {
dependsOn 'publish'
}
}

View File

@ -1,444 +0,0 @@
import gradlecpp.RegamedllPlayTestPlugin
import gradlecpp.RegamedllPlayTestTask
import gradlecpp.VelocityUtils
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
import org.apache.commons.compress.archivers.ArchiveInputStream
apply plugin: 'cpp'
apply plugin: IccCompilerPlugin
apply plugin: GccCompilerPlugin
apply plugin: RegamedllPlayTestPlugin
apply plugin: gradlecpp.CppUnitTestPlugin
repositories {
maven {
url 'http://nexus.rehlds.org/nexus/content/repositories/regamedll-releases/'
}
}
configurations {
regamedll_tests
}
dependencies {
regamedll_tests 'regamedll.testdemos:cstrike-basic:1.0'
}
project.ext.dep_cppunitlite = project(':dep/cppunitlite')
void createIntergrationTestTask(NativeBinarySpec b) {
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
// inputs/outputs for up-to-date check
inputs.files testDemos.files
outputs.dir regamedllTestLogs
// dependencies on test executable
if (unitTestTask) {
dependsOn unitTestTask
}
postExtractAction {
def binaryOutFile = GradleCppUtils.getBinaryOutputFile(b)
def binaryOutDir = new File(project.projectDir, '/_regamedllTestImg/cstrike/dlls')
GradleCppUtils.copyFile(binaryOutFile, new File(binaryOutDir, binaryOutFile.name), true)
}
}
b.buildTask.dependsOn demoItgTestTask
}
void postEvaluate(NativeBinarySpec b) {
// attach generateAppVersion task to all 'compile source' tasks
GradleCppUtils.getCompileTasks(b).each { Task t ->
t.dependsOn project.generateAppVersion
}
createIntergrationTestTask(b)
}
void setupToolchain(NativeBinarySpec b)
{
boolean useGcc = project.hasProperty("useGcc")
boolean useClang = project.hasProperty("useClang")
boolean unitTestExecutable = b.component.name.endsWith('_tests')
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
ToolchainConfig cfg = rootProject.createToolchainConfig(b)
cfg.projectInclude(project, '', '/engine', '/common', '/dlls', '/game_shared', '/pm_shared', '/regamedll', '/public', '/public/regamedll')
if (unitTestExecutable)
{
cfg.projectInclude(dep_cppunitlite, '/include')
b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true)
}
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS', 'USE_QSTRING'
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
}
else {
cfg.compilerOptions.args '/Oi', '/GF', '/GS', '/GR'
}
cfg.projectLibpath(project, '/lib')
cfg.extraLibs 'libacof32.lib'
}
else if (cfg instanceof GccToolchainConfig)
{
if (!useGcc && !useClang)
{
cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
enabled: true,
pchSourceSet: 'regamedll_pch'
);
}
cfg.compilerOptions.languageStandard = 'c++14'
cfg.defines([
'_stricmp': 'strcasecmp',
'_strnicmp': 'strncasecmp',
'_strdup': 'strdup',
'_unlink': 'unlink',
'_vsnprintf': 'vsnprintf',
'_write' : 'write',
'_close' : 'close',
'_vsnwprintf' : 'vswprintf',
'_access' : 'access'
])
if (useGcc || useClang) {
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
// As new processors are deployed in the marketplace, the behavior of this option will change.
cfg.compilerOptions.args '-mtune=generic', '-msse3', '-Wno-write-strings', '-Wno-invalid-offsetof', '-fpermissive', '-Wno-switch', '-Wno-unused-value', '-Wno-enum-compare'
if (useGcc) {
cfg.compilerOptions.args '-fno-devirtualize'
}
else {
cfg.compilerOptions.args '-fno-strict-vtable-pointers', '-Wno-overloaded-virtual'
}
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp'
// Not use c++ class hierarchy for analyze and resolve C++ virtual function calls at compile time.
//
// Example issue:
// Expected: FF .. call dword ptr + offset, pEntity->Spawn();
// Got: E8 .. call CBaseEntity::Spawn();
cfg.linkerOptions.args '-qno-opt-class-analysis'
}
if (cfg.linkerOptions.staticLibStdCpp) {
cfg.singleDefines 'BUILD_STATIC_LIBSTDC'
}
cfg.compilerOptions.args '-g0', '-fno-exceptions'
cfg.projectLibpath(project, '/lib/linux32')
cfg.extraLibs 'dl', 'm', 'aelf32'
}
if (GradleCppUtils.windows && !unitTestExecutable) {
cfg.linkerOptions.definitionFile = "${projectDir}\\msvc\\mp.def";
}
if (unitTestExecutable) {
cfg.singleDefines 'REGAMEDLL_UNIT_TESTS'
}
if (regamedllFixes) {
cfg.singleDefines 'REGAMEDLL_FIXES', 'BUILD_LATEST', 'BUILD_LATEST_FIXES', 'REGAMEDLL_CHECKS', 'REGAMEDLL_ADD', 'UNICODE_FIXES', 'NDEBUG'
} else {
cfg.singleDefines 'PLAY_GAMEDLL'
}
ToolchainConfigUtils.apply(project, cfg, b)
GradleCppUtils.onTasksCreated(project, 'postEvaluate', {
postEvaluate(b)
})
}
class RegamedllSrc {
static void regamedll_src(def h) {
h.engine_src(CppSourceSet) {
source {
srcDir "engine"
include "unicode_strtools.cpp"
}
}
h.shared_src(CppSourceSet) {
source {
srcDirs "game_shared", "pm_shared", "regamedll", "public", "version"
include "**/*.cpp"
exclude "precompiled.cpp"
exclude "tier0/dbg.cpp", "utlsymbol.cpp", "utlbuffer.cpp"
if (GradleCppUtils.windows)
{
exclude "tier0/platform_linux.cpp"
}
else
{
exclude "tier0/platform_win32.cpp"
exclude "classes_dummy.cpp"
}
}
}
h.gamedll_src(CppSourceSet) {
source {
srcDirs "dlls", "dlls/API", "dlls/addons"
include "**/*.cpp"
}
}
}
static void regamedll_pch(def h) {
h.regamedll_pch(CppSourceSet) {
source {
srcDir "regamedll"
include "precompiled.cpp"
}
}
}
static void regamedll_tests_gcc_src(def h) {
h.regamedll_tests_gcc_src(CppSourceSet) {
source {
srcDir "unittests"
include "**/*.cpp"
exclude "mathfun_tests.cpp"
}
}
}
static void regamedll_tests_src(def h) {
h.regamedll_tests_src(CppSourceSet) {
source {
srcDir "unittests"
include "**/*.cpp"
}
}
}
}
model {
buildTypes {
debug
release
}
platforms {
x86 {
architecture "x86"
}
}
toolChains {
visualCpp(VisualCpp) {
}
if (project.hasProperty("useClang")) {
clang(Clang)
}
else if (project.hasProperty("useGcc")) {
gcc(Gcc)
} else {
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)
if (project.hasProperty("useGcc")) {
RegamedllSrc.regamedll_tests_gcc_src(it)
} else {
RegamedllSrc.regamedll_tests_src(it)
}
}
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
}
}
}
task buildFinalize << {
if (GradleCppUtils.windows) {
return;
}
binaries.withType(SharedLibraryBinarySpec) {
def sharedBinary = it.getSharedLibraryFile();
if (sharedBinary.exists()) {
sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", "")));
}
}
}
task buildRelease {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
blib.buildable && blib.buildType.name == 'release'
}
}
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'
}
}
task buildDebug {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching {
SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'debug' && blib.flavor.name == 'regamedllFixes' && blib.component.name == 'regamedll_mp_gamedll'
}
}
buildFixes.finalizedBy(buildFinalize);
buildDebug.finalizedBy(buildFinalize);
buildRelease.finalizedBy(buildFinalize);
gradle.taskGraph.whenReady { graph ->
if (!graph.hasTask(buildFixes) && !graph.hasTask(buildDebug)) {
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;
}
}
task prepareDevEnvTests {
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
}
}
}
}
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)
demoRunner.prepareEngine()
//demoRunner.prepareDemo()
}
}
task prepareDevEnv {
dependsOn prepareDevEnvGamedll, prepareDevEnvTests
}
tasks.clean.doLast {
project.file('version/appversion.h').delete()
}
task generateAppVersion {
RegamedllVersionInfo verInfo = (RegamedllVersionInfo)rootProject.regamedllVersionInfo
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
// 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) + "']";
doLast {
def templateCtx = [
verInfo: verInfo
]
def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
renderedFile.delete()
renderedFile.write(content, 'utf-8')
println 'The current ReGameDLL maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
}
}

View File

@ -100,11 +100,21 @@
g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
}
#define LINK_HOOK_VOID_CHAIN2(functionName)\
void functionName() {\
g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#define LINK_HOOK_CHAIN(ret, functionName, args, ...)\
ret functionName args {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
}
#define LINK_HOOK_CHAIN2(ret, functionName)\
ret functionName() {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#define LINK_HOOK_GLOB_CLASS_VOID_CHAIN(className, functionName, args, ...)\
void className::functionName args {\
g_ReGameHookchains.m_##functionName.callChain(className::functionName##_OrigFunc, __VA_ARGS__);\
@ -120,16 +130,7 @@
return g_ReGameHookchains.m_##customFuncName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
}
#define LINK_HOOK_VOID_CHAIN2(functionName)\
void functionName() {\
g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#define LINK_HOOK_CHAIN2(ret, functionName)\
ret functionName() {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#else
#else // REGAMEDLL_API
#define __API_HOOK(fname)\
fname
@ -141,14 +142,19 @@
#define LINK_HOOK_CLASS_CHAIN3(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM2_CHAIN(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM2_CHAIN2(...)
#define LINK_HOOK_CLASS_CUSTOM_CHAIN(...)
#define LINK_HOOK_CLASS_CUSTOM_CHAIN2(...)
#define LINK_HOOK_CLASS_CUSTOM2_CHAIN(...)
#define LINK_HOOK_CLASS_CUSTOM2_CHAIN2(...)
#define LINK_HOOK_VOID_CHAIN(...)
#define LINK_HOOK_VOID_CHAIN2(...)
#define LINK_HOOK_CHAIN(...)
#define LINK_HOOK_CHAIN2(...)
#define LINK_HOOK_GLOB_CLASS_VOID_CHAIN(...)
#define LINK_HOOK_GLOB_CLASS_CHAIN(...)
#define LINK_HOOK_CUSTOM2_CHAIN(...)
#endif // REGAMEDLL_API

View File

@ -10082,13 +10082,13 @@ void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime
{
#ifdef REGAMEDLL_ADD
if (respawn_immunity_effects.value > 0)
#endif
{
pev->rendermode = kRenderTransAdd;
pev->renderamt = 100.0f;
}
CSPlayer()->m_flSpawnProtectionEndTime = gpGlobals->time + flProtectionTime;
#endif
}
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RemoveSpawnProtection)
@ -10097,7 +10097,6 @@ void CBasePlayer::__API_HOOK(RemoveSpawnProtection)()
{
#ifdef REGAMEDLL_ADD
if (respawn_immunity_effects.value > 0)
#endif
{
if (pev->rendermode == kRenderTransAdd &&
pev->renderamt == 100.0f)
@ -10108,6 +10107,7 @@ void CBasePlayer::__API_HOOK(RemoveSpawnProtection)()
}
CSPlayer()->m_flSpawnProtectionEndTime = 0.0f;
#endif
}
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropIdlePlayer, (const char *reason), reason)

View File

@ -834,8 +834,9 @@ void CBasePlayerWeapon::HandleInfiniteAmmo()
{
m_iClip = iMaxClip();
}
else if ((nInfiniteAmmo == WPNMODE_INFINITE_BPAMMO &&
else if ((nInfiniteAmmo == WPNMODE_INFINITE_BPAMMO
#ifdef REGAMEDLL_API
&&
((m_pPlayer->CSPlayer()->m_iWeaponInfiniteIds & (1 << m_iId)) || (m_pPlayer->CSPlayer()->m_iWeaponInfiniteIds <= 0 && !IsGrenadeWeapon(m_iId)))
#endif
)
@ -1136,6 +1137,7 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer *pPlayer)
void CBasePlayerWeapon::Spawn()
{
#ifdef REGAMEDLL_API
ItemInfo info;
Q_memset(&info, 0, sizeof(info));
@ -1144,6 +1146,7 @@ void CBasePlayerWeapon::Spawn()
}
CSPlayerWeapon()->m_bHasSecondaryAttack = HasSecondaryAttack();
#endif
}
// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal

View File

@ -425,7 +425,7 @@ public:
int m_iShellId;
float m_fMaxSpeed;
bool m_bDelayFire;
int m_iDirection;
BOOL m_iDirection;
bool m_bSecondarySilencerOn;
float m_flAccuracy;
float m_flLastFire;

View File

@ -77,14 +77,6 @@ IF EXIST "%srcdir%\version.h" (
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
)
)
) ELSE (
FOR /F "usebackq tokens=1,2,3,* delims==" %%i in ("%repodir%..\gradle.properties") do (
IF NOT [%%j] == [] (
IF %%i==majorVersion set version_major=%%j
IF %%i==minorVersion set version_minor=%%j
IF %%i==maintenanceVersion set version_maintenance=%%j
)
)
)
::
@ -210,11 +202,5 @@ echo.>>"%srcdir%\appversion.h"
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
::
:: Do update of version.cpp file last modify time to force it recompile
::
copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp"
endlocal
:_exit
exit /B 0

View File

@ -31,10 +31,22 @@
<ClCompile Include="..\dlls\ammo.cpp" />
<ClCompile Include="..\dlls\animating.cpp" />
<ClCompile Include="..\dlls\animation.cpp" />
<ClCompile Include="..\dlls\API\CAPI_Impl.cpp" />
<ClCompile Include="..\dlls\API\CSEntity.cpp" />
<ClCompile Include="..\dlls\API\CSPlayer.cpp" />
<ClCompile Include="..\dlls\API\CSPlayerItem.cpp" />
<ClCompile Include="..\dlls\API\CAPI_Impl.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dlls\API\CSEntity.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dlls\API\CSPlayer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dlls\API\CSPlayerItem.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dlls\basemonster.cpp" />
<ClCompile Include="..\dlls\bmodels.cpp" />
<ClCompile Include="..\dlls\bot\cs_bot.cpp">
@ -580,7 +592,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\version\version.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\com_model.h" />
@ -610,7 +621,10 @@
<ClInclude Include="..\dlls\airtank.h" />
<ClInclude Include="..\dlls\ammo.h" />
<ClInclude Include="..\dlls\animation.h" />
<ClInclude Include="..\dlls\API\CAPI_Impl.h" />
<ClInclude Include="..\dlls\API\CAPI_Impl.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\dlls\basemonster.h" />
<ClInclude Include="..\dlls\bmodels.h" />
<ClInclude Include="..\dlls\bot\cs_bot.h">
@ -781,22 +795,6 @@
<ClInclude Include="..\regamedll\sse_mathfun.h" />
<ClInclude Include="..\version\version.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\linux\appversion.sh">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">true</ExcludedFromBuild>
</None>
<None Include="..\linux\Makefile">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">true</ExcludedFromBuild>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\dep\cppunitlite\msvc\cppunitlite.vcxproj">
<Project>{ceb94f7c-e459-4673-aabb-36e2074396c0}</Project>
@ -811,6 +809,7 @@
<ProjectGuid>{70A2B904-B7DB-4C48-8DE0-AF567360D572}</ProjectGuid>
<RootNamespace>ReGameDLL</RootNamespace>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -820,7 +819,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' &gt;= '16.0'">v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -829,7 +828,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' &gt;= '16.0'">v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'" Label="Configuration">
@ -839,7 +838,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' &gt;= '16.0'">v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'" Label="Configuration">
@ -849,7 +848,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' &gt;= '16.0'">v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@ -857,7 +856,7 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' &gt;= '16.0'">v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -906,7 +905,7 @@
<CodeAnalysisRuleAssemblies />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">
<TargetName>filesystem_stdio</TargetName>
<TargetName>mp</TargetName>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
@ -921,7 +920,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_SSE;REGAMEDLL_FIXES;REGAMEDLL_SELF;BUILD_LATEST;BUILD_LATEST_FIXES;UNICODE_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SSE;REGAMEDLL_SELF;REGAMEDLL_CHECKS;UNICODE_FIXES;BUILD_LATEST;BUILD_LATEST_FIXES;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -957,7 +956,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>REGAMEDLL_ADD;REGAMEDLL_SSE;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;BUILD_LATEST;BUILD_LATEST_FIXES;UNICODE_FIXES;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SSE;REGAMEDLL_SELF;REGAMEDLL_CHECKS;UNICODE_FIXES;BUILD_LATEST;BUILD_LATEST_FIXES;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -1002,7 +1001,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>PLAY_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_API;REGAMEDLL_SSE;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>PLAY_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;REGAMEDLL_SSE;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Precise</FloatingPointModel>
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -1047,7 +1046,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>PLAY_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;REGAMEDLL_SSE;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>PLAY_GAMEDLL;REGAMEDLL_SSE;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FloatingPointModel>Precise</FloatingPointModel>
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -1083,7 +1082,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>REGAMEDLL_FIXES;REGAMEDLL_SELF;UNICODE_FIXES;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_SSE;UNICODE_FIXES;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>

View File

@ -10,10 +10,6 @@
<Filter Include="common">
<UniqueIdentifier>{fe7a8e81-b7d4-4540-ab5b-457ed93672ce}</UniqueIdentifier>
</Filter>
<Filter Include="linux">
<UniqueIdentifier>{9de0de20-070f-4fae-a9df-3dca942e65a7}</UniqueIdentifier>
<ParseFiles>false</ParseFiles>
</Filter>
<Filter Include="public">
<UniqueIdentifier>{d74cb79e-afd5-4215-af0e-029e38925be0}</UniqueIdentifier>
</Filter>
@ -76,9 +72,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\version\version.cpp">
<Filter>version</Filter>
</ClCompile>
<ClCompile Include="..\regamedll\precompiled.cpp">
<Filter>regamedll</Filter>
</ClCompile>
@ -1057,12 +1050,4 @@
<Filter>dlls\addons</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\linux\appversion.sh">
<Filter>linux</Filter>
</None>
<None Include="..\linux\Makefile">
<Filter>linux</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -1,16 +1,10 @@
#include "precompiled.h"
#include "cppunitlite/GradleAdapter.h"
#include "cppunitlite/MainAdapter.h"
int main(int argc, char *argv[])
{
printf("TestRunner: main()\n");
GradleAdapter a;
int res = a.testsEntryPoint(argc, argv);
#ifdef _BUILD_FROM_IDE
system("PAUSE");
#endif
return res;
MainAdapter a;
return a.testsEntryPoint(argc, argv);
}

View File

@ -3,9 +3,9 @@
init()
{
SOURCE_DIR="$@"
GIT_DIR="$SOURCE_DIR/.."
VERSION_FILE="$GIT_DIR/gradle.properties"
APPVERSION_FILE="$SOURCE_DIR/version/appversion.h"
GIT_DIR=$SOURCE_DIR
VERSION_FILE=$SOURCE_DIR/regamedll/version/version.h
APPVERSION_FILE=$SOURCE_DIR/regamedll/version/appversion.h
if test -z "`git --version`"; then
echo "Please install git client"
@ -25,17 +25,17 @@ init()
fi
# Get major, minor and maintenance information from gradle.properties
MAJOR=$(sed -nr -e '/majorVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
MAJOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MAJOR' | sed -e 's/.*VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAJOR" = "" ]; then
MAJOR=0
fi
MINOR=$(sed -nr -e '/minorVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
MINOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MINOR' | sed -e 's/.*VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MINOR" = "" ]; then
MINOR=0
fi
MAINTENANCE=$(sed -nr -e '/maintenanceVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
MAINTENANCE=$(cat "$VERSION_FILE" | grep -i 'VERSION_MAINTENANCE' | sed -e 's/.*VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
MAINTENANCE=0
fi
@ -66,20 +66,37 @@ init()
# Get remote url
COMMIT_URL=$(git -C "$GIT_DIR/" config remote.$BRANCH_REMOTE.url)
# Strip prefix 'git@'
COMMIT_URL=${COMMIT_URL#git@}
URL_CONSTRUCT=0
# Strip postfix '.git'
COMMIT_URL=${COMMIT_URL%.git}
if [[ "$COMMIT_URL" == *"git@"* ]]; then
URL_CONSTRUCT=1
# Replace ':' to '/'
COMMIT_URL=${COMMIT_URL/:/\/}
# Strip prefix 'git@'
COMMIT_URL=${COMMIT_URL#git@}
# Append extra string
if [ $? -ne 0 -o "$COMMIT_URL" = "${COMMIT_URL/bitbucket.org}" ]; then
COMMIT_URL=$(echo https://$COMMIT_URL/commits/)
else
COMMIT_URL=$(echo https://$COMMIT_URL/commit/)
# Strip postfix '.git'
COMMIT_URL=${COMMIT_URL%.git}
# Replace ':' to '/'
COMMIT_URL=${COMMIT_URL/:/\/}
elif [[ "$COMMIT_URL" == *"https://"* ]]; then
URL_CONSTRUCT=1
# Strip prefix 'https://'
COMMIT_URL=${COMMIT_URL#https://}
# Strip postfix '.git'
COMMIT_URL=${COMMIT_URL%.git}
fi
if test "$URL_CONSTRUCT" -eq 1; then
# Append extra string
if [[ "$COMMIT_URL" == *"bitbucket.org"* ]]; then
COMMIT_URL=$(echo https://$COMMIT_URL/commits/)
else
COMMIT_URL=$(echo https://$COMMIT_URL/commit/)
fi
fi
#
@ -101,7 +118,7 @@ init()
update_appversion()
{
day=$(date +%m)
day=$(date +%d)
year=$(date +%Y)
hours=$(date +%H:%M:%S)
month=$(LANG=en_us_88591; date +"%b")

View File

@ -1,18 +0,0 @@
#ifndef __APPVERSION_H__
\#define __APPVERSION_H__
//
// This file is generated automatically.
// Don't edit it.
//
// Version defines
\#define APP_VERSION "$verInfo.asMavenVersion()"
\#define APP_COMMIT_DATE "$verInfo.asCommitDate()"
\#define APP_COMMIT_TIME "$verInfo.asCommitTime()"
\#define APP_COMMIT_SHA "$verInfo.commitSHA"
\#define APP_COMMIT_URL "$verInfo.commitURL"
#endif //__APPVERSION_H__

View File

@ -1,10 +0,0 @@
/*
* Version declaration dependency file
*
*/
//
// This file needed just to add the dependency and appversion.h
//
#include "precompiled.h"

View File

@ -0,0 +1,10 @@
/*
* Version declaration dependency file
*
*/
#pragma once
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_MAINTENANCE 0

View File

@ -1,3 +0,0 @@
rootProject.name = 'regamedll'
include 'dep/cppunitlite'
include 'regamedll'

View File

@ -1,54 +0,0 @@
import org.doomedsociety.gradlecpp.cfg.BinaryKind
import org.doomedsociety.gradlecpp.toolchain.icc.Icc
import org.gradle.nativeplatform.NativeBinarySpec
import org.gradle.nativeplatform.NativeExecutableBinarySpec
import org.gradle.nativeplatform.SharedLibraryBinarySpec
import org.gradle.nativeplatform.StaticLibraryBinarySpec
import org.gradle.nativeplatform.toolchain.VisualCpp
apply from: 'shared_msvc.gradle'
apply from: 'shared_icc.gradle'
apply from: 'shared_clang.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}")
}
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 if (bin.toolChain instanceof Clang)
{
return rootProject.createClangConfig(releaseBuild, binaryKind)
}
else if (bin.toolChain instanceof Gcc)
{
return rootProject.createGccConfig(releaseBuild, binaryKind)
}
else
{
throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}")
}
}

View File

@ -1,55 +0,0 @@
import org.doomedsociety.gradlecpp.cfg.BinaryKind
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
import org.doomedsociety.gradlecpp.gcc.OptimizationLevel
rootProject.ext.createClangConfig = { boolean release, BinaryKind binKind ->
GccToolchainConfig cfg
if (release) {
cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.LEVEL_3,
stackProtector: false,
noBuiltIn: true,
positionIndependentCode: false,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
} else {
// debug
cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true,
noBuiltIn: true,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
}
cfg.singleDefines('LINUX', '_LINUX')
return cfg
}

View File

@ -1,55 +0,0 @@
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,
noBuiltIn: true,
positionIndependentCode: false,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
} else {
// debug
cfg = new GccToolchainConfig(
compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true,
noBuiltIn: true,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
stripSymbolTable: false,
staticLibGcc: false,
staticLibStdCpp: false,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
}
cfg.singleDefines('LINUX', '_LINUX')
return cfg
}

View File

@ -1,66 +0,0 @@
import org.doomedsociety.gradlecpp.cfg.BinaryKind
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, // -ipo
noBuiltIn: true,
intelExtensions: false,
asmBlocks: true,
positionIndependentCode: false,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0, // don't use specific c++11 features from GCC 5.X for backward compatibility to earlier version ABI libstdc++.so.6
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: true, // -ipo
stripSymbolTable: true,
staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: 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,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0, // don't use specific c++11 features from GCC 5.X for backward compatibility to earlier version ABI libstdc++.so.6
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: false,
stripSymbolTable: false,
staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: true,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
}
cfg.singleDefines('REGAMEDLL_SSE')
cfg.singleDefines('LINUX', '_LINUX')
return cfg
}

View File

@ -1,135 +0,0 @@
import org.doomedsociety.gradlecpp.cfg.BinaryKind
import org.doomedsociety.gradlecpp.msvc.CallingConvention
import org.doomedsociety.gradlecpp.msvc.CodeGenerationKind
import org.doomedsociety.gradlecpp.msvc.CppExceptions
import org.doomedsociety.gradlecpp.msvc.DebugInfoFormat
import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet
import org.doomedsociety.gradlecpp.msvc.ErrorReporting
import org.doomedsociety.gradlecpp.msvc.FloatingPointModel
import org.doomedsociety.gradlecpp.msvc.LinkTimeCodeGenKind
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
import org.doomedsociety.gradlecpp.msvc.OptimizationLevel
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,
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,
]
),
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,
),
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,
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,
]
),
linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
enableIncrementalLinking: true,
eliminateUnusedRefs: false,
enableCOMDATFolding: false,
generateDebugInfo: true,
dataExecutionPrevention: true,
randomizedBaseAddress: true
),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
),
generatePdb: true
)
if (binKind == BinaryKind.STATIC_LIBRARY) {
cfg.compilerConfig.extraDefines['_LIB'] = null
}
}
// Detect and setup UCRT paths
def ucrtInfo = "getucrtinfo.bat".execute().text
def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/
if (!m.find()) {
return cfg
}
def kitPath = m.group(1)
def ucrtVersion = m.group(2)
def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h");
if (!ucrtCheckFile.exists()) {
return cfg
}
cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt";
cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86");
cfg.singleDefines('REGAMEDLL_SSE')
return cfg
}