hedronvision / bazel-compile-commands-extractor

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

When a giant project already has a folder called external in the root folder #185

Open YongZhao12 opened 7 months ago

YongZhao12 commented 7 months ago

The external folder already contains some git repos.

I followed the README.md, and I am not sure whether I did everything correctly. I used WORKSPACE, so I adapted accordingly in First step. From what I understand, in Second Step, I just run my bazel build command to build my target. My build succeeded, but I found no compile_commands.json is generated.

So I tried to run path 1 of the four common paths to see what happens. I got an error complaining external folder is not a link.

In this case, do I have a path forward except changing the folder name?

I tried changing the folder name, and it turned out that I came to other tricky bugs, which doesn't seem to be promising.

I also tried to comment out _ensure_external_workspaces_link_exists() in main() of refresh.template.py, then I got a error like the below

in _get_bazel_version bazel_version_process = subprocess.run( ^^^^^^^^^^^^^^^ File "internal/python3.11/subprocess.py", line 571, in run subprocess.CalledProcessError: Command '['bazel', 'version']' returned non-zero exit status 1.

However "bazel version" succeeds when I run it separately.

Thank you for any input.

cpsauer commented 7 months ago

Hi Yong Zhao! Thanks for giving the tool a whirl--sorry this one doesn't work out of the box.

Unfortunately, bazel has some hardcoded edges cases around having an external subfolder, since that's where it stashes external dependencies when it's compiling. It's likely to cause you all kinds pain if you're try to build code from inside of there... We also have to match their folder structure--hence creating the external symlink.

Lots more details in https://github.com/hedronvision/bazel-compile-commands-extractor/issues/30#issuecomment-1049404834 if you want them, but I think the best move (both for this tool and for bazel in general) is going to end up being renaming that folder and avoiding all the subtle collisions :/

Sorry to not have something better for you. Wishing you happy coding! Chris

peakschris commented 5 months ago

There's a lot more discussion from the POV of bazel's own issues with external here: https://github.com/bazelbuild/bazel/discussions/20500