Skip to content

Commit 371d4ad

Browse files
authored
Merge pull request #41 from rabbitmq/enhanced-erlang-mk-autobuild
Enhanced erlang mk autobuild
2 parents 31f3223 + c9cc64f commit 371d4ad

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

bzlmod/extensions.bzl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,25 +359,25 @@ if [ ! -f BUILD.bazel ]; then
359359
echo "\tAttempting auto-configure from erlang.mk files..."
360360
361361
cat << 'MK' > bazel-autobuild.mk
362+
comma:= ,
363+
project:= $(lastword $(subst ., ,$(PROJECT)))
364+
ifnappsrc:= $(if $(wildcard src/$(project).app.src),,$1)
362365
define BUILD_FILE_CONTENT
363366
load("@rules_erlang//:erlang_app.bzl", "erlang_app")
364367
365368
erlang_app(
366-
app_name = "$(PROJECT)",
367-
app_description = \"""$(PROJECT_DESCRIPTION)\""",
368-
app_version = "$(PROJECT_VERSION)",
369-
app_env = \"""$(PROJECT_ENV)\""",
370-
app_extra = \"""$(PROJECT_APP_EXTRA_KEYS)\""",
371-
extra_apps = [
372-
$(foreach dep,$(LOCAL_DEPS), "$(dep)",\n) ],
369+
app_name = "$(project)",
370+
$(call ifnappsrc,$(if $(PROJECT_DESCRIPTION),app_description = \"""$(PROJECT_DESCRIPTION)\"""$(comma)))
371+
$(call ifnappsrc,app_version = "$(PROJECT_VERSION)"$(comma))
372+
$(call ifnappsrc,app_env = \"""$(PROJECT_ENV)\"""$(comma))
373+
$(call ifnappsrc,$(if $(PROJECT_APP_EXTRA_KEYS),app_extra = \"""$(PROJECT_APP_EXTRA_KEYS)\"""$(comma)))
374+
$(call ifnappsrc,$(if $(LOCAL_DEPS),extra_apps = [$(foreach dep,$(LOCAL_DEPS),\n "$(dep)",)\n ]$(comma)))
375+
$(call ifnappsrc,$(if $(BUILD_DEPS),build_deps = [$(foreach dep,$(BUILD_DEPS),\n "@$(dep)//:erlang_app",)\n ]$(comma)))
376+
$(call ifnappsrc,$(if $(DEPS),deps = [$(foreach dep,$(DEPS),\n "@$(dep)//:erlang_app",)\n ]$(comma)))
373377
erlc_opts = [
374378
"+deterministic",
375379
"+debug_info",
376380
],
377-
build_deps = [
378-
$(foreach dep,$(BUILD_DEPS), "@$(dep)//:erlang_app",\n) ],
379-
deps = [
380-
$(foreach dep,$(DEPS), "@$(dep)//:erlang_app",\n) ],
381381
stamp = 0,
382382
)
383383
endef

0 commit comments

Comments
 (0)