Skip to content

Commit

Permalink
Hack to omit modules from polyfill application
Browse files Browse the repository at this point in the history
Summary:
Right now when built together with OTP 27 the polyfill application `toolchain_json` results in errors due to conflicting `json` module in release - where it's coming both from polifill & OTP.  This is determined by the build script by inspecting `.app` files. The application isn't actually used in production deployment. This is only seen in dev-mode releases on OTP 27.

We can omit the list of modules from generated `.app` file for the polyfill application - it will still work just fine in interactive mode on OTP 26 and 27 - correctly picking up the json module. Interactive mode is the only place where we need this polyfill.

Reviewed By: itssundeep

Differential Revision: D65472350

fbshipit-source-id: a86f45628a7107d89b1bd7d3715cb535ab28acad
  • Loading branch information
michalmuskala authored and facebook-github-bot committed Nov 5, 2024
1 parent 980e4c9 commit 8b31f7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions erlang/erlang_application.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def erlang_application_impl(ctx: AnalysisContext) -> list[Provider]:
check_dependencies(ctx.attrs.extra_includes, [ErlangAppIncludeInfo]))
dependencies = flatten_dependencies(ctx, all_direct_dependencies)

return build_application(ctx, toolchains, dependencies, _build_erlang_application)
return build_application(ctx, toolchains, dependencies)

def build_application(ctx, toolchains, dependencies, build_fun) -> list[Provider]:
def build_application(ctx, toolchains, dependencies) -> list[Provider]:
name = ctx.attrs.name

build_environments = {}
app_folders = {}
start_dependencies = {}
for toolchain in toolchains.values():
build_environment = build_fun(ctx, toolchain, dependencies)
build_environment = _build_erlang_application(ctx, toolchain, dependencies)
build_environments[toolchain.name] = build_environment

# link final output
Expand Down Expand Up @@ -290,6 +290,9 @@ def _app_info_content(
srcs: list[Artifact],
output: Artifact) -> Artifact:
"""build an app_info.json file that contains the meta information for building the .app file"""
if "otp_compatibility_polyfill_application" in ctx.attrs.labels:
srcs = []

data = {
"applications": [
app[ErlangAppInfo].name
Expand Down
1 change: 1 addition & 0 deletions erlang/toolchain/BUCK.v2
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ erlang_application(
"+deterministic",
"+warnings_as_errors",
],
labels = ["otp_compatibility_polyfill_application"],
shell_libs = [],
use_global_parse_transforms = False,
visibility = ["PUBLIC"],
Expand Down

0 comments on commit 8b31f7e

Please sign in to comment.