Skip to content

Commit 7685638

Browse files
committed
Return manifest macros as objects
This change makes `rebar3 experimental manifest` return macros as maps (JSON objects) to match the required ELP format.
1 parent aca6b70 commit 7685638

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apps/rebar/src/rebar_prv_manifest.erl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
src_dirs := [file:filename_all()],
2424
extra_src_dirs := [file:filename_all()],
2525
include_dirs := [file:filename_all()],
26-
macros => [macro()],
26+
macros => macros(),
2727
parse_transforms => [any()]}.
28-
-type macro() :: #{key := atom(), value => any()}.
28+
-type macros() :: #{macro_key() => macro_value()}.
29+
-type macro_key() :: atom().
30+
-type macro_value() :: binary().
2931
-type manifest() :: #{ apps := [app_context()],
3032
deps := [app_context()],
3133
otp_lib_dir := file:filename_all(),
@@ -133,7 +135,7 @@ adapt_context(App) ->
133135
src_dirs => [to_binary(D) || D <- SrcDirs],
134136
extra_src_dirs => [to_binary(D) || D <- ExtraSrcDirs],
135137
include_dirs => [to_binary(D) || D <- IncludeDirs],
136-
macros => [to_macro(M) || M <- Macros],
138+
macros => to_macros(Macros),
137139
parse_transforms => ParseTransforms}.
138140

139141
-spec output_manifest(binary(), format(), string() | undefined) -> ok | {error, term()}.
@@ -169,11 +171,15 @@ format(_Manifest, Format) ->
169171
to_binary(Path) ->
170172
unicode:characters_to_binary(Path).
171173

172-
-spec to_macro(atom() | {atom() | any()}) -> macro().
174+
-spec to_macros(proplists:proplist()) -> macros().
175+
to_macros(Macros) ->
176+
maps:from_list([to_macro(M) || M <- Macros]).
177+
178+
-spec to_macro(atom() | {atom() | any()}) -> {macro_key(), macro_value()}.
173179
to_macro({Key, Value}) when is_atom(Key) ->
174-
#{key => Key, value => Value};
180+
{Key, Value};
175181
to_macro(Key) when is_atom(Key) ->
176-
#{key => Key, value => true}.
182+
{Key, <<"true">>}.
177183

178184
-spec is_json_available() -> boolean().
179185
is_json_available() ->

0 commit comments

Comments
 (0)