mirror of
https://github.com/rehlds/reapi.git
synced 2025-03-26 04:09:01 +03:00
Refactoring versioning
This commit is contained in:
parent
5fffe5368a
commit
05a5f1686e
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@
|
||||
|
||||
publish
|
||||
**/appversion.h
|
||||
**/reapi_version.inc
|
||||
|
26
build.gradle
26
build.gradle
@ -1,5 +1,6 @@
|
||||
import versioning.GitVersioner
|
||||
import versioning.ReapiVersionInfo
|
||||
import org.joda.time.DateTime
|
||||
|
||||
apply from: 'shared.gradle'
|
||||
group = 'reapi'
|
||||
@ -13,13 +14,8 @@ idea {
|
||||
}
|
||||
|
||||
def gitInfo = GitVersioner.versionForDir(project.rootDir)
|
||||
if (!gitInfo) {
|
||||
throw new RuntimeException('Running outside git repository')
|
||||
}
|
||||
|
||||
ReapiVersionInfo 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 +25,28 @@ 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 ReapiVersionInfo(
|
||||
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: '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.reapiVersionInfo = versionInfo
|
||||
project.version = versionInfo.asVersion()
|
||||
project.version = versionInfo.asMavenVersion()
|
||||
|
||||
apply from: 'publish.gradle'
|
||||
|
||||
|
@ -20,31 +20,13 @@ class VelocityUtils {
|
||||
|
||||
Velocity.init(p);
|
||||
}
|
||||
static String renderTemplate(File tplFile, ReapiVersionInfo 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())
|
||||
|
||||
velocityContext.put("_DateTimeFormat", DateTimeFormat)
|
||||
|
||||
def velocityContext = new VelocityContext(ctx)
|
||||
def sw = new StringWriter()
|
||||
tpl.merge(velocityContext, sw)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package versioning
|
||||
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 +28,98 @@ class GitVersioner {
|
||||
|
||||
return count;
|
||||
}
|
||||
static String prepareUrlToCommits(String url) {
|
||||
if (url == null) {
|
||||
// default remote url
|
||||
return "https://github.com/s1lentq/reapi/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().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()
|
||||
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()
|
||||
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC)
|
||||
|
||||
int commitCount = getCountCommit(repo);
|
||||
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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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
|
||||
@ -11,31 +12,65 @@ class ReapiVersionInfo {
|
||||
int majorVersion
|
||||
int 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 asReapiVersion() {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
sb.append(majorVersion).append(versionSeparator).append(minorVersion)
|
||||
sb.append(majorVersion).append(minorVersion).append(commitCount);
|
||||
return sb.toString()
|
||||
}
|
||||
String asMavenVersionC() {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
sb.append(majorVersion).append(',' + minorVersion);
|
||||
if (maintenanceVersion != null) {
|
||||
sb.append(versionSeparator).append(maintenanceVersion)
|
||||
sb.append(',' + maintenanceVersion);
|
||||
}
|
||||
|
||||
if (specialVersion && includeSuffix) {
|
||||
sb.append(suffixSeparator).append(specialVersion)
|
||||
if (commitCount != null) {
|
||||
sb.append(',' + commitCount)
|
||||
}
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
String asVersion() {
|
||||
if (specialVersion.length() > 0) {
|
||||
sprintf("%d.%d.%d-%s", majorVersion, minorVersion, countCommit, specialVersion)
|
||||
String asMavenVersion(boolean extra = true) {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
sb.append(majorVersion).append('.' + minorVersion);
|
||||
if (maintenanceVersion != null) {
|
||||
sb.append('.' + maintenanceVersion);
|
||||
}
|
||||
else
|
||||
sprintf("%d.%d.%d", majorVersion, minorVersion, countCommit)
|
||||
|
||||
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 asMavenVersion() {
|
||||
format('.', '-', true)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
majorVersion=0
|
||||
minorVersion=1
|
||||
specialVersion=
|
||||
majorVersion=5
|
||||
minorVersion=0
|
||||
maintenanceVersion=0
|
||||
|
@ -32,7 +32,7 @@ task publishPrepareFiles << {
|
||||
into 'publish/publishRoot/reapi/addons'
|
||||
}
|
||||
copy {
|
||||
from 'reapi/src/reapi_version.inc'
|
||||
from 'reapi/version/reapi_version.inc'
|
||||
into 'publish/publishRoot/reapi/addons/amxmodx/scripting/include'
|
||||
}
|
||||
}
|
||||
|
@ -155,22 +155,35 @@ task buildRelease {
|
||||
|
||||
tasks.clean.doLast {
|
||||
project.file('version/appversion.h').delete()
|
||||
project.file('version/reapi_version.inc').delete()
|
||||
}
|
||||
|
||||
task generateAppVersion {
|
||||
|
||||
ReapiVersionInfo verInfo = (ReapiVersionInfo) rootProject.reapiVersionInfo
|
||||
def tplversionFileInc = project.file('version/reapi_version.vm')
|
||||
def versionFileInc = project.file('version/reapi_version.inc')
|
||||
|
||||
def tplversionFile = project.file('version/appversion.vm')
|
||||
def versionFile = project.file('version/appversion.h')
|
||||
|
||||
inputs.file tplversionFile
|
||||
inputs.file tplversionFileInc
|
||||
inputs.file project.file('gradle.properties')
|
||||
outputs.file versionFile
|
||||
outputs.file versionFileInc
|
||||
|
||||
doLast {
|
||||
def templateCtx = [
|
||||
verInfo : verInfo
|
||||
]
|
||||
|
||||
def versionContent = VelocityUtils.renderTemplate(tplversionFile, verInfo)
|
||||
def versionContent = VelocityUtils.renderTemplate(tplversionFile, templateCtx)
|
||||
versionFile.delete()
|
||||
versionFile.write(versionContent, 'utf-8')
|
||||
|
||||
def versionContentInc = VelocityUtils.renderTemplate(tplversionFileInc, templateCtx)
|
||||
versionFileInc.delete()
|
||||
versionFileInc.write(versionContentInc, 'utf-8')
|
||||
}
|
||||
}
|
||||
|
@ -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_maintenance=0
|
||||
set version_modifed=
|
||||
|
||||
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,27 @@ 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
|
||||
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==specialVersion SET version_specialversion=%%j
|
||||
IF %%i==majorVersion set version_major=%%j
|
||||
IF %%i==minorVersion set version_minor=%%j
|
||||
IF %%i==maintenanceVersion set version_maintenance=%%j
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -69,49 +83,118 @@ 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 commitCount=%%i
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
:: Get remote url repository
|
||||
::
|
||||
IF NOT %errlvl% == "1" (
|
||||
|
||||
set new_version=%version_major%,%version_minor%,0,%version_revision%
|
||||
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!/commit/
|
||||
) ELSE (
|
||||
set commitURL=!commitURL!/commits/
|
||||
)
|
||||
|
||||
) 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!/commit/
|
||||
) ELSE (
|
||||
set commitURL=https://!commitURL!/commits/
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: Detect local modifications
|
||||
::
|
||||
SET localChanged=0
|
||||
set localChanged=0
|
||||
IF NOT %errlvl% == "1" (
|
||||
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO (
|
||||
SET localChanged=1
|
||||
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 version_modifed=+m
|
||||
)
|
||||
|
||||
::
|
||||
:: Update reapi_version.inc
|
||||
::
|
||||
echo #if defined _reapi_version_included>"%srcdir%\reapi_version.inc"
|
||||
echo #endinput>>"%srcdir%\reapi_version.inc"
|
||||
echo #endif>>"%srcdir%\reapi_version.inc"
|
||||
echo #define _reapi_version_included>>"%srcdir%\reapi_version.inc"
|
||||
|
||||
echo.>>"%srcdir%\reapi_version.inc"
|
||||
>>"%srcdir%\reapi_version.inc" echo // reapi version
|
||||
>>"%srcdir%\reapi_version.inc" echo #define REAPI_VERSION %version_major%%version_minor%%commitCount%
|
||||
>>"%srcdir%\reapi_version.inc" echo #define REAPI_VERSION_MAJOR %version_major%
|
||||
>>"%srcdir%\reapi_version.inc" echo #define REAPI_VERSION_MINOR %version_minor%
|
||||
|
||||
::
|
||||
:: Now form full version string like 1.0.0.1
|
||||
::
|
||||
|
||||
set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%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%
|
||||
echo Updating appversion.h and reapi_version.inc, 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 +205,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%,%version_maintenance%,%commitCount%
|
||||
echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintenance%.%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 +227,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
|
||||
|
@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", ""
|
||||
VALUE "FileDescription", "AMX Mod X module, using API regamedll & rehlds"
|
||||
VALUE "FileVersion", APP_VERSION_STRD_RC
|
||||
VALUE "FileVersion", APP_VERSION_STRD
|
||||
VALUE "InternalName", "Reapi"
|
||||
VALUE "LegalCopyright", ""
|
||||
VALUE "OriginalFilename", "reapi_amxx.dll"
|
||||
VALUE "ProductName", "Reapi"
|
||||
VALUE "ProductVersion", APP_VERSION_STRD_RC
|
||||
VALUE "ProductVersion", APP_VERSION_STRD
|
||||
#if APP_VERSION_FLAGS != 0x0L
|
||||
VALUE "SpecialBuild", APP_VERSION_SPECIALBUILD
|
||||
#endif
|
||||
|
@ -216,6 +216,7 @@
|
||||
<ClInclude Include="..\src\precompiled.h" />
|
||||
<ClInclude Include="..\src\reapi_utils.h" />
|
||||
<ClInclude Include="..\src\type_conversion.h" />
|
||||
<ClInclude Include="..\version\appversion.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">
|
||||
@ -259,6 +260,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\reapi_utils.cpp" />
|
||||
<ClCompile Include="..\src\sdk_util.cpp" />
|
||||
<ClCompile Include="..\version\version.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="reapi.rc" />
|
||||
@ -272,7 +274,7 @@
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_addons.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\reapi_test.sma" />
|
||||
<None Include="..\src\reapi_version.inc" />
|
||||
<None Include="..\version\reapi_version.inc" />
|
||||
<None Include="reapi.def" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
@ -55,6 +55,9 @@
|
||||
<Filter Include="src\mods">
|
||||
<UniqueIdentifier>{669b4426-091f-4cac-9281-f5585a2922fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="version">
|
||||
<UniqueIdentifier>{60b1b924-8415-4c1d-9fef-57e717e12f42}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\metamod\dllapi.h">
|
||||
@ -660,6 +663,9 @@
|
||||
<ClInclude Include="..\src\type_conversion.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\version\appversion.h">
|
||||
<Filter>version</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">
|
||||
@ -740,6 +746,9 @@
|
||||
<ClCompile Include="..\src\natives\natives_addons.cpp">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\version\version.cpp">
|
||||
<Filter>version</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi.inc">
|
||||
@ -764,12 +773,12 @@
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_addons.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\src\reapi_version.inc">
|
||||
<Filter>src</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\cssdk_const.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\version\reapi_version.inc">
|
||||
<Filter>version</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="reapi.rc" />
|
||||
|
@ -10,8 +10,8 @@ plugin_info_t Plugin_info =
|
||||
{
|
||||
META_INTERFACE_VERSION, // ifvers
|
||||
"ReAPI", // name
|
||||
APP_VERSION_STRD, // version
|
||||
APP_VERSION_YMD_STR, // date
|
||||
APP_VERSION, // version
|
||||
APP_COMMIT_DATE, // date
|
||||
"Asmodai & s1lent", // author
|
||||
"https://github.com/s1lentq/reapi/", // url
|
||||
"ReAPI", // logtag, all caps please
|
||||
|
@ -1,8 +0,0 @@
|
||||
#if defined _reapi_version_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _reapi_version_included
|
||||
|
||||
// reapi version
|
||||
#define REAPI_VERSION_MAJOR 5
|
||||
#define REAPI_VERSION_MINOR 0
|
@ -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.asMavenVersionC()
|
||||
\#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__
|
||||
|
9
reapi/version/reapi_version.vm
Normal file
9
reapi/version/reapi_version.vm
Normal file
@ -0,0 +1,9 @@
|
||||
\#if defined _reapi_version_included
|
||||
#endinput
|
||||
#endif
|
||||
\#define _reapi_version_included
|
||||
|
||||
// reapi version
|
||||
\#define REAPI_VERSION $verInfo.asReapiVersion()
|
||||
\#define REAPI_VERSION_MAJOR ${verInfo.majorVersion}
|
||||
\#define REAPI_VERSION_MINOR ${verInfo.minorVersion}
|
Loading…
x
Reference in New Issue
Block a user