2
0
mirror of https://github.com/rehlds/revoice.git synced 2025-03-28 05:09:18 +03:00

Refactoring versioning

This commit is contained in:
s1lent 2017-07-07 20:01:43 +07:00
parent 92f1fb87b1
commit 07f5290ad9
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
21 changed files with 368 additions and 228 deletions

View File

@ -1 +1 @@
# revoice # Revoice [![Build Status](http://teamcity.rehlds.org/app/rest/builds/buildType:(id:Revoice_Publish)/statusIcon)](http://teamcity.rehlds.org/viewType.html?buildTypeId=Revoice_Publish&guest=1) [![Download](https://camo.githubusercontent.com/089706eb2571f262bb23afc9434d85d52a423cc3/687474703a2f2f7265686c64732e6f72672f76657273696f6e2f7265766f6963652e737667)](http://teamcity.rehlds.org/guestAuth/downloadArtifacts.html?buildTypeId=Revoice_Publish&buildId=lastSuccessful)

View File

@ -1,6 +1,8 @@
import versioning.GitVersioner import versioning.GitVersioner
import versioning.RevoiceVersionInfo import versioning.RevoiceVersionInfo
import org.joda.time.DateTime
apply plugin: 'maven-publish'
apply from: 'shared.gradle' apply from: 'shared.gradle'
group = 'revoice' group = 'revoice'
@ -13,13 +15,8 @@ idea {
} }
def gitInfo = GitVersioner.versionForDir(project.rootDir) def gitInfo = GitVersioner.versionForDir(project.rootDir)
if (!gitInfo) {
throw new RuntimeException('Running outside git repository')
}
RevoiceVersionInfo versionInfo RevoiceVersionInfo versionInfo
if (gitInfo.tag && gitInfo.tag[0] == 'v') { if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') {
def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
if (!m.find()) { if (!m.find()) {
throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}")
@ -29,22 +26,27 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
majorVersion: m.group(1) as int, majorVersion: m.group(1) as int,
minorVersion: m.group(2) as int, minorVersion: m.group(2) as int,
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null, maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
countCommit: gitInfo.countCommit, localChanges: gitInfo.localChanges,
lastCommitDate: gitInfo.lastCommitDate commitDate: gitInfo.commitDate,
commitSHA: gitInfo.commitSHA,
commitURL: gitInfo.commitURL
) )
} else { } else {
versionInfo = new RevoiceVersionInfo( versionInfo = new RevoiceVersionInfo(
majorVersion: project.majorVersion as int, majorVersion: project.majorVersion as int,
minorVersion: project.minorVersion as int, minorVersion: project.minorVersion as int,
specialVersion: project.specialVersion, maintenanceVersion: project.maintenanceVersion as int,
countCommit: gitInfo.countCommit, suffix: '',
lastCommitDate: gitInfo.lastCommitDate 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.revoiceVersionInfo = versionInfo project.ext.revoiceVersionInfo = versionInfo
project.version = versionInfo.asVersion() project.version = versionInfo.asMavenVersion()
apply from: 'publish.gradle' apply from: 'publish.gradle'

View File

@ -4,7 +4,6 @@ import org.apache.velocity.Template
import org.apache.velocity.VelocityContext import org.apache.velocity.VelocityContext
import org.apache.velocity.app.Velocity import org.apache.velocity.app.Velocity
import org.joda.time.format.DateTimeFormat import org.joda.time.format.DateTimeFormat
import versioning.RevoiceVersionInfo
class VelocityUtils { class VelocityUtils {
@ -20,29 +19,15 @@ class VelocityUtils {
Velocity.init(p); Velocity.init(p);
} }
static String renderTemplate(File tplFile, RevoiceVersionInfo ctx) {
static String renderTemplate(File tplFile, Map<String, ? extends Object> ctx) {
Template tpl = Velocity.getTemplate(tplFile.absolutePath) Template tpl = Velocity.getTemplate(tplFile.absolutePath)
if (!tpl) { if (!tpl) {
throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found") throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found")
} }
def templateCtx = [
verInfo: ctx
]
def velocityContext = new VelocityContext(templateCtx)
if (ctx.specialVersion.length() > 0) {
velocityContext.put("appFlags", 0x0L)
velocityContext.put("formatSpecialVersion", "-" + ctx.specialVersion)
} else {
velocityContext.put("appFlags", "VS_FF_SPECIALBUILD")
velocityContext.put("formatSpecialVersion", "")
}
velocityContext.put("current_version", ctx.asVersion())
def velocityContext = new VelocityContext(ctx)
velocityContext.put("_DateTimeFormat", DateTimeFormat) velocityContext.put("_DateTimeFormat", DateTimeFormat)
def sw = new StringWriter() def sw = new StringWriter()

View File

@ -6,8 +6,11 @@ import org.joda.time.DateTime
@CompileStatic @TypeChecked @CompileStatic @TypeChecked
class GitInfo { class GitInfo {
DateTime lastCommitDate boolean localChanges
DateTime commitDate
String branch String branch
String tag String tag
Integer countCommit String commitSHA
String commitURL
Integer commitCount
} }

View File

@ -1,10 +1,14 @@
package versioning package versioning
import java.util.Set;
import groovy.transform.CompileStatic import groovy.transform.CompileStatic
import groovy.transform.TypeChecked import groovy.transform.TypeChecked
import org.eclipse.jgit.api.Git import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.Status;
import org.eclipse.jgit.lib.ObjectId import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.lib.Repository import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.lib.StoredConfig
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.revwalk.RevWalk import org.eclipse.jgit.revwalk.RevWalk
import org.eclipse.jgit.storage.file.FileRepositoryBuilder import org.eclipse.jgit.storage.file.FileRepositoryBuilder
@ -26,28 +30,96 @@ class GitVersioner {
return count; return count;
} }
static GitInfo versionForDir(File dir) { static String prepareUrlToCommits(String url) {
FileRepositoryBuilder builder = new FileRepositoryBuilder() if (url == null) {
Repository repo = builder.setWorkTree(dir).findGitDir().build() // default remote url
return "https://github.com/s1lentq/Revoice/commit/";
}
ObjectId head = repo.resolve('HEAD') 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().call();
Set<String> uncommittedChanges = status.getUncommittedChanges();
for(String uncommitted : uncommittedChanges) {
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) { if (!head) {
return null return null
} }
def commit = new RevWalk(repo).parseCommit(head) final StoredConfig cfg = repo.getConfig();
def branch = repo.getBranch() def commit = new RevWalk(repo).parseCommit(head);
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC) if (!commit) {
throw new RuntimeException("Can't find last commit.");
}
int commitCount = getCountCommit(repo); 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 tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key
String commitSHA = commit.getId().abbreviate(7).name();
return new GitInfo( return new GitInfo(
lastCommitDate: commitDate, localChanges: localChanges,
commitDate: commitDate,
branch: branch, branch: branch,
tag: tag, tag: tag,
countCommit: commitCount commitSHA: commitSHA,
commitURL: commitURL,
commitCount: getCountCommit(repo)
) )
} }
} }

View File

@ -3,39 +3,56 @@ package versioning
import groovy.transform.CompileStatic import groovy.transform.CompileStatic
import groovy.transform.ToString import groovy.transform.ToString
import groovy.transform.TypeChecked import groovy.transform.TypeChecked
import org.joda.time.format.DateTimeFormat
import org.joda.time.DateTime import org.joda.time.DateTime
@CompileStatic @TypeChecked @CompileStatic @TypeChecked
@ToString(includeNames = true) @ToString(includeNames = true)
class RevoiceVersionInfo { class RevoiceVersionInfo {
int majorVersion Integer majorVersion
int minorVersion Integer minorVersion
Integer maintenanceVersion Integer maintenanceVersion
String specialVersion String suffix
Integer countCommit
DateTime lastCommitDate
String format(String versionSeparator, String suffixSeparator, boolean includeSuffix) { boolean localChanges
DateTime commitDate
String commitSHA
String commitURL
Integer commitCount
String asMavenVersion(boolean extra = true, String separator = ".") {
StringBuilder sb = new StringBuilder() StringBuilder sb = new StringBuilder()
sb.append(majorVersion).append(versionSeparator).append(minorVersion) sb.append(majorVersion).append(separator).append(minorVersion);
if (maintenanceVersion != null) { if (maintenanceVersion != null) {
sb.append(versionSeparator).append(maintenanceVersion) sb.append(separator).append(maintenanceVersion);
} }
if (specialVersion && includeSuffix) { if (commitCount != null) {
sb.append(suffixSeparator).append(specialVersion) sb.append(separator).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() return sb.toString()
} }
String asVersion() { String asCommitDate(String pattern = null) {
if (specialVersion.length() > 0) { if (pattern == null) {
sprintf("%d.%d.%d-%s", majorVersion, minorVersion, countCommit, specialVersion) pattern = "MMM d yyyy";
if (commitDate.getDayOfMonth() >= 10) {
pattern = "MMM d yyyy";
}
} }
else
sprintf("%d.%d.%d", majorVersion, minorVersion, countCommit) return DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH).print(commitDate);
} }
String asMavenVersion() { String asCommitTime() {
format('.', '-', true) return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate);
} }
} }

View File

@ -1,3 +1,3 @@
majorVersion=0 majorVersion=0
minorVersion=1 minorVersion=1
specialVersion= maintenanceVersion=0

0
gradlew vendored Normal file → Executable file
View File

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReVoice", "..\revoice\msvc\ReVoice.vcxproj", "{DAEFE371-7D77-4B72-A8A5-3CD3D1A55786}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "revoice", "..\revoice\msvc\revoice.vcxproj", "{DAEFE371-7D77-4B72-A8A5-3CD3D1A55786}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{E1AC990E-C012-4167-80C2-84C98AA7070C} = {E1AC990E-C012-4167-80C2-84C98AA7070C} {E1AC990E-C012-4167-80C2-84C98AA7070C} = {E1AC990E-C012-4167-80C2-84C98AA7070C}
{966DE7A9-EC15-4C1D-8B46-EA813A845723} = {966DE7A9-EC15-4C1D-8B46-EA813A845723} {966DE7A9-EC15-4C1D-8B46-EA813A845723} = {966DE7A9-EC15-4C1D-8B46-EA813A845723}

View File

@ -10,21 +10,23 @@ void _copyFile(String from, String to) {
GradleCppUtils.copyFile(project.file(from), project.file(to), false) GradleCppUtils.copyFile(project.file(from), project.file(to), false)
} }
task publishPrepareFiles << { task publishPrepareFiles {
def pubRootDir = project.file('publish/publishRoot') doLast {
if (pubRootDir.exists()) { def pubRootDir = project.file('publish/publishRoot')
if (!pubRootDir.deleteDir()) { if (pubRootDir.exists()) {
throw new RuntimeException("Failed to delete ${pubRootDir}") if (!pubRootDir.deleteDir()) {
throw new RuntimeException("Failed to delete ${pubRootDir}")
}
} }
pubRootDir.mkdirs()
project.file('publish/publishRoot/revoice/bin/win32').mkdirs()
project.file('publish/publishRoot/revoice/bin/linux32').mkdirs()
_copyFileToDir('publish/revoice_mm.dll', 'publish/publishRoot/revoice/bin/win32/')
_copyFile('publish/librevoice_mm_i386.so', 'publish/publishRoot/revoice/bin/linux32/revoice_mm_i386.so')
} }
pubRootDir.mkdirs()
project.file('publish/publishRoot/revoice/bin/Windows').mkdirs()
project.file('publish/publishRoot/revoice/bin/Linux').mkdirs()
_copyFileToDir('publish/revoice_mm.dll', 'publish/publishRoot/revoice/bin/Windows/')
_copyFile('publish/librevoice_mm_i386.so', 'publish/publishRoot/revoice/bin/Linux/revoice_mm_i386.so')
} }
task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
@ -35,5 +37,4 @@ task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
task doPackage { task doPackage {
dependsOn 'publishPackage' dependsOn 'publishPackage'
} }

View File

@ -58,7 +58,7 @@ void setupToolchain(NativeBinarySpec b) {
enabled: true, enabled: true,
pchSourceSet: 'revoice_pch' pchSourceSet: 'revoice_pch'
) )
cfg.compilerOptions.languageStandard = 'c++0x' cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([ cfg.defines([
'_stricmp': 'strcasecmp', '_stricmp': 'strcasecmp',
'_strnicmp': 'strncasecmp', '_strnicmp': 'strncasecmp',
@ -137,7 +137,7 @@ model {
rc { rc {
source { source {
srcDir "msvc" srcDir "msvc"
include "ReVoice.rc" include "revoice.rc"
} }
exportedHeaders { exportedHeaders {
srcDirs "msvc" srcDirs "msvc"
@ -158,7 +158,7 @@ afterEvaluate {
Tool linker = binary.linker Tool linker = binary.linker
if (GradleCppUtils.windows) { if (GradleCppUtils.windows) {
linker.args "/DEF:${projectDir}\\msvc\\ReVoice.def" linker.args "/DEF:${projectDir}\\msvc\\revoice.def"
} }
} }
} }
@ -176,17 +176,29 @@ tasks.clean.doLast {
task generateAppVersion { task generateAppVersion {
RevoiceVersionInfo verInfo = (RevoiceVersionInfo) rootProject.revoiceVersionInfo RevoiceVersionInfo verInfo = (RevoiceVersionInfo) rootProject.revoiceVersionInfo
def tplversionFile = project.file('version/appversion.vm') def tplFile = project.file('version/appversion.vm')
def versionFile = project.file('version/appversion.h') def renderedFile = project.file('version/appversion.h')
inputs.file tplversionFile // check to up-to-date
inputs.file tplFile
inputs.file project.file('gradle.properties') inputs.file project.file('gradle.properties')
outputs.file versionFile 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 { doLast {
def templateCtx = [
verInfo: verInfo
]
def versionContent = VelocityUtils.renderTemplate(tplversionFile, verInfo) def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
versionFile.delete() renderedFile.delete()
versionFile.write(versionContent, 'utf-8') renderedFile.write(content, 'utf-8')
println 'The current Revoice maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
} }
} }

View File

@ -1,21 +1,32 @@
@echo OFF @setlocal enableextensions enabledelayedexpansion
@echo off
:: ::
:: Pre-build auto-versioning script :: Pre-build auto-versioning script
:: ::
SET srcdir=%~1 set srcdir=%~1
SET repodir=%~2 set repodir=%~2
SET old_version= set old_version=
set old_specialbuild="" set version_major=0
SET version_revision=0 set version_minor=0
set version_specialbuild= set version_modifed=
SET version_pdate_1=%date:~-4%-%date:~3,2%-%date:~0,2% set svn_old_number=664
SET version_pdate=%version_pdate_1% %time:~0,2%:%time:~3,2%:%time:~6,2%
SET version_date=%version_pdate_1%__%time:~0,2%-%time:~3,2%-%time:~6,2% set commitSHA=
SET version_major=0 set commitURL=
SET version_minor=0 set commitCount=0
SET version_specialversion= set branch_name=master
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "hour=%dt:~8,2%"
set "min=%dt:~10,2%"
set "sec=%dt:~12,2%"
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
:: ::
:: Check for git.exe presence :: Check for git.exe presence
@ -29,8 +40,11 @@ set errlvl="%ERRORLEVEL%"
IF EXIST "%srcdir%\appversion.h" ( IF EXIST "%srcdir%\appversion.h" (
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do ( FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
IF %%i==#define ( IF %%i==#define (
IF %%j==APP_VERSION_C SET old_version=%%k IF %%j==APP_VERSION (
IF %%j==APP_VERSION_SPECIALBUILD SET old_specialbuild=%%k :: Remove quotes
set v=%%k
set old_version=!v:"=!
)
) )
) )
) )
@ -40,27 +54,25 @@ IF %errlvl% == "1" (
:: if we haven't appversion.h, we need to create it :: if we haven't appversion.h, we need to create it
IF NOT "%old_version%" == "" ( IF NOT "%old_version%" == "" (
SET version_revision=0 set commitCount=0
) )
) )
:: ::
:: Read major, minor and maintenance version components from Version.h :: Read major, minor and maintenance version components from Version.h
:: ::
IF EXIST "%srcdir%\version.h" ( IF EXIST "%srcdir%\version.h" (
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do ( FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do (
IF %%i==#define ( IF %%i==#define (
IF %%j==VERSION_MAJOR SET version_major=%%k IF %%j==VERSION_MAJOR set version_major=%%k
IF %%j==VERSION_MINOR SET version_minor=%%k IF %%j==VERSION_MINOR set version_minor=%%k
IF %%j==VERSION_SPECIALVERSION SET version_specialversion=%%k
) )
) )
) ELSE ( ) ELSE (
FOR /F "usebackq tokens=1,2,3,* delims==" %%i in ("%repodir%..\gradle.properties") do ( FOR /F "usebackq tokens=1,2,3,* delims==" %%i in ("%repodir%..\gradle.properties") do (
IF NOT [%%j] == [] ( IF NOT [%%j] == [] (
IF %%i==majorVersion SET version_major=%%j IF %%i==majorVersion set version_major=%%j
IF %%i==minorVersion SET version_minor=%%j IF %%i==minorVersion set version_minor=%%j
IF %%i==specialVersion SET version_specialversion=%%j
) )
) )
) )
@ -69,49 +81,108 @@ IF EXIST "%srcdir%\version.h" (
:: Read revision and release date from it :: Read revision and release date from it
:: ::
IF NOT %errlvl% == "1" ( IF NOT %errlvl% == "1" (
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --all | wc -l"') DO ( :: Get current branch
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO (
set branch_name=%%i
)
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
IF NOT [%%i] == [] ( IF NOT [%%i] == [] (
set version_revision=%%i set /a commitCount=%%i+%svn_old_number%
) )
) )
) )
::
:: Get remote url repository
::
IF NOT %errlvl% == "1" (
set branch_remote=origin
:: Get remote name by current branch
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO (
set branch_remote=%%i
)
:: Get remote url
FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
set commitURL=%%i
)
:: Get commit id
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO (
set shafull=%%i
set commitSHA=!shafull:~0,+7!
)
IF [!commitURL!] == [] (
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
set commitURL=%%i
)
:: strip .git
if "x!commitURL:~-4!"=="x.git" (
set commitURL=!commitURL:~0,-4!
)
:: append extra string
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
set commitURL=!commitURL!/commits/
) ELSE (
set commitURL=!commitURL!/commit/
)
) ELSE (
:: strip .git
if "x!commitURL:~-4!"=="x.git" (
set commitURL=!commitURL:~0,-4!
)
:: replace : to /
set commitURL=!commitURL::=/!
:: append extra string
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
set commitURL=https://!commitURL!/commits/
) ELSE (
set commitURL=https://!commitURL!/commit/
)
)
)
::
:: Detect local modifications
::
set localChanged=0
IF NOT %errlvl% == "1" (
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
set localChanged=1
)
)
IF [%localChanged%]==[1] (
set version_modifed=+m
)
:: ::
:: Now form full version string like 1.0.0.1 :: Now form full version string like 1.0.0.1
:: ::
set new_version=%version_major%,%version_minor%,0,%version_revision% set new_version=%version_major%.%version_minor%.%commitCount%%version_modifed%
::
:: Detect local modifications
::
SET localChanged=0
IF NOT %errlvl% == "1" (
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
SET localChanged=1
)
)
IF [%localChanged%]==[1] (
IF NOT [%version_specialversion%] == [] (
set version_specialbuild=%version_specialversion%
) ELSE (
set version_specialbuild=m
)
) ELSE (
set version_specialbuild=
)
:: ::
:: Update appversion.h if version has changed or modifications/mixed revisions detected :: Update appversion.h if version has changed or modifications/mixed revisions detected
:: ::
IF NOT "%new_version%"=="%old_version%" goto _update IF NOT "%new_version%"=="%old_version%" (
IF NOT "%version_specialbuild%"==%old_specialbuild% goto _update goto _update
)
goto _exit goto _exit
:_update :_update
echo Updating appversion.h, new version is "%new_version%", the old one was "%old_version%"
echo new special build is "%version_specialbuild%", the old one was %old_specialbuild% ::
:: Write appversion.h
::
echo Updating appversion.h, new version is "%new_version%", the old one was %old_version%
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h" echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h" echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
@ -122,38 +193,19 @@ echo // Don't edit it.>>"%srcdir%\appversion.h"
echo // >>"%srcdir%\appversion.h" echo // >>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h"
echo // Version defines>>"%srcdir%\appversion.h" echo // Version defines>>"%srcdir%\appversion.h"
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
IF "%version_specialversion%" == "" ( >>"%srcdir%\appversion.h" echo #define APP_VERSION_C %version_major%,%version_minor%,%commitCount%
echo #define APP_VERSION_D %version_major%.%version_minor%.%version_revision% >>"%srcdir%\appversion.h" echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%commitCount%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h" echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_C %version_major%,%version_minor%,0,%version_revision% >>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRCS "%version_major%, %version_minor%, 0, %version_revision%">>"%srcdir%\appversion.h"
) ELSE (
echo #define APP_VERSION_D %version_major%.%version_minor%.%version_maintenance%.%version_revision% >>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_C %version_major%,%version_minor%,%version_maintenance%,%version_revision% >>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRCS "%version_major%, %version_minor%, %version_maintenance%, %version_revision%">>"%srcdir%\appversion.h"
)
echo.>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h"
echo #define APP_VERSION_DATE %version_date%>>"%srcdir%\appversion.h" echo #define APP_COMMIT_DATE "%YYYY%-%DD%-%MM%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_DATE_STR "%version_date%">>"%srcdir%\appversion.h" echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
echo #define APP_VERSION_PDATE_STR "%version_pdate%">>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
echo #define APP_VERSION_YMD_STR "%version_pdate_1%">>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
IF NOT "%version_specialbuild%" == "" ( echo.>>"%srcdir%\appversion.h"
echo #define APP_VERSION_FLAGS VS_FF_SPECIALBUILD>>"%srcdir%\appversion.h" echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_SPECIALBUILD "%version_specialbuild%">>"%srcdir%\appversion.h" echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
echo #define APP_VERSION APP_VERSION_STRD "" APP_VERSION_SPECIALBUILD>>"%srcdir%\appversion.h"
) ELSE (
echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h"
echo #define APP_VERSION APP_VERSION_STRD>>"%srcdir%\appversion.h"
)
echo.>>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h"
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h" echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
@ -163,6 +215,7 @@ echo.>>"%srcdir%\appversion.h"
:: Do update of version.cpp file last modify time to force it recompile :: Do update of version.cpp file last modify time to force it recompile
:: ::
copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp" copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp"
endlocal
:_exit :_exit
exit /B 0 exit /B 0

View File

@ -28,18 +28,18 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE 1 TEXTINCLUDE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE 2 TEXTINCLUDE
BEGIN BEGIN
"#include ""winres.h""\r\n" "#include ""winres.h""\r\n"
"\0" "\0"
END END
3 TEXTINCLUDE 3 TEXTINCLUDE
BEGIN BEGIN
"\r\n" "\r\n"
"\0" "\0"
@ -72,14 +72,14 @@ BEGIN
BEGIN BEGIN
BLOCK "041904b0" BLOCK "041904b0"
BEGIN BEGIN
VALUE "CompanyName", "" VALUE "CompanyName", "ReHLDS Team"
VALUE "FileDescription", "Voice transcoding module for ReHLDS" VALUE "FileDescription", "Voice transcoding module for ReHLDS"
VALUE "FileVersion", APP_VERSION_STRD_RC VALUE "FileVersion", APP_VERSION_STRD
VALUE "InternalName", "Revoice" VALUE "InternalName", "Revoice"
VALUE "LegalCopyright", "" VALUE "LegalCopyright", "Copyright (c) 2015"
VALUE "OriginalFilename", "revoice_mm.dll" VALUE "OriginalFilename", "revoice_mm.dll"
VALUE "ProductName", "Revoice" VALUE "ProductName", "Revoice"
VALUE "ProductVersion", APP_VERSION_STRD_RC VALUE "ProductVersion", APP_VERSION_STRD
#if APP_VERSION_FLAGS != 0x0L #if APP_VERSION_FLAGS != 0x0L
VALUE "SpecialBuild", APP_VERSION_SPECIALBUILD VALUE "SpecialBuild", APP_VERSION_SPECIALBUILD
#endif #endif
@ -87,7 +87,7 @@ BEGIN
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x419, 1200 VALUE "Translation", 0x0, 1200
END END
END END
@ -105,4 +105,3 @@ END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED #endif // not APSTUDIO_INVOKED

View File

@ -96,15 +96,15 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</None> </None>
<None Include="ReVoice.def" /> <None Include="revoice.def" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="ReVoice.rc" /> <ResourceCompile Include="revoice.rc" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{DAEFE371-7D77-4B72-A8A5-3CD3D1A55786}</ProjectGuid> <ProjectGuid>{DAEFE371-7D77-4B72-A8A5-3CD3D1A55786}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>ReVoice</RootNamespace> <RootNamespace>revoice</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

View File

@ -179,7 +179,7 @@
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="ReVoice.def" /> <None Include="revoice.def" />
<None Include="..\version\appversion.vm"> <None Include="..\version\appversion.vm">
<Filter>version</Filter> <Filter>version</Filter>
</None> </None>
@ -188,6 +188,6 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="ReVoice.rc" /> <ResourceCompile Include="revoice.rc" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -53,8 +53,8 @@ static META_FUNCTIONS gMetaFunctionTable = {
plugin_info_t Plugin_info = { plugin_info_t Plugin_info = {
META_INTERFACE_VERSION, // ifvers META_INTERFACE_VERSION, // ifvers
"Revoice", // name "Revoice", // name
APP_VERSION_STRD, // version APP_VERSION, // version
APP_VERSION_YMD_STR, // date APP_COMMIT_DATE, // date
"The Legion", // author "The Legion", // author
"", // url "", // url
"REVOICE", // logtag, all caps please "REVOICE", // logtag, all caps please

View File

@ -7,21 +7,15 @@
// //
// Version defines // Version defines
\#define VERSION_MAJOR ${verInfo.majorVersion} \#define APP_VERSION "$verInfo.asMavenVersion()"
\#define VERSION_MINOR ${verInfo.minorVersion} \#define APP_VERSION_C $verInfo.asMavenVersion(false, ",")
\#define APP_VERSION_STRD "$verInfo.asMavenVersion(false)"
\#define APP_VERSION_FLAGS 0x0L
\#define APP_VERSION_D ${verInfo.format('.', '-', true)} \#define APP_COMMIT_DATE "$verInfo.asCommitDate("yyyy-MM-dd")"
\#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit} \#define APP_COMMIT_TIME "$verInfo.asCommitTime()"
\#define APP_VERSION_STRD "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}${formatSpecialVersion}" \#define APP_COMMIT_SHA "$verInfo.commitSHA"
\#define APP_VERSION_STRD_RC "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}${formatSpecialVersion}" \#define APP_COMMIT_URL "$verInfo.commitURL"
\#define APP_VERSION_FLAGS ${appFlags}
\#define APP_VERSION_SPECIALBUILD "${verInfo.specialVersion}"
#set ( $commitYMD = $_DateTimeFormat.forPattern('yyyy-MM-dd').print($verInfo.lastCommitDate) )
\#define APP_VERSION_YMD_STR "${commitYMD}"
\#define APP_VERSION APP_VERSION_STRD
#endif //__APPVERSION_H__ #endif //__APPVERSION_H__

View File

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

View File

@ -9,26 +9,26 @@ rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
compilerOptions: new GccToolchainConfig.CompilerOptions( compilerOptions: new GccToolchainConfig.CompilerOptions(
optimizationLevel: OptimizationLevel.LEVEL_3, optimizationLevel: OptimizationLevel.LEVEL_3,
stackProtector: false, stackProtector: false,
interProceduralOptimizations: true, interProceduralOptimizations: true, // -ipo
noBuiltIn: true, noBuiltIn: true,
intelExtensions: false, intelExtensions: false,
asmBlocks: true, asmBlocks: true,
positionIndependentCode: false, positionIndependentCode: false,
extraDefines: [ extraDefines: [
'linux': null, '_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
'__linux__': null,
'NDEBUG': null
] ]
), ),
linkerOptions: new GccToolchainConfig.LinkerOptions( linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: true, interProceduralOptimizations: true, // -ipo
stripSymbolTable: true, stripSymbolTable: true,
staticLibGcc: true, staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: true, staticIntel: true,
), ),
librarianOptions: new GccToolchainConfig.LibrarianOptions( librarianOptions: new GccToolchainConfig.LibrarianOptions(
) )
) )
@ -39,28 +39,27 @@ rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
optimizationLevel: OptimizationLevel.DISABLE, optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true, stackProtector: true,
interProceduralOptimizations: false, interProceduralOptimizations: false,
noBuiltIn: true, noBuiltIn: true,
intelExtensions: false, intelExtensions: false,
asmBlocks: true, asmBlocks: true,
extraDefines: [ extraDefines: [
'linux': null, '_ITERATOR_DEBUG_LEVEL': 0, // for std::list, disable debug iterator in debug mode
'__linux__': null, '_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
'NDEBUG': null
] ]
), ),
linkerOptions: new GccToolchainConfig.LinkerOptions( linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: false, interProceduralOptimizations: false,
stripSymbolTable: false, stripSymbolTable: false,
staticLibGcc: true, staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: true, staticIntel: true,
), ),
librarianOptions: new GccToolchainConfig.LibrarianOptions( librarianOptions: new GccToolchainConfig.LibrarianOptions(
) )
) )
} }
return cfg; return cfg
} }

View File

@ -42,10 +42,8 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
'WIN32': null, 'WIN32': null,
'_MBCS': null, '_MBCS': null,
'NDEBUG': null, 'NDEBUG': null,
'NOMINMAX': null
] ]
), ),
linkerOptions: new MsvcToolchainConfig.LinkerOptions( linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG, linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT, errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
@ -55,13 +53,11 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
enableCOMDATFolding: true, enableCOMDATFolding: true,
generateDebugInfo: true, generateDebugInfo: true,
dataExecutionPrevention: true, dataExecutionPrevention: true,
randomizedBaseAddress: true randomizedBaseAddress: true,
), ),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions( librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
), ),
generatePdb: true generatePdb: true
) )
} else { } else {
@ -93,10 +89,8 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
'WIN32': null, 'WIN32': null,
'_MBCS': null, '_MBCS': null,
'_DEBUG': null, '_DEBUG': null,
'NOMINMAX': null,
] ]
), ),
linkerOptions: new MsvcToolchainConfig.LinkerOptions( linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT, linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT, errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
@ -108,11 +102,9 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
dataExecutionPrevention: true, dataExecutionPrevention: true,
randomizedBaseAddress: true randomizedBaseAddress: true
), ),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions( librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
), ),
generatePdb: true generatePdb: true
) )