From 2e5496f5f5f3c39bd1e23b4601d1e89d4d2c9767 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Tue, 28 Apr 2015 19:50:55 -0500 Subject: remove use of erlydtl in rebar --- priv/templates/LICENSE | 29 ++++++++++++++ priv/templates/LICENSE.dtl | 29 -------------- priv/templates/Makefile | 74 ++++++++++++++++++++++++++++++++++++ priv/templates/Makefile.dtl | 74 ------------------------------------ priv/templates/README.md | 9 +++++ priv/templates/README.md.dtl | 9 ----- priv/templates/app.erl | 27 +++++++++++++ priv/templates/app.erl.dtl | 27 ------------- priv/templates/app.template | 14 +++---- priv/templates/cmake.template | 2 +- priv/templates/gitignore | 18 +++++++++ priv/templates/gitignore.dtl | 18 --------- priv/templates/lib.template | 12 +++--- priv/templates/mod.erl | 13 +++++++ priv/templates/mod.erl.dtl | 13 ------- priv/templates/otp_app.app.src | 12 ++++++ priv/templates/otp_app.app.src.dtl | 12 ------ priv/templates/otp_lib.app.src | 9 +++++ priv/templates/otp_lib.app.src.dtl | 9 ----- priv/templates/plugin.erl | 33 ++++++++++++++++ priv/templates/plugin.erl.dtl | 33 ---------------- priv/templates/plugin.template | 12 +++--- priv/templates/plugin_README.md | 26 +++++++++++++ priv/templates/plugin_README.md.dtl | 26 ------------- priv/templates/rebar.config | 2 + priv/templates/rebar.config.dtl | 2 - priv/templates/release.template | 18 ++++----- priv/templates/relx_rebar.config | 20 ++++++++++ priv/templates/relx_rebar.config.dtl | 20 ---------- priv/templates/sup.erl | 35 +++++++++++++++++ priv/templates/sup.erl.dtl | 35 ----------------- priv/templates/sys.config | 3 ++ priv/templates/sys.config.dtl | 3 -- priv/templates/vm.args | 6 +++ priv/templates/vm.args.dtl | 6 --- 35 files changed, 345 insertions(+), 345 deletions(-) create mode 100644 priv/templates/LICENSE delete mode 100644 priv/templates/LICENSE.dtl create mode 100644 priv/templates/Makefile delete mode 100644 priv/templates/Makefile.dtl create mode 100644 priv/templates/README.md delete mode 100644 priv/templates/README.md.dtl create mode 100644 priv/templates/app.erl delete mode 100644 priv/templates/app.erl.dtl create mode 100644 priv/templates/gitignore delete mode 100644 priv/templates/gitignore.dtl create mode 100644 priv/templates/mod.erl delete mode 100644 priv/templates/mod.erl.dtl create mode 100644 priv/templates/otp_app.app.src delete mode 100644 priv/templates/otp_app.app.src.dtl create mode 100644 priv/templates/otp_lib.app.src delete mode 100644 priv/templates/otp_lib.app.src.dtl create mode 100644 priv/templates/plugin.erl delete mode 100644 priv/templates/plugin.erl.dtl create mode 100644 priv/templates/plugin_README.md delete mode 100644 priv/templates/plugin_README.md.dtl create mode 100644 priv/templates/rebar.config delete mode 100644 priv/templates/rebar.config.dtl create mode 100644 priv/templates/relx_rebar.config delete mode 100644 priv/templates/relx_rebar.config.dtl create mode 100644 priv/templates/sup.erl delete mode 100644 priv/templates/sup.erl.dtl create mode 100644 priv/templates/sys.config delete mode 100644 priv/templates/sys.config.dtl create mode 100644 priv/templates/vm.args delete mode 100644 priv/templates/vm.args.dtl (limited to 'priv') diff --git a/priv/templates/LICENSE b/priv/templates/LICENSE new file mode 100644 index 0000000..41588ab --- /dev/null +++ b/priv/templates/LICENSE @@ -0,0 +1,29 @@ +Copyright (c) {{copyright_year}}, {{author_name}} <{{author_email}}>. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/priv/templates/LICENSE.dtl b/priv/templates/LICENSE.dtl deleted file mode 100644 index 41588ab..0000000 --- a/priv/templates/LICENSE.dtl +++ /dev/null @@ -1,29 +0,0 @@ -Copyright (c) {{copyright_year}}, {{author_name}} <{{author_email}}>. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -* The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/priv/templates/Makefile b/priv/templates/Makefile new file mode 100644 index 0000000..d3c3767 --- /dev/null +++ b/priv/templates/Makefile @@ -0,0 +1,74 @@ +# Based on c_src.mk from erlang.mk by Loic Hoguin + +CURDIR := $(shell pwd) +BASEDIR := $(abspath $(CURDIR)/..) + +PROJECT ?= $(notdir $(BASEDIR)) +PROJECT := $(strip $(PROJECT)) + +ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).") +ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).") +ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).") + +C_SRC_DIR = $(CURDIR) +C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so + +# System type and C compiler/flags. + +UNAME_SYS := $(shell uname -s) +ifeq ($(UNAME_SYS), Darwin) + CC ?= cc + CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall + LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress +else ifeq ($(UNAME_SYS), FreeBSD) + CC ?= cc + CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -finline-functions -Wall +else ifeq ($(UNAME_SYS), Linux) + CC ?= gcc + CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -finline-functions -Wall +endif + +CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) +CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) + +LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei +LDFLAGS += -shared + +# Verbosity. + +c_verbose_0 = @echo " C " $(?F); +c_verbose = $(c_verbose_$(V)) + +cpp_verbose_0 = @echo " CPP " $(?F); +cpp_verbose = $(cpp_verbose_$(V)) + +link_verbose_0 = @echo " LD " $(@F); +link_verbose = $(link_verbose_$(V)) + +SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \)) +OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) + +COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c +COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c + +$(C_SRC_OUTPUT): $(OBJECTS) + @mkdir -p $(BASEDIR)/priv/ + $(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) + +%.o: %.c + $(COMPILE_C) $(OUTPUT_OPTION) $< + +%.o: %.cc + $(COMPILE_CPP) $(OUTPUT_OPTION) $< + +%.o: %.C + $(COMPILE_CPP) $(OUTPUT_OPTION) $< + +%.o: %.cpp + $(COMPILE_CPP) $(OUTPUT_OPTION) $< + +clean: + @rm -f $(C_SRC_OUTPUT) $(OBJECTS) diff --git a/priv/templates/Makefile.dtl b/priv/templates/Makefile.dtl deleted file mode 100644 index d3c3767..0000000 --- a/priv/templates/Makefile.dtl +++ /dev/null @@ -1,74 +0,0 @@ -# Based on c_src.mk from erlang.mk by Loic Hoguin - -CURDIR := $(shell pwd) -BASEDIR := $(abspath $(CURDIR)/..) - -PROJECT ?= $(notdir $(BASEDIR)) -PROJECT := $(strip $(PROJECT)) - -ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).") -ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).") -ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).") - -C_SRC_DIR = $(CURDIR) -C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so - -# System type and C compiler/flags. - -UNAME_SYS := $(shell uname -s) -ifeq ($(UNAME_SYS), Darwin) - CC ?= cc - CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes - CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall - LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress -else ifeq ($(UNAME_SYS), FreeBSD) - CC ?= cc - CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes - CXXFLAGS ?= -O3 -finline-functions -Wall -else ifeq ($(UNAME_SYS), Linux) - CC ?= gcc - CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes - CXXFLAGS ?= -O3 -finline-functions -Wall -endif - -CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) -CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) - -LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei -LDFLAGS += -shared - -# Verbosity. - -c_verbose_0 = @echo " C " $(?F); -c_verbose = $(c_verbose_$(V)) - -cpp_verbose_0 = @echo " CPP " $(?F); -cpp_verbose = $(cpp_verbose_$(V)) - -link_verbose_0 = @echo " LD " $(@F); -link_verbose = $(link_verbose_$(V)) - -SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \)) -OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) - -COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c -COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c - -$(C_SRC_OUTPUT): $(OBJECTS) - @mkdir -p $(BASEDIR)/priv/ - $(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) - -%.o: %.c - $(COMPILE_C) $(OUTPUT_OPTION) $< - -%.o: %.cc - $(COMPILE_CPP) $(OUTPUT_OPTION) $< - -%.o: %.C - $(COMPILE_CPP) $(OUTPUT_OPTION) $< - -%.o: %.cpp - $(COMPILE_CPP) $(OUTPUT_OPTION) $< - -clean: - @rm -f $(C_SRC_OUTPUT) $(OBJECTS) diff --git a/priv/templates/README.md b/priv/templates/README.md new file mode 100644 index 0000000..5507536 --- /dev/null +++ b/priv/templates/README.md @@ -0,0 +1,9 @@ +{{name}} +===== + +{{desc}} + +Build +----- + + $ rebar3 compile diff --git a/priv/templates/README.md.dtl b/priv/templates/README.md.dtl deleted file mode 100644 index 5507536..0000000 --- a/priv/templates/README.md.dtl +++ /dev/null @@ -1,9 +0,0 @@ -{{name}} -===== - -{{desc}} - -Build ------ - - $ rebar3 compile diff --git a/priv/templates/app.erl b/priv/templates/app.erl new file mode 100644 index 0000000..83eb9a3 --- /dev/null +++ b/priv/templates/app.erl @@ -0,0 +1,27 @@ +%%%------------------------------------------------------------------- +%% @doc {{name}} public API +%% @end +%%%------------------------------------------------------------------- + +-module({{name}}_app). + +-behaviour(application). + +%% Application callbacks +-export([start/2 + ,stop/1]). + +%%==================================================================== +%% API +%%==================================================================== + +start(_StartType, _StartArgs) -> + {{name}}_sup:start_link(). + +%%-------------------------------------------------------------------- +stop(_State) -> + ok. + +%%==================================================================== +%% Internal functions +%%==================================================================== diff --git a/priv/templates/app.erl.dtl b/priv/templates/app.erl.dtl deleted file mode 100644 index 83eb9a3..0000000 --- a/priv/templates/app.erl.dtl +++ /dev/null @@ -1,27 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc {{name}} public API -%% @end -%%%------------------------------------------------------------------- - --module({{name}}_app). - --behaviour(application). - -%% Application callbacks --export([start/2 - ,stop/1]). - -%%==================================================================== -%% API -%%==================================================================== - -start(_StartType, _StartArgs) -> - {{name}}_sup:start_link(). - -%%-------------------------------------------------------------------- -stop(_State) -> - ok. - -%%==================================================================== -%% Internal functions -%%==================================================================== diff --git a/priv/templates/app.template b/priv/templates/app.template index b17e30c..4087e5e 100644 --- a/priv/templates/app.template +++ b/priv/templates/app.template @@ -3,10 +3,10 @@ {name, "mylib", "Name of the OTP application"}, {desc, "An OTP application", "Short description of the app"} ]}. -{template, "app.erl.dtl", "{{name}}/src/{{name}}_app.erl"}. -{template, "sup.erl.dtl", "{{name}}/src/{{name}}_sup.erl"}. -{template, "otp_app.app.src.dtl", "{{name}}/src/{{name}}.app.src"}. -{template, "rebar.config.dtl", "{{name}}/rebar.config"}. -{template, "gitignore.dtl", "{{name}}/.gitignore"}. -{template, "LICENSE.dtl", "{{name}}/LICENSE"}. -{template, "README.md.dtl", "{{name}}/README.md"}. +{template, "app.erl", "{{name}}/src/{{name}}_app.erl"}. +{template, "sup.erl", "{{name}}/src/{{name}}_sup.erl"}. +{template, "otp_app.app.src", "{{name}}/src/{{name}}.app.src"}. +{template, "rebar.config", "{{name}}/rebar.config"}. +{template, "gitignore", "{{name}}/.gitignore"}. +{template, "LICENSE", "{{name}}/LICENSE"}. +{template, "README.md", "{{name}}/README.md"}. diff --git a/priv/templates/cmake.template b/priv/templates/cmake.template index b3f23e8..2874c8a 100644 --- a/priv/templates/cmake.template +++ b/priv/templates/cmake.template @@ -1,2 +1,2 @@ {description, "Makefile for building C/C++ in c_src"}. -{template, "Makefile.dtl", "c_src/Makefile"}. +{template, "Makefile", "c_src/Makefile"}. diff --git a/priv/templates/gitignore b/priv/templates/gitignore new file mode 100644 index 0000000..40a1d4f --- /dev/null +++ b/priv/templates/gitignore @@ -0,0 +1,18 @@ +.rebar3 +_* +.eunit +*.o +*.beam +*.plt +*.swp +*.swo +.erlang.cookie +ebin +log +erl_crash.dump +.rebar +_rel +_deps +_plugins +_tdeps +logs diff --git a/priv/templates/gitignore.dtl b/priv/templates/gitignore.dtl deleted file mode 100644 index 40a1d4f..0000000 --- a/priv/templates/gitignore.dtl +++ /dev/null @@ -1,18 +0,0 @@ -.rebar3 -_* -.eunit -*.o -*.beam -*.plt -*.swp -*.swo -.erlang.cookie -ebin -log -erl_crash.dump -.rebar -_rel -_deps -_plugins -_tdeps -logs diff --git a/priv/templates/lib.template b/priv/templates/lib.template index 4b9a75d..cbb3672 100644 --- a/priv/templates/lib.template +++ b/priv/templates/lib.template @@ -3,9 +3,9 @@ {name, "mylib", "Name of the OTP library application"}, {desc, "An OTP library", "Short description of the app"} ]}. -{template, "mod.erl.dtl", "{{name}}/src/{{name}}.erl"}. -{template, "otp_lib.app.src.dtl", "{{name}}/src/{{name}}.app.src"}. -{template, "rebar.config.dtl", "{{name}}/rebar.config"}. -{template, "gitignore.dtl", "{{name}}/.gitignore"}. -{template, "LICENSE.dtl", "{{name}}/LICENSE"}. -{template, "README.md.dtl", "{{name}}/README.md"}. +{template, "mod.erl", "{{name}}/src/{{name}}.erl"}. +{template, "otp_lib.app.src", "{{name}}/src/{{name}}.app.src"}. +{template, "rebar.config", "{{name}}/rebar.config"}. +{template, "gitignore", "{{name}}/.gitignore"}. +{template, "LICENSE", "{{name}}/LICENSE"}. +{template, "README.md", "{{name}}/README.md"}. diff --git a/priv/templates/mod.erl b/priv/templates/mod.erl new file mode 100644 index 0000000..2f5e09e --- /dev/null +++ b/priv/templates/mod.erl @@ -0,0 +1,13 @@ +-module({{name}}). + +%% API exports +-export([]). + +%%==================================================================== +%% API functions +%%==================================================================== + + +%%==================================================================== +%% Internal functions +%%==================================================================== diff --git a/priv/templates/mod.erl.dtl b/priv/templates/mod.erl.dtl deleted file mode 100644 index 2f5e09e..0000000 --- a/priv/templates/mod.erl.dtl +++ /dev/null @@ -1,13 +0,0 @@ --module({{name}}). - -%% API exports --export([]). - -%%==================================================================== -%% API functions -%%==================================================================== - - -%%==================================================================== -%% Internal functions -%%==================================================================== diff --git a/priv/templates/otp_app.app.src b/priv/templates/otp_app.app.src new file mode 100644 index 0000000..5188f56 --- /dev/null +++ b/priv/templates/otp_app.app.src @@ -0,0 +1,12 @@ +{application, {{name}}, + [{description, "{{desc}}"} + ,{vsn, "0.1.0"} + ,{registered, []} + ,{mod, {'{{name}}_app', []}} + ,{applications, + [kernel + ,stdlib + ]} + ,{env,[]} + ,{modules, []} + ]}. diff --git a/priv/templates/otp_app.app.src.dtl b/priv/templates/otp_app.app.src.dtl deleted file mode 100644 index 5188f56..0000000 --- a/priv/templates/otp_app.app.src.dtl +++ /dev/null @@ -1,12 +0,0 @@ -{application, {{name}}, - [{description, "{{desc}}"} - ,{vsn, "0.1.0"} - ,{registered, []} - ,{mod, {'{{name}}_app', []}} - ,{applications, - [kernel - ,stdlib - ]} - ,{env,[]} - ,{modules, []} - ]}. diff --git a/priv/templates/otp_lib.app.src b/priv/templates/otp_lib.app.src new file mode 100644 index 0000000..3adefeb --- /dev/null +++ b/priv/templates/otp_lib.app.src @@ -0,0 +1,9 @@ +{application, {{name}}, + [{description, "{{desc}}"} + ,{vsn, "0.1.0"} + ,{registered, []} + ,{applications, + [kernel,stdlib]} + ,{env,[]} + ,{modules, []} + ]}. diff --git a/priv/templates/otp_lib.app.src.dtl b/priv/templates/otp_lib.app.src.dtl deleted file mode 100644 index 3adefeb..0000000 --- a/priv/templates/otp_lib.app.src.dtl +++ /dev/null @@ -1,9 +0,0 @@ -{application, {{name}}, - [{description, "{{desc}}"} - ,{vsn, "0.1.0"} - ,{registered, []} - ,{applications, - [kernel,stdlib]} - ,{env,[]} - ,{modules, []} - ]}. diff --git a/priv/templates/plugin.erl b/priv/templates/plugin.erl new file mode 100644 index 0000000..abf4648 --- /dev/null +++ b/priv/templates/plugin.erl @@ -0,0 +1,33 @@ +-module({{name}}). +-behaviour(provider). + +-export([init/1, do/1, format_error/1]). + +-define(PROVIDER, {{name}}). +-define(DEPS, [app_discovery]). + +%% =================================================================== +%% Public API +%% =================================================================== +-spec init(rebar_state:t()) -> {ok, rebar_state:t()}. +init(State) -> + Provider = providers:create([ + {name, ?PROVIDER}, % The 'user friendly' name of the task + {module, ?MODULE}, % The module implementation of the task + {bare, true}, % The task can be run by the user, always true + {deps, ?DEPS}, % The list of dependencies + {example, "rebar3 {{name}}"}, % How to use the plugin + {opts, []}, % list of options understood by the plugin + {short_desc, "{{desc}}"}, + {desc, "{{desc}}"} + ]), + {ok, rebar_state:add_provider(State, Provider)}. + + +-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. +do(State) -> + {ok, State}. + +-spec format_error(any()) -> iolist(). +format_error(Reason) -> + io_lib:format("~p", [Reason]). diff --git a/priv/templates/plugin.erl.dtl b/priv/templates/plugin.erl.dtl deleted file mode 100644 index abf4648..0000000 --- a/priv/templates/plugin.erl.dtl +++ /dev/null @@ -1,33 +0,0 @@ --module({{name}}). --behaviour(provider). - --export([init/1, do/1, format_error/1]). - --define(PROVIDER, {{name}}). --define(DEPS, [app_discovery]). - -%% =================================================================== -%% Public API -%% =================================================================== --spec init(rebar_state:t()) -> {ok, rebar_state:t()}. -init(State) -> - Provider = providers:create([ - {name, ?PROVIDER}, % The 'user friendly' name of the task - {module, ?MODULE}, % The module implementation of the task - {bare, true}, % The task can be run by the user, always true - {deps, ?DEPS}, % The list of dependencies - {example, "rebar3 {{name}}"}, % How to use the plugin - {opts, []}, % list of options understood by the plugin - {short_desc, "{{desc}}"}, - {desc, "{{desc}}"} - ]), - {ok, rebar_state:add_provider(State, Provider)}. - - --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -do(State) -> - {ok, State}. - --spec format_error(any()) -> iolist(). -format_error(Reason) -> - io_lib:format("~p", [Reason]). diff --git a/priv/templates/plugin.template b/priv/templates/plugin.template index 3419191..0181bd2 100644 --- a/priv/templates/plugin.template +++ b/priv/templates/plugin.template @@ -3,9 +3,9 @@ {name, "myplugin", "Name of the plugin"}, {desc, "A rebar plugin", "Short description of the plugin's purpose"} ]}. -{template, "plugin.erl.dtl", "{{name}}/src/{{name}}.erl"}. -{template, "otp_lib.app.src.dtl", "{{name}}/src/{{name}}.app.src"}. -{template, "rebar.config.dtl", "{{name}}/rebar.config"}. -{template, "gitignore.dtl", "{{name}}/.gitignore"}. -{template, "LICENSE.dtl", "{{name}}/LICENSE"}. -{template, "plugin_README.md.dtl", "{{name}}/README.md"}. +{template, "plugin.erl", "{{name}}/src/{{name}}.erl"}. +{template, "otp_lib.app.src", "{{name}}/src/{{name}}.app.src"}. +{template, "rebar.config", "{{name}}/rebar.config"}. +{template, "gitignore", "{{name}}/.gitignore"}. +{template, "LICENSE", "{{name}}/LICENSE"}. +{template, "plugin_README.md", "{{name}}/README.md"}. diff --git a/priv/templates/plugin_README.md b/priv/templates/plugin_README.md new file mode 100644 index 0000000..7f9ba84 --- /dev/null +++ b/priv/templates/plugin_README.md @@ -0,0 +1,26 @@ +{{name}} +===== + +{{desc}} + +Build +----- + + $ rebar3 compile + +Use +--- + +Add the plugin to your rebar config: + + {plugins, [ + { {{name}}, ".*", {git, "git@host:user/{{name}}.git", {tag, "0.1.0"}}} + ]}. + +Then just call your plugin directly in an existing application: + + + $ rebar3 {{name}} + ===> Fetching {{name}} + ===> Compiling {{name}} + diff --git a/priv/templates/plugin_README.md.dtl b/priv/templates/plugin_README.md.dtl deleted file mode 100644 index 7f9ba84..0000000 --- a/priv/templates/plugin_README.md.dtl +++ /dev/null @@ -1,26 +0,0 @@ -{{name}} -===== - -{{desc}} - -Build ------ - - $ rebar3 compile - -Use ---- - -Add the plugin to your rebar config: - - {plugins, [ - { {{name}}, ".*", {git, "git@host:user/{{name}}.git", {tag, "0.1.0"}}} - ]}. - -Then just call your plugin directly in an existing application: - - - $ rebar3 {{name}} - ===> Fetching {{name}} - ===> Compiling {{name}} - diff --git a/priv/templates/rebar.config b/priv/templates/rebar.config new file mode 100644 index 0000000..f618f3e --- /dev/null +++ b/priv/templates/rebar.config @@ -0,0 +1,2 @@ +{erl_opts, [debug_info]}. +{deps, []}. \ No newline at end of file diff --git a/priv/templates/rebar.config.dtl b/priv/templates/rebar.config.dtl deleted file mode 100644 index f618f3e..0000000 --- a/priv/templates/rebar.config.dtl +++ /dev/null @@ -1,2 +0,0 @@ -{erl_opts, [debug_info]}. -{deps, []}. \ No newline at end of file diff --git a/priv/templates/release.template b/priv/templates/release.template index e350130..a15d163 100644 --- a/priv/templates/release.template +++ b/priv/templates/release.template @@ -3,12 +3,12 @@ {name, "myapp", "Name of the OTP release. An app with this name will also be created."}, {desc, "An OTP application", "Short description of the release's main app's purpose"} ]}. -{template, "app.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_app.erl"}. -{template, "sup.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}. -{template, "otp_app.app.src.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}.app.src"}. -{template, "relx_rebar.config.dtl", "{{name}}/rebar.config"}. -{template, "sys.config.dtl", "{{name}}/config/sys.config"}. -{template, "vm.args.dtl", "{{name}}/config/vm.args"}. -{template, "gitignore.dtl", "{{name}}/.gitignore"}. -{template, "LICENSE.dtl", "{{name}}/LICENSE"}. -{template, "README.md.dtl", "{{name}}/README.md"}. +{template, "app.erl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_app.erl"}. +{template, "sup.erl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}. +{template, "otp_app.app.src", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}.app.src"}. +{template, "relx_rebar.config", "{{name}}/rebar.config"}. +{template, "sys.config", "{{name}}/config/sys.config"}. +{template, "vm.args", "{{name}}/config/vm.args"}. +{template, "gitignore", "{{name}}/.gitignore"}. +{template, "LICENSE", "{{name}}/LICENSE"}. +{template, "README.md", "{{name}}/README.md"}. diff --git a/priv/templates/relx_rebar.config b/priv/templates/relx_rebar.config new file mode 100644 index 0000000..e7505eb --- /dev/null +++ b/priv/templates/relx_rebar.config @@ -0,0 +1,20 @@ +{erl_opts, [debug_info]}. +{deps, []}. + +{relx, [{release, {'{{name}}', "0.1.0"}, + [{{name}}, + sasl]}, + + {sys_config, "./config/sys.config"}, + {vm_args, "./config/vm.args"}, + + {dev_mode, true}, + {include_erts, false}, + + {extended_start_script, true}] +}. + +{profiles, [{prod, [{relx, [{dev_mode, false}, + {include_erts, true}]}] + }] +}. diff --git a/priv/templates/relx_rebar.config.dtl b/priv/templates/relx_rebar.config.dtl deleted file mode 100644 index e7505eb..0000000 --- a/priv/templates/relx_rebar.config.dtl +++ /dev/null @@ -1,20 +0,0 @@ -{erl_opts, [debug_info]}. -{deps, []}. - -{relx, [{release, {'{{name}}', "0.1.0"}, - [{{name}}, - sasl]}, - - {sys_config, "./config/sys.config"}, - {vm_args, "./config/vm.args"}, - - {dev_mode, true}, - {include_erts, false}, - - {extended_start_script, true}] -}. - -{profiles, [{prod, [{relx, [{dev_mode, false}, - {include_erts, true}]}] - }] -}. diff --git a/priv/templates/sup.erl b/priv/templates/sup.erl new file mode 100644 index 0000000..a2e7209 --- /dev/null +++ b/priv/templates/sup.erl @@ -0,0 +1,35 @@ +%%%------------------------------------------------------------------- +%% @doc {{name}} top level supervisor. +%% @end +%%%------------------------------------------------------------------- + +-module({{name}}_sup). + +-behaviour(supervisor). + +%% API +-export([start_link/0]). + +%% Supervisor callbacks +-export([init/1]). + +-define(SERVER, ?MODULE). + +%%==================================================================== +%% API functions +%%==================================================================== + +start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + +%%==================================================================== +%% Supervisor callbacks +%%==================================================================== + +%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules} +init([]) -> + {ok, { {one_for_all, 0, 1}, []} }. + +%%==================================================================== +%% Internal functions +%%==================================================================== diff --git a/priv/templates/sup.erl.dtl b/priv/templates/sup.erl.dtl deleted file mode 100644 index a2e7209..0000000 --- a/priv/templates/sup.erl.dtl +++ /dev/null @@ -1,35 +0,0 @@ -%%%------------------------------------------------------------------- -%% @doc {{name}} top level supervisor. -%% @end -%%%------------------------------------------------------------------- - --module({{name}}_sup). - --behaviour(supervisor). - -%% API --export([start_link/0]). - -%% Supervisor callbacks --export([init/1]). - --define(SERVER, ?MODULE). - -%%==================================================================== -%% API functions -%%==================================================================== - -start_link() -> - supervisor:start_link({local, ?SERVER}, ?MODULE, []). - -%%==================================================================== -%% Supervisor callbacks -%%==================================================================== - -%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules} -init([]) -> - {ok, { {one_for_all, 0, 1}, []} }. - -%%==================================================================== -%% Internal functions -%%==================================================================== diff --git a/priv/templates/sys.config b/priv/templates/sys.config new file mode 100644 index 0000000..7fd6bcb --- /dev/null +++ b/priv/templates/sys.config @@ -0,0 +1,3 @@ +[ + {'{{name}}', []} +]. diff --git a/priv/templates/sys.config.dtl b/priv/templates/sys.config.dtl deleted file mode 100644 index 7fd6bcb..0000000 --- a/priv/templates/sys.config.dtl +++ /dev/null @@ -1,3 +0,0 @@ -[ - {'{{name}}', []} -]. diff --git a/priv/templates/vm.args b/priv/templates/vm.args new file mode 100644 index 0000000..a8a43f0 --- /dev/null +++ b/priv/templates/vm.args @@ -0,0 +1,6 @@ +-name {{name}} + +-setcookie {{name}}_cookie + ++K true ++A30 diff --git a/priv/templates/vm.args.dtl b/priv/templates/vm.args.dtl deleted file mode 100644 index a8a43f0..0000000 --- a/priv/templates/vm.args.dtl +++ /dev/null @@ -1,6 +0,0 @@ --name {{name}} - --setcookie {{name}}_cookie - -+K true -+A30 -- cgit v1.1