mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-27 07:05:38 +03:00
Improved versioning: Added detection remote url repository.
Update PreBuild.bat
This commit is contained in:
parent
6d282d58e4
commit
9fd5eaa043
@ -7,7 +7,7 @@ Regamedll_CS is a result of reverse engineering of original library mods HLDS (b
|
||||
At the moment, the work of reverse engineering continues
|
||||
|
||||
## Goals of the project
|
||||
* Provide more stable (than official) version of Half-Life dedicated server with extended API for mods and plugins
|
||||
* Provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins
|
||||
|
||||
## How can use it?
|
||||
Regamedll_CS is fully compatible with official mod CS 1.6 by Valve. All you have to do is to download binaries and replace original mo.dll/cs.so
|
||||
|
@ -32,7 +32,8 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit
|
||||
authorCommit: gitInfo.authorCommit,
|
||||
urlCommits: gitInfo.urlCommits
|
||||
)
|
||||
} else {
|
||||
versionInfo = new RegamedllVersionInfo(
|
||||
@ -42,7 +43,8 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') {
|
||||
countCommit: gitInfo.countCommit,
|
||||
lastCommitDate: gitInfo.lastCommitDate,
|
||||
commitID: gitInfo.commitID,
|
||||
authorCommit: gitInfo.authorCommit
|
||||
authorCommit: gitInfo.authorCommit,
|
||||
urlCommits: gitInfo.urlCommits
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -12,4 +12,5 @@ class GitInfo {
|
||||
Integer countCommit
|
||||
String commitID
|
||||
String authorCommit
|
||||
String urlCommits
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import groovy.transform.TypeChecked
|
||||
import org.eclipse.jgit.api.Git
|
||||
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
|
||||
@ -38,6 +39,20 @@ class GitVersioner {
|
||||
|
||||
return null;
|
||||
}
|
||||
static String prepareUrlToCommits(String url) {
|
||||
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 {
|
||||
childPath = url.substring(0, url.lastIndexOf('.git'));
|
||||
}
|
||||
|
||||
sb.append(childPath).append('/commit/');
|
||||
return sb.toString();
|
||||
}
|
||||
static GitInfo versionForDir(File dir) {
|
||||
FileRepositoryBuilder builder = new FileRepositoryBuilder()
|
||||
Repository repo = builder.setWorkTree(dir)
|
||||
@ -49,6 +64,7 @@ class GitVersioner {
|
||||
return null
|
||||
}
|
||||
|
||||
final StoredConfig cfg = repo.getConfig();
|
||||
def commit = new RevWalk(repo).parseCommit(head)
|
||||
def commitLast = parseCommitLast(repo)
|
||||
int commitCount = getCountCommit(repo)
|
||||
@ -56,6 +72,11 @@ class GitVersioner {
|
||||
def branch = repo.getBranch()
|
||||
def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC)
|
||||
|
||||
String remote_name = cfg.getString("branch", branch, "remote");
|
||||
|
||||
String url = cfg.getString("remote", remote_name, "url");
|
||||
String urlCommits = prepareUrlToCommits(url);
|
||||
|
||||
if (!commit) {
|
||||
throw new RuntimeException("Can't find last commit.")
|
||||
}
|
||||
@ -70,7 +91,8 @@ class GitVersioner {
|
||||
tag: tag,
|
||||
countCommit: commitCount,
|
||||
commitID: headCommitId,
|
||||
authorCommit: authorCommit
|
||||
authorCommit: authorCommit,
|
||||
urlCommits: urlCommits
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class RegamedllVersionInfo {
|
||||
DateTime lastCommitDate
|
||||
String commitID
|
||||
String authorCommit
|
||||
String urlCommits
|
||||
|
||||
String format(String versionSeparator, String suffixSeparator, boolean includeSuffix) {
|
||||
StringBuilder sb = new StringBuilder()
|
||||
|
@ -107,7 +107,7 @@ void GameDLL_Version_f()
|
||||
// print version
|
||||
CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n");
|
||||
CONSOLE_ECHO("ReGameDLL API version %i.%i\n", REGAMEDLL_API_VERSION_MAJOR, REGAMEDLL_API_VERSION_MINOR);
|
||||
CONSOLE_ECHO("Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/" APP_COMMIT_ID " (" APP_COMMIT_AUTHOR ")\n");
|
||||
CONSOLE_ECHO("Build from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR "\n");
|
||||
}
|
||||
|
||||
void GameDLL_EndRound_f()
|
||||
|
@ -586,7 +586,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch
|
||||
{
|
||||
// search the place name where is located the player
|
||||
const char *placeName = NULL;
|
||||
if (TheBotPhrases != NULL)
|
||||
if (g_bIsCzeroGame && TheBotPhrases != NULL)
|
||||
{
|
||||
Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin);
|
||||
const BotPhraseList *placeList = TheBotPhrases->GetPlaceList();
|
||||
|
@ -2337,6 +2337,9 @@ int UTIL_ReadFlags(const char *c)
|
||||
// Determine whether bots can be used or not
|
||||
bool UTIL_AreBotsAllowed()
|
||||
{
|
||||
if (g_engfuncs.pfnEngCheckParm == NULL)
|
||||
return false;
|
||||
|
||||
if (g_bIsCzeroGame)
|
||||
{
|
||||
// If they pass in -nobots, don't allow bots. This is for people who host servers, to
|
||||
|
@ -1,21 +1,27 @@
|
||||
@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_version=
|
||||
set old_specialbuild=""
|
||||
SET version_revision=0
|
||||
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 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=
|
||||
|
||||
::
|
||||
:: Check for git.exe presence
|
||||
@ -29,8 +35,8 @@ 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_C set old_version=%%k
|
||||
IF %%j==APP_VERSION_SPECIALBUILD set old_specialbuild=%%k
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -40,7 +46,7 @@ IF %errlvl% == "1" (
|
||||
|
||||
:: if we haven't appversion.h, we need to create it
|
||||
IF NOT "%old_version%" == "" (
|
||||
SET version_revision=0
|
||||
set version_revision=0
|
||||
)
|
||||
)
|
||||
|
||||
@ -50,17 +56,17 @@ IF %errlvl% == "1" (
|
||||
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_SPECIALVERSION set version_specialversion=%%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==specialVersion set version_specialversion=%%j
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -82,13 +88,66 @@ IF NOT %errlvl% == "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
|
||||
)
|
||||
:: 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!
|
||||
)
|
||||
|
||||
IF [!url_commit!] == [] (
|
||||
|
||||
FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO (
|
||||
set url_commit=%%i
|
||||
)
|
||||
|
||||
:: strip .git
|
||||
if "x!url_commit:~-4!"=="x.git" (
|
||||
set url_commit=!url_commit:~0,-4!
|
||||
)
|
||||
:: append extra string
|
||||
set url_commit=!url_commit!/commit/
|
||||
) ELSE (
|
||||
:: strip .git
|
||||
if "x!url_commit:~-4!"=="x.git" (
|
||||
set url_commit=!url_commit:~0,-4!
|
||||
)
|
||||
:: replace : to /
|
||||
set url_commit=!url_commit::=/!
|
||||
:: append extra string
|
||||
set url_commit=https://!url_commit!/commit/
|
||||
)
|
||||
)
|
||||
|
||||
::
|
||||
:: 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
|
||||
)
|
||||
)
|
||||
|
||||
@ -140,11 +199,13 @@ IF "%version_specialversion%" == "" (
|
||||
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_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"
|
||||
|
||||
IF NOT "%version_specialbuild%" == "" (
|
||||
echo #define APP_VERSION_FLAGS VS_FF_SPECIALBUILD>>"%srcdir%\appversion.h"
|
||||
@ -163,6 +224,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
|
@ -10,8 +10,9 @@
|
||||
\#define VERSION_MAJOR ${verInfo.majorVersion}
|
||||
\#define VERSION_MINOR ${verInfo.minorVersion}
|
||||
|
||||
\#define APP_COMMIT_AUTHOR "${verInfo.authorCommit}"
|
||||
\#define APP_COMMIT_AUTHOR "(${verInfo.authorCommit})"
|
||||
\#define APP_COMMIT_ID "${verInfo.commitID}"
|
||||
\#define APP_COMMITS_URL "${verInfo.urlCommits}"
|
||||
|
||||
\#define APP_VERSION_D ${verInfo.format('.', '-', true)}
|
||||
\#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit}
|
||||
|
Loading…
Reference in New Issue
Block a user