Skip to content

Commit 02af372

Browse files
Add custom rebar plugin to create releases (#5)
* Create custom rebar plugin * Add missing modules * Remove invalid fields * Add `cauder_plugin` * Add `cauder_plugin` as a new module in IntelliJ * Add launcher script for Windows and Unix * Set executable bit in unix systems * Create `include` folder * Create `priv` folder * Add improved clean command to cauder plugin Refactor cauder plugin * Unignore rebar3 * Update .gitignore * Update commands * Move `cauder_plugin.iml` file * Remove line break * Delete Makefile * Remove redundant line and add clarification * Update execute file permission * Rename release launch script for linux
1 parent f946801 commit 02af372

18 files changed

+301
-123
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
erl_crash.dump
55

66
# Rebar 3
7-
rebar3
8-
rebar3.cmd
97
rebar.lock
8+
rebar3.crashdump
109
_build/
1110

1211
### JetBrains
@@ -17,6 +16,7 @@ _build/
1716
.idea/**/usage.statistics.xml
1817
.idea/**/dictionaries
1918
.idea/**/shelf
19+
.idea/emacs.xml
2020

2121
# IntelliJ
2222
out/

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 0 additions & 77 deletions
This file was deleted.

README.md

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,58 @@ A Causal-Consistent Reversible Debugger for Erlang
44

55
![CauDEr screenshot](screenshot.png)
66

7+
**_CAUTION: This tool is still under development_**
78

89
## Dependencies
910

10-
* **Erlang/OTP** ≥ 23.0
11-
* **Rebar3** (Optional)
12-
* **Make**
13-
11+
* Erlang 23 or higher
1412

1513
## Building
1614

17-
You can use the following `make` tasks to build CauDEr:
15+
To build the project, type:
1816

19-
* Create _escript_: `make` (or `make escriptize`)
20-
* Compile only: `make compile`
21-
* Build documentation: `make edoc`
22-
* Run dialyzer: `make dialyzer`
23-
* Cleanup: `make clean`
17+
./rebar3 compile
2418

19+
To create an _escript_, type:
2520

26-
## Running
21+
./rebar3 escriptize
22+
23+
To create a release for your platform, type:
24+
25+
./rebar3 reltool
26+
27+
To run tests, type:
28+
29+
./rebar3 do eunit, ct
30+
31+
To run dialyzer, type:
2732

28-
You can run CauDEr in multiple ways:
33+
./rebar3 dialyzer
34+
35+
To clean-up the build files, type:
36+
37+
./rebar3 clean
38+
39+
## Running
2940

3041
### Using the Erlang shell
3142

32-
Using `rebar3 shell` will start a shell with all the required dependencies.
43+
To start an Erlang shell with all the required dependencies, type:
3344

34-
There are multiples ways to run CauDEr:
45+
./rebar3 shell
3546

36-
#### Like an _escript_
47+
There are multiples ways to run CauDEr from the Erlang shell:
3748

38-
Calling the function `cauder:main/0` will start CauDEr like the _escript_.
49+
#### Like an _escript_
3950

4051
```
4152
Eshell V11.0 (abort with ^G)
4253
1> cauder:main().
4354
ok
4455
```
4556

46-
ℹ️ This function will wait for the GUI to close before returning, which means the shell will be blocked.
57+
ℹ️ This function will wait for the CauDEr window to close before returning,
58+
which means the shell will be blocked.
4759

4860
#### Like an application
4961

@@ -53,47 +65,41 @@ Eshell V11.0 (abort with ^G)
5365
ok
5466
```
5567

56-
ℹ️ To stop CauDEr you can use `application:stop(cauder)`, but it is not necessary if you just close the window.
68+
ℹ️ To stop CauDEr you can use `application:stop(cauder)`, or simply close the
69+
window.
5770

5871
#### Manually
5972

60-
##### Debugger only
61-
62-
To start the debugger only you can call the following function:
63-
6473
```
6574
Eshell V11.0 (abort with ^G)
6675
1> cauder:start(). % Starting the debugger
6776
{ok,<0.80.0>}
77+
2> cauder_wx:start(). % Starting the GUI
78+
{ok,<0.82.0>,{wx_ref,35,wxFrame,<0.82.0>}}
6879
```
6980

70-
##### Debugger and GUI
81+
⚠️ If you try to start the GUI without previously starting the debugger, it will
82+
fail with the following error: `{error,{not_started,cauder}}`
7183

72-
To start the debugger and the GUI you will need to call the following functions in order:
7384

74-
```
75-
Eshell V11.0 (abort with ^G)
76-
1> cauder:start(). % Starting the debugger
77-
{ok,<0.80.0>}
78-
2> cauder_wx:start(). % Starting the GUI
79-
{ok,<0.82.0>,{wx_ref,35,wxFrame,<0.82.0>}}
80-
```
85+
### Using the _escript_
8186

82-
⚠️ If you try to start the GUI without previously starting the debugger, it will fail with the following error: `{error,{not_started,cauder}}`
87+
./_build/default/bin/cauder
8388

89+
ℹ️ This will block the current shell until the CauDEr window is closed.
8490

85-
#### Using the _escript_
91+
### Using the release
8692

87-
Simply run the `cauder` binary generated in the `_build/default/bin` folder:
93+
./_build/default/reltool/cauder
8894

89-
```shell script
90-
./_build/default/bin/cauder
91-
```
95+
ℹ️ This script will start CauDEr in detached mode.
9296

93-
## Usage
97+
## Documentation
9498

95-
For more information about how to use CauDEr you can check the [Wiki](https://github.com/mistupv/cauder-v2/wiki) (Under construction!)
99+
To learn how to use CauDEr you can check the
100+
[Wiki](https://github.com/mistupv/cauder-v2/wiki) (Under construction!)
96101

97102
## License
98103

99-
See [LICENSE](LICENSE) file.
104+
This project is available under the terms of the MIT license. See the
105+
[`LICENSE`](LICENSE) file for the copyright information and licensing terms.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="ERLANG_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="erlang" name="Erlang">
5+
<configuration />
6+
</facet>
7+
</component>
8+
<component name="NewModuleRootManager" inherit-compiler-output="true">
9+
<exclude-output />
10+
<content url="file://$MODULE_DIR$">
11+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
12+
</content>
13+
<orderEntry type="jdk" jdkName="Erlang 23" jdkType="Erlang SDK" />
14+
<orderEntry type="sourceFolder" forTests="false" />
15+
</component>
16+
</module>

_checkouts/cauder_plugin/rebar.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{erl_opts, [debug_info]}.
2+
{deps, []}.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{application, cauder_plugin,
2+
[
3+
{description, "Custom rebar3 plugin for CauDEr"},
4+
{vsn, "0.1.0"},
5+
{registered, []},
6+
{applications, [kernel, stdlib]},
7+
{env, []},
8+
{modules, []}
9+
]}.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-module(cauder_plugin).
2+
3+
-export([init/1]).
4+
5+
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
6+
init(State) ->
7+
{ok, init_providers(State)}.
8+
9+
init_providers(State) ->
10+
lists:foldl(fun init_provider/2, State, [
11+
cauder_plugin_prv_clean,
12+
cauder_plugin_prv_reltool
13+
]).
14+
15+
init_provider(Module, State) ->
16+
{ok, NewState} = Module:init(State),
17+
NewState.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-module(cauder_plugin_prv_clean).
2+
3+
%% API
4+
-export([init/1, do/1, format_error/1]).
5+
6+
-include_lib("kernel/include/file.hrl").
7+
8+
-define(PROVIDER, ?MODULE).
9+
-define(DEPS, []).
10+
11+
12+
%%%=============================================================================
13+
%%% API
14+
%%%=============================================================================
15+
16+
17+
%% Called when rebar3 first boots, before even parsing the arguments
18+
%% or commands to be run. Purely initiates the provider, and nothing
19+
%% else should be done here.
20+
21+
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
22+
23+
init(State) ->
24+
Provider = providers:create(
25+
[
26+
{name, ?PROVIDER},
27+
{module, ?MODULE},
28+
{bare, true},
29+
{deps, ?DEPS},
30+
{desc, "Creates a release of CauDEr using reltool"},
31+
{short_desc, "Creates a release of CauDEr using reltool"},
32+
{example, "rebar3 " ++ atom_to_list(?PROVIDER)},
33+
{opts, []}
34+
]),
35+
{ok, rebar_state:add_provider(State, Provider)}.
36+
37+
38+
%% Run the code for the plugin. The command line argument are parsed
39+
%% and dependencies have been run.
40+
41+
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
42+
43+
do(State) ->
44+
case rebar_state:current_app(State) of
45+
undefined ->
46+
ok;
47+
AppInfo ->
48+
case rebar_app_info:name(AppInfo) of
49+
<<"cauder">> ->
50+
rebar_file_utils:rm_rf(rebar_dir:base_dir(State));
51+
_ ->
52+
ok
53+
end
54+
end,
55+
56+
{ok, State}.
57+
58+
59+
%% When an exception is raised or a value returned as
60+
%% `{error, {?MODULE, Reason}}` will see the `format_error(Reason)`
61+
%% function called for them, so a string can be formatted explaining
62+
%% the issue.
63+
64+
-spec format_error(any()) -> iolist().
65+
66+
format_error(Reason) ->
67+
io_lib:format("~p", [Reason]).

0 commit comments

Comments
 (0)