コード例 #1
0
ファイル: Sjc.cs プロジェクト: rexzh/SharpJs
        public override bool Execute()
        {
            CompileEngine engine = new CompileEngine();
            CompileOptions options = new CompileOptions(_singleFile ? ArtifactsType.SingleFile : ArtifactsType.MultipleFile, _build);
            options.GenerateSourceMap = this._generateSourceMap;
            engine.InitializeCompiler(this._csprojPath, options, _supressWarnings);

            var watch = Stopwatch.StartNew();
            var issues = engine.Compile();
            watch.Stop();
            Log.LogMessage(" {0} Compile done in {1} ms.", Constants.SharpJs, watch.ElapsedMilliseconds);

            foreach (var issue in issues.Issues)
            {
                var loc = issue.Location;
                string code = string.Format("{0}-{1}", Constants.SharpJs, issue.IssueId.ToString("0000"));
                switch (issue.IssueType)
                {
                    case IssueType.Warning:
                        Log.LogWarning(Constants.SharpJs, code, null, loc.FileName, loc.Line, loc.Column, loc.EndLine, loc.EndColumn, issue.Message);
                        break;

                    case IssueType.Error:
                        Log.LogError(Constants.SharpJs, code, null, loc.FileName, loc.Line, loc.Column, loc.EndLine, loc.EndColumn, issue.Message);
                        break;
                }
            }

            return !issues.HasError;
        }
コード例 #2
0
        public override bool Execute()
        {
            CompileEngine  engine  = new CompileEngine();
            CompileOptions options = new CompileOptions(_singleFile ? ArtifactsType.SingleFile : ArtifactsType.MultipleFile, _build);

            options.GenerateSourceMap = this._generateSourceMap;
            engine.InitializeCompiler(this._csprojPath, options, _supressWarnings);

            var watch  = Stopwatch.StartNew();
            var issues = engine.Compile();

            watch.Stop();
            Log.LogMessage(" {0} Compile done in {1} ms.", Constants.SharpJs, watch.ElapsedMilliseconds);

            foreach (var issue in issues.Issues)
            {
                var    loc  = issue.Location;
                string code = string.Format("{0}-{1}", Constants.SharpJs, issue.IssueId.ToString("0000"));
                switch (issue.IssueType)
                {
                case IssueType.Warning:
                    Log.LogWarning(Constants.SharpJs, code, null, loc.FileName, loc.Line, loc.Column, loc.EndLine, loc.EndColumn, issue.Message);
                    break;

                case IssueType.Error:
                    Log.LogError(Constants.SharpJs, code, null, loc.FileName, loc.Line, loc.Column, loc.EndLine, loc.EndColumn, issue.Message);
                    break;
                }
            }

            return(!issues.HasError);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: rexzh/SharpJs
        static void Main(string[] args)
        {
            if (!ExtractParams(args))
            {
                ShowMessage();
                return;
            }
            else
            {
                CompileEngine engine = new CompileEngine();
                ArtifactsType artifactsType = ArtifactsType.Console;
                if (_writeFile)
                {
                    if (_singleFile)
                        artifactsType = ArtifactsType.SingleFile;
                    else
                        artifactsType = ArtifactsType.MultipleFile;
                }

                if ((!string.IsNullOrEmpty(_config)) && _config.ToUpper() == "RELEASE")
                    _config = CompileOptions.RELEASE_ANY_CPU;
                else
                    _config = CompileOptions.DEBUG_ANY_CPU;


                CompileOptions opts = new CompileOptions(artifactsType, _config);
                opts.GenerateSourceMap = _generateSourceMap;

                engine.InitializeCompiler(_csprojFile, opts, _suppressWarnings);
                var errors = engine.Compile();
                errors.WriteToStdErr(opts.StdError);
            }
            System.Console.ReadLine();
        }