Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

577 řádky
21 KiB

před 8 roky
před 8 roky
  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. -module(rebar_prv_dialyzer).
  4. -behaviour(provider).
  5. -export([init/1,
  6. do/1,
  7. format_error/1]).
  8. -include("rebar.hrl").
  9. -include_lib("providers/include/providers.hrl").
  10. -define(PROVIDER, dialyzer).
  11. -define(DEPS, [compile]).
  12. -define(PLT_PREFIX, "rebar3").
  13. %% ===================================================================
  14. %% Public API
  15. %% ===================================================================
  16. -spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
  17. init(State) ->
  18. Opts = [{update_plt, $u, "update-plt", boolean, "Enable updating the PLT. Default: true"},
  19. {succ_typings, $s, "succ-typings", boolean, "Enable success typing analysis. Default: true"}],
  20. State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
  21. {module, ?MODULE},
  22. {bare, true},
  23. {deps, ?DEPS},
  24. {example, "rebar3 dialyzer"},
  25. {short_desc, short_desc()},
  26. {desc, desc()},
  27. {opts, Opts}])),
  28. {ok, State1}.
  29. desc() ->
  30. short_desc() ++ "\n"
  31. "\n"
  32. "This command will build, and keep up-to-date, a suitable PLT and will use "
  33. "it to carry out success typing analysis on the current project.\n"
  34. "\n"
  35. "The following (optional) configurations can be added to a `proplist` of "
  36. "options `dialyzer` in rebar.config:\n"
  37. "`warnings` - a list of dialyzer warnings\n"
  38. "`get_warnings` - display warnings when altering a PLT file (boolean)\n"
  39. "`plt_apps` - the strategy for determining the applications which included "
  40. "in the PLT file, `top_level_deps` to include just the direct dependencies "
  41. "or `all_deps` to include all nested dependencies*\n"
  42. "`plt_extra_apps` - a list of extra applications to include in the PLT "
  43. "file\n"
  44. "`plt_extra_mods` - a list of extra modules to includes in the PLT file\n"
  45. "`plt_location` - the location of the PLT file, `local` to store in the "
  46. "profile's base directory (default) or a custom directory.\n"
  47. "`plt_prefix` - the prefix to the PLT file, defaults to \"rebar3\"**\n"
  48. "`base_plt_apps` - a list of applications to include in the base "
  49. "PLT file***\n"
  50. "`base_plt_mods` - a list of modules to include in the base "
  51. "PLT file***\n"
  52. "`base_plt_location` - the location of base PLT file, `global` to store in "
  53. "$HOME/.cache/rebar3 (default) or a custom directory***\n"
  54. "`base_plt_prefix` - the prefix to the base PLT file, defaults to "
  55. "\"rebar3\"** ***\n"
  56. "`exclude_apps` - a list of applications to exclude from PLT files and "
  57. "success typing analysis, `plt_extra_mods` and `base_plt_mods` can add "
  58. "modules from excluded applications\n"
  59. "`exclude_mods` - a list of modules to exclude from PLT files and "
  60. "success typing analysis\n"
  61. "\n"
  62. "For example, to warn on unmatched returns: \n"
  63. "{dialyzer, [{warnings, [unmatched_returns]}]}.\n"
  64. "\n"
  65. "*The direct dependent applications are listed in `applications` and "
  66. "`included_applications` of their .app files.\n"
  67. "**PLT files are named \"<prefix>_<otp_release>_plt\".\n"
  68. "***The base PLT is a PLT containing the core applications often required "
  69. "for a project's PLT. One base PLT is created per OTP version and "
  70. "stored in `base_plt_location`. A base PLT is used to build project PLTs."
  71. "\n".
  72. short_desc() ->
  73. "Run the Dialyzer analyzer on the project.".
  74. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
  75. do(State) ->
  76. maybe_fix_env(),
  77. ?INFO("Dialyzer starting, this may take a while...", []),
  78. rebar_paths:unset_paths([plugins], State), % no plugins in analysis
  79. rebar_paths:set_paths([deps], State),
  80. Plt = get_plt(State),
  81. try
  82. do(State, Plt)
  83. catch
  84. throw:{dialyzer_error, Error} ->
  85. ?PRV_ERROR({error_processing_apps, Error});
  86. throw:{dialyzer_warnings, Warnings} ->
  87. ?PRV_ERROR({dialyzer_warnings, Warnings});
  88. throw:{unknown_application, _} = Error ->
  89. ?PRV_ERROR(Error);
  90. throw:{unknown_module, _} = Error ->
  91. ?PRV_ERROR(Error);
  92. throw:{duplicate_module, _, _, _} = Error ->
  93. ?PRV_ERROR(Error);
  94. throw:{output_file_error, _, _} = Error ->
  95. ?PRV_ERROR(Error)
  96. after
  97. rebar_paths:set_paths([plugins,deps], State)
  98. end.
  99. %% This is used to workaround dialyzer quirk discussed here
  100. %% https://github.com/erlang/rebar3/pull/489#issuecomment-107953541
  101. %% Dialyzer gets default plt location wrong way by peeking HOME environment
  102. %% variable which usually is not defined on Windows.
  103. maybe_fix_env() ->
  104. os:putenv("DIALYZER_PLT", filename:join(rebar_dir:home_dir(), ".dialyzer_plt")).
  105. -spec format_error(any()) -> iolist().
  106. format_error({error_processing_apps, Error}) ->
  107. io_lib:format("Error in dialyzing apps: ~ts", [Error]);
  108. format_error({dialyzer_warnings, Warnings}) ->
  109. io_lib:format("Warnings occurred running dialyzer: ~b", [Warnings]);
  110. format_error({unknown_application, App}) ->
  111. io_lib:format("Could not find application: ~ts", [App]);
  112. format_error({unknown_module, Mod}) ->
  113. io_lib:format("Could not find module: ~ts", [Mod]);
  114. format_error({duplicate_module, Mod, File1, File2}) ->
  115. io_lib:format("Duplicates of module ~ts: ~ts ~ts", [Mod, File1, File2]);
  116. format_error({output_file_error, File, Error}) ->
  117. Error1 = file:format_error(Error),
  118. io_lib:format("Failed to write to ~ts: ~ts", [File, Error1]);
  119. format_error(Reason) ->
  120. io_lib:format("~p", [Reason]).
  121. %% Internal functions
  122. get_plt(State) ->
  123. Prefix = get_config(State, plt_prefix, ?PLT_PREFIX),
  124. Name = plt_name(Prefix),
  125. case get_config(State, plt_location, local) of
  126. local ->
  127. BaseDir = rebar_dir:base_dir(State),
  128. filename:join(BaseDir, Name);
  129. Dir ->
  130. filename:join(Dir, Name)
  131. end.
  132. plt_name(Prefix) ->
  133. Prefix ++ "_" ++ rebar_utils:otp_release() ++ "_plt".
  134. do(State, Plt) ->
  135. Output = get_output_file(State),
  136. {PltWarnings, State1} = update_proj_plt(State, Plt, Output),
  137. {Warnings, State2} = succ_typings(State1, Plt, Output),
  138. case PltWarnings + Warnings of
  139. 0 ->
  140. {ok, State2};
  141. TotalWarnings ->
  142. ?INFO("Warnings written to ~ts", [Output]),
  143. throw({dialyzer_warnings, TotalWarnings})
  144. end.
  145. get_output_file(State) ->
  146. BaseDir = rebar_dir:base_dir(State),
  147. Output = filename:join(BaseDir, default_output_file()),
  148. case file:open(Output, [write]) of
  149. {ok, File} ->
  150. ok = file:close(File),
  151. Output;
  152. {error, Reason} ->
  153. throw({output_file_error, Output, Reason})
  154. end.
  155. default_output_file() ->
  156. rebar_utils:otp_release() ++ ".dialyzer_warnings".
  157. update_proj_plt(State, Plt, Output) ->
  158. {Args, _} = rebar_state:command_parsed_args(State),
  159. case proplists:get_value(update_plt, Args) of
  160. false ->
  161. {0, State};
  162. _ ->
  163. do_update_proj_plt(State, Plt, Output)
  164. end.
  165. do_update_proj_plt(State, Plt, Output) ->
  166. ?INFO("Updating plt...", []),
  167. Files = proj_plt_files(State),
  168. case read_plt(State, Plt) of
  169. {ok, OldFiles} ->
  170. check_plt(State, Plt, Output, OldFiles, Files);
  171. error ->
  172. build_proj_plt(State, Plt, Output, Files)
  173. end.
  174. proj_plt_files(State) ->
  175. BasePltApps = base_plt_apps(State),
  176. PltApps = get_config(State, plt_extra_apps, []) ++ BasePltApps,
  177. BasePltMods = get_config(State, base_plt_mods, []),
  178. PltMods = get_config(State, plt_extra_mods, []) ++ BasePltMods,
  179. Apps = proj_apps(State),
  180. DepApps = proj_deps(State),
  181. get_files(State, DepApps ++ PltApps, Apps -- PltApps, PltMods, []).
  182. proj_apps(State) ->
  183. [ec_cnv:to_atom(rebar_app_info:name(App)) ||
  184. App <- rebar_state:project_apps(State)].
  185. proj_deps(State) ->
  186. Apps = rebar_state:project_apps(State),
  187. DepApps = lists:flatmap(fun rebar_app_info:applications/1, Apps),
  188. case get_config(State, plt_apps, top_level_deps) of
  189. top_level_deps -> DepApps;
  190. all_deps -> collect_nested_dependent_apps(DepApps)
  191. end.
  192. get_files(State, Apps, SkipApps, Mods, SkipMods) ->
  193. ?INFO("Resolving files...", []),
  194. ExcludeApps = get_config(State, exclude_apps, []),
  195. Files = apps_files(Apps, ExcludeApps ++ SkipApps, dict:new()),
  196. ExcludeMods = get_config(State, exclude_mods, []),
  197. Files2 = mods_files(Mods, ExcludeMods ++ SkipMods, Files),
  198. dict:fold(fun(_, File, Acc) -> [File | Acc] end, [], Files2).
  199. apps_files([], _, Files) ->
  200. Files;
  201. apps_files([AppName | DepApps], SkipApps, Files) ->
  202. case lists:member(AppName, SkipApps) of
  203. true ->
  204. apps_files(DepApps, SkipApps, Files);
  205. false ->
  206. AppFiles = app_files(AppName),
  207. ?DEBUG("~ts modules: ~p", [AppName, dict:fetch_keys(AppFiles)]),
  208. Files2 = merge_files(Files, AppFiles),
  209. apps_files(DepApps, [AppName | SkipApps], Files2)
  210. end.
  211. app_files(AppName) ->
  212. case app_ebin(AppName) of
  213. {ok, EbinDir} ->
  214. ebin_files(EbinDir);
  215. {error, bad_name} ->
  216. throw({unknown_application, AppName})
  217. end.
  218. app_ebin(AppName) ->
  219. case code:lib_dir(AppName, ebin) of
  220. {error, bad_name} = Error ->
  221. Error;
  222. EbinDir ->
  223. check_ebin(EbinDir)
  224. end.
  225. check_ebin(EbinDir) ->
  226. case filelib:is_dir(EbinDir) of
  227. true ->
  228. {ok, EbinDir};
  229. false ->
  230. {error, bad_name}
  231. end.
  232. ebin_files(EbinDir) ->
  233. Ext = code:objfile_extension(),
  234. Wildcard = "*" ++ Ext,
  235. Files = filelib:wildcard(Wildcard, EbinDir),
  236. Store = fun(File, Mods) ->
  237. Mod = list_to_atom(filename:basename(File, Ext)),
  238. Absname = filename:join(EbinDir, File),
  239. dict:store(Mod, Absname, Mods)
  240. end,
  241. lists:foldl(Store, dict:new(), Files).
  242. merge_files(Files1, Files2) ->
  243. Duplicate = fun(Mod, File1, File2) ->
  244. throw({duplicate_module, Mod, File1, File2})
  245. end,
  246. dict:merge(Duplicate, Files1, Files2).
  247. mods_files(Mods, SkipMods, Files) ->
  248. Keep = fun(File) -> File end,
  249. Ensure = fun(Mod, Acc) ->
  250. case lists:member(Mod, SkipMods) of
  251. true ->
  252. Acc;
  253. false ->
  254. dict:update(Mod, Keep, mod_file(Mod), Acc)
  255. end
  256. end,
  257. Files2 = lists:foldl(Ensure, Files, Mods),
  258. lists:foldl(fun dict:erase/2, Files2, SkipMods).
  259. mod_file(Mod) ->
  260. File = atom_to_list(Mod) ++ code:objfile_extension(),
  261. case code:where_is_file(File) of
  262. non_existing -> throw({unknown_module, Mod});
  263. Absname -> Absname
  264. end.
  265. read_plt(_State, Plt) ->
  266. Vsn = dialyzer_version(),
  267. case plt_files(Plt) of
  268. {ok, Files} when Vsn < {2, 9, 0} ->
  269. % Before dialyzer-2.9 (OTP 18.3) removing a beam file from the PLT
  270. % that no longer exists would crash. Therefore force a rebuild of
  271. % PLT if any files no longer exist.
  272. read_plt_files(Plt, Files);
  273. {ok, _} = Result when Vsn >= {2, 9, 0} ->
  274. Result;
  275. {error, no_such_file} ->
  276. error;
  277. {error, not_valid} ->
  278. error;
  279. {error, read_error} ->
  280. Error = io_lib:format("Could not read the PLT file ~p", [Plt]),
  281. throw({dialyzer_error, Error})
  282. end.
  283. plt_files(Plt) ->
  284. case dialyzer:plt_info(Plt) of
  285. {ok, Info} ->
  286. {ok, proplists:get_value(files, Info, [])};
  287. {error, _} = Error ->
  288. Error
  289. end.
  290. %% If any file no longer exists dialyzer will fail when updating the PLT.
  291. read_plt_files(Plt, Files) ->
  292. case [File || File <- Files, not filelib:is_file(File)] of
  293. [] ->
  294. {ok, Files};
  295. Missing ->
  296. ?INFO("Could not find ~p files in ~p...", [length(Missing), Plt]),
  297. ?DEBUG("Could not find files: ~p", [Missing]),
  298. error
  299. end.
  300. check_plt(State, Plt, Output, OldList, FilesList) ->
  301. Old = sets:from_list(OldList),
  302. Files = sets:from_list(FilesList),
  303. Remove = sets:to_list(sets:subtract(Old, Files)),
  304. {RemWarnings, State1} = remove_plt(State, Plt, Output, Remove),
  305. Check = sets:to_list(sets:intersection(Files, Old)),
  306. {CheckWarnings, State2} = check_plt(State1, Plt, Output, Check),
  307. Add = sets:to_list(sets:subtract(Files, Old)),
  308. {AddWarnings, State3} = add_plt(State2, Plt, Output, Add),
  309. {RemWarnings + CheckWarnings + AddWarnings, State3}.
  310. remove_plt(State, _Plt, _Output, []) ->
  311. {0, State};
  312. remove_plt(State, Plt, Output, Files) ->
  313. ?INFO("Removing ~b files from ~p...", [length(Files), Plt]),
  314. run_plt(State, Plt, Output, plt_remove, Files).
  315. check_plt(State, _Plt, _Output, []) ->
  316. {0, State};
  317. check_plt(State, Plt, Output, Files) ->
  318. ?INFO("Checking ~b files in ~p...", [length(Files), Plt]),
  319. run_plt(State, Plt, Output, plt_check, Files).
  320. add_plt(State, _Plt, _Output, []) ->
  321. {0, State};
  322. add_plt(State, Plt, Output, Files) ->
  323. ?INFO("Adding ~b files to ~p...", [length(Files), Plt]),
  324. run_plt(State, Plt, Output, plt_add, Files).
  325. run_plt(State, Plt, Output, Analysis, Files) ->
  326. GetWarnings = get_config(State, get_warnings, false),
  327. Opts = [{analysis_type, Analysis},
  328. {get_warnings, GetWarnings},
  329. {init_plt, Plt},
  330. {output_plt, Plt},
  331. {from, byte_code},
  332. {files, Files}],
  333. run_dialyzer(State, Opts, Output).
  334. build_proj_plt(State, Plt, Output, Files) ->
  335. BasePlt = get_base_plt(State),
  336. ?INFO("Updating base plt...", []),
  337. BaseFiles = base_plt_files(State),
  338. {BaseWarnings, State1} = update_base_plt(State, BasePlt, Output, BaseFiles),
  339. ?INFO("Copying ~p to ~p...", [BasePlt, Plt]),
  340. _ = filelib:ensure_dir(Plt),
  341. case file:copy(BasePlt, Plt) of
  342. {ok, _} ->
  343. {CheckWarnings, State2} = check_plt(State1, Plt, Output, BaseFiles,
  344. Files),
  345. {BaseWarnings + CheckWarnings, State2};
  346. {error, Reason} ->
  347. Error = io_lib:format("Could not copy PLT from ~p to ~p: ~p",
  348. [BasePlt, Plt, file:format_error(Reason)]),
  349. throw({dialyzer_error, Error})
  350. end.
  351. get_base_plt(State) ->
  352. Prefix = get_config(State, base_plt_prefix, ?PLT_PREFIX),
  353. Name = plt_name(Prefix),
  354. case get_config(State, base_plt_location, global) of
  355. global ->
  356. GlobalCacheDir = rebar_dir:global_cache_dir(rebar_state:opts(State)),
  357. filename:join(GlobalCacheDir, Name);
  358. Dir ->
  359. filename:join(Dir, Name)
  360. end.
  361. base_plt_files(State) ->
  362. BasePltApps = base_plt_apps(State),
  363. BasePltMods = get_config(State, base_plt_mods, []),
  364. get_files(State, BasePltApps, [], BasePltMods, []).
  365. base_plt_apps(State) ->
  366. get_config(State, base_plt_apps, [erts, crypto, kernel, stdlib]).
  367. update_base_plt(State, BasePlt, Output, BaseFiles) ->
  368. case read_plt(State, BasePlt) of
  369. {ok, OldBaseFiles} ->
  370. check_plt(State, BasePlt, Output, OldBaseFiles, BaseFiles);
  371. error ->
  372. _ = filelib:ensure_dir(BasePlt),
  373. build_plt(State, BasePlt, Output, BaseFiles)
  374. end.
  375. build_plt(State, Plt, _, []) ->
  376. ?INFO("Building with no files in ~p...", [Plt]),
  377. Opts = [{get_warnings, false},
  378. {output_plt, Plt},
  379. {apps, [erts]}],
  380. % Create a PLT with erts files and then remove erts files to be left with an
  381. % empty PLT. Dialyzer will crash when trying to build a PLT with an empty
  382. % file list.
  383. _ = dialyzer:run([{analysis_type, plt_build} | Opts]),
  384. _ = dialyzer:run([{analysis_type, plt_remove}, {init_plt, Plt} | Opts]),
  385. {0, State};
  386. build_plt(State, Plt, Output, Files) ->
  387. ?INFO("Building with ~b files in ~p...", [length(Files), Plt]),
  388. GetWarnings = get_config(State, get_warnings, false),
  389. Opts = [{analysis_type, plt_build},
  390. {get_warnings, GetWarnings},
  391. {output_plt, Plt},
  392. {files, Files}],
  393. run_dialyzer(State, Opts, Output).
  394. succ_typings(State, Plt, Output) ->
  395. {Args, _} = rebar_state:command_parsed_args(State),
  396. case proplists:get_value(succ_typings, Args) of
  397. false ->
  398. {0, State};
  399. _ ->
  400. ?INFO("Doing success typing analysis...", []),
  401. Files = proj_files(State),
  402. succ_typings(State, Plt, Output, Files)
  403. end.
  404. succ_typings(State, Plt, _, []) ->
  405. ?INFO("Analyzing no files with ~p...", [Plt]),
  406. {0, State};
  407. succ_typings(State, Plt, Output, Files) ->
  408. ?INFO("Analyzing ~b files with ~p...", [length(Files), Plt]),
  409. Opts = [{analysis_type, succ_typings},
  410. {get_warnings, true},
  411. {from, byte_code},
  412. {files, Files},
  413. {init_plt, Plt}],
  414. run_dialyzer(State, Opts, Output).
  415. proj_files(State) ->
  416. Apps = proj_apps(State),
  417. BasePltApps = get_config(State, base_plt_apps, []),
  418. PltApps = get_config(State, plt_extra_apps, []) ++ BasePltApps,
  419. BasePltMods = get_config(State, base_plt_mods, []),
  420. PltMods = get_config(State, plt_extra_mods, []) ++ BasePltMods,
  421. get_files(State, Apps, PltApps, [], PltMods).
  422. run_dialyzer(State, Opts, Output) ->
  423. %% dialyzer may return callgraph warnings when get_warnings is false
  424. case proplists:get_bool(get_warnings, Opts) of
  425. true ->
  426. WarningsList = get_config(State, warnings, []),
  427. Opts2 = [{warnings, legacy_warnings(WarningsList)},
  428. {check_plt, false} |
  429. Opts],
  430. ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
  431. Warnings = format_warnings(rebar_state:opts(State),
  432. Output, dialyzer:run(Opts2)),
  433. {Warnings, State};
  434. false ->
  435. Opts2 = [{warnings, no_warnings()},
  436. {check_plt, false} |
  437. Opts],
  438. ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
  439. dialyzer:run(Opts2),
  440. {0, State}
  441. end.
  442. legacy_warnings(Warnings) ->
  443. case dialyzer_version() of
  444. TupleVsn when TupleVsn < {2, 8, 0} ->
  445. [Warning || Warning <- Warnings, Warning =/= unknown];
  446. _ ->
  447. Warnings
  448. end.
  449. format_warnings(Opts, Output, Warnings) ->
  450. Warnings1 = rebar_dialyzer_format:format_warnings(Opts, Warnings),
  451. console_warnings(Warnings1),
  452. file_warnings(Output, Warnings),
  453. length(Warnings).
  454. console_warnings(Warnings) ->
  455. _ = [?CONSOLE("~ts", [Warning]) || Warning <- Warnings],
  456. ok.
  457. file_warnings(_, []) ->
  458. ok;
  459. file_warnings(Output, Warnings) ->
  460. Warnings1 = [[dialyzer:format_warning(Warning, fullpath), $\n] || Warning <- Warnings],
  461. case file:write_file(Output, Warnings1, [append]) of
  462. ok ->
  463. ok;
  464. {error, Reason} ->
  465. throw({output_file_error, Output, Reason})
  466. end.
  467. no_warnings() ->
  468. [no_return,
  469. no_unused,
  470. no_improper_lists,
  471. no_fun_app,
  472. no_match,
  473. no_opaque,
  474. no_fail_call,
  475. no_contracts,
  476. no_behaviours,
  477. no_undefined_callbacks].
  478. get_config(State, Key, Default) ->
  479. Config = rebar_state:get(State, dialyzer, []),
  480. proplists:get_value(Key, Config, Default).
  481. -spec collect_nested_dependent_apps([atom()]) -> [atom()].
  482. collect_nested_dependent_apps(RootApps) ->
  483. Deps = lists:foldl(fun collect_nested_dependent_apps/2, sets:new(), RootApps),
  484. sets:to_list(Deps).
  485. -spec collect_nested_dependent_apps(atom(), rebar_set()) -> rebar_set().
  486. collect_nested_dependent_apps(App, Seen) ->
  487. case sets:is_element(App, Seen) of
  488. true ->
  489. Seen;
  490. false ->
  491. Seen1 = sets:add_element(App, Seen),
  492. case code:lib_dir(App) of
  493. {error, _} ->
  494. throw({unknown_application, App});
  495. AppDir ->
  496. case rebar_app_discover:find_app(AppDir, all) of
  497. false ->
  498. throw({unknown_application, App});
  499. {true, AppInfo} ->
  500. lists:foldl(fun collect_nested_dependent_apps/2,
  501. Seen1,
  502. rebar_app_info:applications(AppInfo))
  503. end
  504. end
  505. end.
  506. dialyzer_version() ->
  507. _ = application:load(dialyzer),
  508. {ok, Vsn} = application:get_key(dialyzer, vsn),
  509. case rebar_string:lexemes(Vsn, ".") of
  510. [Major, Minor] ->
  511. version_tuple(Major, Minor, "0");
  512. [Major, Minor, Patch | _] ->
  513. version_tuple(Major, Minor, Patch)
  514. end.
  515. version_tuple(Major, Minor, Patch) ->
  516. {list_to_integer(Major), list_to_integer(Minor), list_to_integer(Patch)}.