Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions aspect/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# Description: Bazel aspect bundled with the Bazel IntelliJ plugin.
#

load(
":intellij_info_impl.bzl",
"define_flag_hack",
)

licenses(["notice"])

# Files needed at runtime for blaze-invoking integration tests
Expand Down Expand Up @@ -93,5 +88,3 @@ genrule(
cmd = "cat $(SRCS) >$@ && " +
"sed -i -e 's,:intellij_info_impl.bzl,:intellij_info_impl_bundled.bzl,g' $@",
)

define_flag_hack()
45 changes: 1 addition & 44 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,6 @@ PY2 = 1

PY3 = 2

##### Begin bazel-flag-hack
# The flag hack stuff below is a way to detect flags that bazel has been invoked with from the
# aspect. Once PY3-as-default is stable, it can be removed. When removing, also remove the
# define_flag_hack() call in BUILD and the "_flag_hack" attr on the aspect below. See
# "PY3-as-default" in:
# https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java

FlagHackInfo = provider(fields = ["incompatible_py2_outputs_are_suffixed"])

def _flag_hack_impl(ctx):
return [FlagHackInfo(incompatible_py2_outputs_are_suffixed = ctx.attr.incompatible_py2_outputs_are_suffixed)]

_flag_hack_rule = rule(
attrs = {"incompatible_py2_outputs_are_suffixed": attr.bool()},
implementation = _flag_hack_impl,
)

def define_flag_hack():
native.config_setting(
name = "incompatible_py2_outputs_are_suffixed_setting",
values = {"incompatible_py2_outputs_are_suffixed": "true"},
)
_flag_hack_rule(
name = "flag_hack",
incompatible_py2_outputs_are_suffixed = select({
":incompatible_py2_outputs_are_suffixed_setting": True,
"//conditions:default": False,
}),
visibility = ["//visibility:public"],
)

##### End bazel-flag-hack

# PythonCompatVersion enum; must match PyIdeInfo.PythonSrcsVersion
SRC_PY2 = 1

Expand Down Expand Up @@ -306,14 +273,7 @@ def _get_output_mnemonic(ctx):
return ctx.bin_dir.path.split("/")[1]

def _get_python_version(ctx):
if ctx.attr._flag_hack[FlagHackInfo].incompatible_py2_outputs_are_suffixed:
if _get_output_mnemonic(ctx).find("-py2-") != -1:
return PY2
return PY3
else:
if _get_output_mnemonic(ctx).find("-py3-") != -1:
return PY3
return PY2
return PY3

_SRCS_VERSION_MAPPING = {
"PY2": SRC_PY2,
Expand Down Expand Up @@ -1243,9 +1203,6 @@ def make_intellij_info_aspect(aspect_impl, semantics, **kwargs):
executable = True,
allow_files = True,
),
"_flag_hack": attr.label(
default = flag_hack_label,
),
"_create_aar": attr.label(
default = tool_label("CreateAar"),
cfg = "exec",
Expand Down
Loading