Skip to content

Commit

Permalink
Handle resource duplicates in resource merger (#185)
Browse files Browse the repository at this point in the history
Fixes #185
  • Loading branch information
arunkumar9t2 committed Dec 3, 2024
1 parent f0b7887 commit fb41053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rules/android/resources.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@grab_bazel_common//rules/android:utils.bzl", "utils")
load("@grab_bazel_common//rules/android/private:resource_merger.bzl", "resource_merger")
load("@grab_bazel_common//tools/res_value:res_value.bzl", "res_value")

Expand Down Expand Up @@ -144,6 +145,8 @@ def build_resources(
source_sets.append("%s:%s:%s" % (resource_dir, asset_dir, manifest))

merge_target_name = "_" + name + "_res"
all_resources = utils.to_set(all_resources)
all_assets = utils.to_set(all_assets)
merged_resources = _calculate_output_files(merge_target_name, all_resources)
merged_assets = _calculate_output_files(merge_target_name, all_assets)

Expand Down
7 changes: 7 additions & 0 deletions rules/android/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ def _collect_providers(provider_type, *all_deps):
def _to_depset(list):
return depset(list)

def _to_set(items):
value_dict = {}
for item in items:
value_dict[item] = item
return list(value_dict.values())

utils = struct(
to_path = _to_path,
inspect = _inspect,
collect_providers = _collect_providers,
to_depset = _to_depset,
to_set = _to_set,
)

0 comments on commit fb41053

Please sign in to comment.