Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson.build: ensure the project git directory is used #544

Open
wants to merge 1 commit into
base: bleeding
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/isdir.py

This file was deleted.

19 changes: 9 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ prefix = get_option('prefix')
localedir = get_option('localedir')

# Helper scripts
auxdir = join_paths(meson.current_source_dir(), 'ci')
isdir = join_paths(auxdir, 'isdir.py')

python3 = find_program('python3')
git = find_program('git', required: false)
git = find_program('git', required: false)

# Get the right version
fs = import('fs')

is_git_repo = run_command([isdir, '.git'], check: false).returncode() == 0
git_dir = join_paths(meson.current_source_dir(), '.git')
is_git_repo = fs.exists(git_dir)

version = 'v' + meson.project_version()
if git.found() and is_git_repo
git_version = run_command([git.full_path(), 'describe', '--dirty', '--tags'], check: false).stdout().strip()
branch = run_command([git.full_path(), 'rev-parse', '--abbrev-ref', 'HEAD'], check: false).stdout().strip()
git_version = run_command([git.full_path(), '--git-dir', git_dir, 'describe', '--dirty', '--tags'], check: false).stdout().strip()
branch = run_command([git.full_path(), '--git-dir', git_dir, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false).stdout().strip()
if branch == 'HEAD'
branch = run_command([git.full_path(), 'rev-parse', 'HEAD'], check: false).stdout().strip()
branch = run_command([git.full_path(), '--git-dir', git_dir, 'rev-parse', 'HEAD'], check: false).stdout().strip()
endif
if git_version != ''
version = git_version
endif
if branch != 'master'
default_branch = run_command([git.full_path(), '--git-dir', git_dir, 'config', '--default', 'master', '--get', 'init.defaultBranch']).stdout().strip()
if branch != default_branch
version = '@0@ (@1@)'.format(version, branch)
endif
endif
Expand Down