meson: don't generate git_version.xml and don't regenerate git_version.h on windows

Also fix incorrect use of return outside function. Fixes #80
This commit is contained in:
Myaamori 2020-11-19 17:33:20 +00:00 committed by odrling
parent 68fecbff20
commit b36b81acd7
3 changed files with 6 additions and 34 deletions

View File

@ -24,7 +24,7 @@ version_h = custom_target('git_version.h',
command: [version_sh, meson.current_build_dir(), meson.current_source_dir()],
build_by_default: true,
build_always_stale: true, # has internal check whether target file will be refreshed
output: ['git_version.h', 'git_version.xml'])
output: ['git_version.h'])
if host_machine.system() == 'darwin' and get_option('build_osx_bundle')
prefix = meson.current_build_dir() / 'Aegisub.app' / 'Contents'

View File

@ -28,7 +28,6 @@ if ([System.IO.Path]::GetFullPath([System.IO.Path]::Combine((pwd).Path, $BuildRo
$BuildRoot = Join-Path $repositoryRootPath 'build'
}
$gitVersionHeaderPath = Join-Path $BuildRoot 'git_version.h'
$gitVersionXmlPath = Join-Path $BuildRoot 'git_version.xml'
$version = @{}
if (Test-Path $gitVersionHeaderPath) {
@ -50,6 +49,10 @@ $gitHash = git -C $repositoryRootPath rev-parse --short HEAD 2>$null
$gitVersionString = $gitRevision, $gitBranch, $gitHash -join '-'
$exactGitTag = git -C $repositoryRootPath describe --exact-match --tags 2>$null
if ($gitVersionString -eq $version['BUILD_GIT_VERSION_STRING']) {
exit 0
}
if ($exactGitTag -match $semVerMatch) {
$version['TAGGED_RELEASE'] = $true
$version['RESOURCE_BASE_VERSION'] = $Matches[1..3]
@ -85,19 +88,3 @@ $version.GetEnumerator() | %{
}
"#define $($_.Key) $($fmtValue)"
} | Out-File -FilePath $gitVersionHeaderPath -Encoding utf8
$gitVersionXml = [xml]@'
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GitVersionNumber></GitVersionNumber>
<GitVersionString></GitVersionString>
<ReleaseVersion></ReleaseVersion>
</PropertyGroup>
</Project>
'@
$gitVersionXml.Project.PropertyGroup.GitVersionNumber = $gitRevision.ToString()
$gitVersionXml.Project.PropertyGroup.GitVersionString = $gitVersionString
$gitVersionXml.Project.PropertyGroup.ReleaseVersion = $gitVersionString
$gitVersionXml.Save($gitVersionXmlPath)

View File

@ -11,8 +11,7 @@ if ! test -d "${srcdir}/.git"; then
export $2=$(echo $3 | sed 's/"//g')
done < "${version_h_path}"
if test x$BUILD_GIT_VERSION_NUMBER != x -a x$BUILD_GIT_VERSION_STRING != x; then
export VERSION_SOURCE="from cached git_version.h"
return 0
exit 0
else
echo "invalid git_version.h"
exit 2
@ -65,17 +64,3 @@ in
"${new_version_h}");;
*) echo "${new_version_h}" > "${version_h_path}"
esac
export BUILD_GIT_VERSION_NUMBER="${git_revision}"
export BUILD_GIT_VERSION_STRING="${git_version_str}"
export VERSION_SOURCE="from git"
cat << EOF > "${builddir}/git_version.xml"
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GitVersionNumber>${git_revision}</GitVersionNumber>
<GitVersionString>${git_version_str}</GitVersionString>
</PropertyGroup>
</Project>
EOF