Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions src/rebar3_grisp_deploy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,15 @@ do(RState) ->
try
{RelName, RelVsn}
= rebar3_grisp_util:select_release(RState2, RelNameArg, RelVsnArg),
DistSpec = case {Tar, CopyDest} of
{false, D} when D =:= undefined; D =:= "" ->
error(no_deploy_destination);
{true, D} when D =:= undefined; D =:= "" -> [
bundle_dist_spec(RState2, RelName, RelVsn, Force)
];
{false, _} -> [
copy_dist_spec(RState2, CopyDest, Force)
];
{true, _} -> [
bundle_dist_spec(RState2, RelName, RelVsn, Force),
copy_dist_spec(RState2, CopyDest, Force)
]
end,
DistOptions = #{
destination => CopyDest,
pre_script => PreScript,
post_script => PostScript,
tar => Tar,
force => Force,
bundle =>
rebar3_grisp_util:bundle_file_path(RState, RelName, RelVsn)
},
Profiles = [P || P <- rebar_state:current_profiles(RState2),
P =/= default, P =/= grisp, P =/= test],
DeploySpec = #{
Expand All @@ -97,13 +92,11 @@ do(RState) ->
otp_version_requirement => OTPVersion,
platform => Board,
custom_build => CustomBuild,
distribute => DistSpec,
distribute => distribution_spec(DistOptions),
release => #{
name => RelName,
version => RelVsn,
profiles => Profiles,
tar => Tar,
force => Force
profiles => Profiles
},
handlers => grisp_tools:handlers_init(#{
event => {fun event_handler/2, #{
Expand All @@ -112,11 +105,7 @@ do(RState) ->
}},
shell => {fun rebar3_grisp_handler:shell/3, #{}},
release => {fun release_handler/2, RState2}
}),
scripts => #{
pre_script => PreScript,
post_script => PostScript
}
})
},
State = grisp_tools:deploy(DeploySpec),
#{release := RState3} = grisp_tools:handlers_finalize(State),
Expand Down Expand Up @@ -235,9 +224,17 @@ format_error(Reason) ->

%--- Internal ------------------------------------------------------------------

copy_dist_spec(RState, CopyDest, Force) ->
PreScript = get_option(pre_script, [deploy, pre_script], RState, undefined),
PostScript = get_option(pre_script, [deploy, post_script], RState, undefined),
distribution_spec(#{tar := true} = DistOptions) ->
[bundle_dist_spec(DistOptions)];
distribution_spec(#{tar := false} = DistOptions) ->
[copy_dist_spec(DistOptions)].

copy_dist_spec(#{destination := undefined}) ->
error(no_deploy_destination);
copy_dist_spec(#{destination := CopyDest,
pre_script := PreScript,
post_script := PostScript,
force := Force}) ->
{copy, #{
type => copy,
force => Force,
Expand All @@ -248,8 +245,7 @@ copy_dist_spec(RState, CopyDest, Force) ->
}
}}.

bundle_dist_spec(RState, RelName, RelVsn, Force) ->
BundleFile = rebar3_grisp_util:bundle_file_path(RState, RelName, RelVsn),
bundle_dist_spec(#{bundle := BundleFile, force := Force}) ->
{bundle, #{
type => archive,
force => Force,
Expand Down
5 changes: 2 additions & 3 deletions src/rebar3_grisp_firmware.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ init(State) ->
{image, $i, "image", {boolean, false}, "Generate an eMMC image firmware under _grisp/firmware"},
{bootloader, $b, "bootloader", {boolean, false}, "Generate a bootloader firmware under _grisp/firmware"},
{truncate, $t, "truncate", {boolean, true}, "Truncate the generated image firmware to contain only the first partition"},
{quiet, $q, "quiet", {boolean, false}, "Do not show the instructions on how to burn the firmwares"}
{quiet, $q, "quiet", {boolean, false}, "Do not show the instructions on how to burn the firmwares"}
]},
{profiles, [grisp]},
{short_desc, "Generate GRiSP firmware image files"},
Expand Down Expand Up @@ -181,8 +181,7 @@ deploy_bundle(RState, Refresh, RelName, RelVsn, ExtraRelArgs) ->
"deploy",
"--tar",
"--relname", atom_to_list(RelName),
"--relvsn", RelVsn,
"--destination", ""
"--relvsn", RelVsn
] ++ case Refresh =:= true of
true -> ["--force"];
false -> []
Expand Down