diff options
| -rw-r--r-- | erlang.mk | 47 |
1 files changed, 38 insertions, 9 deletions
@@ -17,7 +17,7 @@ ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST))) export ERLANG_MK_FILENAME -ERLANG_MK_VERSION = e13b4c7 +ERLANG_MK_VERSION = 2022.05.31-142-gba4dcff-dirty ERLANG_MK_WITHOUT = # Make 3.81 and 3.82 are deprecated. @@ -559,6 +559,14 @@ export ERL_LIBS export NO_AUTOPATCH +# Elixir. + +# Elixir is automatically enabled in all cases except when +# an Erlang project uses an Elixir dependency. In that case +# $(ELIXIR) must be set explicitly. +ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,$(if $(EX_FILES),system,disable)) +export ELIXIR + # Verbosity. dep_verbose_0 = @echo " DEP $1 ($(call query_version,$1))"; @@ -940,10 +948,11 @@ define dep_autopatch_rebar.erl Write(io_lib:format("COMPILE_FIRST +=~s\n", [Names])) end end(), - Write("\n\nrebar_dep: preprocess pre-deps deps pre-app app\n"), + Write("\n\nrebar_dep: preprocess pre-deps deps pre-app app post-app\n"), Write("\npreprocess::\n"), Write("\npre-deps::\n"), Write("\npre-app::\n"), + Write("\npost-app::\n"), PatchHook = fun(Cmd) -> Cmd2 = re:replace(Cmd, "^([g]?make)(.*)( -C.*)", "\\\\1\\\\3\\\\2", [{return, list}]), case Cmd2 of @@ -974,6 +983,24 @@ define dep_autopatch_rebar.erl end || H <- Hooks] end end(), + fun() -> + case lists:keyfind(post_hooks, 1, Conf) of + false -> ok; + {_, Hooks} -> + [case H of + {compile, Cmd} -> + Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n"); + {{pc, compile}, Cmd} -> + Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n"); + {Regex, compile, Cmd} -> + case rebar_utils:is_arch(Regex) of + true -> Write("\npost-app::\n\tCC=$$\(CC) " ++ PatchHook(Cmd) ++ "\n"); + false -> ok + end; + _ -> ok + end || H <- Hooks] + end + end(), ShellToMk = fun(V0) -> V1 = re:replace(V0, "[$$][(]", "$$\(shell ", [global]), V = re:replace(V1, "([$$])(?![(])(\\\\w*)", "\\\\1(\\\\2)", [global]), @@ -1691,6 +1718,12 @@ endef ifeq ($(if $(NO_MAKEDEP),$(wildcard $(PROJECT).d),),) $(PROJECT).d:: $(ERL_FILES) $(EX_FILES) $(call core_find,include/,*.hrl) $(MAKEFILE_LIST) +# Rebuild everything when the .d file does not exist. +# We touch $@ to make sure the command doesn't fail in empty projects. +# The file will be generated with content immediately after. + $(verbose) if ! test -e $@; then \ + touch $@ $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES); \ + fi $(makedep_verbose) $(call erlang,$(call makedep.erl,$@)) endif @@ -1778,12 +1811,6 @@ endif # Copyright (c) 2024, Loïc Hoguin <[email protected]> # This file is part of erlang.mk and subject to the terms of the ISC License. -# Elixir is automatically enabled in all cases except when -# an Erlang project uses an Elixir dependency. In that case -# $(ELIXIR) must be set explicitly. -ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,$(if $(EX_FILES),system,disable)) -export ELIXIR - ifeq ($(ELIXIR),system) # We expect 'elixir' to be on the path. ELIXIR_BIN ?= $(shell readlink -f `which elixir`) @@ -1952,7 +1979,8 @@ define dep_autopatch_mix.erl endef define dep_autopatch_mix - sed 's|\(defmodule.*do\)|\1\n try do\n Code.compiler_options(on_undefined_variable: :warn)\n rescue _ -> :ok\n end\n|g' -i $(DEPS_DIR)/$(1)/mix.exs; \ + sed 's|\(defmodule.*do\)|\1\n try do\n Code.compiler_options(on_undefined_variable: :warn)\n rescue _ -> :ok\n end\n|g' $(DEPS_DIR)/$(1)/mix.exs > $(DEPS_DIR)/$(1)/mix.exs.new; \ + mv $(DEPS_DIR)/$(1)/mix.exs.new $(DEPS_DIR)/$(1)/mix.exs; \ $(MAKE) $(DEPS_DIR)/hex_core/ebin/dep_built; \ MIX_ENV="$(if $(MIX_ENV),$(strip $(MIX_ENV)),prod)" \ $(call erlang,$(call dep_autopatch_mix.erl,$1)) @@ -1964,6 +1992,7 @@ endef define compile_ex.erl {ok, _} = application:ensure_all_started(elixir), {ok, _} = application:ensure_all_started(mix), + $(foreach dep,$(LOCAL_DEPS),_ = application:load($(dep)),) ModCode = list_to_atom("Elixir.Code"), ModCode:put_compiler_option(ignore_module_conflict, true), ModComp = list_to_atom("Elixir.Kernel.ParallelCompiler"), |
