hedronvision / bazel-compile-commands-extractor

Goal: Enable awesome tooling for Bazel users of the C language family.
Other
683 stars 113 forks source link

failed to generate the compile_commands.json for proxy_wasm_cpp_host #223

Open wbpcode opened 3 weeks ago

wbpcode commented 3 weeks ago

Hi, thanks for you guys provide so great tools. But I encountered a problem when I wanted to use it in the proxy_wasm_cpp_host.

Here is my build configuration:

refresh_compile_commands(
    name = "refresh_compile_commands",

    # Specify the targets of interest.
    # For example, specify a dict of targets and any flags required to build.
    targets = {
        "//:lib": "--define=engine=multi",
        "//test/...": "--define=engine=multi",
    },
)

Here is error:

bazel run :refresh_compile_commands
INFO: Build options --define, --features, and --host_features have changed, discarding analysis cache.
INFO: Analyzed target //:refresh_compile_commands (115 packages loaded, 2942 targets configured).
INFO: Found 1 target...
Target //:refresh_compile_commands up-to-date:
  bazel-bin/refresh_compile_commands.check_python_version.py
  bazel-bin/refresh_compile_commands.py
  bazel-bin/refresh_compile_commands
INFO: Elapsed time: 0.496s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/refresh_compile_commands
>>> Analyzing commands used in //:lib
>>> Finished extracting commands for //:lib
>>> Analyzing commands used in //test/...
>>> A source file you compile doesn't (yet) exist: bazel-out/aarch64-fastbuild-ST-5c2a6e57c052/bin/external/v8/src/inspector/protocol/Protocol.cpp
    It's probably a generated file, and you haven't yet run a build to generate it.
    That's OK; your code doesn't even have to compile for this tool to work.
    If you can, though, you might want to run a build of your code with --keep_going.
        That way everything possible is generated, browsable and indexed for autocomplete.
    However, if you have *already* built your code, and generated the missing file...
        Please make sure you're supplying this tool with the same flags you use to build.
        You can either use a refresh_compile_commands rule or the special -- syntax. Please see the README.
        [Supplying flags normally won't work. That just causes this tool to be built with those flags.]
    Continuing gracefully...
Traceback (most recent call last):
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.runfiles/proxy_wasm_cpp_host/refresh_compile_commands.check_python_version.py", line 15, in <module>
    refresh_compile_commands.main()
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.py", line 1417, in main
    compile_command_entries.extend(_get_commands(target, flags))
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.py", line 1278, in _get_commands
    yield from _convert_compile_commands(parsed_aquery_output)
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.py", line 1158, in _convert_compile_commands
    for source_files, header_files, compile_command_args in outputs:
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/external/python_3_9_aarch64-unknown-linux-gnu/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator
    yield fs.pop().result()
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/external/python_3_9_aarch64-unknown-linux-gnu/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/external/python_3_9_aarch64-unknown-linux-gnu/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/external/python_3_9_aarch64-unknown-linux-gnu/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.py", line 1118, in _get_cpp_command_for_files
    compile_action.arguments = _emscripten_platform_patch(compile_action)
  File "/build/.cache/bazel/_bazel_vscode/72bf4cf5051f0ae23cbc1f567f09b13f/execroot/proxy_wasm_cpp_host/bazel-out/aarch64-fastbuild/bin/refresh_compile_commands.py", line 855, in _emscripten_platform_patch
    assert False, f'Failed to parse emcc output: {emcc_process.stderr}'
AssertionError: Failed to parse emcc output: python3: can't open file '/build/proxy-wasm-cpp-host/external/emsdk/emscripten/emcc.py': [Errno 2] No such file or directory
wbpcode commented 3 weeks ago

Another interesting thing is the old version "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/dc36e462a2468bd79843fe5176542883b8ce4abe.tar.gz" could generate a compile_commands.json.

Although even I pre-build the lib/binnary, there are still some files are missing and make the clangd connot work well.