Skip to content

Commit 42846ef

Browse files
pks-tgitster
authored andcommitted
meson: improve handling of sane_tool_path option
The `sane_tool_path` option can be used to override the PATH variable from which the build process, tests and ultimately Git will end up picking programs from. It is currently lacking though because we only use it to populate the PATH environment variable for executed scripts and for the `BROKEN_PATH_FIX` mechanism, but we don't use it to find programs used in the build process itself. Fix this issue by treating it similar to the Windows-specific paths, which will make us use it both to find programs and to populate the PATH environment variable. To help with this fix, change the type of the option to be an array of paths, which makes the handling a bit easier for us. It's also the correct thing to do as the input indeed is a list of paths. Furthermore, the option now overrides the default behaviour on Windows, which si to pick up tools from Git for Windows. This is done so that it becomes easier to override that default behaviour in case it's not desired. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 454d79b commit 42846ef

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

meson.build

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ project('git', 'c',
191191
fs = import('fs')
192192

193193
program_path = []
194-
# Git for Windows provides all the tools we need to build Git.
195-
if host_machine.system() == 'windows'
196-
program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
194+
if get_option('sane_tool_path').length() != 0
195+
program_path = get_option('sane_tool_path')
196+
elif host_machine.system() == 'windows'
197+
# Git for Windows provides all the tools we need to build Git.
198+
program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
197199
endif
198200

199201
cygpath = find_program('cygpath', dirs: program_path, required: false)
@@ -212,10 +214,6 @@ foreach path : program_path
212214
script_environment.prepend('PATH', path)
213215
endforeach
214216

215-
if get_option('sane_tool_path') != ''
216-
script_environment.prepend('PATH', get_option('sane_tool_path'))
217-
endif
218-
219217
# The environment used by GIT-VERSION-GEN. Note that we explicitly override
220218
# environment variables that might be set by the user. This is by design so
221219
# that we always use whatever Meson has configured instead of what is present
@@ -671,8 +669,9 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
671669
build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
672670
build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
673671

674-
if get_option('sane_tool_path') != ''
675-
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
672+
if get_option('sane_tool_path').length() != 0
673+
sane_tool_path = (host_machine.system() == 'windows' ? ';' : ':').join(get_option('sane_tool_path'))
674+
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + sane_tool_path + '"|')
676675
else
677676
build_options_config.set_quoted('BROKEN_PATH_FIX', '/^\# @BROKEN_PATH_FIX@$/d')
678677
endif

meson_options.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ option('perl_cpan_fallback', type: 'boolean', value: true,
1313
description: 'Install bundled copies of CPAN modules that serve as a fallback in case the modules are not available on the system.')
1414
option('runtime_prefix', type: 'boolean', value: false,
1515
description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.')
16-
option('sane_tool_path', type: 'string', value: '',
17-
description: 'A colon-separated list of paths to prepend to PATH if your tools in /usr/bin are broken.')
16+
option('sane_tool_path', type: 'array', value: [],
17+
description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.')
1818

1919
# Build information compiled into Git and other parts like documentation.
2020
option('build_date', type: 'string', value: '',

0 commit comments

Comments
 (0)