mirror of
https://github.com/Homebrew/brew.git
synced 2024-11-25 16:33:34 +08:00
Improve VS Code debugger support
This commit is contained in:
parent
bbe3584168
commit
842b4ac3d3
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -3,9 +3,18 @@
|
|||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"type": "rdbg",
|
"type": "rdbg",
|
||||||
"name": "Attach with rdbg",
|
"name": "Debug Homebrew command",
|
||||||
|
"request": "launch",
|
||||||
|
"rdbgPath": "${workspaceFolder}/Library/Homebrew/shims/gems/rdbg",
|
||||||
|
"command": "brew debugger --",
|
||||||
|
"script": "${fileBasenameNoExtension}",
|
||||||
|
"askParameters": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "rdbg",
|
||||||
|
"name": "Attach to Homebrew debugger",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"rdbgPath": "${workspaceFolder}/Library/Homebrew/vendor/portable-ruby/current/lib/ruby/gems/3.3.0/gems/debug-1.9.1/exe/rdbg",
|
"rdbgPath": "${workspaceFolder}/Library/Homebrew/shims/gems/rdbg",
|
||||||
"env": {
|
"env": {
|
||||||
"TMPDIR": "/private/tmp/",
|
"TMPDIR": "/private/tmp/",
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ module Homebrew
|
|||||||
To pass flags to the command, use `--` to separate them from the `brew` flags.
|
To pass flags to the command, use `--` to separate them from the `brew` flags.
|
||||||
For example: `brew debugger -- list --formula`.
|
For example: `brew debugger -- list --formula`.
|
||||||
EOS
|
EOS
|
||||||
switch "-s", "--stop",
|
|
||||||
description: "Stop at the beginning of the script."
|
|
||||||
switch "-O", "--open",
|
switch "-O", "--open",
|
||||||
description: "Start remote debugging over a Unix socket."
|
description: "Start remote debugging over a Unix socket."
|
||||||
|
|
||||||
@ -28,14 +26,17 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
||||||
nonstop = "1" unless args.stop?
|
|
||||||
debugger_method = if args.open?
|
debugger_method = if args.open?
|
||||||
"open"
|
"open"
|
||||||
else
|
else
|
||||||
"start"
|
"start"
|
||||||
end
|
end
|
||||||
|
|
||||||
with_env RUBY_DEBUG_NONSTOP: nonstop, RUBY_DEBUG_FORK_MODE: "parent" do
|
env = {}
|
||||||
|
env[:RUBY_DEBUG_FORK_MODE] = "parent"
|
||||||
|
env[:RUBY_DEBUG_NONSTOP] = "1" unless ENV["HOMEBREW_RDBG"]
|
||||||
|
|
||||||
|
with_env(**env) do
|
||||||
system(*HOMEBREW_RUBY_EXEC_ARGS,
|
system(*HOMEBREW_RUBY_EXEC_ARGS,
|
||||||
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
|
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
|
||||||
"-rdebug/#{debugger_method}",
|
"-rdebug/#{debugger_method}",
|
||||||
|
6
Library/Homebrew/shims/gems/rdbg
Executable file
6
Library/Homebrew/shims/gems/rdbg
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export HOMEBREW_RDBG="1"
|
||||||
|
|
||||||
|
HOMEBREW_PORTABLE_RUBY_BIN="$(cd "$(dirname "$0")"/../../ && pwd)/vendor/portable-ruby/current/bin/"
|
||||||
|
exec "${HOMEBREW_PORTABLE_RUBY_BIN}"rdbg "$@"
|
12
bin/brew
12
bin/brew
@ -258,6 +258,18 @@ then
|
|||||||
FILTERED_ENV+=("${VAR}=${!VAR}")
|
FILTERED_ENV+=("${VAR}=${!VAR}")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${HOMEBREW_RDBG:-}" ]]
|
||||||
|
then
|
||||||
|
for VAR in "${!RUBY_DEBUG_@}"
|
||||||
|
do
|
||||||
|
# Skip if variable value is empty.
|
||||||
|
[[ -z "${!VAR:-}" ]] && continue
|
||||||
|
|
||||||
|
FILTERED_ENV+=("${VAR}=${!VAR}")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
unset VAR ENV_VAR_NAMES
|
unset VAR ENV_VAR_NAMES
|
||||||
|
|
||||||
exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash -p "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" "$@"
|
exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash -p "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user