您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

62 行
1.6 KiB

  1. % This file is part of Jiffy released under the MIT license.
  2. % See the LICENSE file for more information.
  3. % Only include PropEr as a dependency when the JIFFY_DEV
  4. % environment variable is defined. This allows downstream
  5. % applications to avoid requiring PropEr.
  6. %
  7. % This script is based on the example provided with Rebar.
  8. IsRebar3 = erlang:function_exported(rebar3, main, 1),
  9. PropErUrl = "git://github.com/manopapad/proper.git",
  10. PortCompilerUrl = "git@github.com:blt/port_compiler.git",
  11. IsDevEnv = begin
  12. ConfigPath = filename:dirname(SCRIPT),
  13. DevMarker = filename:join([ConfigPath, ".jiffy.dev"]),
  14. filelib:is_file(DevMarker)
  15. end.
  16. Deps = if not IsDevEnv -> []; true ->
  17. [{proper, ".*", {git, PropErUrl, {branch, "master"}}}]
  18. end,
  19. ErlOpts = if not IsDevEnv -> []; true ->
  20. [{d, 'JIFFY_DEV'}]
  21. end,
  22. Plugins = case IsRebar3 of
  23. true -> [{pc, {git, PortCompilerUrl, {branch, "master"}}}];
  24. false -> [rebar_gdb_plugin]
  25. end,
  26. ProviderHooks = if not IsRebar3 -> []; true ->
  27. [{pre, [
  28. {compile, {pc, compile}},
  29. {clean, {pc, clean}}
  30. ]}]
  31. end,
  32. OptsToAdd = [
  33. {deps, Deps},
  34. {erl_opts, ErlOpts},
  35. {plugins, Plugins},
  36. {provider_hooks, ProviderHooks}
  37. ],
  38. AddOpt = fun(Name, Value, Config) when is_list(Value) ->
  39. case lists:keyfind(Name, 1, Config) of
  40. {Name, CurrVal} when is_list(CurrVal) ->
  41. lists:keyreplace(Name, 1, Config, {Name, CurrVal ++ Value});
  42. false ->
  43. Config ++ [{Name, Value}];
  44. _ ->
  45. Config
  46. end
  47. end,
  48. lists:foldl(fun({Name, Value}, CfgAcc) ->
  49. AddOpt(Name, Value, CfgAcc)
  50. end, CONFIG, OptsToAdd).