Skip to content

Commit ce60053

Browse files
committed
Apply Erlang.mk import enhancements from main branch
1 parent 39903a0 commit ce60053

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

bzlmod/erlang_package.bzl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,26 @@ if [ ! -f BUILD.bazel ]; then
224224
echo "\tAttempting auto-configure from erlang.mk files..."
225225
226226
cat << 'MK' > bazel-autobuild.mk
227+
comma:= ,
228+
project:= $(lastword $(subst ., ,$(PROJECT)))
229+
ifnappsrc:= $(if $(wildcard src/$(project).app.src),,$1)
230+
227231
define BUILD_FILE_CONTENT
228232
load("@rules_erlang//:erlang_app.bzl", "erlang_app")
229233
230234
erlang_app(
231-
app_name = "$(PROJECT)",
232-
app_description = \"""$(PROJECT_DESCRIPTION)\""",
233-
app_version = "$(PROJECT_VERSION)",
234-
app_env = \"""$(PROJECT_ENV)\""",
235-
app_extra_keys = \"""$(PROJECT_APP_EXTRA_KEYS)\""",
236-
extra_apps = [
237-
$(foreach dep,$(LOCAL_DEPS), "$(dep)",\n) ],
235+
app_name = "$(project)",
236+
$(call ifnappsrc,$(if $(PROJECT_DESCRIPTION),app_description = \"""$(PROJECT_DESCRIPTION)\"""$(comma)))
237+
$(call ifnappsrc,app_version = "$(PROJECT_VERSION)"$(comma))
238+
$(call ifnappsrc,app_env = \"""$(PROJECT_ENV)\"""$(comma))
239+
$(call ifnappsrc,$(if $(PROJECT_APP_EXTRA_KEYS),app_extra = \"""$(PROJECT_APP_EXTRA_KEYS)\"""$(comma)))
240+
$(call ifnappsrc,$(if $(LOCAL_DEPS),extra_apps = [$(foreach dep,$(LOCAL_DEPS),\n "$(dep)",)\n ]$(comma)))
241+
$(call ifnappsrc,$(if $(BUILD_DEPS),build_deps = [$(foreach dep,$(BUILD_DEPS),\n "@$(dep)//:erlang_app",)\n ]$(comma)))
242+
$(call ifnappsrc,$(if $(DEPS),deps = [$(foreach dep,$(DEPS),\n "@$(dep)//:erlang_app",)\n ]$(comma)))
238243
erlc_opts = [
239244
"+deterministic",
240245
"+debug_info",
241246
],
242-
build_deps = [
243-
$(foreach dep,$(BUILD_DEPS), "@$(dep)//:erlang_app",\n) ],
244-
deps = [
245-
$(foreach dep,$(DEPS), "@$(dep)//:erlang_app",\n) ],
246247
stamp = 0,
247248
)
248249
endef

0 commit comments

Comments
 (0)