meson: add a wrapper to bootstrap scripts from within build dir

This doesn't do quite as good of a job of "hiding away" the real script
as we did with autotools, but it satisfies the need for being able to
run scripts which depend on libmakepkg with the local copy within the
repo. We do, however, improve upon the autotools script by ensuring that
the bash path used in configuring pacman is the interpreter used to run
the underlying script.
This commit is contained in:
Dave Reisner 2018-10-28 02:42:53 -04:00
parent 51db84750e
commit d230ec6f17
4 changed files with 42 additions and 4 deletions

View file

@ -0,0 +1,6 @@
#!/bin/sh
built_script=$1
dest_path=$2
install -Dm755 "$built_script" "$DESTDIR/$dest_path"

6
build-aux/script-wrapper.sh.in Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
# This script serves as a trampoline for running scripts which depend on
# libmakepkg with the libmakepkg within the build tree.
LIBRARY=@BUILDDIR@/libmakepkg exec @BASH@ -$- @REAL_PROGPATH@ "$@"

View file

@ -33,6 +33,7 @@ SED = find_program('sed')
DU = find_program('du') DU = find_program('du')
LDCONFIG = get_option('ldconfig') LDCONFIG = get_option('ldconfig')
MESON_MAKE_SYMLINK = join_paths(meson.source_root(), 'build-aux/meson-make-symlink.sh') MESON_MAKE_SYMLINK = join_paths(meson.source_root(), 'build-aux/meson-make-symlink.sh')
MESON_INSTALL_SCRIPT = join_paths(meson.source_root(), 'build-aux/meson-install-script.sh')
BASH = find_program('bash4', 'bash') BASH = find_program('bash4', 'bash')
if BASH.found() if BASH.found()

View file

@ -24,14 +24,39 @@ m4_edit = generator(
capture : true) capture : true)
foreach script : scripts foreach script : scripts
custom_target( script_shortname = script.split('.')[0]
# Build the script, but don't install it. We want to keep it as a "private"
# artifact that we reference from a wrapper script in order to bootstrap it
# the build directory.
internal_script = custom_target(
script, script,
input : m4_edit.process(script), input : m4_edit.process(script),
command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@', '0755'], command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@', '0755'],
output : script.split('.')[0], output : script,
depend_files : library_files, depend_files : library_files,
install : true, build_by_default : true)
install_dir : get_option('bindir'))
# Create a wrapper script that bootstraps the real script within the build
# directory.
custom_target(
'wrap_@0@'.format(script_shortname),
input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'),
output : script_shortname,
build_by_default : true,
command : [
SED,
'-e', 's,@BASH@,"@0@",'.format(BASH.path()),
'-e', 's,@BUILDDIR@,"@0@",'.format(meson.current_build_dir()),
'-e', 's,@REAL_PROGPATH@,"@0@",'.format(internal_script.full_path()),
'@INPUT@',
],
capture : true)
# Install the real script
meson.add_install_script(MESON_INSTALL_SCRIPT,
internal_script.full_path(),
join_paths(BINDIR, script_shortname))
endforeach endforeach
foreach symlink : ['repo-remove', 'repo-elephant'] foreach symlink : ['repo-remove', 'repo-elephant']