Skip to content

Commit

Permalink
Copy querysync aspect code from repo studio-main to Google3
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 697775331
  • Loading branch information
Googler authored and copybara-github committed Dec 3, 2024
1 parent 54de94b commit baaf466
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 323 deletions.
32 changes: 20 additions & 12 deletions aspect/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,35 @@ filegroup(
# the aspect files that will be bundled with the final plugin zip
filegroup(
name = "aspect_files",
srcs = [
":aspect_files_only",
":aspect_tools",
],
visibility = ["//visibility:public"],
)

# Separate different targets as they are put into different directories
filegroup(
name = "aspect_files_only",
srcs = [
"WORKSPACE",
"artifacts.bzl",
"build_compose_dependencies.bzl",
"build_dependencies.bzl",
"fast_build_info_bundled.bzl",
"build_dependencies_deps.bzl",
"intellij_info.bzl",
"intellij_info_bundled.bzl",
"intellij_info_impl_bundled.bzl",
"java_classpath.bzl",
"make_variables.bzl",
":BUILD.bazel",
],
visibility = ["//visibility:public"],
)

filegroup(
name = "aspect_tools",
srcs = [
"//aspect/tools:CreateAar",
"//aspect/tools:JarFilter_deploy.jar",
"//aspect/tools:PackageParser_deploy.jar",
Expand Down Expand Up @@ -81,17 +99,7 @@ genrule(
srcs = ["intellij_info_impl.bzl"],
outs = ["intellij_info_impl_bundled.bzl"],
cmd = "cat $(SRCS) >$@ && " +
"sed -i -e '/BUNDLED-IGNORE-BEGIN/,/BUNDLED-IGNORE-END/d' $@ && " +
"sed -i -e 's,load(\".*/rules_java/,load(\"@rules_java//', $@",
)

# Makes bundled fast_build_info.bzl use bundled intellij_info_impl.bzl
genrule(
name = "create_fast_build_info_bundle",
srcs = ["fast_build_info.bzl"],
outs = ["fast_build_info_bundled.bzl"],
cmd = "cat $(SRCS) >$@ && " +
"sed -i -e 's,:intellij_info_impl.bzl,:intellij_info_impl_bundled.bzl,g' $@",
"sed -i -e '/BUNDLED-IGNORE-BEGIN/,/BUNDLED-IGNORE-END/d' $@",
)

define_flag_hack()
37 changes: 37 additions & 0 deletions aspect/build_compose_dependencies.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Aspects to build and collect project's compose dependencies."""

load("@rules_java//java:defs.bzl", "JavaInfo")

ComposeDependenciesInfo = provider(
"The compose dependencies",
fields = {
"render_jars": "a list of render jars generated for project files and external dependencies",
},
)

def _package_compose_dependencies_impl(target, ctx): # @unused
return [OutputGroupInfo(
render_jars = target[ComposeDependenciesInfo].render_jars.to_list(),
)]

package_compose_dependencies = aspect(
implementation = _package_compose_dependencies_impl,
required_aspect_providers = [[ComposeDependenciesInfo]],
)

def _collect_compose_dependencies_impl(target, ctx): # @unused
if JavaInfo not in target:
return [ComposeDependenciesInfo(
render_jars = depset(),
)]
return [
ComposeDependenciesInfo(
render_jars = depset([], transitive = [target[JavaInfo].transitive_runtime_jars]),
),
]

collect_compose_dependencies = aspect(
implementation = _collect_compose_dependencies_impl,
provides = [ComposeDependenciesInfo],
attr_aspects = ["deps", "exports", "_android_sdk"],
)
Loading

0 comments on commit baaf466

Please sign in to comment.