From 2e2a5e3b24c4e1cf5e97f47a36bdc6cffa561aeb Mon Sep 17 00:00:00 2001 From: Mai Hussien Date: Mon, 15 Sep 2025 11:14:05 -0700 Subject: [PATCH 1/2] Remove no-op python2->python3 flags PiperOrigin-RevId: 807310643 --- aspect/BUILD | 7 ++----- aspect/intellij_info_impl.bzl | 12 +----------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/aspect/BUILD b/aspect/BUILD index 95679a889f8..053c29466f7 100644 --- a/aspect/BUILD +++ b/aspect/BUILD @@ -4,7 +4,6 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load(":build_defs.bzl", "aspect_files", "aspect_library") -load(":flag_hack.bzl", "define_flag_hack") licenses(["notice"]) @@ -123,11 +122,11 @@ genrule( "sed -i -e 's,:intellij_info_impl.bzl,:intellij_info_impl_bundled.bzl,g' $@", ) -define_flag_hack() - aspect_library( name = "aspect_template_lib", files = [ + "cc_info.bzl", + "cc_info.template.bzl", "code_generator_info.bzl", "code_generator_info.template.bzl", "intellij_info.template.bzl", @@ -136,8 +135,6 @@ aspect_library( "java_info.template.bzl", "python_info.bzl", "python_info.template.bzl", - "cc_info.bzl", - "cc_info.template.bzl", ], namespace = "aspect/template", visibility = ["//visibility:public"], diff --git a/aspect/intellij_info_impl.bzl b/aspect/intellij_info_impl.bzl index 3657a22b23d..798dc50a9ee 100644 --- a/aspect/intellij_info_impl.bzl +++ b/aspect/intellij_info_impl.bzl @@ -320,14 +320,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, @@ -1353,9 +1346,6 @@ def make_intellij_info_aspect(aspect_impl, semantics, **kwargs): default = tool_label("JarFilter_deploy.jar"), allow_single_file = True, ), - "_flag_hack": attr.label( - default = flag_hack_label, - ), "_create_aar": attr.label( default = tool_label("CreateAar_deploy.jar"), allow_single_file = True, From 33698e1a36516128659ad1e406b1243bcbf64236 Mon Sep 17 00:00:00 2001 From: Daniel Brauner Date: Fri, 26 Sep 2025 09:50:12 +0200 Subject: [PATCH 2/2] further cleanup --- aspect/BUILD | 3 --- aspect/BUILD.aspect | 4 ---- aspect/flag_hack.bzl | 32 -------------------------------- aspect/intellij_info.bzl | 1 - aspect/intellij_info_impl.bzl | 6 ++---- 5 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 aspect/flag_hack.bzl diff --git a/aspect/BUILD b/aspect/BUILD index 053c29466f7..9b0522ca9c2 100644 --- a/aspect/BUILD +++ b/aspect/BUILD @@ -41,7 +41,6 @@ aspect_files( files = [ "artifacts.bzl", "fast_build_info_bundled.bzl", - "flag_hack.bzl", "intellij_info_impl_bundled.bzl", "java_classpath.bzl", "make_variables.bzl", @@ -88,7 +87,6 @@ _dev_aspect_path = package_name() # This genrule is required for the aspect to be valid in all three repositories in which it's used. # Changes: # //.../aspect/tools:tool_name -> //:tool_name_bin -# //.../aspect:flag_hack -> //:flag_hack # :intellij_info_impl.bzl -> :intellij_info_impl_bundled.bzl genrule( name = "modify_tools_path", @@ -96,7 +94,6 @@ genrule( outs = ["intellij_info_bundled.bzl"], cmd = "cat $(SRCS) >$@ && " + "sed -i -e 's,//%s/tools:\" + tool_name,tools/\" + tool_name,g' $@ && " % _dev_aspect_path + - "sed -i -e 's,//%s:flag_hack,:flag_hack,g' $@ && " % _dev_aspect_path + "sed -i -e 's,:intellij_info_impl.bzl,:intellij_info_impl_bundled.bzl,g' $@", ) diff --git a/aspect/BUILD.aspect b/aspect/BUILD.aspect index 1797ffe5e7e..8ca21e9b78f 100644 --- a/aspect/BUILD.aspect +++ b/aspect/BUILD.aspect @@ -5,12 +5,8 @@ licenses(["notice"]) # Apache 2.0 -load(":flag_hack.bzl", "define_flag_hack") - exports_files([ "tools/PackageParser_deploy.jar", "tools/CreateAar_deploy.jar", "tools/JarFilter_deploy.jar", ]) - -define_flag_hack() diff --git a/aspect/flag_hack.bzl b/aspect/flag_hack.bzl deleted file mode 100644 index 8d4494f63e6..00000000000 --- a/aspect/flag_hack.bzl +++ /dev/null @@ -1,32 +0,0 @@ -##### 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 diff --git a/aspect/intellij_info.bzl b/aspect/intellij_info.bzl index 7da36f13d7e..34bfaf6528a 100644 --- a/aspect/intellij_info.bzl +++ b/aspect/intellij_info.bzl @@ -85,7 +85,6 @@ semantics = struct( py = struct( get_launcher = get_py_launcher, ), - flag_hack_label = "//aspect:flag_hack", ) def _aspect_impl(target, ctx): diff --git a/aspect/intellij_info_impl.bzl b/aspect/intellij_info_impl.bzl index 798dc50a9ee..d7f59281d09 100644 --- a/aspect/intellij_info_impl.bzl +++ b/aspect/intellij_info_impl.bzl @@ -13,15 +13,14 @@ load( "struct_omit_none", "to_artifact_location", ) +load(":cc_info.bzl", "CC_USE_GET_TOOL_FOR_ACTION") load(":code_generator_info.bzl", "CODE_GENERATOR_RULE_NAMES") -load(":flag_hack.bzl", "FlagHackInfo") -load(":java_info.bzl", "get_java_info", "java_info_in_target", "java_info_reference", "get_provider_from_target") +load(":java_info.bzl", "get_java_info", "get_provider_from_target", "java_info_in_target", "java_info_reference") load( ":make_variables.bzl", "expand_make_variables", ) load(":python_info.bzl", "get_py_info", "py_info_in_target") -load(":cc_info.bzl", "CC_USE_GET_TOOL_FOR_ACTION") IntelliJInfo = provider( doc = "Collected information about the targets visited by the aspect.", @@ -1330,7 +1329,6 @@ def semantics_extra_deps(base, semantics, name): def make_intellij_info_aspect(aspect_impl, semantics, **kwargs): """Creates the aspect given the semantics.""" tool_label = semantics.tool_label - flag_hack_label = semantics.flag_hack_label deps = semantics_extra_deps(DEPS, semantics, "extra_deps") runtime_deps = RUNTIME_DEPS prerequisite_deps = semantics_extra_deps(PREREQUISITE_DEPS, semantics, "extra_prerequisites")