Skip to content

Commit

Permalink
Better .app autopatch handling
Browse files Browse the repository at this point in the history
If we have a .app and a .app.src we delete the .app.

If we have a Rebar project with a .app file, rename it to
.app.src and continue with autopatch.

If we have a non-Rebar project, leave the .app file, and then...

For all cases, delete the ebin/ folder after autopatch completes.
essen committed Nov 20, 2016

Unverified

This user has not yet uploaded their public signing key.
1 parent a8fffe1 commit 8a2ccf7
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions core/deps.mk
Original file line number Diff line number Diff line change
@@ -115,8 +115,6 @@ define dep_autopatch
$(call dep_autopatch2,$(1)); \
elif [ -n "`find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk -exec grep -i "^[^#].*rebar" '{}' \;`" ]; then \
$(call dep_autopatch2,$(1)); \
else \
$(call erlang,$(call dep_autopatch_app.erl,$(1))); \
fi \
else \
if [ ! -d $(DEPS_DIR)/$(1)/src/ ]; then \
@@ -128,6 +126,8 @@ define dep_autopatch
endef

define dep_autopatch2
mv -n $(DEPS_DIR)/$1/ebin/$1.app $(DEPS_DIR)/$1/src/$1.app.src; \
rm -f $(DEPS_DIR)/$1/ebin/$1.app; \
if [ -f $(DEPS_DIR)/$1/src/$1.app.src.script ]; then \
$(call erlang,$(call dep_autopatch_appsrc_script.erl,$(1))); \
fi; \
@@ -439,22 +439,6 @@ define dep_autopatch_rebar.erl
halt()
endef

define dep_autopatch_app.erl
UpdateModules = fun(App) ->
case filelib:is_regular(App) of
false -> ok;
true ->
{ok, [{application, '$(1)', L0}]} = file:consult(App),
Mods = filelib:fold_files("$(call core_native_path,$(DEPS_DIR)/$1/src)", "\\\\.erl$$", true,
fun (F, Acc) -> [list_to_atom(filename:rootname(filename:basename(F)))|Acc] end, []),
L = lists:keystore(modules, 1, L0, {modules, Mods}),
ok = file:write_file(App, io_lib:format("~p.~n", [{application, '$(1)', L}]))
end
end,
UpdateModules("$(call core_native_path,$(DEPS_DIR)/$1/ebin/$1.app)"),
halt()
endef

define dep_autopatch_appsrc_script.erl
AppSrc = "$(call core_native_path,$(DEPS_DIR)/$1/src/$1.app.src)",
AppSrcScript = AppSrc ++ ".script",
@@ -571,6 +555,7 @@ ifeq ($(filter $(1),$(NO_AUTOPATCH)),)
$$(call dep_autopatch,$(DEP_NAME)) \
fi
endif
$(verbose) rm -rf $(DEPS_DIR)/$(DEP_NAME)/ebin/
endef

$(foreach dep,$(BUILD_DEPS) $(DEPS),$(eval $(call dep_target,$(dep))))

0 comments on commit 8a2ccf7

Please sign in to comment.