Skip to content

Commit

Permalink
Update git_version generation tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Myaamori committed Nov 1, 2020
1 parent 31ac6ec commit c4d9f91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
endif
version_inc = include_directories('.')
version_h = custom_target('git_version.h',
command: [version_sh, meson.source_root(), '@OUTDIR@'],
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'])
Expand Down
8 changes: 7 additions & 1 deletion tools/version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$BuildRoot = $null
[string]$BuildRoot = $null,
[Parameter(Position = 1, Mandatory = $false)]
[string]$SourceRoot = $null
)

$lastSvnRevision = 6962
Expand All @@ -21,6 +23,10 @@ if ($BuildRoot -eq $null -or $BuildRoot.Trim() -eq "") {
}

# 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 $BuildRoot 'git_version.xml'

Expand Down
8 changes: 4 additions & 4 deletions tools/version.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
srcdir="$1"
destdir="$2"
builddir="$1"
srcdir="$2"

# If no git repo try to read from the existing git_version.h, for building from tarballs
version_h_path="${destdir}/git_version.h"
version_h_path="${builddir}/git_version.h"
if ! test -d "${srcdir}/.git"; then
if test -f "${version_h_path}"; then
while read line; do
Expand Down Expand Up @@ -66,7 +66,7 @@ export BUILD_GIT_VERSION_NUMBER="${git_revision}"
export BUILD_GIT_VERSION_STRING="${git_version_str}"
export VERSION_SOURCE="from git"

cat << EOF > "${destdir}/git_version.xml"
cat << EOF > "${builddir}/git_version.xml"
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
Expand Down

0 comments on commit c4d9f91

Please sign in to comment.