зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 1 changesets (bug 1773520) for breaking the ./mach ide vscode
Backed out changeset d9571dde686f (bug 1773520)
This commit is contained in:
Родитель
041120d0b6
Коммит
ea20959e2d
|
@ -73,9 +73,6 @@ the terminal:
|
|||
|
||||
./mach ide vscode
|
||||
|
||||
After that, subsequent `./mach build` invocations will automatically run
|
||||
the `Clangd` integration.
|
||||
|
||||
If `VS Code` is already open with a previous configuration generated, please make sure to
|
||||
restart `VS Code` otherwise the new configuration will not be used, and the `compile_commands.json`
|
||||
needed by `clangd` server will not be refreshed. This is a known `bug <https://github.com/clangd/vscode-clangd/issues/42>`__
|
||||
|
|
|
@ -365,7 +365,6 @@ imply_option("--build-backends", build_backend)
|
|||
"--help",
|
||||
)
|
||||
@imports("sys")
|
||||
@imports(_from="mozbuild.backend.clangd", _import="find_vscode_cmd")
|
||||
def build_backend_defaults(
|
||||
host,
|
||||
target,
|
||||
|
@ -396,12 +395,6 @@ def build_backend_defaults(
|
|||
and project not in ("mobile/android", "memory", "tools/update-programs")
|
||||
):
|
||||
all_backends.append("VisualStudio")
|
||||
if (
|
||||
compile_environment
|
||||
and find_vscode_cmd()
|
||||
and project not in ("mobile/android", "memory", "tools/update-programs")
|
||||
):
|
||||
all_backends.append("Clangd")
|
||||
return tuple(all_backends) or None
|
||||
|
||||
|
||||
|
|
|
@ -17,75 +17,6 @@ from mozbuild.compilation.database import CompileDBBackend
|
|||
import mozpack.path as mozpath
|
||||
|
||||
|
||||
def find_vscode_cmd():
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
# Try to look up the `code` binary on $PATH, and use it if present. This
|
||||
# should catch cases like being run from within a vscode-remote shell,
|
||||
# even if vscode itself is also installed on the remote host.
|
||||
path = shutil.which("code")
|
||||
if path is not None:
|
||||
return [path]
|
||||
|
||||
# If the binary wasn't on $PATH, try to find it in a variety of other
|
||||
# well-known install locations based on the current platform.
|
||||
if sys.platform.startswith("darwin"):
|
||||
cmd_and_path = [
|
||||
{"path": "/usr/local/bin/code", "cmd": ["/usr/local/bin/code"]},
|
||||
{
|
||||
"path": "/Applications/Visual Studio Code.app",
|
||||
"cmd": ["open", "/Applications/Visual Studio Code.app", "--args"],
|
||||
},
|
||||
{
|
||||
"path": "/Applications/Visual Studio Code - Insiders.app",
|
||||
"cmd": [
|
||||
"open",
|
||||
"/Applications/Visual Studio Code - Insiders.app",
|
||||
"--args",
|
||||
],
|
||||
},
|
||||
]
|
||||
elif sys.platform.startswith("win"):
|
||||
from pathlib import Path
|
||||
|
||||
vscode_path = mozpath.join(
|
||||
str(Path.home()),
|
||||
"AppData",
|
||||
"Local",
|
||||
"Programs",
|
||||
"Microsoft VS Code",
|
||||
"Code.exe",
|
||||
)
|
||||
vscode_insiders_path = mozpath.join(
|
||||
str(Path.home()),
|
||||
"AppData",
|
||||
"Local",
|
||||
"Programs",
|
||||
"Microsoft VS Code Insiders",
|
||||
"Code - Insiders.exe",
|
||||
)
|
||||
cmd_and_path = [
|
||||
{"path": vscode_path, "cmd": [vscode_path]},
|
||||
{"path": vscode_insiders_path, "cmd": [vscode_insiders_path]},
|
||||
]
|
||||
elif sys.platform.startswith("linux"):
|
||||
cmd_and_path = [
|
||||
{"path": "/usr/local/bin/code", "cmd": ["/usr/local/bin/code"]},
|
||||
{"path": "/snap/bin/code", "cmd": ["/snap/bin/code"]},
|
||||
{"path": "/usr/bin/code", "cmd": ["/usr/bin/code"]},
|
||||
{"path": "/usr/bin/code-insiders", "cmd": ["/usr/bin/code-insiders"]},
|
||||
]
|
||||
|
||||
# Did we guess the path?
|
||||
for element in cmd_and_path:
|
||||
if os.path.exists(element["path"]):
|
||||
return element["cmd"]
|
||||
|
||||
# Path cannot be found
|
||||
return None
|
||||
|
||||
|
||||
class ClangdBackend(CompileDBBackend):
|
||||
"""
|
||||
Configuration that generates the backend for clangd, it is used with `clangd`
|
||||
|
|
|
@ -49,10 +49,8 @@ def run(command_context, ide, args):
|
|||
return 1
|
||||
|
||||
if ide == "vscode":
|
||||
from .clangd import find_vscode_cmd
|
||||
|
||||
# Check if platform has VSCode installed
|
||||
vscode_cmd = find_vscode_cmd()
|
||||
vscode_cmd = find_vscode_cmd(command_context)
|
||||
if vscode_cmd is None:
|
||||
choice = prompt_bool(
|
||||
"VSCode cannot be found, and may not be installed. Proceed?"
|
||||
|
@ -128,6 +126,74 @@ def get_visualstudio_workspace_path(command_context):
|
|||
)
|
||||
|
||||
|
||||
def find_vscode_cmd(command_context):
|
||||
import shutil
|
||||
|
||||
# Try to look up the `code` binary on $PATH, and use it if present. This
|
||||
# should catch cases like being run from within a vscode-remote shell,
|
||||
# even if vscode itself is also installed on the remote host.
|
||||
path = shutil.which("code")
|
||||
if path is not None:
|
||||
return [path]
|
||||
|
||||
# If the binary wasn't on $PATH, try to find it in a variety of other
|
||||
# well-known install locations based on the current platform.
|
||||
if "linux" in command_context.platform[0]:
|
||||
cmd_and_path = [
|
||||
{"path": "/usr/local/bin/code", "cmd": ["/usr/local/bin/code"]},
|
||||
{"path": "/snap/bin/code", "cmd": ["/snap/bin/code"]},
|
||||
{"path": "/usr/bin/code", "cmd": ["/usr/bin/code"]},
|
||||
{"path": "/usr/bin/code-insiders", "cmd": ["/usr/bin/code-insiders"]},
|
||||
]
|
||||
elif "macos" in command_context.platform[0]:
|
||||
cmd_and_path = [
|
||||
{"path": "/usr/local/bin/code", "cmd": ["/usr/local/bin/code"]},
|
||||
{
|
||||
"path": "/Applications/Visual Studio Code.app",
|
||||
"cmd": ["open", "/Applications/Visual Studio Code.app", "--args"],
|
||||
},
|
||||
{
|
||||
"path": "/Applications/Visual Studio Code - Insiders.app",
|
||||
"cmd": [
|
||||
"open",
|
||||
"/Applications/Visual Studio Code - Insiders.app",
|
||||
"--args",
|
||||
],
|
||||
},
|
||||
]
|
||||
elif "win64" in command_context.platform[0]:
|
||||
from pathlib import Path
|
||||
|
||||
vscode_path = mozpath.join(
|
||||
str(Path.home()),
|
||||
"AppData",
|
||||
"Local",
|
||||
"Programs",
|
||||
"Microsoft VS Code",
|
||||
"Code.exe",
|
||||
)
|
||||
vscode_insiders_path = mozpath.join(
|
||||
str(Path.home()),
|
||||
"AppData",
|
||||
"Local",
|
||||
"Programs",
|
||||
"Microsoft VS Code Insiders",
|
||||
"Code - Insiders.exe",
|
||||
)
|
||||
cmd_and_path = [
|
||||
{"path": vscode_path, "cmd": [vscode_path]},
|
||||
{"path": vscode_insiders_path, "cmd": [vscode_insiders_path]},
|
||||
]
|
||||
|
||||
# Did we guess the path?
|
||||
for element in cmd_and_path:
|
||||
if os.path.exists(element["path"]):
|
||||
return element["cmd"]
|
||||
|
||||
# Path cannot be found
|
||||
return None
|
||||
|
||||
|
||||
def setup_vscode(command_context, vscode_cmd):
|
||||
vscode_settings = mozpath.join(
|
||||
command_context.topsrcdir, ".vscode", "settings.json"
|
||||
|
|
Загрузка…
Ссылка в новой задаче