2
0
mirror of https://github.com/s1lentq/revoice.git synced 2024-10-16 14:36:50 +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.RevoiceVersionInfo
import org.joda.time.DateTime
apply plugin: 'maven-publish'
apply from: 'shared.gradle'
group = 'revoice'
@ -13,13 +15,8 @@ idea {
}
def gitInfo = GitVersioner.versionForDir(project.rootDir)
if (!gitInfo) {
throw new RuntimeException('Running outside git repository')
}
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+))?$/
if (!m.find()) {
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,
minorVersion: m.group(2) as int,
maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
countCommit: gitInfo.countCommit,
lastCommitDate: gitInfo.lastCommitDate
localChanges: gitInfo.localChanges,
commitDate: gitInfo.commitDate,
commitSHA: gitInfo.commitSHA,
commitURL: gitInfo.commitURL
)
} else {
versionInfo = new RevoiceVersionInfo(
majorVersion: project.majorVersion as int,
minorVersion: project.minorVersion as int,
specialVersion: project.specialVersion,
countCommit: gitInfo.countCommit,
lastCommitDate: gitInfo.lastCommitDate
maintenanceVersion: project.maintenanceVersion as int,
suffix: '',
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.version = versionInfo.asVersion()
project.version = versionInfo.asMavenVersion()
apply from: 'publish.gradle'

View File

@ -4,7 +4,6 @@ import org.apache.velocity.Template
import org.apache.velocity.VelocityContext
import org.apache.velocity.app.Velocity
import org.joda.time.format.DateTimeFormat
import versioning.RevoiceVersionInfo
class VelocityUtils {
@ -20,29 +19,15 @@ class VelocityUtils {
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)
if (!tpl) {
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)
def sw = new StringWriter()

View File

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

View File

@ -1,10 +1,14 @@
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.revwalk.RevCommit
import org.eclipse.jgit.revwalk.RevWalk
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
@ -26,28 +30,96 @@ class GitVersioner {
return count;
}
static GitInfo versionForDir(File dir) {
FileRepositoryBuilder builder = new FileRepositoryBuilder()
Repository repo = builder.setWorkTree(dir).findGitDir().build()
static String prepareUrlToCommits(String url) {
if (url == null) {
// 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) {
return null
}
def commit = new RevWalk(repo).parseCommit(head)
def branch = repo.getBranch()
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC)
final StoredConfig cfg = repo.getConfig();
def commit = new RevWalk(repo).parseCommit(head);
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 commitSHA = commit.getId().abbreviate(7).name();
return new GitInfo(
lastCommitDate: commitDate,
localChanges: localChanges,
commitDate: commitDate,
branch: branch,
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.ToString
import groovy.transform.TypeChecked
import org.joda.time.format.DateTimeFormat
import org.joda.time.DateTime
@CompileStatic @TypeChecked
@ToString(includeNames = true)
class RevoiceVersionInfo {
int majorVersion
int minorVersion
Integer majorVersion
Integer minorVersion
Integer maintenanceVersion
String specialVersion
Integer countCommit
DateTime lastCommitDate
String suffix
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()
sb.append(majorVersion).append(versionSeparator).append(minorVersion)
sb.append(majorVersion).append(separator).append(minorVersion);
if (maintenanceVersion != null) {
sb.append(versionSeparator).append(maintenanceVersion)
sb.append(separator).append(maintenanceVersion);
}
if (specialVersion && includeSuffix) {
sb.append(suffixSeparator).append(specialVersion)
if (commitCount != null) {
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()
}
String asVersion() {
if (specialVersion.length() > 0) {
sprintf("%d.%d.%d-%s", majorVersion, minorVersion, countCommit, specialVersion)
String asCommitDate(String pattern = null) {
if (pattern == null) {
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() {
format('.', '-', true)
String asCommitTime() {
return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate);
}
}

View File

@ -1,3 +1,3 @@
majorVersion=0
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
VisualStudioVersion = 14.0.25420.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
{E1AC990E-C012-4167-80C2-84C98AA7070C} = {E1AC990E-C012-4167-80C2-84C98AA7070C}
{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)
}
task publishPrepareFiles << {
def pubRootDir = project.file('publish/publishRoot')
if (pubRootDir.exists()) {
if (!pubRootDir.deleteDir()) {
throw new RuntimeException("Failed to delete ${pubRootDir}")
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/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') {
@ -35,5 +37,4 @@ task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
task doPackage {
dependsOn 'publishPackage'
}

View File

@ -58,7 +58,7 @@ void setupToolchain(NativeBinarySpec b) {
enabled: true,
pchSourceSet: 'revoice_pch'
)
cfg.compilerOptions.languageStandard = 'c++0x'
cfg.compilerOptions.languageStandard = 'c++11'
cfg.defines([
'_stricmp': 'strcasecmp',
'_strnicmp': 'strncasecmp',
@ -137,7 +137,7 @@ model {
rc {
source {
srcDir "msvc"
include "ReVoice.rc"
include "revoice.rc"
}
exportedHeaders {
srcDirs "msvc"
@ -158,7 +158,7 @@ afterEvaluate {
Tool linker = binary.linker
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 {
RevoiceVersionInfo verInfo = (RevoiceVersionInfo) rootProject.revoiceVersionInfo
def tplversionFile = project.file('version/appversion.vm')
def versionFile = project.file('version/appversion.h')
def tplFile = project.file('version/appversion.vm')
def renderedFile = project.file('version/appversion.h')
inputs.file tplversionFile
// check to up-to-date
inputs.file tplFile
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 {
def templateCtx = [
verInfo: verInfo
]
def versionContent = VelocityUtils.renderTemplate(tplversionFile, verInfo)
versionFile.delete()
versionFile.write(versionContent, 'utf-8')
def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
renderedFile.delete()
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
::
SET srcdir=%~1
SET repodir=%~2
set srcdir=%~1
set repodir=%~2
SET old_version=
set old_specialbuild=""
SET version_revision=0
set version_specialbuild=
SET version_pdate_1=%date:~-4%-%date:~3,2%-%date:~0,2%
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 version_major=0
SET version_minor=0
SET version_specialversion=
set old_version=
set version_major=0
set version_minor=0
set version_modifed=
set svn_old_number=664
set commitSHA=
set commitURL=
set commitCount=0
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
@ -29,8 +40,11 @@ set errlvl="%ERRORLEVEL%"
IF EXIST "%srcdir%\appversion.h" (
FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do (
IF %%i==#define (
IF %%j==APP_VERSION_C SET old_version=%%k
IF %%j==APP_VERSION_SPECIALBUILD SET old_specialbuild=%%k
IF %%j==APP_VERSION (
:: 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 NOT "%old_version%" == "" (
SET version_revision=0
set commitCount=0
)
)
::
:: 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 (
IF %%i==#define (
IF %%j==VERSION_MAJOR SET version_major=%%k
IF %%j==VERSION_MINOR SET version_minor=%%k
IF %%j==VERSION_SPECIALVERSION SET version_specialversion=%%k
IF %%j==VERSION_MAJOR set version_major=%%k
IF %%j==VERSION_MINOR set version_minor=%%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==specialVersion SET version_specialversion=%%j
IF %%i==majorVersion set version_major=%%j
IF %%i==minorVersion set version_minor=%%j
)
)
)
@ -69,49 +81,108 @@ IF EXIST "%srcdir%\version.h" (
:: Read revision and release date from it
::
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] == [] (
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
::
set new_version=%version_major%,%version_minor%,0,%version_revision%
::
:: 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=
)
set new_version=%version_major%.%version_minor%.%commitCount%%version_modifed%
::
:: Update appversion.h if version has changed or modifications/mixed revisions detected
::
IF NOT "%new_version%"=="%old_version%" goto _update
IF NOT "%version_specialbuild%"==%old_specialbuild% goto _update
IF NOT "%new_version%"=="%old_version%" (
goto _update
)
goto _exit
:_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 #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 // Version defines>>"%srcdir%\appversion.h"
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
IF "%version_specialversion%" == "" (
echo #define APP_VERSION_D %version_major%.%version_minor%.%version_revision% >>"%srcdir%\appversion.h"
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_revision%">>"%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"
)
>>"%srcdir%\appversion.h" echo #define APP_VERSION_C %version_major%,%version_minor%,%commitCount%
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%commitCount%">>"%srcdir%\appversion.h"
echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
echo #define APP_VERSION_DATE %version_date%>>"%srcdir%\appversion.h"
echo #define APP_VERSION_DATE_STR "%version_date%">>"%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"
echo #define APP_COMMIT_DATE "%YYYY%-%DD%-%MM%">>"%srcdir%\appversion.h"
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
IF NOT "%version_specialbuild%" == "" (
echo #define APP_VERSION_FLAGS VS_FF_SPECIALBUILD>>"%srcdir%\appversion.h"
echo #define APP_VERSION_SPECIALBUILD "%version_specialbuild%">>"%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 #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h"
echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h"
echo.>>"%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
::
copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp"
endlocal
:_exit
exit /B 0
exit /B 0

View File

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

View File

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

View File

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

View File

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

View File

@ -7,21 +7,15 @@
//
// Version defines
\#define VERSION_MAJOR ${verInfo.majorVersion}
\#define VERSION_MINOR ${verInfo.minorVersion}
\#define APP_VERSION "$verInfo.asMavenVersion()"
\#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_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit}
\#define APP_COMMIT_DATE "$verInfo.asCommitDate("yyyy-MM-dd")"
\#define APP_COMMIT_TIME "$verInfo.asCommitTime()"
\#define APP_VERSION_STRD "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}${formatSpecialVersion}"
\#define APP_VERSION_STRD_RC "${verInfo.majorVersion}.${verInfo.minorVersion}.${verInfo.countCommit}${formatSpecialVersion}"
\#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
\#define APP_COMMIT_SHA "$verInfo.commitSHA"
\#define APP_COMMIT_URL "$verInfo.commitURL"
#endif //__APPVERSION_H__

View File

@ -11,23 +11,34 @@ apply from: 'shared_icc.gradle'
rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
BinaryKind binaryKind
if (bin instanceof NativeExecutableBinarySpec) {
if (bin instanceof NativeExecutableBinarySpec)
{
binaryKind = BinaryKind.EXECUTABLE
} else if (bin instanceof SharedLibraryBinarySpec) {
}
else if (bin instanceof SharedLibraryBinarySpec)
{
binaryKind = BinaryKind.SHARED_LIBRARY
} else if (bin instanceof StaticLibraryBinarySpec) {
}
else if (bin instanceof StaticLibraryBinarySpec)
{
binaryKind = BinaryKind.STATIC_LIBRARY
} else {
}
else
{
throw new RuntimeException("Unknown executable kind ${bin.class.name}")
}
boolean releaseBuild = bin.buildType.name.toLowerCase() == 'release'
if (bin.toolChain instanceof VisualCpp) {
if (bin.toolChain instanceof VisualCpp)
{
return rootProject.createMsvcConfig(releaseBuild, binaryKind)
} else if (bin.toolChain instanceof Icc) {
}
else if (bin.toolChain instanceof Icc)
{
return rootProject.createIccConfig(releaseBuild, binaryKind)
} else {
}
else
{
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(
optimizationLevel: OptimizationLevel.LEVEL_3,
stackProtector: false,
interProceduralOptimizations: true,
interProceduralOptimizations: true, // -ipo
noBuiltIn: true,
intelExtensions: false,
asmBlocks: true,
positionIndependentCode: false,
extraDefines: [
'linux': null,
'__linux__': null,
'NDEBUG': 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
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
interProceduralOptimizations: true,
interProceduralOptimizations: true, // -ipo
stripSymbolTable: true,
staticLibGcc: true,
staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: true,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
@ -39,28 +39,27 @@ rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
optimizationLevel: OptimizationLevel.DISABLE,
stackProtector: true,
interProceduralOptimizations: false,
noBuiltIn: true,
intelExtensions: false,
asmBlocks: true,
extraDefines: [
'linux': null,
'__linux__': null,
'NDEBUG': null
'_ITERATOR_DEBUG_LEVEL': 0, // for std::list, disable debug iterator in debug mode
'_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,
staticLibGcc: true,
staticLibStdCpp: false,
staticLibGcc: false,
staticIntel: true,
),
librarianOptions: new GccToolchainConfig.LibrarianOptions(
)
)
}
return cfg;
return cfg
}

View File

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