@@ -23,10 +23,12 @@ class Tools {
2323 /**
2424 Inject `json.JStack.onReady()` into app entry point, so that app will not start untill source map is ready.
2525 **/
26- static public function addInjectmetaToMain () : Void
26+ static public function addInjectMetaToMain () : Void
2727 {
28- if (Compiler .getDefine (' display' ) != null ) return ;
29- if (Compiler .getDefine (' debug' ) == null || Compiler .getDefine (' js' ) == null ) return ;
28+ #if (display || !debug)
29+ return ;
30+ #end
31+ if (Context .definedValue (' js' ) == null ) return ;
3032
3133 var main : String = null ;
3234 var args = Sys .args ();
@@ -37,15 +39,15 @@ class Tools {
3739 }
3840 }
3941 if (main == null ) {
40- Context .warning (' Failed to find entry point. Did you specify `-main` directive?' , Context . currentPos () );
41- return ;
42+ Context .warning (' JStack: Failed to find entry point. Did you specify `-main` directive?' , ( macro {}). pos );
43+ return ;
4244 }
43-
45+
4446 Compiler .addMetadata (' @:build(jstack.Tools.injectInMain())' , main );
4547 }
4648#end
4749
48- macro static public function injectInMain () : Array <Field >
50+ macro static public function injectInMain () : Array <Field >
4951 {
5052 var fields = Context .getBuildFields ();
5153 var injected = false ;
@@ -56,13 +58,14 @@ class Tools {
5658 switch (field .kind ) {
5759 case FFun (fn ):
5860 fn .expr = macro jstack. JStack .onReady (function () ${fn .expr });
59- case _ :
60- Context .error (' Failed to inject JStack in `main` function.' , field .pos );
61+ injected = true ;
62+ case _ :
63+ Context .error (' JStack: Failed to inject JStack in `main` function.' , field .pos );
6164 }
6265 }
6366
6467 if (! injected ) {
65- Context .error (' Failed to find static function main.' , Context . currentPos () );
68+ Context .error (' JStack: Failed to find static function main.' , ( macro {}). pos );
6669 }
6770
6871 return fields ;
0 commit comments