From bfd3035ee9a0603ca202ef1d702c241d00b3adf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 30 Nov 2018 13:49:16 +0100 Subject: Correct expanding of shell variables in autopatch The $(...) form was improperly converted. In addition it must be changed into a $(shell ...) form. --- core/deps.mk | 7 ++++--- test/core_deps.mk | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/core/deps.mk b/core/deps.mk index 6b7513e..0efde17 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -379,9 +379,10 @@ define dep_autopatch_rebar.erl end || H <- Hooks] end end(), - ShellToMk = fun(V) -> - re:replace(re:replace(V, "(\\\\$$)(\\\\w*)", "\\\\1(\\\\2)", [global]), - "-Werror\\\\b", "", [{return, list}, global]) + ShellToMk = fun(V0) -> + V1 = re:replace(V0, "[$$][(]", "$$\(shell ", [global]), + V = re:replace(V1, "(\\\\$$$$)(?![(])(\\\\w*)", "\\\\1(\\\\2)", [global]), + re:replace(V, "-Werror\\\\b", "", [{return, list}, global]) end, PortSpecs = fun() -> case lists:keyfind(port_specs, 1, Conf) of diff --git a/test/core_deps.mk b/test/core_deps.mk index a27a2b4..aa47dec 100644 --- a/test/core_deps.mk +++ b/test/core_deps.mk @@ -26,6 +26,43 @@ ifneq ($(PLATFORM),msys2) $t test -f $(APP)/deps/erlsha2/priv/erlsha2_nif.so endif +core-deps-autopatch-port_env: build clean + + $i "Bootstrap a new OTP library named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v + + $i "Bootstrap a new NIF named my_dep inside $(APP) that uses rebar" + $t mkdir $(APP)/my_dep + $t cp ../erlang.mk $(APP)/my_dep/ + $t $(MAKE) -C $(APP)/my_dep/ -f erlang.mk bootstrap-lib $v + $t $(MAKE) -C $(APP)/my_dep/ new-nif n=my_dep $v + $t rm $(APP)/my_dep/erlang.mk $(APP)/my_dep/Makefile + + $i "Add a rebar.config file with port_env to my_dep" + $t echo "{port_env, [" >> $(APP)/my_dep/rebar.config + $t echo "{\"CFLAGS\", \"\$$CFLAGS \$$(pkg-config --cflags domain-classifier 2>/dev/null)\"}," >> $(APP)/my_dep/rebar.config + $t echo "{\"LDFLAGS\", \"\$$LDFLAGS \$$(pkg-config --libs domain-classifier 2>/dev/null)\"}" >> $(APP)/my_dep/rebar.config + $t echo "]}." >> $(APP)/my_dep/rebar.config + + $i "Add my_dep to the list of dependencies" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = my_dep\ndep_my_dep = cp $(CURDIR)/$(APP)/my_dep/\n"}' $(APP)/Makefile + +ifdef LEGACY + $i "Add my_dep to the applications key in the .app.src file" + $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tmy_dep,\n"}' $(APP)/src/$(APP).app.src +endif + + $i "Build the application" + $t $(MAKE) -C $(APP) $v + + $i "Check that all dependencies were fetched" + $t test -d $(APP)/deps/my_dep + + $i "Confirm that the port_env configuration was expanded properly" + $t grep -q "shell pkg-config" $(APP)/deps/my_dep/c_src/Makefile.erlang.mk + # This test is expected to fail when run in parallel and flock/lockf is not available. core-deps-autopatch-two-rebar: build clean -- cgit v1.2.3