makeWrapper: implement --inherit-argv0
For symmetry/interoperability with makeBinaryWrapper. Implemented as --argv0 '$0'
This commit is contained in:
parent
8b79ef2cb6
commit
2ae69114a1
@ -108,7 +108,7 @@ let
|
||||
hostprog_check_table);
|
||||
in
|
||||
[
|
||||
"--argv0" "$0" "--add-flags" (lib.escapeShellArgs flags)
|
||||
"--inherit-argv0" "--add-flags" (lib.escapeShellArgs flags)
|
||||
] ++ lib.optionals withRuby [
|
||||
"--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}"
|
||||
] ++ lib.optionals (binPath != "") [
|
||||
|
@ -237,10 +237,7 @@ let
|
||||
parseMakeCWrapperCall() {
|
||||
shift # makeCWrapper
|
||||
oldExe=$1; shift
|
||||
for arg do case $arg in
|
||||
--inherit-argv0) oldWrapperArgs+=(--argv0 '$0');; # makeWrapper doesn't understand --inherit-argv0
|
||||
*) oldWrapperArgs+=("$arg");;
|
||||
esac done
|
||||
oldWrapperArgs=("$@")
|
||||
}
|
||||
eval "parseMakeCWrapperCall ''${wrapperCmd//"${browser}"/"$out"}"
|
||||
rm "$executablePath"
|
||||
|
@ -32,7 +32,7 @@ let
|
||||
# All arguments besides the input and output binaries (${mpv}/bin/mpv and
|
||||
# $out/bin/mpv). These are used by the darwin specific makeWrapper call
|
||||
# used to wrap $out/Applications/mpv.app/Contents/MacOS/mpv as well.
|
||||
mostMakeWrapperArgs = lib.strings.escapeShellArgs ([ "--argv0" "'$0'"
|
||||
mostMakeWrapperArgs = lib.strings.escapeShellArgs ([ "--inherit-argv0"
|
||||
# These are always needed (TODO: Explain why)
|
||||
"--prefix" "LUA_CPATH" ";" "${mpv.luaEnv}/lib/lua/${mpv.lua.luaversion}/?.so"
|
||||
"--prefix" "LUA_PATH" ";" "${mpv.luaEnv}/share/lua/${mpv.lua.luaversion}/?.lua"
|
||||
@ -53,7 +53,7 @@ let
|
||||
)) ++ extraMakeWrapperArgs)
|
||||
;
|
||||
umpvWrapperArgs = lib.strings.escapeShellArgs ([
|
||||
"--argv0" "'$0'"
|
||||
"--inherit-argv0"
|
||||
"--set" "MPV" "${placeholder "out"}/bin/mpv"
|
||||
] ++ extraUmpvWrapperArgs)
|
||||
;
|
||||
|
@ -15,17 +15,17 @@ assertExecutable() {
|
||||
# makeWrapper EXECUTABLE OUT_PATH ARGS
|
||||
|
||||
# ARGS:
|
||||
# --argv0 NAME : set name of executed process to NAME
|
||||
# (otherwise it’s called …-wrapped)
|
||||
# --argv0 NAME : set the name of the executed process to NAME
|
||||
# (if unset or empty, defaults to EXECUTABLE)
|
||||
# --inherit-argv0 : the executable inherits argv0 from the wrapper.
|
||||
# (use instead of --argv0 '$0')
|
||||
# --set VAR VAL : add VAR with value VAL to the executable’s
|
||||
# environment
|
||||
# --set VAR VAL : add VAR with value VAL to the executable's environment
|
||||
# --set-default VAR VAL : like --set, but only adds VAR if not already set in
|
||||
# the environment
|
||||
# --unset VAR : remove VAR from the environment
|
||||
# --chdir DIR : change working directory (use instead of --run "cd DIR")
|
||||
# --add-flags FLAGS : add FLAGS to invocation of executable
|
||||
# TODO(@ncfavier): --append-flags
|
||||
|
||||
# --prefix ENV SEP VAL : suffix/prefix ENV with VAL, separated by SEP
|
||||
# --suffix
|
||||
@ -65,8 +65,6 @@ wrapProgramBinary() {
|
||||
hidden="${hidden}_"
|
||||
done
|
||||
mv "$prog" "$hidden"
|
||||
# Silence warning about unexpanded $0:
|
||||
# shellcheck disable=SC2016
|
||||
makeWrapper "$hidden" "$prog" --inherit-argv0 "${@:2}"
|
||||
}
|
||||
|
||||
|
@ -11,16 +11,18 @@ assertExecutable() {
|
||||
# makeWrapper EXECUTABLE OUT_PATH ARGS
|
||||
|
||||
# ARGS:
|
||||
# --argv0 NAME : set name of executed process to NAME
|
||||
# (otherwise it’s called …-wrapped)
|
||||
# --set VAR VAL : add VAR with value VAL to the executable’s
|
||||
# environment
|
||||
# --argv0 NAME : set the name of the executed process to NAME
|
||||
# (if unset or empty, defaults to EXECUTABLE)
|
||||
# --inherit-argv0 : the executable inherits argv0 from the wrapper.
|
||||
# (use instead of --argv0 '$0')
|
||||
# --set VAR VAL : add VAR with value VAL to the executable's environment
|
||||
# --set-default VAR VAL : like --set, but only adds VAR if not already set in
|
||||
# the environment
|
||||
# --unset VAR : remove VAR from the environment
|
||||
# --chdir DIR : change working directory (use instead of --run "cd DIR")
|
||||
# --run COMMAND : run command before the executable
|
||||
# --add-flags FLAGS : add FLAGS to invocation of executable
|
||||
# TODO(@ncfavier): --append-flags
|
||||
|
||||
# --prefix ENV SEP VAL : suffix/prefix ENV with VAL, separated by SEP
|
||||
# --suffix
|
||||
@ -166,6 +168,9 @@ makeShellWrapper() {
|
||||
elif [[ "$p" == "--argv0" ]]; then
|
||||
argv0="${params[$((n + 1))]}"
|
||||
n=$((n + 1))
|
||||
elif [[ "$p" == "--inherit-argv0" ]]; then
|
||||
# Whichever comes last of --argv0 and --inherit-argv0 wins
|
||||
argv0='$0'
|
||||
else
|
||||
die "makeWrapper doesn't understand the arg $p"
|
||||
fi
|
||||
@ -206,7 +211,5 @@ wrapProgramShell() {
|
||||
hidden="${hidden}_"
|
||||
done
|
||||
mv "$prog" "$hidden"
|
||||
# Silence warning about unexpanded $0:
|
||||
# shellcheck disable=SC2016
|
||||
makeWrapper "$hidden" "$prog" --argv0 '$0' "${@:2}"
|
||||
makeWrapper "$hidden" "$prog" --inherit-argv0 "${@:2}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user