Skip to content

Commit b62659b

Browse files
authored
Merge pull request #2962 from eproxus/manifest-macro-objects
Return manifest macros as objects
2 parents 4fe80ac + 50e5b85 commit b62659b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

apps/rebar/src/rebar_prv_manifest.erl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
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() :: #{atom() => any()}.
2929
-type manifest() :: #{ apps := [app_context()],
3030
deps := [app_context()],
3131
otp_lib_dir := file:filename_all(),
@@ -133,7 +133,7 @@ adapt_context(App) ->
133133
src_dirs => [to_binary(D) || D <- SrcDirs],
134134
extra_src_dirs => [to_binary(D) || D <- ExtraSrcDirs],
135135
include_dirs => [to_binary(D) || D <- IncludeDirs],
136-
macros => [to_macro(M) || M <- Macros],
136+
macros => to_macros(Macros),
137137
parse_transforms => ParseTransforms}.
138138

139139
-spec output_manifest(binary(), format(), string() | undefined) -> ok | {error, term()}.
@@ -169,11 +169,15 @@ format(_Manifest, Format) ->
169169
to_binary(Path) ->
170170
unicode:characters_to_binary(Path).
171171

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

178182
-spec is_json_available() -> boolean().
179183
is_json_available() ->

0 commit comments

Comments
 (0)