From 0845e2e3a7d252bb6879b3fd5d9cdce4deb13983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 23 May 2015 13:17:18 +0300 Subject: Fix numerous issues with rebar autopatching Packages color, enet, hamcrest and i18n were temporarily removed pending fixes. All other packages build and load properly. --- core/deps.mk | 100 +++++++++++++++++++++++++++++++++++++++++--------------- packages.v1.tsv | 4 --- packages.v1.txt | 4 --- packages.v2.tsv | 4 --- 4 files changed, 74 insertions(+), 38 deletions(-) diff --git a/core/deps.mk b/core/deps.mk index 368bc2a..5f000ac 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -120,6 +120,12 @@ define dep_autopatch_rebar_utils fi; \ if [ ! -f $(ERLANG_MK_TMP)/ebin/rebar_utils.beam ]; then \ erlc -o $(ERLANG_MK_TMP)/ebin $(ERLANG_MK_TMP)/rebar_utils.erl; \ + fi; \ + if [ ! -f $(ERLANG_MK_TMP)/rebar_log.erl ]; then \ + $(call core_http_get,$(ERLANG_MK_TMP)/rebar_log.erl,https://raw.githubusercontent.com/rebar/rebar/791db716b5a3a7671e0b351f95ddf24b848ee173/src/rebar_log.erl); \ + fi; \ + if [ ! -f $(ERLANG_MK_TMP)/ebin/rebar_log.beam ]; then \ + erlc -o $(ERLANG_MK_TMP)/ebin $(ERLANG_MK_TMP)/rebar_log.erl; \ fi endef @@ -132,20 +138,23 @@ define dep_autopatch_rebar endef define dep_autopatch_rebar.erl + application:set_env(rebar, log_level, debug), Conf1 = case file:consult("$(DEPS_DIR)/$(1)/rebar.config") of {ok, Conf0} -> Conf0; _ -> [] end, - {Conf, OsEnv} = case filelib:is_file("$(DEPS_DIR)/$(1)/rebar.config.script") of - false -> {Conf1, []}; - true -> - Bindings0 = erl_eval:new_bindings(), - Bindings1 = erl_eval:add_binding('CONFIG', Conf1, Bindings0), - Bindings = erl_eval:add_binding('SCRIPT', "$(DEPS_DIR)/$(1)/rebar.config.script", Bindings1), - Before = os:getenv(), - {ok, Conf2} = file:script("$(DEPS_DIR)/$(1)/rebar.config.script", Bindings), - {Conf2, lists:foldl(fun(E, Acc) -> lists:delete(E, Acc) end, os:getenv(), Before)} - end, + {Conf, OsEnv} = fun() -> + case filelib:is_file("$(DEPS_DIR)/$(1)/rebar.config.script") of + false -> {Conf1, []}; + true -> + Bindings0 = erl_eval:new_bindings(), + Bindings1 = erl_eval:add_binding('CONFIG', Conf1, Bindings0), + Bindings = erl_eval:add_binding('SCRIPT', "$(DEPS_DIR)/$(1)/rebar.config.script", Bindings1), + Before = os:getenv(), + {ok, Conf2} = file:script("$(DEPS_DIR)/$(1)/rebar.config.script", Bindings), + {Conf2, lists:foldl(fun(E, Acc) -> lists:delete(E, Acc) end, os:getenv(), Before)} + end + end(), Write = fun (Text) -> file:write_file("$(DEPS_DIR)/$(1)/Makefile", Text, [append]) end, @@ -240,7 +249,8 @@ define dep_autopatch_rebar.erl Write(["COMPILE_FIRST +=", [[" ", atom_to_list(M)] || M <- First, lists:member("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(M) ++ ".erl", ErlFiles)], "\n"]) end(), - Write("\n\nrebar_dep: pre-deps deps pre-app app\n"), + Write("\n\nrebar_dep: preprocess pre-deps deps pre-app app\n"), + Write("\npreprocess::\n"), Write("\npre-deps::\n"), Write("\npre-app::\n"), fun() -> @@ -276,9 +286,11 @@ define dep_autopatch_rebar.erl PortSpecs = fun() -> case lists:keyfind(port_specs, 1, Conf) of false -> - case filelib:wildcard("$(DEPS_DIR)/$(1)/c_src/*.c") of - [] -> []; - Src -> [{"priv/$(1)_drv.so", ["c_src/*.c"], []}] + case filelib:is_dir("$(DEPS_DIR)/$(1)/c_src") of + false -> []; + true -> + [{"priv/" ++ proplists:get_value(so_name, Conf, "$(1)_drv.so"), + proplists:get_value(port_sources, Conf, ["c_src/*.c"]), []}] end; {_, Specs} -> lists:flatten([case S of @@ -335,12 +347,13 @@ define dep_autopatch_rebar.erl filelib:ensure_dir("$(DEPS_DIR)/$(1)/" ++ Output), Input = [[" ", I] || I <- Input0], PortSpecWrite([ - [["\n", K, " = ", ShellToMk(V)] || {K, V} <- lists:reverse(MergeEnv(PortEnv ++ FilterEnv(Env)))], + [["\n", K, " = ", ShellToMk(V)] || {K, V} <- lists:reverse(MergeEnv(PortEnv))], "\n\nall:: ", Output, "\n\n", "%.o: %.c\n\t$$$$\(CC) -c -o $$$$\@ $$$$\< $$$$\(CFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n", "%.o: %.C\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n", "%.o: %.cc\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n", "%.o: %.cpp\n\t$$$$\(CXX) -c -o $$$$\@ $$$$\< $$$$\(CXXFLAGS) $$$$\(ERL_CFLAGS) $$$$\(DRV_CFLAGS) $$$$\(EXE_CFLAGS)\n\n", + [[Output, ": ", K, " = ", ShellToMk(V), "\n"] || {K, V} <- lists:reverse(MergeEnv(FilterEnv(Env)))], Output, ": $$$$\(foreach ext,.c .C .cc .cpp,", "$$$$\(patsubst %$$$$\(ext),%.o,$$$$\(filter %$$$$\(ext),$$$$\(wildcard", Input, "))))\n", "\t$$$$\(CC) -o $$$$\@ $$$$\? $$$$\(LDFLAGS) $$$$\(ERL_LDFLAGS) $$$$\(DRV_LDFLAGS) $$$$\(EXE_LDFLAGS)", @@ -352,19 +365,54 @@ define dep_autopatch_rebar.erl [PortSpec(S) || S <- PortSpecs] end, Write("\ninclude ../../erlang.mk"), + PatchPlugin = fun(ErlFile) -> + {ok, F0} = file:read_file(ErlFile), + F = re:replace(F0, "rebar_config:", "rebar_config_", [global]), + ok = file:write_file(ErlFile, [F, + "\nrebar_config_get(_, current_command, _) -> compile.\n" + ]) + end, + RunPlugin = fun(Plugin, Step) -> + case erlang:function_exported(Plugin, Step, 2) of + false -> ok; + true -> + c:cd("$(DEPS_DIR)/$(1)/"), + Ret = Plugin:Step(Conf, undefined), + io:format("rebar plugin ~p step ~p ret ~p~n", [Plugin, Step, Ret]) + end + end, fun() -> case lists:keyfind(plugins, 1, Conf) of - {_, [Plugin]} when is_atom(Plugin) -> - ErlFile = "$(DEPS_DIR)/$(1)/plugins/" ++ atom_to_list(Plugin) ++ ".erl", - try - {ok, Mod, Bin} = compile:file(ErlFile, [binary]), - {module, Mod} = code:load_binary(Mod, ErlFile, Bin), - c:cd("$(DEPS_DIR)/$(1)/"), - ok = Mod:pre_compile(Conf, undefined) - catch _:_ -> - ok - end; - _ -> ok + false -> ok; + {_, Plugins} -> + [begin + case lists:keyfind(deps, 1, Conf) of + false -> ok; + {_, Deps} -> + case lists:keyfind(P, 1, Deps) of + false -> ok; + _ -> + Path = "$(DEPS_DIR)/" ++ atom_to_list(P), + io:format("~s", [os:cmd("$(MAKE) -C $(DEPS_DIR)/$(1) " ++ Path)]), + io:format("~s", [os:cmd("$(MAKE) -C " ++ Path ++ " IS_DEP=1")]), + code:add_patha(Path ++ "/ebin") + end + end + end || P <- Plugins], + [case code:load_file(P) of + {module, P} -> ok; + _ -> + case lists:keyfind(plugin_dir, 1, Conf) of + false -> ok; + {_, PluginsDir} -> + ErlFile = "$(DEPS_DIR)/$(1)/" ++ PluginsDir ++ "/" ++ atom_to_list(P) ++ ".erl", + PatchPlugin(ErlFile), + {ok, P, Bin} = compile:file(ErlFile, [binary]), + {module, P} = code:load_binary(P, ErlFile, Bin) + end + end || P <- Plugins], + [RunPlugin(P, preprocess) || P <- Plugins], + [RunPlugin(P, pre_compile) || P <- Plugins] end end(), halt() diff --git a/packages.v1.tsv b/packages.v1.tsv index 23673ac..62c3494 100644 --- a/packages.v1.tsv +++ b/packages.v1.tsv @@ -30,7 +30,6 @@ chronos https://github.com/lehoff/chronos https://github.com/lehoff/chronos Time classifier https://github.com/inaka/classifier https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier clique https://github.com/basho/clique https://github.com/basho/clique CLI Framework for Erlang cluster_info https://github.com/basho/cluster_info https://github.com/basho/cluster_info Fork of Hibari's nifty cluster_info OTP app -color https://github.com/julianduque/erlang-color https://github.com/julianduque/erlang-color ANSI colors for your Erlang confetti https://github.com/jtendo/confetti https://github.com/jtendo/confetti Erlang configuration provider / application:get_env/2 on steroids couchbeam https://github.com/benoitc/couchbeam https://github.com/benoitc/couchbeam Apache CouchDB client in Erlang couch https://github.com/benoitc/opencouch https://github.com/benoitc/opencouch A embeddable document oriented database compatible with Apache CouchDB @@ -75,7 +74,6 @@ elli https://github.com/knutin/elli https://github.com/knutin/elli Simple, robus elvis https://github.com/inaka/elvis https://github.com/inaka/elvis Erlang Style Reviewer emagick https://github.com/kivra/emagick https://github.com/kivra/emagick Wrapper for Graphics/ImageMagick command line tool. emysql https://github.com/Eonblast/Emysql https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver. -enet https://github.com/archaelus/enet https://github.com/archaelus/enet Pure Erlang network stack enm https://github.com/basho/enm https://github.com/basho/enm Erlang driver for nanomsg entop https://github.com/mazenharake/entop https://github.com/mazenharake/entop A top-like tool for monitoring an Erlang node epcap https://github.com/msantos/epcap https://github.com/msantos/epcap Erlang packet capture interface using pcap @@ -163,10 +161,8 @@ gproc https://github.com/uwiger/gproc https://github.com/uwiger/gproc Extended p grapherl https://github.com/eproxus/grapherl https://github.com/eproxus/grapherl Create graphs of Erlang systems and programs gun https://github.com/ninenines/gun http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang. hackney https://github.com/benoitc/hackney https://github.com/benoitc/hackney simple HTTP client in Erlang -hamcrest https://github.com/hyperthunk/hamcrest-erlang https://github.com/hyperthunk/hamcrest-erlang Erlang port of Hamcrest hanoidb https://github.com/krestenkrab/hanoidb https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage hottub https://github.com/bfrog/hottub https://github.com/bfrog/hottub Permanent Erlang Worker Pool -i18n https://github.com/erlang-unicode/i18n https://github.com/erlang-unicode/i18n icu nif: international components for unicode from Erlang (unicode, date, string, number, format, locale, localization, transliteration, icu4e) ibrowse https://github.com/cmullaparthi/ibrowse https://github.com/cmullaparthi/ibrowse Erlang HTTP client ierlang https://github.com/robbielynch/ierlang https://github.com/robbielynch/ierlang An Erlang language kernel for IPython. ircbot https://github.com/gdamjan/erlang-irc-bot https://github.com/gdamjan/erlang-irc-bot A simple extendable irc bot in Erlang diff --git a/packages.v1.txt b/packages.v1.txt index 23673ac..62c3494 100644 --- a/packages.v1.txt +++ b/packages.v1.txt @@ -30,7 +30,6 @@ chronos https://github.com/lehoff/chronos https://github.com/lehoff/chronos Time classifier https://github.com/inaka/classifier https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier clique https://github.com/basho/clique https://github.com/basho/clique CLI Framework for Erlang cluster_info https://github.com/basho/cluster_info https://github.com/basho/cluster_info Fork of Hibari's nifty cluster_info OTP app -color https://github.com/julianduque/erlang-color https://github.com/julianduque/erlang-color ANSI colors for your Erlang confetti https://github.com/jtendo/confetti https://github.com/jtendo/confetti Erlang configuration provider / application:get_env/2 on steroids couchbeam https://github.com/benoitc/couchbeam https://github.com/benoitc/couchbeam Apache CouchDB client in Erlang couch https://github.com/benoitc/opencouch https://github.com/benoitc/opencouch A embeddable document oriented database compatible with Apache CouchDB @@ -75,7 +74,6 @@ elli https://github.com/knutin/elli https://github.com/knutin/elli Simple, robus elvis https://github.com/inaka/elvis https://github.com/inaka/elvis Erlang Style Reviewer emagick https://github.com/kivra/emagick https://github.com/kivra/emagick Wrapper for Graphics/ImageMagick command line tool. emysql https://github.com/Eonblast/Emysql https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver. -enet https://github.com/archaelus/enet https://github.com/archaelus/enet Pure Erlang network stack enm https://github.com/basho/enm https://github.com/basho/enm Erlang driver for nanomsg entop https://github.com/mazenharake/entop https://github.com/mazenharake/entop A top-like tool for monitoring an Erlang node epcap https://github.com/msantos/epcap https://github.com/msantos/epcap Erlang packet capture interface using pcap @@ -163,10 +161,8 @@ gproc https://github.com/uwiger/gproc https://github.com/uwiger/gproc Extended p grapherl https://github.com/eproxus/grapherl https://github.com/eproxus/grapherl Create graphs of Erlang systems and programs gun https://github.com/ninenines/gun http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang. hackney https://github.com/benoitc/hackney https://github.com/benoitc/hackney simple HTTP client in Erlang -hamcrest https://github.com/hyperthunk/hamcrest-erlang https://github.com/hyperthunk/hamcrest-erlang Erlang port of Hamcrest hanoidb https://github.com/krestenkrab/hanoidb https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage hottub https://github.com/bfrog/hottub https://github.com/bfrog/hottub Permanent Erlang Worker Pool -i18n https://github.com/erlang-unicode/i18n https://github.com/erlang-unicode/i18n icu nif: international components for unicode from Erlang (unicode, date, string, number, format, locale, localization, transliteration, icu4e) ibrowse https://github.com/cmullaparthi/ibrowse https://github.com/cmullaparthi/ibrowse Erlang HTTP client ierlang https://github.com/robbielynch/ierlang https://github.com/robbielynch/ierlang An Erlang language kernel for IPython. ircbot https://github.com/gdamjan/erlang-irc-bot https://github.com/gdamjan/erlang-irc-bot A simple extendable irc bot in Erlang diff --git a/packages.v2.tsv b/packages.v2.tsv index cc7ac43..1ade952 100644 --- a/packages.v2.tsv +++ b/packages.v2.tsv @@ -30,7 +30,6 @@ chronos git https://github.com/lehoff/chronos master https://github.com/lehoff/c classifier git https://github.com/inaka/classifier master https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier clique git https://github.com/basho/clique develop https://github.com/basho/clique CLI Framework for Erlang cluster_info git https://github.com/basho/cluster_info master https://github.com/basho/cluster_info Fork of Hibari's nifty cluster_info OTP app -color git https://github.com/julianduque/erlang-color master https://github.com/julianduque/erlang-color ANSI colors for your Erlang confetti git https://github.com/jtendo/confetti master https://github.com/jtendo/confetti Erlang configuration provider / application:get_env/2 on steroids couchbeam git https://github.com/benoitc/couchbeam master https://github.com/benoitc/couchbeam Apache CouchDB client in Erlang couch git https://github.com/benoitc/opencouch master https://github.com/benoitc/opencouch A embeddable document oriented database compatible with Apache CouchDB @@ -75,7 +74,6 @@ elli git https://github.com/knutin/elli master https://github.com/knutin/elli Si elvis git https://github.com/inaka/elvis 0.2.4 https://github.com/inaka/elvis Erlang Style Reviewer emagick git https://github.com/kivra/emagick master https://github.com/kivra/emagick Wrapper for Graphics/ImageMagick command line tool. emysql git https://github.com/Eonblast/Emysql master https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver. -enet git https://github.com/archaelus/enet master https://github.com/archaelus/enet Pure Erlang network stack enm git https://github.com/basho/enm master https://github.com/basho/enm Erlang driver for nanomsg entop git https://github.com/mazenharake/entop master https://github.com/mazenharake/entop A top-like tool for monitoring an Erlang node epcap git https://github.com/msantos/epcap master https://github.com/msantos/epcap Erlang packet capture interface using pcap @@ -163,10 +161,8 @@ gproc git https://github.com/uwiger/gproc master https://github.com/uwiger/gproc grapherl git https://github.com/eproxus/grapherl master https://github.com/eproxus/grapherl Create graphs of Erlang systems and programs gun git https://github.com/ninenines/gun master http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang. hackney git https://github.com/benoitc/hackney master https://github.com/benoitc/hackney simple HTTP client in Erlang -hamcrest git https://github.com/hyperthunk/hamcrest-erlang master https://github.com/hyperthunk/hamcrest-erlang Erlang port of Hamcrest hanoidb git https://github.com/krestenkrab/hanoidb master https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage hottub git https://github.com/bfrog/hottub master https://github.com/bfrog/hottub Permanent Erlang Worker Pool -i18n git https://github.com/erlang-unicode/i18n master https://github.com/erlang-unicode/i18n icu nif: international components for unicode from Erlang (unicode, date, string, number, format, locale, localization, transliteration, icu4e) ibrowse git https://github.com/cmullaparthi/ibrowse v4.1.1 https://github.com/cmullaparthi/ibrowse Erlang HTTP client ierlang git https://github.com/robbielynch/ierlang master https://github.com/robbielynch/ierlang An Erlang language kernel for IPython. ircbot git https://github.com/gdamjan/erlang-irc-bot master https://github.com/gdamjan/erlang-irc-bot A simple extendable irc bot in Erlang -- cgit v1.2.3