Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate clangd index #456

Open
jiushun opened this issue Dec 31, 2024 · 11 comments
Open

generate clangd index #456

jiushun opened this issue Dec 31, 2024 · 11 comments
Assignees

Comments

@jiushun
Copy link

jiushun commented Dec 31, 2024

你好,关于使用 bazel module 系统下的 clangd 索引该如何生成呢,去掉了 workspace 之前的方式无法使用

@deadlywing
Copy link

一个短期的方法:

在BUILD.bazel中增加:

load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

refresh_compile_commands(
    name = "refresh_compile_commands",
    targets = {
        "//yacl/...": "",
    },
)

在MODULE.bazel中增加

bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
    module_name = "hedron_compile_commands",
    commit = "f5fbd4cee671d8d908f37c83abaf70fba5928fc7",
    remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)

@deadlywing
Copy link

然后运行bazel run -s :refresh_compile_commands

@jiushun
Copy link
Author

jiushun commented Dec 31, 2024

好的谢谢

@jiushun jiushun closed this as completed Dec 31, 2024
@jiushun jiushun reopened this Dec 31, 2024
@jiushun
Copy link
Author

jiushun commented Dec 31, 2024

ERROR: no such package '@@rules_python~~python~python_3_11_aarch64-unknown-linux-gnu//': The current user is root, please run as non-root when using the hermetic Python interpreter 中间报了个这个错,麻烦问一下有啥解决方案吗,必须以非root运行?

@deadlywing
Copy link

可以用conda创建一个虚拟环境试试

@deadlywing
Copy link

如果conda不行的话,可以参考:bazelbuild/rules_python#713 (comment)
修改一下MODULE.bazel;

@jiushun
Copy link
Author

jiushun commented Dec 31, 2024

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = False,
ignore_root_user_error = True,
python_version = "3.11",
) 这个方法解决了问题,谢谢,在此期待贵方能在 devtools 仓库内同步一个生成 compile_commands.json 的脚本

@jiushun
Copy link
Author

jiushun commented Dec 31, 2024

不过 psi 仓库的索引生成也会有这个python的问题,python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = False,
ignore_root_user_error = True,
python_version = "3.11",
) 无法解决,会提示 no repo visible as '@rules_python' here

@deadlywing
Copy link

PSI没有引入rules_python这个dep,手动加一下即可

@tongke6
Copy link
Collaborator

tongke6 commented Jan 2, 2025

python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( configure_coverage_tool = False, ignore_root_user_error = True, python_version = "3.11", ) 这个方法解决了问题,谢谢,在此期待贵方能在 devtools 仓库内同步一个生成 compile_commands.json 的脚本

Here you are, added by @tyrone-yu in secretflow/devtools#87

@jiushun
Copy link
Author

jiushun commented Jan 2, 2025

python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( configure_coverage_tool = False, ignore_root_user_error = True, python_version = "3.11", ) 这个方法解决了问题,谢谢,在此期待贵方能在 devtools 仓库内同步一个生成 compile_commands.json 的脚本

Here you are, added by @tyrone-yu in secretflow/devtools#87

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants