---
 src/internal.hrl        |   20 ++++++++++++++++++++
 src/sin_compile_erl.erl |   23 +++++++++++++----------
 src/sin_compile_yrl.erl |   18 +++++++++++-------
 src/sin_config.erl      |   13 +++++++++++++
 4 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/src/internal.hrl b/src/internal.hrl
index 9f82ebf..3617949 100644
--- a/src/internal.hrl
+++ b/src/internal.hrl
@@ -55,6 +55,26 @@
                {?MODULE, ?LINE,
                 {Problem, io_lib:format(Description, DescArgs)}}})).
 
+-define(WARN(Config, Warnings),
+        ((fun() ->
+                  WarnRef =
+                      sin_config:add_run_warning(Config, ?MODULE, Warnings),
+                  ewl_talk:say(Warnings),
+                  WarnRef
+          end)())).
+
+
+-define(WARN(Config, Warnings, Detail),
+        ((fun() ->
+                WarnRef =
+                     sin_config:add_run_warning(Config, ?MODULE,
+                                                io_lib:format(Warnings, 
Detail)),
+                 ewl_talk:say(Warnings, Detail),
+                 WarnRef
+          end)())).
+
+
+
 
 -record(task,  {name :: atom(),            % The 'user friendly' name of the 
task
                 task_impl :: atom(),       % The implementation of the task, 
maybe fun or
diff --git a/src/sin_compile_erl.erl b/src/sin_compile_erl.erl
index 7c7b3a4..c6fb224 100644
--- a/src/sin_compile_erl.erl
+++ b/src/sin_compile_erl.erl
@@ -38,23 +38,26 @@ get_dependencies(File, Includes) ->
 
 %% @doc Do the actual compilation on the file.
 -spec build_file(sin_config:config(), string(), [term()], string()) ->
-    [module()].
+                        {module(), sin_config:config()}.
 build_file(BuildRef, File, Options, _Target) ->
     ewl_talk:say("Building ~s", [File]),
     case compile:file(File, Options) of
         {ok, ModuleName} ->
-            ModuleName;
+            {ModuleName, BuildRef};
         {ok, ModuleName, []} ->
-            ModuleName;
+            {ModuleName, BuildRef};
         {ok, ModuleName, Warnings} ->
-            ewl_talk:say(sin_task_build:gather_fail_info(Warnings, "warning")),
-            ModuleName;
+            {ModuleName,
+             ?WARN(BuildRef,
+                  sin_task_build:gather_fail_info(Warnings, "warning"))};
         {error, Errors, Warnings} ->
-            ewl_talk:say(
-              lists:flatten([sin_task_build:gather_fail_info(Errors, "error"),
-                             sin_task_build:gather_fail_info(Warnings,
-                                                             "warning")])),
-            ?SIN_RAISE(BuildRef, {build_error, error_building_erl_file, File});
+            NewRef =
+                ?WARN(BuildRef,
+                  lists:flatten([sin_task_build:gather_fail_info(Errors,
+                                                                 "error"),
+                                 sin_task_build:gather_fail_info(Warnings,
+                                                                 "warning")])),
+            ?SIN_RAISE(NewRef, {build_error, error_building_erl_file, File});
         error ->
             ewl_talk:say("Unknown error occured during build"),
             ?SIN_RAISE(BuildRef, {build_error, error_building_erl_file, File})
diff --git a/src/sin_compile_yrl.erl b/src/sin_compile_yrl.erl
index 6cff54d..1cc0591 100644
--- a/src/sin_compile_yrl.erl
+++ b/src/sin_compile_yrl.erl
@@ -39,14 +39,18 @@ build_file(BuildRef, File, Options, Target) ->
         {ok, _ModuleName, []} ->
             sin_compile_erl:build_file(BuildRef, ErlName, Options, Target);
         {ok, _ModuleName, Warnings} ->
-            ewl_talk:say(sin_task_build:gather_fail_info(Warnings, "warning")),
-            ?SIN_RAISE(BuildRef, {build_error, error_building_yecc, File});
+            NewRef =
+                ?WARN(BuildRef,
+                      sin_task_build:gather_fail_info(Warnings, "warning")),
+            ?SIN_RAISE(NewRef, {build_error, error_building_yecc, File});
         {error, Errors, Warnings} ->
-            ewl_talk:say(
-              lists:flatten([sin_task_build:gather_fail_info(Errors, "error"),
-                             sin_task_build:gather_fail_info(Warnings,
-                                                             "warning")])),
-            ?SIN_RAISE(BuildRef, {build_error, error_building_yecc, File})
+            NewRef =
+                ?WARN(BuildRef,
+                      lists:flatten([sin_task_build:gather_fail_info(Errors,
+                                                                     "error"),
+                                     sin_task_build:gather_fail_info(Warnings,
+                                                                     
"warning")])),
+            ?SIN_RAISE(NewRef, {build_error, error_building_yecc, File})
     end.
 
 %% @doc Format an exception thrown by this module
diff --git a/src/sin_config.erl b/src/sin_config.erl
index ba9284c..b036a1f 100644
--- a/src/sin_config.erl
+++ b/src/sin_config.erl
@@ -25,6 +25,8 @@
          delete/2,
          add_run_error/3,
          get_run_errors/1,
+         add_run_warning/3,
+         get_run_warnings/1,
          format_exception/1]).
 
 -export_type([key/0,
@@ -147,6 +149,17 @@ add_run_error(Config, Task, Error) ->
 get_run_errors(Config) ->
     get_value(Config, run_errors, []).
 
+%% @doc Add a run time warning occurance to the config
+-spec add_run_warning(config(), atom(), term()) -> config().
+add_run_warning(Config, Task, Warning) ->
+    CurrentWarnings = get_value(Config, run_warnings, []),
+    store(Config, run_warnings, [{Task, Warning} | CurrentWarnings]).
+
+%% @doc return the list of run warnings in the state
+-spec get_run_warnings(config()) -> [term()].
+get_run_warnings(Config) ->
+    get_value(Config, run_warnings, []).
+
 %% @doc Format an exception thrown by this module
 -spec format_exception(sin_exceptions:exception()) ->
     string().
-- 
1.7.5.2

-- 
You received this message because you are subscribed to the Google Groups 
"erlware-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/erlware-dev?hl=en.

Reply via email to