Compare commits
3 Commits
84d67d9709
...
c4d2431cb0
| Author | SHA1 | Date | |
|---|---|---|---|
| c4d2431cb0 | |||
| 67d24d69f5 | |||
| 4a4c51d124 |
@@ -354,9 +354,10 @@ void PrintFullUsageExamples()
|
|||||||
_T(" gitver nuitkabuild=<pid> [repodir=<path>可选] [-test可选] [params=\"<mainPy> <nuitka参数>\"可选]\n")
|
_T(" gitver nuitkabuild=<pid> [repodir=<path>可选] [-test可选] [params=\"<mainPy> <nuitka参数>\"可选]\n")
|
||||||
_T(" gitver nuitkapydbuild=<pid> [repodir=<path>可选] [-test可选] [params=\"<modulePy> <nuitka参数>\"可选]\n")
|
_T(" gitver nuitkapydbuild=<pid> [repodir=<path>可选] [-test可选] [params=\"<modulePy> <nuitka参数>\"可选]\n")
|
||||||
_T(" gitver pyinstaller=<pid> [repodir=<path>可选] [-test可选] [params=\"<mainPy|specFile> <pyinstaller参数>\"可选]\n")
|
_T(" gitver pyinstaller=<pid> [repodir=<path>可选] [-test可选] [params=\"<mainPy|specFile> <pyinstaller参数>\"可选]\n")
|
||||||
_T(" gitver -setup=0|1 [pid] [repodir=<path>可选] [-test可选]\n")
|
_T(" gitver setup=n [pid=m可选] [repodir=<path>可选] [-test可选]\n")
|
||||||
_T(" -setup=0: 使用 Inno Setup 脚本 (setup.iss)\n")
|
_T(" setup=0: 使用 Inno Setup 脚本 (setup.iss)\n")
|
||||||
_T(" -setup=1: 使用 NSIS 脚本 (setup.nsh)\n")
|
_T(" setup=1: 使用 NSIS 脚本 (setup.nsi)\n")
|
||||||
|
_T(" 不指定 pid 时自动从 .rc / AssemblyInfo.cs / version_info.txt 读取版本\n")
|
||||||
_T("\n示例:\n")
|
_T("\n示例:\n")
|
||||||
_T(" gitver\n")
|
_T(" gitver\n")
|
||||||
_T(" gitver rewrite\n")
|
_T(" gitver rewrite\n")
|
||||||
@@ -377,8 +378,9 @@ void PrintFullUsageExamples()
|
|||||||
_T(" gitver pyinstaller=5 params=\"myapp.spec\"\n")
|
_T(" gitver pyinstaller=5 params=\"myapp.spec\"\n")
|
||||||
_T(" gitver pyinstaller=5 -test params=\"myapp.spec\"\n")
|
_T(" gitver pyinstaller=5 -test params=\"myapp.spec\"\n")
|
||||||
_T(" gitver pyinstaller=5 repodir=E:\\Code\\MyPyProj params=\"myapp.spec\"\n")
|
_T(" gitver pyinstaller=5 repodir=E:\\Code\\MyPyProj params=\"myapp.spec\"\n")
|
||||||
_T(" gitver -setup=0 5\n")
|
_T(" gitver setup=0\n")
|
||||||
_T(" gitver -setup=1 5 repodir=E:\\Code\\MyProj\n")
|
_T(" gitver setup=0 pid=5\n")
|
||||||
|
_T(" gitver setup=1 pid=5 repodir=E:\\Code\\MyProj\n")
|
||||||
_T("params: 传递给 Nuitka/PyInstaller 的参数(含入口文件),用双引号括起来,如 params=\"main.py --standalone --output-dir=dist\"。\n")
|
_T("params: 传递给 Nuitka/PyInstaller 的参数(含入口文件),用双引号括起来,如 params=\"main.py --standalone --output-dir=dist\"。\n")
|
||||||
_T("-test: 将产品版本号的 major 和 minor 都置为 0(用于测试版本构建)。\n")
|
_T("-test: 将产品版本号的 major 和 minor 都置为 0(用于测试版本构建)。\n")
|
||||||
_T("无参数时会读取当前分支最近三次 tag,并提示选择 major 加 1 或 minor 加 1,然后创建新 tag。\n")
|
_T("无参数时会读取当前分支最近三次 tag,并提示选择 major 加 1 或 minor 加 1,然后创建新 tag。\n")
|
||||||
@@ -484,7 +486,7 @@ LPCTSTR GetExitCodeHint(int nRetCode)
|
|||||||
case 35:
|
case 35:
|
||||||
return _T("rewrite version file failed");
|
return _T("rewrite version file failed");
|
||||||
case 36:
|
case 36:
|
||||||
return _T("setup: unsupported -setup value");
|
return _T("setup: unsupported setup value");
|
||||||
case 37:
|
case 37:
|
||||||
return _T("setup: setup script not found");
|
return _T("setup: setup script not found");
|
||||||
case 38:
|
case 38:
|
||||||
@@ -631,35 +633,6 @@ int HandleSetVerCommand(int argc, TCHAR* argv[])
|
|||||||
_tprintf(_T("ProductVersion=%s\n"), strProductVersion.GetString());
|
_tprintf(_T("ProductVersion=%s\n"), strProductVersion.GetString());
|
||||||
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
||||||
|
|
||||||
// 检查是否附带了 -setup=N 标志
|
|
||||||
int nSetupType = -1;
|
|
||||||
for (int i = 2; i < argc; ++i)
|
|
||||||
{
|
|
||||||
CString strArg = argv[i];
|
|
||||||
if (strArg.GetLength() > 7 && strArg.Left(7).CompareNoCase(_T("-setup=")) == 0)
|
|
||||||
{
|
|
||||||
UINT nVal = 0;
|
|
||||||
if (!TryParseUInt16(strArg.Mid(7), nVal) || (nVal != 0 && nVal != 1))
|
|
||||||
{
|
|
||||||
_tprintf(_T("错误: -setup 参数值 \"%s\" 不支持,仅支持 0(Inno Setup)或 1(NSIS)。\n"),
|
|
||||||
strArg.Mid(7).GetString());
|
|
||||||
return 36;
|
|
||||||
}
|
|
||||||
nSetupType = (int)nVal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nSetupType >= 0)
|
|
||||||
{
|
|
||||||
// -setup=N 存在:不回写版本信息到项目文件,只修改安装脚本并编译
|
|
||||||
if (!ExecuteSetupBuild(nSetupType, strProductVersion, strFileVersion))
|
|
||||||
{
|
|
||||||
return 38;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RewriteSetVerByProjectType(lpRepoPath, strProductVersion, strFileVersion);
|
return RewriteSetVerByProjectType(lpRepoPath, strProductVersion, strFileVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,12 +896,12 @@ int main(int argc, TCHAR* argv[], TCHAR* envp[])
|
|||||||
return nCmdRet;
|
return nCmdRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 2 && _tcsnicmp(argv[1], _T("-setup="), 7) == 0)
|
if (argc >= 2 && _tcsnicmp(argv[1], _T("setup="), 6) == 0)
|
||||||
{
|
{
|
||||||
DWORD dwStartTick = LogCommandStart(_T("-setup"));
|
DWORD dwStartTick = LogCommandStart(_T("setup"));
|
||||||
int nCmdRet = HandleSetupCommand(argc, argv);
|
int nCmdRet = HandleSetupCommand(argc, argv);
|
||||||
LogCommandEnd(_T("-setup"), dwStartTick, nCmdRet);
|
LogCommandEnd(_T("setup"), dwStartTick, nCmdRet);
|
||||||
PrintCommandFailedWithCode(_T("-setup"), nCmdRet);
|
PrintCommandFailedWithCode(_T("setup"), nCmdRet);
|
||||||
return nCmdRet;
|
return nCmdRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,6 @@ int ParseSetVerOptions(int argc, TCHAR* argv[], int nStartIndex, LPCTSTR& lpRepo
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -setup=N 由调用方单独处理,此处静默跳过
|
|
||||||
if (strArg.GetLength() > 7 && strArg.Left(7).CompareNoCase(_T("-setup=")) == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strArg.GetLength() > 8 && strArg.Left(8).CompareNoCase(_T("repodir=")) == 0)
|
if (strArg.GetLength() > 8 && strArg.Left(8).CompareNoCase(_T("repodir=")) == 0)
|
||||||
{
|
{
|
||||||
if (lpRepoPath != NULL)
|
if (lpRepoPath != NULL)
|
||||||
|
|||||||
@@ -462,6 +462,125 @@ static BOOL UpdateVersionInfoFile(LPCTSTR lpPath, LPCTSTR lpProductVersion, LPCT
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查 spec 文件中 version= 是否为无引号标识符(表示 spec 内内联 VSVersionInfo 对象)
|
||||||
|
static BOOL HasInlineVersionInfoBlock(LPCTSTR lpSpecPath)
|
||||||
|
{
|
||||||
|
if (!PathFileExists(lpSpecPath)) return FALSE;
|
||||||
|
|
||||||
|
CFile myFile;
|
||||||
|
CFileException fileEx;
|
||||||
|
if (!myFile.Open(lpSpecPath, CFile::modeRead, &fileEx)) return FALSE;
|
||||||
|
|
||||||
|
DWORD dwLen = (DWORD)myFile.GetLength();
|
||||||
|
std::vector<char> buf(dwLen + 1, 0);
|
||||||
|
myFile.Read(buf.data(), dwLen);
|
||||||
|
myFile.Close();
|
||||||
|
|
||||||
|
std::string strContent(buf.data(), dwLen);
|
||||||
|
std::string::size_type nPos = 0;
|
||||||
|
while ((nPos = strContent.find("version=", nPos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
bool bIsParam = (nPos == 0
|
||||||
|
|| strContent[nPos - 1] == '\n'
|
||||||
|
|| strContent[nPos - 1] == '\r'
|
||||||
|
|| strContent[nPos - 1] == ' '
|
||||||
|
|| strContent[nPos - 1] == '\t');
|
||||||
|
if (bIsParam)
|
||||||
|
{
|
||||||
|
std::string::size_type nValStart = nPos + 8;
|
||||||
|
while (nValStart < strContent.size() && strContent[nValStart] == ' ')
|
||||||
|
nValStart++;
|
||||||
|
if (nValStart < strContent.size())
|
||||||
|
{
|
||||||
|
char c = strContent[nValStart];
|
||||||
|
// 无引号且以字母或下划线开头,视为 Python 标识符
|
||||||
|
if (c != '\'' && c != '"' && (isalpha((unsigned char)c) || c == '_'))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nPos += 8;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改 spec 文件中 version= 的引号值(内联版本号字符串场景)
|
||||||
|
// 当 version= 后是非外部文件路径的字符串字面量时,直接替换该值为新版本号
|
||||||
|
static BOOL UpdateVersionStringInSpec(LPCTSTR lpSpecPath, LPCTSTR lpNewValue)
|
||||||
|
{
|
||||||
|
if (!PathFileExists(lpSpecPath))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: spec 文件不存在: %s\n"), lpSpecPath);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFile myFile;
|
||||||
|
CFileException fileEx;
|
||||||
|
if (!myFile.Open(lpSpecPath, CFile::modeReadWrite, &fileEx))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 无法打开 spec 文件: %s\n"), lpSpecPath);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwLen = (DWORD)myFile.GetLength();
|
||||||
|
std::vector<char> buf(dwLen + 1, 0);
|
||||||
|
myFile.Read(buf.data(), dwLen);
|
||||||
|
myFile.Close();
|
||||||
|
|
||||||
|
std::string strContent(buf.data(), dwLen);
|
||||||
|
CStringA strNewValueA(lpNewValue);
|
||||||
|
std::string strNewValue(strNewValueA);
|
||||||
|
|
||||||
|
std::string::size_type nPos = 0;
|
||||||
|
bool bUpdated = false;
|
||||||
|
while ((nPos = strContent.find("version=", nPos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
bool bIsParam = (nPos == 0
|
||||||
|
|| strContent[nPos - 1] == '\n'
|
||||||
|
|| strContent[nPos - 1] == '\r'
|
||||||
|
|| strContent[nPos - 1] == ' '
|
||||||
|
|| strContent[nPos - 1] == '\t');
|
||||||
|
if (bIsParam)
|
||||||
|
{
|
||||||
|
std::string::size_type nValStart = nPos + 8; // skip "version="
|
||||||
|
while (nValStart < strContent.size() && strContent[nValStart] == ' ')
|
||||||
|
nValStart++;
|
||||||
|
if (nValStart < strContent.size())
|
||||||
|
{
|
||||||
|
char cQuote = strContent[nValStart];
|
||||||
|
if (cQuote == '\'' || cQuote == '"')
|
||||||
|
{
|
||||||
|
std::string::size_type nValEnd = strContent.find(cQuote, nValStart + 1);
|
||||||
|
if (nValEnd != std::string::npos)
|
||||||
|
{
|
||||||
|
strContent.replace(nValStart + 1, nValEnd - nValStart - 1, strNewValue);
|
||||||
|
bUpdated = true;
|
||||||
|
_tprintf(_T("成功: 已更新 spec 内联版本号 -> %s\n"), lpNewValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nPos += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bUpdated)
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 未在 spec 文件中找到可替换的 version= 引号值。\n"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!myFile.Open(lpSpecPath, CFile::modeCreate | CFile::modeWrite, &fileEx))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 无法写入 spec 文件: %s\n"), lpSpecPath);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
myFile.Write(strContent.c_str(), (UINT)strContent.size());
|
||||||
|
myFile.Close();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int HandlePyinstallerBuildCommand(int argc, TCHAR* argv[])
|
int HandlePyinstallerBuildCommand(int argc, TCHAR* argv[])
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -535,19 +654,43 @@ int HandlePyinstallerBuildCommand(int argc, TCHAR* argv[])
|
|||||||
CString strExistingVersionPath;
|
CString strExistingVersionPath;
|
||||||
if (ReadVersionPathFromSpec(strSpecPath, strExistingVersionPath))
|
if (ReadVersionPathFromSpec(strSpecPath, strExistingVersionPath))
|
||||||
{
|
{
|
||||||
// spec 已有 version=,直接更新所指向的文件(不存在则创建)
|
// spec 已有 version=,解析其指向的文件路径
|
||||||
CString strVersionInfoFullPath;
|
CString strVersionInfoFullPath;
|
||||||
if (PathIsRelative(strExistingVersionPath))
|
if (PathIsRelative(strExistingVersionPath))
|
||||||
strVersionInfoFullPath.Format(_T("%s\\%s"), szSpecDir, strExistingVersionPath.GetString());
|
strVersionInfoFullPath.Format(_T("%s\\%s"), szSpecDir, strExistingVersionPath.GetString());
|
||||||
else
|
else
|
||||||
strVersionInfoFullPath = strExistingVersionPath;
|
strVersionInfoFullPath = strExistingVersionPath;
|
||||||
|
|
||||||
if (!UpdateVersionInfoFile(strVersionInfoFullPath, strProductVersion, strFileVersion))
|
if (PathFileExists(strVersionInfoFullPath))
|
||||||
{
|
{
|
||||||
_tprintf(_T("错误: 无法更新版本信息文件: %s。\n"), strVersionInfoFullPath.GetString());
|
// 外部版本信息文件存在,直接更新
|
||||||
|
if (!UpdateVersionInfoFile(strVersionInfoFullPath, strProductVersion, strFileVersion))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 无法更新版本信息文件: %s。\n"), strVersionInfoFullPath.GetString());
|
||||||
|
return 45;
|
||||||
|
}
|
||||||
|
_tprintf(_T("版本信息文件已更新: %s\n"), strVersionInfoFullPath.GetString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// version= 后的值不是有效的外部文件路径,视为 spec 内联版本号定义,直接修改 spec
|
||||||
|
_tprintf(_T("版本信息文件未找到(%s),将修改 spec 内联版本号。\n"), strVersionInfoFullPath.GetString());
|
||||||
|
if (!UpdateVersionStringInSpec(strSpecPath, strFileVersion))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 无法修改 spec 文件内联版本号。\n"));
|
||||||
|
return 46;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (HasInlineVersionInfoBlock(strSpecPath))
|
||||||
|
{
|
||||||
|
// spec 中 version=<标识符>,标识符指向 spec 内定义的 VSVersionInfo 对象,直接更新 spec 文件中的版本字段
|
||||||
|
if (!UpdateVersionInfoFile(strSpecPath, strProductVersion, strFileVersion))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 无法更新 spec 内联版本块: %s。\n"), strSpecPath.GetString());
|
||||||
return 45;
|
return 45;
|
||||||
}
|
}
|
||||||
_tprintf(_T("版本信息文件已更新: %s\n"), strVersionInfoFullPath.GetString());
|
_tprintf(_T("spec 内联版本块已更新: %s\n"), strSpecPath.GetString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ BOOL WriteTextFileAsAnsi(LPCTSTR lpFile, const std::string& strContent, const st
|
|||||||
|
|
||||||
void PrintInvalidRepoPathError(LPCTSTR lpRepoPath);
|
void PrintInvalidRepoPathError(LPCTSTR lpRepoPath);
|
||||||
int ParseSetVerOptions(int argc, TCHAR* argv[], int nStartIndex, LPCTSTR& lpRepoPath, BOOL& bTestMode);
|
int ParseSetVerOptions(int argc, TCHAR* argv[], int nStartIndex, LPCTSTR& lpRepoPath, BOOL& bTestMode);
|
||||||
|
BOOL FindPreferredCppRcFileAt(LPCTSTR lpBaseDir, CString& strResFile);
|
||||||
|
BOOL FindPreferredAssemblyInfoFileAt(LPCTSTR lpBaseDir, CString& strResFile);
|
||||||
|
BOOL FindFirstFileByPatternRecursive(LPCTSTR lpBaseDir, LPCTSTR lpPattern, CString& strFoundPath);
|
||||||
|
|
||||||
static const UINT DEFAULT_MAJOR_WHEN_NO_TAG_FOR_SETUP = 1;
|
static const UINT DEFAULT_MAJOR_WHEN_NO_TAG_FOR_SETUP = 1;
|
||||||
static const UINT DEFAULT_MINOR_WHEN_NO_TAG_FOR_SETUP = 0;
|
static const UINT DEFAULT_MINOR_WHEN_NO_TAG_FOR_SETUP = 0;
|
||||||
@@ -246,7 +249,105 @@ static CString FindNsisCompiler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
// 公共执行函数(供 HandleSetupCommand 和 setver -setup=N 共用)
|
// 从项目文件读取版本号(当 setup=n 未指定 pid 时使用)
|
||||||
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从 strContent 中查找 strToken 之后第一个双引号括起来的值。
|
||||||
|
/// </summary>
|
||||||
|
static CString ExtractQuotedValueAfterToken(const std::string& strContent, const std::string& strToken)
|
||||||
|
{
|
||||||
|
std::string::size_type nPos = strContent.find(strToken);
|
||||||
|
if (nPos == std::string::npos)
|
||||||
|
return CString();
|
||||||
|
|
||||||
|
std::string::size_type nStart = strContent.find('"', nPos + strToken.size());
|
||||||
|
if (nStart == std::string::npos)
|
||||||
|
return CString();
|
||||||
|
++nStart;
|
||||||
|
|
||||||
|
std::string::size_type nEnd = strContent.find('"', nStart);
|
||||||
|
if (nEnd == std::string::npos)
|
||||||
|
return CString();
|
||||||
|
|
||||||
|
return CString(strContent.substr(nStart, nEnd - nStart).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从 .rc / AssemblyInfo.cs / version_info.txt / .spec 文件中读取版本号字符串。
|
||||||
|
/// 优先顺序:.rc > AssemblyInfo.cs > version_info.txt/.spec。
|
||||||
|
/// </summary>
|
||||||
|
static BOOL ReadVersionFromProjectFiles(LPCTSTR lpBaseDir, CString& strVersion)
|
||||||
|
{
|
||||||
|
strVersion.Empty();
|
||||||
|
std::string strContent, strBomPrefix;
|
||||||
|
|
||||||
|
// 1. .rc 文件 -> VALUE "FileVersion", "x.x.x.x"
|
||||||
|
CString strRcFile;
|
||||||
|
if (FindPreferredCppRcFileAt(lpBaseDir, strRcFile))
|
||||||
|
{
|
||||||
|
if (ReadTextFileAsAnsi(strRcFile, strContent, strBomPrefix))
|
||||||
|
{
|
||||||
|
CString strVal = ExtractQuotedValueAfterToken(strContent, "VALUE \"FileVersion\",");
|
||||||
|
if (!strVal.IsEmpty())
|
||||||
|
{
|
||||||
|
strVersion = strVal;
|
||||||
|
_tprintf(_T("从 .rc 文件读取版本号: %s\n"), strVersion.GetString());
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. AssemblyInfo.cs -> AssemblyFileVersion("x.x.x.x")
|
||||||
|
CString strAiFile;
|
||||||
|
if (FindPreferredAssemblyInfoFileAt(lpBaseDir, strAiFile))
|
||||||
|
{
|
||||||
|
if (ReadTextFileAsAnsi(strAiFile, strContent, strBomPrefix))
|
||||||
|
{
|
||||||
|
CString strVal = ExtractQuotedValueAfterToken(strContent, "AssemblyFileVersion(");
|
||||||
|
if (!strVal.IsEmpty())
|
||||||
|
{
|
||||||
|
strVersion = strVal;
|
||||||
|
_tprintf(_T("从 AssemblyInfo.cs 读取版本号: %s\n"), strVersion.GetString());
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. version_info.txt / .spec -> filevers=(x, x, x, x)
|
||||||
|
CString strSpecFile;
|
||||||
|
CString strBaseWithSlash = lpBaseDir;
|
||||||
|
if (!strBaseWithSlash.IsEmpty() && strBaseWithSlash.Right(1) != _T("\\"))
|
||||||
|
strBaseWithSlash += _T("\\");
|
||||||
|
if (FindFirstFileByPatternRecursive(strBaseWithSlash, _T("version_info.txt"), strSpecFile) ||
|
||||||
|
FindFirstFileByPatternRecursive(strBaseWithSlash, _T("*.spec"), strSpecFile))
|
||||||
|
{
|
||||||
|
if (ReadTextFileAsAnsi(strSpecFile, strContent, strBomPrefix))
|
||||||
|
{
|
||||||
|
std::string::size_type nPos = strContent.find("filevers=(");
|
||||||
|
if (nPos != std::string::npos)
|
||||||
|
{
|
||||||
|
nPos += 10;
|
||||||
|
std::string::size_type nEnd = strContent.find(')', nPos);
|
||||||
|
if (nEnd != std::string::npos)
|
||||||
|
{
|
||||||
|
std::string strTuple = strContent.substr(nPos, nEnd - nPos);
|
||||||
|
std::string strClean;
|
||||||
|
for (char c : strTuple)
|
||||||
|
if (c != ' ') strClean += (c == ',' ? '.' : c);
|
||||||
|
strVersion = CString(strClean.c_str());
|
||||||
|
_tprintf(_T("从 version_info.txt/.spec 读取版本号: %s\n"), strVersion.GetString());
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────
|
||||||
|
// 公共执行函数
|
||||||
// 不回写版本信息到项目文件,只修改安装脚本并调用编译器打包。
|
// 不回写版本信息到项目文件,只修改安装脚本并调用编译器打包。
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -318,7 +419,7 @@ BOOL ExecuteSetupBuild(int nSetupType, const CString& strProductVersion, const C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
// 独立命令入口(argv[1] 形如 "-setup=0")
|
// 独立命令入口(argv[1] 形如 "setup=0")
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
int HandleSetupCommand(int argc, TCHAR* argv[])
|
int HandleSetupCommand(int argc, TCHAR* argv[])
|
||||||
@@ -326,73 +427,119 @@ int HandleSetupCommand(int argc, TCHAR* argv[])
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Sleep(15000);
|
Sleep(15000);
|
||||||
#endif
|
#endif
|
||||||
// 解析 -setup=n 中的 n
|
// 解析 setup=n 中的 n
|
||||||
CString strSetupArg = argv[1];
|
CString strSetupArg = argv[1];
|
||||||
CString strN = strSetupArg.Mid(7); // 跳过 "-setup="
|
CString strN = strSetupArg.Mid(6); // 跳过 "setup="
|
||||||
UINT nSetupType = UINT(-1);
|
UINT nSetupType = UINT(-1);
|
||||||
if (!TryParseUInt16(strN, nSetupType) || (nSetupType != 0 && nSetupType != 1))
|
if (!TryParseUInt16(strN, nSetupType) || (nSetupType != 0 && nSetupType != 1))
|
||||||
{
|
{
|
||||||
_tprintf(_T("错误: -setup 参数值 \"%s\" 不支持,仅支持 0(Inno Setup)或 1(NSIS)。\n"),
|
_tprintf(_T("错误: setup 参数值 \"%s\" 不支持,仅支持 0(Inno Setup)或 1(NSIS)。\n"),
|
||||||
strN.GetString());
|
strN.GetString());
|
||||||
return 36;
|
return 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3)
|
// 解析可选的 pid=m、repodir=、-test
|
||||||
|
LPCTSTR lpRepoPath = NULL;
|
||||||
|
BOOL bTestMode = FALSE;
|
||||||
|
BOOL bHasPid = FALSE;
|
||||||
|
UINT nPid = 0;
|
||||||
|
|
||||||
|
for (int i = 2; i < argc; ++i)
|
||||||
{
|
{
|
||||||
_tprintf(_T("错误: 参数不足。\n"));
|
CString strArg = argv[i];
|
||||||
_tprintf(_T("用法:gitver -setup=0|1 [pid] [repodir=<path>可选]\n"));
|
if (strArg.CompareNoCase(_T("-test")) == 0)
|
||||||
_tprintf(_T("示例:gitver -setup=0 5\n"));
|
{
|
||||||
_tprintf(_T("示例:gitver -setup=1 5 repodir=E:\\Code\\MyProj\n"));
|
bTestMode = TRUE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strArg.GetLength() > 8 && strArg.Left(8).CompareNoCase(_T("repodir=")) == 0)
|
||||||
|
{
|
||||||
|
if (lpRepoPath != NULL)
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: repodir 参数重复: %s\n"), argv[i]);
|
||||||
|
return 23;
|
||||||
|
}
|
||||||
|
LPCTSTR lpPath = argv[i] + 8;
|
||||||
|
if (!PathIsDirectory(lpPath))
|
||||||
|
{
|
||||||
|
PrintInvalidRepoPathError(lpPath);
|
||||||
|
return 23;
|
||||||
|
}
|
||||||
|
lpRepoPath = lpPath;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strArg.GetLength() > 4 && strArg.Left(4).CompareNoCase(_T("pid=")) == 0)
|
||||||
|
{
|
||||||
|
if (bHasPid)
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: pid 参数重复: %s\n"), argv[i]);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
CString strPid = strArg.Mid(4);
|
||||||
|
if (!TryParseUInt16(strPid, nPid))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: pid 参数值 \"%s\" 无效,应为 0-65535 范围整数。\n"), strPid.GetString());
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
bHasPid = TRUE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_tprintf(_T("错误: 多余的参数 %s\n"), argv[i]);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT nPid = 0;
|
if (lpRepoPath == NULL)
|
||||||
int nArgRet = ParseUInt16ArgOrError(argv, 2, _T("pid"), nPid, 4);
|
|
||||||
if (nArgRet != 0)
|
|
||||||
{
|
{
|
||||||
return nArgRet;
|
lpRepoPath = g_szCurModuleDir;
|
||||||
}
|
|
||||||
|
|
||||||
LPCTSTR lpRepoPath = NULL;
|
|
||||||
BOOL bTestMode = FALSE;
|
|
||||||
int nRepoArgRet = ParseSetVerOptions(argc, argv, 3, lpRepoPath, bTestMode);
|
|
||||||
if (nRepoArgRet != 0)
|
|
||||||
{
|
|
||||||
return nRepoArgRet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CString strFileVersion;
|
CString strFileVersion;
|
||||||
CString strProductVersion;
|
CString strProductVersion;
|
||||||
VersionBuildErrorCodes errorCodes = { 5, 6, 9 };
|
|
||||||
int nVersionRet = BuildVersionsFromRepo(
|
|
||||||
lpRepoPath,
|
|
||||||
nPid,
|
|
||||||
errorCodes,
|
|
||||||
strProductVersion,
|
|
||||||
strFileVersion,
|
|
||||||
DEFAULT_MAJOR_WHEN_NO_TAG_FOR_SETUP,
|
|
||||||
DEFAULT_MINOR_WHEN_NO_TAG_FOR_SETUP);
|
|
||||||
|
|
||||||
if (nVersionRet != 0)
|
if (bHasPid)
|
||||||
{
|
{
|
||||||
return nVersionRet;
|
// 从 git 仓库生成版本号
|
||||||
}
|
VersionBuildErrorCodes errorCodes = { 5, 6, 9 };
|
||||||
|
int nVersionRet = BuildVersionsFromRepo(
|
||||||
if (bTestMode)
|
lpRepoPath,
|
||||||
{
|
nPid,
|
||||||
int nDot1 = strProductVersion.Find(_T('.'));
|
errorCodes,
|
||||||
int nDot2 = (nDot1 >= 0) ? strProductVersion.Find(_T('.'), nDot1 + 1) : -1;
|
strProductVersion,
|
||||||
if (nDot2 > nDot1)
|
strFileVersion,
|
||||||
|
DEFAULT_MAJOR_WHEN_NO_TAG_FOR_SETUP,
|
||||||
|
DEFAULT_MINOR_WHEN_NO_TAG_FOR_SETUP);
|
||||||
|
if (nVersionRet != 0)
|
||||||
{
|
{
|
||||||
strProductVersion = strProductVersion.Left(nDot2 + 1) + _T("0.0");
|
return nVersionRet;
|
||||||
}
|
}
|
||||||
_tprintf(_T("[测试版本] 已将 major/minor 置零: ProductVersion=%s\n"), strProductVersion.GetString());
|
|
||||||
|
if (bTestMode)
|
||||||
|
{
|
||||||
|
int nDot1 = strProductVersion.Find(_T('.'));
|
||||||
|
int nDot2 = (nDot1 >= 0) ? strProductVersion.Find(_T('.'), nDot1 + 1) : -1;
|
||||||
|
if (nDot2 > nDot1)
|
||||||
|
{
|
||||||
|
strProductVersion = strProductVersion.Left(nDot2 + 1) + _T("0.0");
|
||||||
|
}
|
||||||
|
_tprintf(_T("[测试版本] 已将 major/minor 置零: ProductVersion=%s\n"), strProductVersion.GetString());
|
||||||
|
}
|
||||||
|
|
||||||
|
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
||||||
|
_tprintf(_T("ProductVersion=%s\n"), strProductVersion.GetString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 从项目文件读取版本号
|
||||||
|
if (!ReadVersionFromProjectFiles(lpRepoPath, strFileVersion))
|
||||||
|
{
|
||||||
|
_tprintf(_T("错误: 未找到 .rc、AssemblyInfo.cs 或 version_info.txt/.spec 文件,无法读取版本号。\n"));
|
||||||
|
_tprintf(_T("请使用 pid=m 参数指定产品 ID 以从 git 仓库生成版本号。\n"));
|
||||||
|
return 35;
|
||||||
|
}
|
||||||
|
strProductVersion = strFileVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tprintf(_T("FileVersion=%s\n"), strFileVersion.GetString());
|
// 修改安装脚本并编译打包
|
||||||
_tprintf(_T("ProductVersion=%s\n"), strProductVersion.GetString());
|
|
||||||
|
|
||||||
// 不回写版本信息到项目文件,直接修改安装脚本并编译打包
|
|
||||||
if (!ExecuteSetupBuild((int)nSetupType, strProductVersion, strFileVersion))
|
if (!ExecuteSetupBuild((int)nSetupType, strProductVersion, strFileVersion))
|
||||||
{
|
{
|
||||||
return 38;
|
return 38;
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
BOOL ExecuteSetupBuild(int nSetupType, const CString& strProductVersion, const CString& strFileVersion);
|
BOOL ExecuteSetupBuild(int nSetupType, const CString& strProductVersion, const CString& strFileVersion);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理独立的 -setup=n 命令行入口。
|
/// 处理独立的 setup=n 命令行入口。
|
||||||
/// 退出码:0 成功,36 -setup 值不支持,37 未找到脚本,
|
/// 退出码:0 成功,36 setup 值不支持,37 未找到脚本,
|
||||||
/// 38 修改脚本失败,39 未找到编译器,其他同通用错误码。
|
/// 38 修改脚本失败,39 未找到编译器,其他同通用错误码。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int HandleSetupCommand(int argc, TCHAR* argv[]);
|
int HandleSetupCommand(int argc, TCHAR* argv[]);
|
||||||
|
|||||||
76
README.md
76
README.md
@@ -13,7 +13,7 @@ gitver setver=<pid> [repodir=<path>] [-test] [-setup=0|1]
|
|||||||
gitver nuitkabuild=<pid> [repodir=<path>] [-test] [params="<mainPy> <nuitka参数>"]
|
gitver nuitkabuild=<pid> [repodir=<path>] [-test] [params="<mainPy> <nuitka参数>"]
|
||||||
gitver nuitkapydbuild=<pid> [repodir=<path>] [-test] [params="<modulePy> <nuitka参数>"]
|
gitver nuitkapydbuild=<pid> [repodir=<path>] [-test] [params="<modulePy> <nuitka参数>"]
|
||||||
gitver pyinstaller=<pid> [repodir=<path>] [-test] [params="<mainPy|specFile> <pyinstaller参数>"]
|
gitver pyinstaller=<pid> [repodir=<path>] [-test] [params="<mainPy|specFile> <pyinstaller参数>"]
|
||||||
gitver -setup=0|1 <pid> [repodir=<path>] [-test]
|
gitver setup=n [pid=m] [repodir=<path>] [-test]
|
||||||
```
|
```
|
||||||
|
|
||||||
**通用参数说明:**
|
**通用参数说明:**
|
||||||
@@ -94,7 +94,7 @@ gitver rewrite -f
|
|||||||
从 Git 仓库读取 tag,生成产品版本号与文件版本号,并按源码类型自动回写。
|
从 Git 仓库读取 tag,生成产品版本号与文件版本号,并按源码类型自动回写。
|
||||||
|
|
||||||
```
|
```
|
||||||
gitver setver=<pid> [repodir=<path>] [-test] [-setup=0|1]
|
gitver setver=<pid> [repodir=<path>] [-test]
|
||||||
```
|
```
|
||||||
|
|
||||||
**版本号生成规则:**
|
**版本号生成规则:**
|
||||||
@@ -102,26 +102,12 @@ gitver setver=<pid> [repodir=<path>] [-test] [-setup=0|1]
|
|||||||
- `ProductVersion = pid.bid.major.minor`(取当前分支前缀的最新 tag)
|
- `ProductVersion = pid.bid.major.minor`(取当前分支前缀的最新 tag)
|
||||||
- `FileVersion = pid.yy.mmdd.id`(id = 当天当前分支提交次数)
|
- `FileVersion = pid.yy.mmdd.id`(id = 当天当前分支提交次数)
|
||||||
|
|
||||||
**`-setup=N` 标志(打包模式):**
|
|
||||||
|
|
||||||
存在 `-setup=N` 时,**不回写**版本信息到项目文件,改为:
|
|
||||||
1. 在 exe 目录或上级目录查找安装脚本
|
|
||||||
2. 修改脚本中的版本号字段
|
|
||||||
3. 调用对应编译器打包
|
|
||||||
|
|
||||||
| 值 | 脚本文件 | 编译器 |
|
|
||||||
|---|---|---|
|
|
||||||
| `0` | `setup.iss` | Inno Setup(`ISCC.exe`) |
|
|
||||||
| `1` | `setup.nsi` | NSIS(`makensis.exe`) |
|
|
||||||
|
|
||||||
**示例:**
|
**示例:**
|
||||||
|
|
||||||
```
|
```
|
||||||
gitver setver=5
|
gitver setver=5
|
||||||
gitver setver=5 repodir=E:\Code\OTH\gitver
|
gitver setver=5 repodir=E:\Code\OTH\gitver
|
||||||
gitver setver=5 -test
|
gitver setver=5 -test
|
||||||
gitver setver=5 -setup=0
|
|
||||||
gitver setver=5 repodir=E:\Code\MyProj -setup=1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**输出示例:**
|
**输出示例:**
|
||||||
@@ -215,14 +201,23 @@ gitver pyinstaller=<pid> [repodir=<path>] [-test] [params="<mainPy|specFile> <py
|
|||||||
python -m PyInstaller <params>
|
python -m PyInstaller <params>
|
||||||
```
|
```
|
||||||
|
|
||||||
版本号照常从 Git tag 计算并输出,但 PyInstaller 本身不接受 `--windows-product-version` 等命令行参数。如需将版本信息嵌入 EXE,建议在 `.spec` 文件中通过 `version=` 字段或外部 version resource 文件实现。
|
版本号照常从 Git tag 计算并输出。在 **spec 模式**下,gitver 会在调用 PyInstaller 前自动将版本号写入版本信息,具体行为取决于 spec 文件中 `version=` 字段的值:
|
||||||
|
|
||||||
|
| spec 中 `version=` 的值 | 行为 |
|
||||||
|
|---|---|
|
||||||
|
| `'version_info.txt'`(引号路径,文件存在) | 就地更新外部版本信息文件 |
|
||||||
|
| `'1.2.3.4'`(引号字符串,非有效文件路径) | 替换 spec 内该引号字符串为新版本号 |
|
||||||
|
| `version_info`(无引号标识符,spec 内定义的 VSVersionInfo 对象) | 就地更新 spec 文件内的版本字段 |
|
||||||
|
| 无 `version=` / `version=None` | 在 spec 目录生成 `version_info.txt` 并自动注入 `version='version_info.txt'` |
|
||||||
|
|
||||||
|
在 **脚本模式**(`.py` 入口)下,PyInstaller 不接受命令行版本参数,版本号仅输出到控制台,不嵌入 EXE。
|
||||||
|
|
||||||
**两种打包模式:**
|
**两种打包模式:**
|
||||||
|
|
||||||
| 模式 | 参数示例 | 说明 |
|
| 模式 | 参数示例 | 说明 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 脚本模式 | `params="main.py"` | 由 PyInstaller 自动生成 spec 并打包 |
|
| 脚本模式 | `params="main.py"` | 由 PyInstaller 自动生成 spec 并打包 |
|
||||||
| spec 模式 | `params="myapp.spec"` | 使用已有 spec 文件,打包配置完全由 spec 控制,`params=` 仅适用于路径类运行时选项(`--distpath` 等) |
|
| spec 模式 | `params="myapp.spec"` | 使用已有 spec 文件,打包配置完全由 spec 控制;gitver 在调用 PyInstaller 前**自动将版本号写入版本信息**(见下表) |
|
||||||
|
|
||||||
**示例:**
|
**示例:**
|
||||||
|
|
||||||
@@ -247,19 +242,26 @@ FileVersion=5.26.0519.3
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### `gitver -setup=0|1`(独立打包命令)
|
### `gitver setup=n`(独立打包命令)
|
||||||
|
|
||||||
独立调用安装脚本打包,不依赖 `setver=` 命令。
|
独立调用安装脚本打包,不依赖其他命令。
|
||||||
|
|
||||||
```
|
```
|
||||||
gitver -setup=0|1 <pid> [repodir=<path>] [-test]
|
gitver setup=n [pid=m] [repodir=<path>] [-test]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
| 参数 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| `n` | 安装脚本类型,`0`=Inno Setup(`setup.iss`),`1`=NSIS(`setup.nsi`) |
|
||||||
|
| `pid=m` | 可选,产品 ID(整数 0-65535);不指定时自动从项目的 `.rc`、`AssemblyInfo.cs` 或 `.spec` 文件中读取版本信息 |
|
||||||
|
|
||||||
**示例:**
|
**示例:**
|
||||||
|
|
||||||
```
|
```
|
||||||
gitver -setup=0 5
|
gitver setup=0
|
||||||
gitver -setup=1 5 repodir=E:\Code\MyProj
|
gitver setup=1
|
||||||
|
gitver setup=0 pid=5
|
||||||
|
gitver setup=1 pid=5 repodir=E:\Code\MyProj
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -459,7 +461,7 @@ VSVersionInfo(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
> `version_info.txt` 中的版本号需与实际构建版本保持一致。如需自动同步,可在构建脚本中先调用 `gitver setver=<pid>` 获取版本,再用脚本替换 `version_info.txt` 中的版本字段,然后执行 `gitver pyinstaller=<pid> params="myapp.spec"`。
|
> 在 spec 模式下,gitver 会在调用 PyInstaller 前自动将计算出的版本号写入版本信息,无需手动维护 `version_info.txt`。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -491,7 +493,7 @@ VSVersionInfo(
|
|||||||
| 33 | 无参数模式下创建 tag 失败 |
|
| 33 | 无参数模式下创建 tag 失败 |
|
||||||
| 34 | 无参数模式下创建 tag 后校验失败 |
|
| 34 | 无参数模式下创建 tag 后校验失败 |
|
||||||
| 35 | 未找到可回写目标文件,或回写失败 |
|
| 35 | 未找到可回写目标文件,或回写失败 |
|
||||||
| 36 | `-setup=` 值不支持(仅支持 0 和 1) |
|
| 36 | `setup=` 值不支持(仅支持 0 和 1) |
|
||||||
| 37 | 未找到安装脚本(setup.iss / setup.nsi) |
|
| 37 | 未找到安装脚本(setup.iss / setup.nsi) |
|
||||||
| 38 | 修改安装脚本失败 |
|
| 38 | 修改安装脚本失败 |
|
||||||
| 39 | 未找到安装编译器(ISCC.exe / makensis.exe) |
|
| 39 | 未找到安装编译器(ISCC.exe / makensis.exe) |
|
||||||
@@ -500,6 +502,8 @@ VSVersionInfo(
|
|||||||
| 42 | `pyinstaller=` 无法根据分支名计算 bid |
|
| 42 | `pyinstaller=` 无法根据分支名计算 bid |
|
||||||
| 43 | `pyinstaller=` 读取 tag 失败 |
|
| 43 | `pyinstaller=` 读取 tag 失败 |
|
||||||
| 44 | `pyinstaller=` 获取当天分支提交次数失败 |
|
| 44 | `pyinstaller=` 获取当天分支提交次数失败 |
|
||||||
|
| 45 | `pyinstaller=` 版本信息文件无法生成或更新 |
|
||||||
|
| 46 | `pyinstaller=` spec 文件无法注入或修改版本信息 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -576,12 +580,15 @@ gitver pyinstaller=5 params="main.py --onefile --name=MyApp"
|
|||||||
# 预期: 额外参数传递给 PyInstaller
|
# 预期: 额外参数传递给 PyInstaller
|
||||||
```
|
```
|
||||||
|
|
||||||
### 验证 `-setup=`
|
### 验证 `setup=`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 确保 exe 目录或上级目录有 setup.iss
|
# 确保 exe 目录或上级目录有 setup.iss
|
||||||
gitver setver=5 -setup=0
|
gitver setup=0
|
||||||
# 预期: 修改 setup.iss 中的版本号并调用 ISCC.exe 编译
|
# 预期: 从 .rc 或 AssemblyInfo.cs 读取版本号,修改 setup.iss 并调用 ISCC.exe 编译
|
||||||
|
|
||||||
|
gitver setup=0 pid=5
|
||||||
|
# 预期: 使用 pid=5 生成版本号,修改 setup.iss 并调用 ISCC.exe 编译
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -604,8 +611,6 @@ gitver setver=5 -setup=0
|
|||||||
| `gitver setver=5` | 0 |
|
| `gitver setver=5` | 0 |
|
||||||
| `gitver setver=5 -test` | 0 |
|
| `gitver setver=5 -test` | 0 |
|
||||||
| `gitver setver=5 repodir=E:\NotExists` | 23 |
|
| `gitver setver=5 repodir=E:\NotExists` | 23 |
|
||||||
| `gitver setver=5 -setup=0` | 0 / 37 / 38 / 39 |
|
|
||||||
| `gitver setver=5 -setup=9` | 36 |
|
|
||||||
| `gitver setver=abc` | 4 |
|
| `gitver setver=abc` | 4 |
|
||||||
|
|
||||||
### nuitkabuild= 组
|
### nuitkabuild= 组
|
||||||
@@ -641,6 +646,17 @@ gitver setver=5 -setup=0
|
|||||||
| `gitver pyinstaller=5` | 0 |
|
| `gitver pyinstaller=5` | 0 |
|
||||||
| `gitver pyinstaller=abc params="main.py"` | 41 |
|
| `gitver pyinstaller=abc params="main.py"` | 41 |
|
||||||
|
|
||||||
|
### setup= 组
|
||||||
|
|
||||||
|
| 命令 | 预期返回码 |
|
||||||
|
|---|---|
|
||||||
|
| `gitver setup=0` | 0 / 37 / 38 / 39 |
|
||||||
|
| `gitver setup=1` | 0 / 37 / 38 / 39 |
|
||||||
|
| `gitver setup=0 pid=5` | 0 / 37 / 38 / 39 |
|
||||||
|
| `gitver setup=0 pid=5 repodir=E:\NotExists` | 23 |
|
||||||
|
| `gitver setup=9` | 36 |
|
||||||
|
| `gitver setup=0 pid=abc` | 4 |
|
||||||
|
|
||||||
> **注意**:如果打包时提示“未找到安装编译器(ISCC.exe / makensis.exe)”,请手动下载安装对应工具,并将其可执行文件路径(如 `ISCC.exe` 或 `makensis.exe` 所在目录)添加到系统环境变量 `PATH`。常见下载地址:
|
> **注意**:如果打包时提示“未找到安装编译器(ISCC.exe / makensis.exe)”,请手动下载安装对应工具,并将其可执行文件路径(如 `ISCC.exe` 或 `makensis.exe` 所在目录)添加到系统环境变量 `PATH`。常见下载地址:
|
||||||
>
|
>
|
||||||
> - Inno Setup: https://jrsoftware.org/isinfo.php
|
> - Inno Setup: https://jrsoftware.org/isinfo.php
|
||||||
|
|||||||
Reference in New Issue
Block a user