Skip to content

Commit

Permalink
Rename j2cl_js_deps to externs_deps.
Browse files Browse the repository at this point in the history
This is normally used to pass extra externs files that needs to ends up as dependency of the generated `j2cl_library`.
Fix a bug where these extra dependencies are not passed to the generated `j2cl_library`.

PiperOrigin-RevId: 567729304
  • Loading branch information
jDramaix authored and copybara-github committed Sep 22, 2023
1 parent 6066f4e commit 42f17db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
15 changes: 2 additions & 13 deletions javatests/jsinterop/generator/jsinterop_generator_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jsinterop_generator_test(
"""

load("//:jsinterop_generator.bzl", "jsinterop_generator")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")

def jsinterop_generator_test(
name,
Expand All @@ -25,7 +24,7 @@ def jsinterop_generator_test(
name_mapping_files = [],
deps = [],
conversion_mode = "closure",
j2cl_test_externs_list = [],
j2cl_test_externs_list = None,
integer_entities_files = [],
wildcard_types_files = [],
generate_j2cl_build_test = None):
Expand All @@ -35,16 +34,6 @@ def jsinterop_generator_test(

jsinterop_generator_name = "%s__jsinterop_generator" % name
generator_output = ":%s__internal_src_generated.srcjar" % jsinterop_generator_name

j2cl_js_deps = None
if j2cl_test_externs_list:
externs_lib_name = "%s-externs" % name
closure_js_library(
name = externs_lib_name,
srcs = j2cl_test_externs_list,
)
j2cl_js_deps = [":%s" % externs_lib_name]

jsinterop_generator(
name = jsinterop_generator_name,
srcs = srcs,
Expand All @@ -53,7 +42,7 @@ def jsinterop_generator_test(
name_mapping_files = name_mapping_files,
deps = deps,
conversion_mode = conversion_mode,
j2cl_js_deps = j2cl_js_deps,
externs_deps = j2cl_test_externs_list,
integer_entities_files = integer_entities_files,
wildcard_types_files = wildcard_types_files,
generate_j2cl_build_test = generate_j2cl_build_test,
Expand Down
14 changes: 9 additions & 5 deletions jsinterop_generator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Examples:
"""

load("@bazel_common_javadoc//:javadoc.bzl", "javadoc_library")
load("@com_google_j2cl//build_defs:rules.bzl", "j2cl_library")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
load("@bazel_common_javadoc//:javadoc.bzl", "javadoc_library")

_is_bazel = not hasattr(native, "genmpm") # this_is_bazel

Expand Down Expand Up @@ -259,7 +259,7 @@ def jsinterop_generator(
generate_gwt_library = True,
conversion_mode = "closure",
generate_j2cl_build_test = None,
j2cl_js_deps = None,
externs_deps = None, # Auto-populated from srcs by default.
runtime_deps = [],
custom_preprocessing_pass = [],
visibility = None,
Expand Down Expand Up @@ -292,13 +292,17 @@ def jsinterop_generator(
package_prefix = _get_java_package(native.package_name())

if conversion_mode == "closure":
if j2cl_js_deps == None:
if externs_deps == None:
# Pass the extern files present in the srcs as deps of the j2cl_library
externs_deps = srcs

if externs_deps:
externs_lib_name = "%s-externs" % name
closure_js_library(
name = externs_lib_name,
srcs = srcs,
srcs = externs_deps,
)
deps_j2cl += [":%s" % externs_lib_name]
deps_j2cl.append(":%s" % externs_lib_name)

else:
fail("Unknown conversion mode")
Expand Down

0 comments on commit 42f17db

Please sign in to comment.