Skip to content

Instantly share code, notes, and snippets.

@bjnortier
Forked from kevsmith/HOWTO.txt
Created October 7, 2010 12:09

Revisions

  1. bjnortier revised this gist Oct 7, 2010. 2 changed files with 1 addition and 1 deletion.
    Empty file modified build_flymake.sh
    100644 → 100755
    Empty file.
    2 changes: 1 addition & 1 deletion flymake.erl
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ normalize_rebar_error(Err, FileName) ->

    rebar_build(FileName, Path) ->
    file:set_cwd(Path),
    Cmd = "./rebar compile 2>&1",
    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"]).
  2. kevsmith created this gist Apr 10, 2010.
    4 changes: 4 additions & 0 deletions HOWTO.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    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!
    6 changes: 6 additions & 0 deletions build_flymake.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/bin/sh

    erlc flymake.erl
    echo "#!/usr/bin/env escript" > eflymake
    cat flymake.beam >> eflymake
    chmod +x eflymake
    49 changes: 49 additions & 0 deletions flymake.erl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    -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 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.