Re: [PATCH 08/11] meson: simplify setup of PATH environment variable
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Jan 29, 2025, 20:42 UTC
- Message-ID
- <ujdktdisdk56ow3f2uudfgyh4lkya372wennuh7xsurbmylkgx@gh6p3l5hx3nf>
- In-Reply-To
- <20250129-b4-pks-meson-improvements-v1-8-ab709f0be12c@pks.im>
On 25/01/29 08:12AM, Patrick Steinhardt wrote:
Show 25 quoted lines
> We're setting up the PATH environment variable such that a set of
> necessary build tools can be found at build time. Make this step a bit
> less repetitive by only looping through the set of found programs once.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> meson.build | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 48eb068fd8..e3829f2365 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -181,22 +181,21 @@ if host_machine.system() == 'windows'
> program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
> endif
>
> +cat = find_program('cat', dirs: program_path)
> cygpath = find_program('cygpath', dirs: program_path, required: false)
> diff = find_program('diff', dirs: program_path)
> +git = find_program('git', dirs: program_path, required: false)
> +grep = find_program('grep', dirs: program_path)
> +sed = find_program('sed', dirs: program_path)
> shell = find_program('sh', dirs: program_path)
> tar = find_program('tar', dirs: program_path)At first I was curious to why we wouldn't just invoke `find_program()` during the loop as well, but some of these programs are not required and marked as such here.
Show 8 quoted lines
> script_environment = environment()
> -foreach tool : ['cat', 'grep', 'sed']
> - program = find_program(tool, dirs: program_path)
> - script_environment.prepend('PATH', fs.parent(program.full_path()))
> +foreach program : [cat, cygpath, diff, git, grep, sed, shell, tar]
> + if program.found()
> + script_environment.prepend('PATH', fs.parent(program.full_path()))
> + endifIt looks like cygpath, diff, shell, and tar were previously not being appended to the path environment. With this change now they are.
Show 15 quoted lines
> endforeach
> -
> -git = find_program('git', dirs: program_path, required: false)
> -if git.found()
> - script_environment.prepend('PATH', fs.parent(git.full_path()))
> -endif
> -
> if get_option('sane_tool_path') != ''
> script_environment.prepend('PATH', get_option('sane_tool_path'))
> endif
>
> --
> 2.48.1.362.g079036d154.dirty
>
>