anchor.diff:  -module(sinan).
   
   %% API
  --export([build/1, build/2,
  -         analyze/2, analyze/1,
  -         doc/2, doc/1,
  -         shell/1, shell/2,
  -         gen/2, gen/1,
  -         clean/1, clean/2,
  -         help/1, help/2,
  -         depends/1, depends/2,
  -         test/1, test/2,
  -         release/1, release/2,
  -         dist/1, dist/2,
  -         do_task/3,
  +-export([gen_build_ref/0,
  +         build/2, build/3,
  +         analyze/3, analyze/2,
  +         doc/3, doc/2,
  +         shell/2, shell/3,
  +         gen/3, gen/2,
  +         clean/2, clean/3,
  +         help/2, help/3,
  +         depends/2, depends/3,
  +         test/2, test/3,
  +         release/2, release/3,
  +         dist/2, dist/3,
            do_task/4,
  +         do_task/5,
            start/0]).
   
   %%====================================================================
  
positive.code: %%--------------------------------------------------------------------
  %% @doc
  %%  Run the build task. {@link sin_erl_builder}
  %% @spec build(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  build(StartDir) ->
      build(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  Run the build with the specified args. {@link sin_erl_builder}
  %% @spec build(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  build(StartDir, Args) ->
      do_task(build, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  Run the analyze task. {@link sin_analyze}
  %% @spec analyze(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  analyze(StartDir) ->
      analyze(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  Run the analyze task. {@link sin_analyze}
  %% @spec analyze(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  analyze(StartDir, Args) ->
      do_task(analyze, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the doc task. {@link sin_edoc}
  %% @spec doc(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  doc(StartDir) ->
      doc(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the doc task. {@link sin_edoc}
  %% @spec doc(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  doc(StartDir, Args) ->
      do_task(doc, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the shell task. {@link sin_shell}
  %% @spec shell(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  shell(StartDir) ->
      shell(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the shell task. {@link sin_shell}
  %% @spec shell(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  shell(StartDir, Args) ->
     do_task(shell, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  Run the gen task. {@link sin_gen}
  %% @spec gen(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  gen(StartDir) ->
      gen(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  Run the gen task. {@link sin_gen}
  %% @spec gen(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  gen(StartDir, Args) ->
      do_task(singen, gen, StartDir, Args).
  
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the clean task. {@link sin_clean}
  %% @spec clean(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  clean(StartDir) ->
      clean(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the clean task. {@link sin_clean}
  %% @spec clean(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  clean(StartDir, Args) ->
      do_task(clean, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the help task. {@link sin_help}
  %% @spec help(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  help(StartDir) ->
      help(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the help task. {@link sin_help}
  %% @spec help(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  help(StartDir, Args) ->
      do_task(sinhelp, help, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the depends task. {@link sin_depends}
  %% @spec depends(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  depends(StartDir) ->
      depends(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the depends task. {@link sin_depends}
  %% @spec depends(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  depends(StartDir, Args) ->
      do_task(depends, StartDir, Args).
  
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the test task. {@link sin_test}
  %% @spec test(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  test(StartDir) ->
      test(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the test task. {@link sin_test}
  %% @spec test(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  test(StartDir, Args) ->
      do_task(test, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the release task. {@link sin_release_builder}
  %% @spec release(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  release(StartDir) ->
      release(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the release task. {@link sin_release_builder}
  %% @spec release(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  release(StartDir, Args) ->
      do_task(release, StartDir, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the dist task. {@link sin_dist_builder}
  %% @spec dist(StartDir::startdir()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  dist(StartDir) ->
      dist(StartDir, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the dist task. {@link sin_dist_builder}
  %% @spec dist(StartDir::startdir(), Args::args()) -> ok
  %% @end
  %%--------------------------------------------------------------------
  dist(StartDir, Args) ->
      do_task(dist, StartDir, Args).
  
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the specified task, with the default chain
  %% @spec do_task(Task, Args) -> ok
  %% @end
  %%--------------------------------------------------------------------
  do_task(Task, StartDir, Args) when is_atom(Task) ->
      do_task(sinan, StartDir, Task, Args).
  
  %%--------------------------------------------------------------------
  %% @doc
  %%  run the specified task
  %% @spec do_task(Chain, Task, Args) -> ok
  %% @end
  %%--------------------------------------------------------------------
  do_task(Chain, StartDir, Task, Args) when is_atom(Task) ->
      BuildRef = eta_engine:make_run_id(),
      fconf:start_config(BuildRef,
                         fun sin_parse_handle:parse_config_file/1),
      fconf:store(BuildRef, "build.args", Args),
      fconf:store(BuildRef, "build.start_dir", StartDir),
      eta_engine:run(Chain, Task, BuildRef),
      fconf:stop_config(BuildRef).
  
  %%--------------------------------------------------------------------
  %% @doc
  
negative.code: %%%  Two possible arguments may be passed in. The start dir that should
  %%%  be somewhere inside a project and a list of args for the system.
  %%%
  %%%  @type buildref() = string(). A globally unique id for the build
  %%%  @type startdir() = string(). A dir that is somewhere in a project
  %%%  @type args() = {[{TaskName, args}]}
  %%%    TaskName = string(). The name of the task the args apply too.
  