Skip to content

Commit

Permalink
Use rebar3:run/1 to call sub-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sylane committed Oct 3, 2024
1 parent 3119934 commit 2154609
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- The utility function rebar3_grisp_util:rebar_command/4 has been removed as it
runs app_discovery provider again and that causes issues with dependencies
using semver. Instead rebar3:run/1 is used. [#91](https://github.com/grisp/rebar3_grisp/pull/91)

## [2.7.0] - 2024-09-06

### Added
Expand Down
5 changes: 4 additions & 1 deletion src/rebar3_grisp_firmware.erl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ deploy_bundle(RState, Force, RelName, RelVsn, ExtraRelArgs) ->
[_|_] -> ["--" | ExtraRelArgs];
_ -> []
end,
rebar3_grisp_util:rebar_command(RState, grisp, deploy, Args).
case rebar3:run(["grisp", "deploy" | Args]) of
{error, _Reason} = Error -> Error;
{ok, _} -> {ok, RState}
end.

grisp_tools_firmware(RState, RelName, RelVsn, Args) ->
Config = rebar3_grisp_util:config(RState),
Expand Down
5 changes: 4 additions & 1 deletion src/rebar3_grisp_pack.erl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ build_firmwares(RState, WithBoot, Force, RelName, RelVsn, ExtraRelArgs) ->
[_|_] -> ["--" | ExtraRelArgs];
_ -> []
end,
rebar3_grisp_util:rebar_command(RState, grisp, firmware, Args).
case rebar3:run(["grisp", "firmware" | Args]) of
{error, _Reason} = Error -> Error;
{ok, _} -> {ok, RState}
end.

grisp_tools_pack(RState, RelName, RelVsn, Args) ->
SysFile = proplists:get_value(system, Args),
Expand Down
21 changes: 0 additions & 21 deletions src/rebar3_grisp_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
-export([select_release/3]).
-export([bundle_file_name/3]).
-export([bundle_file_path/3]).
-export([rebar_command/4]).
-export([firmware_dir/1]).
-export([firmware_file_name/4]).
-export([firmware_file_path/4]).
Expand Down Expand Up @@ -249,26 +248,6 @@ update_file_path(RebarState, RelName, RelVsn) ->
UpdateName = update_file_name(RebarState, RelName, RelVsn),
filename:join(UpdateDir, UpdateName).

rebar_command(RebarState, Namespace, Command, Args) ->
% Backup current command state
OriginalNamespace = rebar_state:namespace(RebarState),
OriginalArgs = rebar_state:command_args(RebarState),
OriginalParsedArgs = rebar_state:command_parsed_args(RebarState),

% Args are parsed by rebar_core
RebarState2 = rebar_state:namespace(RebarState, Namespace),
RebarState3 = rebar_state:command_args(RebarState2, Args),

case rebar_core:process_command(RebarState3, Command) of
{error, _Reason} = Error -> Error;
{ok, RS} ->
% Restore current command state
RS2 = rebar_state:namespace(RS, OriginalNamespace),
RS3 = rebar_state:command_args(RS2, OriginalArgs),
RS4 = rebar_state:command_parsed_args(RS3, OriginalParsedArgs),
{ok, RS4}
end.

toolchain_root(RebarState) ->
Config = rebar3_grisp_util:config(RebarState),
DockerImg = rebar3_grisp_util:get([build, toolchain, docker], Config, error),
Expand Down

0 comments on commit 2154609

Please sign in to comment.