Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion elixir/toolchain/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ def _elixir_impl(mctx):
name = "rules_elixir",
dropped = RULES_ELIXIR_DROPPED,
patches = [
Label("//patches/rules_elixir:hermetic_elixir.patch"),
# Applied in this order: the deps patch builds on the name patch.
Label("//patches/rules_elixir:elixir_app_name.patch"),
Label("//patches/rules_elixir:elixir_app_deps.patch"),
Label("//patches/rules_elixir:warnings_as_errors.patch"),
Label("//patches/rules_elixir:relocatable_tree.patch"),
Label("//patches/rules_elixir:toolchain_type_alias.patch"),
Label("//patches/rules_elixir:windows_ex_unit_test.patch"),
],
Expand Down
5 changes: 4 additions & 1 deletion patches/rules_elixir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
load("@rules_dx//quality:fixtures.bzl", "real_source_target")

exports_files([
"hermetic_elixir.patch",
"elixir_app_deps.patch",
"elixir_app_name.patch",
"relocatable_tree.patch",
"toolchain_type_alias.patch",
"warnings_as_errors.patch",
"windows_ex_unit_test.patch",
])

Expand Down
11 changes: 11 additions & 0 deletions patches/rules_elixir/elixir_app_deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/elixir_app.bzl b/elixir_app.bzl
--- a/elixir_app.bzl
+++ b/elixir_app.bzl
@@ -80,6 +80,7 @@ def elixir_app(
app_name = app_name,
extra_apps = ["elixir"] + extra_apps,
modules = [":" + beam_files],
+ deps = deps,
**(common | kwargs)
)

130 changes: 130 additions & 0 deletions patches/rules_elixir/elixir_app_name.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
diff --git a/elixir_app.bzl b/elixir_app.bzl
--- a/elixir_app.bzl
+++ b/elixir_app.bzl
@@ -4,7 +4,15 @@ load("//private:elixir_bytecode.bzl", "elixir_bytecode")
load("//private:elixir_ebin_dir.bzl", "elixir_ebin_dir")
load("//private:erlang_app_filter_module_conflicts.bzl", "erlang_app_filter_module_conflicts")

+def _prefixed(name, suffix, sep):
+ # The default name keeps the internal names and output dirs that
+ # elixir_app has always used, so existing users see no change.
+ if name == "erlang_app":
+ return suffix
+ return name + sep + suffix
+
def elixir_app(
+ name = "erlang_app",
app_name = None,
extra_apps = [],
srcs = None,
@@ -12,10 +20,18 @@ def elixir_app(
elixirc_opts = [],
ez_deps = [],
deps = [],
+ target_compatible_with = None,
+ testonly = False,
+ tags = None,
**kwargs):
"""compiles elixir sources in a manner compatible with @rules_erlang

Args:
+ name: Name of the final ErlangAppInfo target. With the default
+ "erlang_app", the internal targets are named beam_files,
+ app_file, ebin and elixir_without_app_overlap. With any other
+ name they are prefixed with "<name>_", and their output dirs
+ with "<name>/", so several apps can share a package.
app_name: Name of the application
extra_apps: additional apps (elixir is always included) injected into
the .app file
@@ -23,6 +39,9 @@ def elixir_app(
elixirc_opts: elixirc options
ez_deps: Dependencies that are .ez files
deps: ErlangAppInfo labels
+ target_compatible_with: Passed to every generated target
+ testonly: Passed to every generated target
+ tags: Passed to every generated target
**kwargs: Additional args passed to the underlying app_file rule, such
as app_description

@@ -34,45 +53,58 @@ def elixir_app(
"lib/**/*.ex",
])

+ beam_files = _prefixed(name, "beam_files", "_")
+ app_file_name = _prefixed(name, "app_file", "_")
+ ebin = _prefixed(name, "ebin", "_")
+ without_overlap = _prefixed(name, "elixir_without_app_overlap", "_")
+ common = dict(
+ target_compatible_with = target_compatible_with,
+ testonly = testonly,
+ tags = tags,
+ )
+
elixir_bytecode(
- name = "beam_files",
+ name = beam_files,
srcs = srcs,
data = data,
- dest = "beam_files",
+ dest = _prefixed(name, "beam_files", "/"),
elixirc_opts = elixirc_opts,
ez_deps = ez_deps,
deps = deps,
+ **common
)

app_file(
- name = "app_file",
+ name = app_file_name,
out = "%s.app" % app_name,
app_name = app_name,
extra_apps = ["elixir"] + extra_apps,
- modules = [":beam_files"],
- **kwargs
+ modules = [":" + beam_files],
+ **(common | kwargs)
)

elixir_ebin_dir(
- name = "ebin",
- beam_files_dir = ":beam_files",
- app_file = ":app_file",
- dest = "ebin",
+ name = ebin,
+ beam_files_dir = ":" + beam_files,
+ app_file = ":" + app_file_name,
+ dest = _prefixed(name, "ebin", "/"),
+ **common
)

erlang_app_filter_module_conflicts(
- name = "elixir_without_app_overlap",
- dest = "unconsolidated",
+ name = without_overlap,
+ dest = _prefixed(name, "unconsolidated", "/"),
src = Label("@rules_elixir//elixir:elixir"),
- without = [":ebin"],
+ without = [":" + ebin],
+ **common
)

erlang_app_info(
- name = "erlang_app",
+ name = name,
srcs = srcs,
hdrs = [],
app_name = app_name,
- beam = [":ebin"],
+ beam = [":" + ebin],
extra_apps = extra_apps,
# allow_empty: plenty of Hex packages ship no LICENSE file (ash among them), and
# with --incompatible_disallow_empty_glob on -- the default since Bazel 7 -- an
@@ -81,6 +113,7 @@ def elixir_app(
priv = [],
visibility = ["//visibility:public"],
deps = [
- ":elixir_without_app_overlap",
+ ":" + without_overlap,
] + deps,
+ **common
)
Loading