diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-09-19 18:54:22 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-09-19 18:54:22 -0500 |
commit | 52fcf0278d0e603f04a6b6181a61c84af1eebe5e (patch) | |
tree | 1edfd38f822d0dd5138eda0d89202f4624e76170 | |
parent | d78f66291f0f82b6c50193b041c7a26b4ced9037 (diff) |
add rebar providers create and plugin inclusion with providers
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | ebin/rebar.app | 32 | ||||
-rw-r--r-- | rebar.config | 20 | ||||
-rw-r--r-- | src/rebar3.erl | 4 | ||||
-rw-r--r-- | src/rebar_provider.erl | 16 |
5 files changed, 21 insertions, 53 deletions
@@ -14,4 +14,4 @@ rebar3 /.rebar rebar.lock priv/templates/*.dtl.erl -ebin/rebar.app
\ No newline at end of file +ebin diff --git a/ebin/rebar.app b/ebin/rebar.app deleted file mode 100644 index 831567b..0000000 --- a/ebin/rebar.app +++ /dev/null @@ -1,32 +0,0 @@ -{application,rebar, - [{description,"Rebar: Erlang Build Tool"}, - {vsn,"3.0.0"}, - {modules,['LICENSE_dtl','README.md_dtl','app.erl_dtl', - gitignore_dtl,'mod.erl_dtl','otp_app.app.src_dtl', - 'otp_lib.app.src_dtl','otp_lib.template_dtl', - 'rebar.config_dtl',rebar3,rebar_app_discover, - rebar_app_info,rebar_app_utils,rebar_base_compiler, - rebar_config,rebar_core,rebar_erlc_compiler, - rebar_erlydtl_compiler,rebar_fetch,rebar_file_utils, - rebar_log,rebar_otp_app,rebar_packages,rebar_plugins, - rebar_provider,rebar_prv_app_discovery, - rebar_prv_compile,rebar_prv_deps,rebar_prv_do, - rebar_prv_escripter,rebar_prv_help, - rebar_prv_install_deps,rebar_prv_lock,rebar_prv_new, - rebar_prv_packages,rebar_prv_release,rebar_prv_shell, - rebar_prv_tar,rebar_prv_update,rebar_prv_version, - rebar_state,rebar_templater,rebar_topo,rebar_utils, - 'relx.config_dtl','sup.erl_dtl','sys.config_dtl', - 'vm.args_dtl']}, - {registered,[]}, - {applications,[kernel,stdlib,sasl,compiler,crypto,syntax_tools, - tools,erlware_commons,relx,inets]}, - {env,[{log_level,warn}, - {providers,[rebar_prv_escripter,rebar_prv_deps, - rebar_prv_do,rebar_prv_lock, - rebar_prv_install_deps,rebar_prv_packages, - rebar_erlydtl_compiler,rebar_prv_compile, - rebar_prv_app_discovery,rebar_prv_shell, - rebar_prv_tar,rebar_prv_new,rebar_prv_update, - rebar_prv_release,rebar_prv_version, - rebar_prv_help]}]}]}. diff --git a/rebar.config b/rebar.config index e465df1..3e2dcbb 100644 --- a/rebar.config +++ b/rebar.config @@ -5,9 +5,10 @@ %% escript_incl_extra is for internal rebar-private use only. %% Do not use outside rebar. Config interface is not stable. -{escript_incl_extra, [{"priv/templates/*", "."}]}. +{escript_incl_extra, [{"priv/templates/*", "."}, {"rebar/include/*", "."}]}. + {escript_incl_apps, - [inets, getopt, erlydtl, erlware_commons, relx]}. + [inets, getopt, erlydtl, erlware_commons, relx, rebar]}. {escript_top_level_app, rebar}. {escript_name, rebar3}. @@ -20,21 +21,6 @@ {platform_define, "^[0-9]+", namespaced_types} ]}. -{xref_checks, []}. -{xref_queries, - [{"(XC - UC) || (XU - X - B - - (\"escript\":\"foldl\"/\"3\") - - (\"eunit_test\":\"function_wrapper\"/\"2\") - - (\"abnfc\":\"file\"/\"2\") - - (\"erlydtl\":\"compile\"/\"3\") - - (\"lfe_comp\":\"file\"/\"2\") - - (\"neotoma\":\"file\"/\"2\") - - (\"protobuffs_compile\":\"scan_file\"/\"2\") - - (\"diameter_codegen\":\"from_dict\"/\"4\") - - (\"diameter_dict_util\":\"format_error\"/\"1\") - - (\"diameter_dict_util\":\"parse\"/\"2\"))", - []}]}. - {first_files, [rebar_provider]}. {deps, [{relx, "", diff --git a/src/rebar3.erl b/src/rebar3.erl index dcd78f7..ec464fb 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -136,10 +136,12 @@ run_aux(State, Args) -> State1 = init_config1(State), + code:add_pathsa([filename:join(rebar_utils:get_cwd(), "plugins")]), %% Process each command, resetting any state between each one State2 = rebar_state:set(State1, base_dir, filename:absname(rebar_state:dir(State1))), {ok, Providers} = application:get_env(rebar, providers), - State3 = rebar_state:create_logic_providers(Providers, State2), + Plugins = rebar_state:get(State2, plugins, []), + State3 = rebar_state:create_logic_providers(Providers++Plugins, State2), Task = rebar_state:get(State3, task, "help"), rebar_core:process_command(rebar_state:command_args(State3, Args), list_to_atom(Task)), ok. diff --git a/src/rebar_provider.erl b/src/rebar_provider.erl index e5d7520..69ee22b 100644 --- a/src/rebar_provider.erl +++ b/src/rebar_provider.erl @@ -1,7 +1,8 @@ -module(rebar_provider). %% API --export([new/2, +-export([create/1, + new/2, do/2, impl/1, get_provider/2, @@ -59,6 +60,17 @@ new(ModuleName, State0) when is_atom(ModuleName) -> ModuleName:init(State0) end. +-spec create([{atom(), any()}]) -> t(). +create(Attrs) -> + #provider{name=proplists:get_value(name, Attrs, undefined) + ,provider_impl=proplists:get_value(provider_impl, Attrs, undefined) + ,bare=proplists:get_value(bare, Attrs, false) + ,deps=proplists:get_value(deps, Attrs, []) + ,desc=proplists:get_value(desc, Attrs, "") + ,short_desc=proplists:get_value(short_desc, Attrs, "") + ,example=proplists:get_value(example, Attrs, "") + ,opts=proplists:get_value(opts, Attrs, [])}. + %% @doc Manipulate the state of the system, that new state %% %% @param Provider the provider object @@ -109,7 +121,7 @@ get_target_providers(Target, State) -> Providers = rebar_state:providers(State), TargetProviders = lists:filter(fun(#provider{name=T}) when T =:= Target-> true; - (#provider{name=T}) -> + (_) -> false end, Providers), process_deps(TargetProviders, Providers). |