meson: generate git_version header in build root rather than within the source tree

fixes an issue where the windows version of the git version update script generated the header in a place where it couldn't be found by the include in version.cpp
This commit is contained in:
line0 2020-04-11 00:56:21 +02:00
parent f5621bc6a6
commit 5f06eb3376
2 changed files with 18 additions and 6 deletions

View File

@ -11,7 +11,7 @@ else
endif
version_inc = include_directories('.')
version_h = custom_target('git_version.h',
command: [version_sh, meson.source_root()],
command: [version_sh, meson.current_build_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'])

View File

@ -1,20 +1,32 @@
#!/usr/bin/env powershell
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$BuildRoot = $null
)
$lastSvnRevision = 6962
$lastSvnHash = '16cd907fe7482cb54a7374cd28b8501f138116be'
$defineNumberMatch = [regex] '^#define\s+(\w+)\s+(\d+)$'
$defineStringMatch = [regex] "^#define\s+(\w+)\s+[`"']?(.+?)[`"']?$"
$semVerMatch = [regex] 'v?(\d+)\.(\d+).(\d+)(?:-(\w+))?'
$repositoryRootPath = Join-Path $PSScriptRoot .. | Resolve-Path
if (!(git -C $repositoryRootPath rev-parse --is-inside-work-tree 2>$null)) {
throw "$repositoryRootPath is not a git repository"
}
$gitVersionHeaderPath = Join-Path $repositoryRootPath 'src' | Join-Path -ChildPath 'include' | Join-Path -ChildPath 'aegisub' `
| Join-Path -ChildPath 'git_version.h'
$gitVersionXmlPath = Join-Path $repositoryRootPath 'packages' | Join-Path -ChildPath 'win_installer' `
| Join-Path -ChildPath 'git_version.xml'
if ($BuildRoot -eq $null -or $BuildRoot.Trim() -eq "") {
$BuildRoot = $repositoryRootPath
}
# support legacy in-tree builds
if ([System.IO.Path]::GetFullPath([System.IO.Path]::Combine((pwd).Path, $BuildRoot)) -eq
[System.IO.Path]::GetFullPath([System.IO.Path]::Combine((pwd).Path, $repositoryRootPath))) {
$BuildRoot = Join-Path $repositoryRootPath 'build'
}
$gitVersionHeaderPath = Join-Path $BuildRoot 'git_version.h'
$gitVersionXmlPath = Join-Path $repositoryRootPath 'build' | Join-Path -ChildPath 'git_version.xml'
$version = @{}
if (Test-Path $gitVersionHeaderPath) {