mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:10:12 +01:00
This restores the symlinks for the installation, but teaches the busybox info search to look for a relative path to the busybox binary itself before walking through symlinks. This let's it find the tree structure when directly invoking `prefix_root/bin/carbon` or similar, either inside of a Bazel rule or from the command line, and mirrors how we expect the installed tree to look. This works even when Bazel resolves the symlink target fully, and potentially to something nonsensical like a CAS file. In order to make a convenient Bazel target that can be used with `bazel run //toolchain`, this adds an override to explicitly set the desired argv[0] to use when selecting a mode for the busybox and a busybox binary. Currently, the workaround uses an environment variable because that required the least amount of plumbing, and seems a useful override mechanism generally, but I'm open to other approaches. This should allow a few things to work a bit more nicely: - It should handle sibling symlinks like `clang++` to `clang` or `ld.lld` to `lld`, where that symlink in turn points at the busybox. We want to use *initial* `argv[0]` value to select the mode there. - It avoids bouncing through Python (or other subprocesses) when invoking the `carbon` binary in Bazel rules, which will be nice for building the example code and benchmarking. It does come at a cost of removing one feature: the initial symlink can't be some unrelated alias like `my_carbon_symlink` -- we expect the *first* argv[0] name to have the meaningful filename for selecting a busybox mode. It also trades the complexity of the Python script for some complexity in the busybox search in order to look for a relative `carbon-busybox` binary. On the whole, I think that tradeoff is worthwhile, but it isn't free. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
29 lines
739 B
Lua
29 lines
739 B
Lua
-- Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
-- Exceptions. See /LICENSE for license information.
|
|
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
vim.filetype.add({
|
|
extension = {
|
|
carbon = 'carbon',
|
|
},
|
|
})
|
|
|
|
vim.treesitter.language.add("carbon")
|
|
|
|
-- LSP
|
|
local lsp = require 'lspconfig'
|
|
local configs = require 'lspconfig.configs'
|
|
local util = require 'lspconfig.util'
|
|
|
|
-- Check if the config is already defined (useful when reloading this file)
|
|
if not configs.carbon then
|
|
configs.carbon = {
|
|
default_config = {
|
|
cmd = { "./bazel-bin/toolchain/carbon language-server" },
|
|
filetypes = { "carbon" },
|
|
root_dir = util.find_git_ancestor,
|
|
}
|
|
}
|
|
end
|
|
lsp.carbon.setup {}
|