Skip to content

Commit

Permalink
Rename conly parameter to enable_cxx and switch default to choose c f…
Browse files Browse the repository at this point in the history
…lags
  • Loading branch information
jsharpe committed Oct 27, 2021
1 parent 1a0fe35 commit 1a377af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build_tools/py/cffi.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def dbx_cffi_module(
python3_compatible = python3_compatible,
setup_requires = ["//pip/cffi"],
ignore_missing_static_libraries = ignore_missing_static_libraries,
conly = conly,
enable_cxx = not conly,
tags = tags,
import_test_tags = import_test_tags,
)
14 changes: 7 additions & 7 deletions build_tools/py/py.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _get_build_interpreters_for_target(ctx):
# Placeholder text which gets replaced with base/root directory where action is executed.
ROOT_PLACEHOLDER = "____root____"

def _add_vpip_compiler_args(ctx, cc_toolchain, copts, conly, args):
def _add_vpip_compiler_args(ctx, cc_toolchain, copts, enable_cxx, args):
# Set the compiler to the crosstool compilation driver.
feature_configuration = cc_common.configure_features(
ctx = ctx,
Expand All @@ -78,7 +78,7 @@ def _add_vpip_compiler_args(ctx, cc_toolchain, copts, conly, args):
)
c_compiler = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = C_COMPILE_ACTION_NAME if conly else CPP_COMPILE_ACTION_NAME,
action_name = CPP_COMPILE_ACTION_NAME if enable_cxx else C_COMPILE_ACTION_NAME,
)
archiver = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
Expand All @@ -92,16 +92,16 @@ def _add_vpip_compiler_args(ctx, cc_toolchain, copts, conly, args):
# flags are added in addition to whatever other flags distutils sees fit to
# use. distutils does not distinguish between compilation of C and C++; we
# must pass the C++ flags through CFLAGS if there is any C++ in the extension
# module. Passing C++ options when compiling C is basically harmless. At most,
# it generates some warnings that no one ever has to look at.
# module. Passing C++ options when compiling C is basically harmless but some
# stricter compilers such as clang 13 (or newer) will see this as an error.
compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
user_compile_flags = copts,
)
compiler_options = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
action_name = C_COMPILE_ACTION_NAME if conly else CPP_COMPILE_ACTION_NAME,
action_name = CPP_COMPILE_ACTION_NAME if enable_cxx else C_COMPILE_ACTION_NAME,
variables = compile_variables,
)
args.add_all(compiler_options, format_each = "--compile-flags=%s")
Expand Down Expand Up @@ -171,7 +171,7 @@ def _build_wheel(ctx, wheel, python_interp, sdist_tar):
outputs = [wheel]

cc_toolchain = find_cpp_toolchain(ctx)
link_env = _add_vpip_compiler_args(ctx, cc_toolchain, ctx.attr.copts, ctx.attr.conly, command_args)
link_env = _add_vpip_compiler_args(ctx, cc_toolchain, ctx.attr.copts, ctx.attr.enable_cxx, command_args)

inputs_direct = []
inputs_trans = [
Expand Down Expand Up @@ -554,7 +554,7 @@ _piplib_attrs = {
"deps": attr.label_list(allow_files = True),
"data": attr.label_list(allow_files = True),
"copts": attr.string_list(),
"conly": attr.bool(default = False),
"enable_cxx": attr.bool(default = False),
"global_options": attr.string_list(),
"build_options": attr.string_list(),
"extra_path": attr.string_list(),
Expand Down

0 comments on commit 1a377af

Please sign in to comment.