Permalink
Browse files

fix a nasty bug in app generation

It seems that the docs for app files was off and we included more
information then we needed too. This patch resolves that problem. It
also removes bits from the app file that are just defaults. No need to
specify those and they seem to confuse erlang.
  • Loading branch information...
1 parent 9cd6dbc commit 5bcbf520b6e72e658fdff4134ce05b7b01ea5d72 @ericbmerritt committed May 17, 2012
Showing with 21 additions and 13 deletions.
  1. +21 −13 src/sin_app_meta.erl
View
34 src/sin_app_meta.erl
@@ -37,19 +37,21 @@ write_app_file(#app{name=AppName,vsn=Vsn,path=Path,
erlang:atom_to_list(AppName) ++
".app"]),
MetaData = {application, AppName,
- [{description, Desc},
- {id, Id},
- {vsn, Vsn},
- {modules, AppModules},
- {maxP, MaxP},
- {maxT, MaxT},
- {registered, Reg},
- {included_applications, IA},
- {applications, Appls},
- {env, Env},
- {mod, Mod},
- {start_phases, StartPhases}]},
- file:write_file(MetaDataPath,
+ lists:flatten(
+ [{description, Desc},
+ is_not_default(Id, [], {id, Id}),
+ {vsn, Vsn},
+ {modules, AppModules},
+ is_not_default(MaxP, infinity, {maxP, MaxP}),
+ is_not_default(MaxT, infinity, {maxT, MaxT}),
+ {registered, Reg},
+ is_not_default(IA, [], {included_applications, IA}),
+ {applications, Appls},
+ is_not_default(Env, [], {env, Env}),
+ is_not_default(Mod, undefined, {mod, Mod}),
+ is_not_default(StartPhases, undefined, {start_phases, StartPhases})
+ ])},
+ file:write_file(MetaDataPath,
io_lib:format("~p.\n",
[MetaData])).
@@ -112,6 +114,12 @@ format_exception(Exception) ->
%%====================================================================
%% Internal functions
%%====================================================================
+is_not_default(Value, Value, _) ->
+ [];
+is_not_default(_Value, _DefaultValue, Result) ->
+ Result.
+
+
rewrite_vsn(Config, State, AppDir, BaseDetails) ->
RWVSN = fun({vsn, VsnSpec}) ->
{vsn, vcs_vsn(Config, State, VsnSpec, AppDir)};

0 comments on commit 5bcbf52

Please sign in to comment.