Skip to content

Commit d731c15

Browse files
committed
Initial commit.
Signed-off-by: Brian L. Troutwine <[email protected]>
0 parents  commit d731c15

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2015, Brian L. Troutwine <[email protected]>.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
* The names of its contributors may not be used to endorse or promote
16+
products derived from this software without specific prior written
17+
permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
port_compiler
2+
=====
3+
4+
a rebar3 port compiler for native code
5+
6+
Build
7+
-----
8+
9+
$ rebar3 compile
10+
11+
Use
12+
---
13+
14+
Add the plugin to your rebar config:
15+
16+
{plugins, [
17+
{ port_compiler, ".*", {git, "git@host:user/port_compiler.git", {tag, "0.1.0"}}}
18+
]}.
19+
20+
Then just call your plugin directly in an existing application:
21+
22+
23+
$ rebar3 port_compiler
24+
===> Fetching port_compiler
25+
===> Compiling port_compiler
26+
<Plugin Output>

rebar.config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{erl_opts, [debug_info]}.
2+
{deps, []}.

src/port_compiler.app.src

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{application, port_compiler,
2+
[{description, "a rebar3 port compiler for native code"}
3+
,{vsn, "0.1.0"}
4+
,{registered, []}
5+
,{applications,
6+
[kernel,stdlib]}
7+
,{env,[]}
8+
,{modules, []}
9+
]}.

src/port_compiler.erl

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-module(port_compiler).
2+
-behaviour(provider).
3+
4+
-export([init/1, do/1, format_error/1]).
5+
6+
-define(PROVIDER, port_compiler).
7+
-define(DEPS, [app_discovery]).
8+
9+
%% ===================================================================
10+
%% Public API
11+
%% ===================================================================
12+
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
13+
init(State) ->
14+
Provider = providers:create([
15+
{name, ?PROVIDER}, % The 'user friendly' name of the task
16+
{module, ?MODULE}, % The module implementation of the task
17+
{bare, true}, % The task can be run by the user, always true
18+
{deps, ?DEPS}, % The list of dependencies
19+
{example, "rebar port_compiler"}, % How to use the plugin
20+
{opts, []}, % list of options understood by the plugin
21+
{short_desc, "a rebar3 port compiler for native code"},
22+
{desc, ""}
23+
]),
24+
{ok, rebar_state:add_provider(State, Provider)}.
25+
26+
27+
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
28+
do(State) ->
29+
{ok, State}.
30+
31+
-spec format_error(any()) -> iolist().
32+
format_error(Reason) ->
33+
io_lib:format("~p", [Reason]).

0 commit comments

Comments
 (0)