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

Error: Information about the C++ toolchain API is not accessible anymore through ctx.fragments.cpp #10

Open
plule opened this issue Dec 14, 2018 · 4 comments

Comments

@plule
Copy link

plule commented Dec 14, 2018

Hello and first, thanks for making this!

It seems that a bazel change broke Lavender. When trying to convert a project, I get:

Information about the C++ toolchain API is not accessible anymore through ctx.fragments.cpp (see --incompatible_disable_legacy_cpp_toolchain_skylark_api on http://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disable-legacy-c-configuration-api for migration notes). Use CcToolchainInfo instead.

The link provides instructions for migration, but I just started learning Bazel so I did not manage to fix it myself. Removing the + ctx.fragments.cpp.compiler_options([]) + ctx.fragments.cpp.cxx_options([]) parts from msbuild.bzl allows the script to complete.

@tmandry
Copy link
Owner

tmandry commented Dec 14, 2018

Hey, thanks for your report! I'm not actively maintaining this anymore, unfortunately (and don't have a codebase to test it with), but willing to help guide you through fixing it.

The before/after example from the documentation you linked is more or less what needs to be done. You need to add a load statement to the top of the file:

load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

Then, at the top of this function:

def _get_project_info(target, ctx):
cc = getattr(target, 'cc', None)
if cc:
cc_info = struct(
include_dirs = cc.include_directories,
system_include_dirs = cc.system_include_directories,
quote_include_dirs = cc.quote_include_directories,
compile_flags = cc.compile_flags + ctx.fragments.cpp.compiler_options([]) + ctx.fragments.cpp.cxx_options([]),
defines = cc.defines,
)

add the line cc_toolchain = find_cpp_toolchain(ctx), and you should be able to replace those expressions you removed with their counterparts, listed in the table on the doc page you linked to. Looks like you can remove the unused [] arguments in each of them.

@tmandry
Copy link
Owner

tmandry commented Dec 14, 2018

Let me know if you have any issues. If you get it working, please submit a PR and I'll get it merged. Thanks!

@plule
Copy link
Author

plule commented Dec 15, 2018

Thanks for the guidance, I'll take a look at it!

@lummax
Copy link

lummax commented Apr 13, 2021

lummax@623e18c was my attempt at this. Inspired by https://github.com/grailbio/bazel-compilation-database

Edit: And xforce@01609c4 is another one.

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

3 participants