-
-
Save bjnortier/615014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
erlc flymake.erl | |
echo "#!/usr/bin/env escript" > eflymake | |
cat flymake.beam >> eflymake | |
chmod +x eflymake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(flymake). | |
-export([main/1]). | |
-define(REBARS, ["..", "../../.."]). | |
file_exists(FileName) -> | |
case file:read_file_info(FileName) of | |
{error, _} -> | |
false; | |
_ -> | |
true | |
end. | |
locate_build_tool([]) -> | |
not_found; | |
locate_build_tool([H|T]) -> | |
case file_exists(filename:join([H, "rebar"])) of | |
true -> | |
H; | |
false -> | |
locate_build_tool(T) | |
end. | |
manual_compile(FileName) -> | |
compile:file(FileName, [warn_obsolete_guard, warn_unused_import, | |
warn_shadow_vars, warn_export_vars, | |
strong_validation, report, | |
{i, "../include"}, | |
{outdir, "/tmp"}]). | |
normalize_rebar_error(Err, FileName) -> | |
[_|T] = string:tokens(Err, ":"), | |
string:join([FileName|T], ":"). | |
rebar_build(FileName, Path) -> | |
file:set_cwd(Path), | |
Cmd = "./rebar compile skip_deps=true 2>&1", | |
[_|T] = string:tokens(os:cmd(Cmd), "\n"), | |
Errors = [normalize_rebar_error(Err, FileName) || Err <- T], | |
io:format("~s", [string:join(Errors, "\n") ++ "\n"]). | |
main([FileName]) -> | |
case locate_build_tool(?REBARS) of | |
not_found -> | |
manual_compile(FileName); | |
Rebar -> | |
rebar_build(FileName, Rebar) | |
end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Use build_flymake.sh to compile flymake.erl into the eflymake script. | |
2) Replace your existing eflymake script with the newly built one. | |
NOTE: Don't forget to make a back up copy of your original eflymake in case this one has bugs! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment