diff --git a/build.gradle b/build.gradle index 5e2bd13..b6f2efa 100644 --- a/build.gradle +++ b/build.gradle @@ -25,27 +25,27 @@ if (gitInfo && 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, - commitID: gitInfo.commitID, - authorCommit: gitInfo.authorCommit, - urlCommits: gitInfo.urlCommits + localChanges: gitInfo.localChanges, + commitDate: gitInfo.commitDate, + commitSHA: gitInfo.commitSHA, + commitURL: gitInfo.commitURL ) } else { versionInfo = new MetamodVersionInfo( majorVersion: project.majorVersion as int, minorVersion: project.minorVersion as int, - specialVersion: gitInfo ? project.specialVersion : "SNAPSHOT", - countCommit: gitInfo ? gitInfo.countCommit : 0, - lastCommitDate: gitInfo ? gitInfo.lastCommitDate : new DateTime(), - commitID: gitInfo ? gitInfo.commitID : "", - authorCommit: gitInfo ? gitInfo.authorCommit : "", - urlCommits: gitInfo ? gitInfo.urlCommits : "" + 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.metamodVersionInfo = versionInfo -project.version = versionInfo.asVersion() +project.version = versionInfo.asMavenVersion() apply from: 'publish.gradle' diff --git a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy b/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy index 74233c5..2dc0fb2 100644 --- a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy +++ b/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy @@ -4,49 +4,34 @@ import org.apache.velocity.Template import org.apache.velocity.VelocityContext import org.apache.velocity.app.Velocity import org.joda.time.format.DateTimeFormat -import versioning.MetamodVersionInfo class VelocityUtils { - static { - Properties p = new Properties(); + static { + Properties p = new Properties(); - p.setProperty("resource.loader", "class"); - p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); - p.setProperty("class.resource.loader.path", ""); + p.setProperty("resource.loader", "class"); + p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); + p.setProperty("class.resource.loader.path", ""); - p.setProperty("input.encoding", "UTF-8"); - p.setProperty("output.encoding", "UTF-8"); + p.setProperty("input.encoding", "UTF-8"); + p.setProperty("output.encoding", "UTF-8"); - Velocity.init(p); - } - static String renderTemplate(File tplFile, MetamodVersionInfo ctx) { - Template tpl = Velocity.getTemplate(tplFile.absolutePath) - if (!tpl) { - throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found") - } + Velocity.init(p); + } - def templateCtx = [ - verInfo: ctx - ] + static String renderTemplate(File tplFile, Map ctx) { + Template tpl = Velocity.getTemplate(tplFile.absolutePath) + if (!tpl) { + throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found") + } - def velocityContext = new VelocityContext(templateCtx) + def velocityContext = new VelocityContext(ctx) + velocityContext.put("_DateTimeFormat", DateTimeFormat) - if (ctx.specialVersion.length() > 0) { - velocityContext.put("appFlags", 0x0L) - velocityContext.put("formatSpecialVersion", "-" + ctx.specialVersion) - } else { - - velocityContext.put("appFlags", "VS_FF_SPECIALBUILD") - velocityContext.put("formatSpecialVersion", "") - } + def sw = new StringWriter() + tpl.merge(velocityContext, sw) - velocityContext.put("current_version", ctx.asVersion()) - velocityContext.put("_DateTimeFormat", DateTimeFormat) - - def sw = new StringWriter() - tpl.merge(velocityContext, sw) - - return sw.toString() - } + return sw.toString() + } } diff --git a/buildSrc/src/main/groovy/versioning/GitInfo.groovy b/buildSrc/src/main/groovy/versioning/GitInfo.groovy index 3a6a42d..e0ad38f 100644 --- a/buildSrc/src/main/groovy/versioning/GitInfo.groovy +++ b/buildSrc/src/main/groovy/versioning/GitInfo.groovy @@ -6,11 +6,11 @@ import org.joda.time.DateTime @CompileStatic @TypeChecked class GitInfo { - DateTime lastCommitDate + boolean localChanges + DateTime commitDate String branch String tag - Integer countCommit - String commitID - String authorCommit - String urlCommits + String commitSHA + String commitURL + Integer commitCount } diff --git a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy index 77f86c5..840ff66 100644 --- a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy +++ b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy @@ -1,8 +1,11 @@ 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 @@ -14,6 +17,7 @@ import org.joda.time.DateTimeZone @CompileStatic @TypeChecked class GitVersioner { + static GitInfo versionForDir(String dir) { versionForDir(new File(dir)) } @@ -26,22 +30,10 @@ class GitVersioner { return count; } - // return last commit excluding merge commit - static RevCommit parseCommitLast(Repository repo) { - Iterable commits = Git.wrap(repo).log().call() - for (RevCommit b : commits) { - if (b.getParents().length > 1) { // it's merge commit ignore it - continue; - } - return b; - } - - return null; - } static String prepareUrlToCommits(String url) { if (url == null) { // default remote url - return "https://bitbucket.org/rehlds/metamod/commits/"; + return "https://github.com/theAsmodai/metamod-r/commits/"; } StringBuilder sb = new StringBuilder(); @@ -61,27 +53,44 @@ class GitVersioner { } 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 uncommittedChanges = status.getUncommittedChanges(); + for(String uncommitted : uncommittedChanges) { + return true; + } + + return false; + } static GitInfo versionForDir(File dir) { - FileRepositoryBuilder builder = new FileRepositoryBuilder() + FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repo = builder.setWorkTree(dir) .findGitDir() .build() - ObjectId head = repo.resolve('HEAD') + ObjectId head = repo.resolve('HEAD'); if (!head) { return null } final StoredConfig cfg = repo.getConfig(); - def commit = new RevWalk(repo).parseCommit(head) - def commitLast = parseCommitLast(repo) - int commitCount = getCountCommit(repo) + def commit = new RevWalk(repo).parseCommit(head); + if (!commit) { + throw new RuntimeException("Can't find last commit."); + } - def branch = repo.getBranch() - def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC) + 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"); @@ -99,31 +108,18 @@ class GitVersioner { url = cfg.getString("remote", remote_name, "url"); } - println 'Debug: Start'; - println ' cfg: (' + cfg + ')'; - println ' branch: (' + branch + ')'; - println ' remote_name: (' + remote_name + ')'; - println ' url: (' + url + ')'; - println 'Debug: End'; - - String urlCommits = prepareUrlToCommits(url); - - if (!commit) { - throw new RuntimeException("Can't find last commit.") - } - + String commitURL = prepareUrlToCommits(url); String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key - String headCommitId = commit.getId().abbreviate(7).name(); - String authorCommit = commitLast.getAuthorIdent().getName(); + String commitSHA = commit.getId().abbreviate(7).name(); return new GitInfo( - lastCommitDate: commitDate, + localChanges: localChanges, + commitDate: commitDate, branch: branch, tag: tag, - countCommit: commitCount, - commitID: headCommitId, - authorCommit: authorCommit, - urlCommits: urlCommits + commitSHA: commitSHA, + commitURL: commitURL, + commitCount: getCountCommit(repo) ) } } diff --git a/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy b/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy index 95d11fc..1c3fea6 100644 --- a/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy +++ b/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy @@ -3,40 +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 MetamodVersionInfo { - int majorVersion - int minorVersion + Integer majorVersion + Integer minorVersion Integer maintenanceVersion - String specialVersion - Integer countCommit - DateTime lastCommitDate - String commitID - String authorCommit - String urlCommits + 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() { - StringBuilder sb = new StringBuilder() - sb.append(majorVersion).append('.' + minorVersion).append('.' + countCommit); - return sb; + 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 asMavenVersion() { - format('.', '-', true) + String asCommitTime() { + return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate); } } diff --git a/gradle.properties b/gradle.properties index 87892d5..ea3ef06 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=1 minorVersion=3 -specialVersion= +maintenanceVersion=0 diff --git a/metamod/build.gradle b/metamod/build.gradle index c8a1ec9..f619fb3 100644 --- a/metamod/build.gradle +++ b/metamod/build.gradle @@ -171,20 +171,26 @@ task generateAppVersion { def tplFile = project.file('version/appversion.vm') def renderedFile = project.file('version/appversion.h') + // check to up-to-date inputs.file tplFile inputs.file project.file('gradle.properties') outputs.file renderedFile - inputs.property('version', verInfo.asMavenVersion()) - inputs.property('lastCommitDate', verInfo.lastCommitDate.toString()) - println "##teamcity[buildNumber '" + verInfo.asVersion() + "']"; + // 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 content = VelocityUtils.renderTemplate(tplFile, verInfo) + def templateCtx = [ + verInfo: verInfo + ] + def content = VelocityUtils.renderTemplate(tplFile, templateCtx) renderedFile.delete() renderedFile.write(content, 'utf-8') - println 'The current Metamod version is ' + verInfo.asVersion().toString() + ', maven version is ' + verInfo.asMavenVersion().toString() + ', commit id: ' + verInfo.commitID.toString() + ', commit author: ' + verInfo.authorCommit.toString() + ', url: (' + verInfo.urlCommits.toString() + ')'; + println 'The current Metamod maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')'; } } diff --git a/metamod/msvc/PreBuild.bat b/metamod/msvc/PreBuild.bat index d456330..a6d2798 100644 --- a/metamod/msvc/PreBuild.bat +++ b/metamod/msvc/PreBuild.bat @@ -8,20 +8,24 @@ set srcdir=%~1 set repodir=%~2 set old_version= -set old_specialbuild="" -set version_revision=0 -set version_specialbuild= -set version_id_commit= -set version_author_commit= -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_pdate_2=%time:~0,2%-%time:~3,2%-%time:~6,2% -set version_pdate_2=%version_pdate_2: =% -set version_date=%version_pdate_1%__%version_pdate_2% set version_major=0 set version_minor=0 -set version_specialversion= -set url_commit= +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 @@ -35,8 +39,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:"=! + ) ) ) ) @@ -46,7 +53,7 @@ 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 ) ) @@ -58,7 +65,6 @@ IF EXIST "%srcdir%\version.h" ( 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 ) ) ) ELSE ( @@ -66,7 +72,6 @@ IF EXIST "%srcdir%\version.h" ( IF NOT [%%j] == [] ( IF %%i==majorVersion set version_major=%%j IF %%i==minorVersion set version_minor=%%j - IF %%i==specialVersion set version_specialversion=%%j ) ) ) @@ -75,79 +80,69 @@ 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 ) ) ) -:: -:: Now form full version string like 1.0.0.1 -:: - -set new_version=%version_major%,%version_minor%,0,%version_revision% - :: :: Get remote url repository :: IF NOT %errlvl% == "1" ( - set branch_name=master set branch_remote=origin - :: Get current branch - FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO ( - set branch_name=%%i - ) :: 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 url_commit=%%i - ) - :: Get author last no-merge commit - FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." log -1 --no-merges --pretty=format:%%an"') DO ( - set version_author_commit=%%i + set commitURL=%%i ) :: Get commit id FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO ( - set var=%%i - set version_id_commit=!var:~0,+7! + set shafull=%%i + set commitSHA=!shafull:~0,+7! ) - IF [!url_commit!] == [] ( + IF [!commitURL!] == [] ( FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO ( - set url_commit=%%i + set commitURL=%%i ) :: strip .git - if "x!url_commit:~-4!"=="x.git" ( - set url_commit=!url_commit:~0,-4! + if "x!commitURL:~-4!"=="x.git" ( + set commitURL=!commitURL:~0,-4! ) :: append extra string - If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( - set url_commit=!url_commit!/commits/ + If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" ( + set commitURL=!commitURL!/commits/ ) ELSE ( - set url_commit=!url_commit!/commit/ + set commitURL=!commitURL!/commit/ ) ) ELSE ( :: strip .git - if "x!url_commit:~-4!"=="x.git" ( - set url_commit=!url_commit:~0,-4! + if "x!commitURL:~-4!"=="x.git" ( + set commitURL=!commitURL:~0,-4! ) :: replace : to / - set url_commit=!url_commit::=/! + set commitURL=!commitURL::=/! :: append extra string - If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( - set url_commit=https://!url_commit!/commits/ + If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" ( + set commitURL=https://!commitURL!/commits/ ) ELSE ( - set url_commit=https://!url_commit!/commit/ + set commitURL=https://!commitURL!/commit/ ) ) ) @@ -163,25 +158,30 @@ IF NOT %errlvl% == "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 ) +:: +:: Now form full version string like 1.0.0.1 +:: + +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" @@ -192,40 +192,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 #define APP_VERSION_PDATE_STR "%version_pdate%">>"%srcdir%\appversion.h" -echo #define APP_VERSION_YMD_STR "%version_pdate_1%">>"%srcdir%\appversion.h" -echo.>>"%srcdir%\appversion.h" -echo #define APP_COMMIT_AUTHOR "(%version_author_commit%)">>"%srcdir%\appversion.h" -echo #define APP_COMMIT_ID "%version_id_commit%">>"%srcdir%\appversion.h" -echo #define APP_COMMITS_URL "%url_commit%">>"%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" @@ -238,4 +217,4 @@ copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp" endlocal :_exit -exit /B 0 \ No newline at end of file +exit /B 0 diff --git a/metamod/msvc/metamod.rc b/metamod/msvc/metamod.rc index c8d5bdf..8e2c052 100644 --- a/metamod/msvc/metamod.rc +++ b/metamod/msvc/metamod.rc @@ -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 "FileDescription", "Metamod Counter-Strike GameMod DLL" - VALUE "FileVersion", APP_VERSION_STRD_RC - VALUE "InternalName", "Metamod" - VALUE "LegalCopyright", "" + VALUE "Comments", "Metamod-r is fully reworked fork of original Metamod-p by Jussi Kivilinna. Metamod allows running multiple mod-like plugin DLLs, to add functionality or change the behavior of the running HLDS game mod." + VALUE "FileDescription", "Metamod-r Half-Life MOD DLL" + VALUE "FileVersion", APP_VERSION_STRD + VALUE "InternalName", "Metamod-r" + VALUE "LegalCopyright", "Copyright (c) 2017" VALUE "OriginalFilename", "metamod_mm.dll" VALUE "ProductName", "Metamod" - 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 - diff --git a/metamod/src/commands_meta.cpp b/metamod/src/commands_meta.cpp index 2bbd2c0..1f2f43e 100644 --- a/metamod/src/commands_meta.cpp +++ b/metamod/src/commands_meta.cpp @@ -115,8 +115,8 @@ void cmd_meta_version() } META_CONS("Metamod-r v%s, API (%s)", APP_VERSION_STRD, META_INTERFACE_VERSION); - META_CONS("Metamod-r build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")"); - META_CONS("Metamod-r from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR ""); + META_CONS("Metamod-r build: " __TIME__ " " __DATE__ ""); + META_CONS("Metamod-r from: " APP_COMMIT_URL APP_COMMIT_SHA ""); } // "meta version" client command. @@ -128,8 +128,8 @@ void client_meta_version(edict_t *pEntity) } META_CONS("Metamod-r v%s, API (%s)", APP_VERSION_STRD, META_INTERFACE_VERSION); - META_CONS("Metamod-r build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")"); - META_CONS("Metamod-r from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR ""); + META_CONS("Metamod-r build: " __TIME__ " " __DATE__ ""); + META_CONS("Metamod-r from: " APP_COMMIT_URL APP_COMMIT_SHA ""); } // "meta gpl" console command. diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp index fa62311..d6d1e7d 100644 --- a/metamod/src/metamod.cpp +++ b/metamod/src/metamod.cpp @@ -44,15 +44,15 @@ void metamod_startup() Q_snprintf(execFile, sizeof execFile, "%s/%s", g_config->directory(), EXEC_CFG); META_CONS(" "); - META_CONS(" Metamod-r version %s Copyright (c) 2016-2017 ReHlds Team (rebuild of original Metamod by Will Day)", APP_VERSION_STRD); + META_CONS(" Metamod-r version %s Copyright (c) 2016-2017 ReHLDS Team (rebuild of original Metamod by Will Day and Jussi Kivilinna)", APP_VERSION_STRD); META_CONS(" Metamod-r comes with ABSOLUTELY NO WARRANTY; for details type `meta gpl'."); META_CONS(" This is free software, and you are welcome to redistribute it"); META_CONS(" under certain conditions; type `meta gpl' for details."); META_CONS(" "); META_CONS("Metamod-r v%s, API (%s)", APP_VERSION_STRD, META_INTERFACE_VERSION); - META_CONS("Metamod-r build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")"); - META_CONS("Metamod-r from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR ""); + META_CONS("Metamod-r build: " __TIME__ " " __DATE__ ""); + META_CONS("Metamod-r from: " APP_COMMIT_URL APP_COMMIT_SHA ""); // Get gamedir, very early on, because it seems we need it all over the // place here at the start. diff --git a/metamod/version/appversion.vm b/metamod/version/appversion.vm index e726c69..1b8fbf6 100644 --- a/metamod/version/appversion.vm +++ b/metamod/version/appversion.vm @@ -7,25 +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_COMMIT_AUTHOR "(${verInfo.authorCommit})" -\#define APP_COMMIT_ID "${verInfo.commitID}" -\#define APP_COMMITS_URL "${verInfo.urlCommits}" +\#define APP_COMMIT_DATE "$verInfo.asCommitDate("yyyy-MM-dd")" +\#define APP_COMMIT_TIME "$verInfo.asCommitTime()" -\#define APP_VERSION_D ${verInfo.format('.', '-', true)} -\#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit} - -\#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__