Skip to content

Commit 454d79b

Browse files
pks-tgitster
authored andcommitted
meson: improve PATH handling
When locating programs required for the build we give some special treatment to Windows systems so that we know to also look up tools provided by a Git for Windows installation. This ensures that the build doesn't have any prerequisites other than Microsoft Visual Studio, Meson and Git for Windows. Consequently, some of the programs returned by `find_program()` may not be found via PATH, but via these extra directories. But while Meson can use these tools directly without any special treatment, any scripts that we execute may not be able to find those programs. To help them we thus prepend the directories of a subset of the found programs to PATH. This doesn't make much sense though: we don't need to prepend PATH for any program that was found via PATH, but we really only need to do so for programs located via the extraneous Windows-specific paths. So instead of prepending all programs paths, we really only need to prepend the Windows-specific paths. Adapt the code accordingly by only prepeding Windows-specific paths to PATH, which both simplifies the code and clarifies intent. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eee25bb commit 454d79b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

meson.build

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,19 @@ endif
198198

199199
cygpath = find_program('cygpath', dirs: program_path, required: false)
200200
diff = find_program('diff', dirs: program_path)
201+
git = find_program('git', dirs: program_path, required: false)
201202
shell = find_program('sh', dirs: program_path)
202203
tar = find_program('tar', dirs: program_path)
203204

204-
script_environment = environment()
205+
# Sanity-check that programs required for the build exist.
205206
foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
206-
program = find_program(tool, dirs: program_path)
207-
script_environment.prepend('PATH', fs.parent(program.full_path()))
207+
find_program(tool, dirs: program_path)
208208
endforeach
209209

210-
git = find_program('git', dirs: program_path, required: false)
211-
if git.found()
212-
script_environment.prepend('PATH', fs.parent(git.full_path()))
213-
endif
210+
script_environment = environment()
211+
foreach path : program_path
212+
script_environment.prepend('PATH', path)
213+
endforeach
214214

215215
if get_option('sane_tool_path') != ''
216216
script_environment.prepend('PATH', get_option('sane_tool_path'))

0 commit comments

Comments
 (0)