예제 #1
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerResult = compiler.CompileFromFile(inputFilePath,
                                                              Debug ? EffectCompilerFlags.Debug : EffectCompilerFlags.None,
                                                              null,
                                                              null,
                                                              item.DynamicCompiling,
                                                              dependencyFilePath);

            if (!compilerResult.HasErrors && compilerResult.EffectData != null)
            {
                CreateDirectoryIfNotExists(outputFilePath);

                if (item.OutputCs)
                {
                    var codeWriter = new EffectDataCodeWriter
                                     {
                                         Namespace = item.OutputNamespace,
                                         ClassName = item.OutputClassName,
                                         FieldName = item.OutputFieldName,
                                     };

                    using (var stream = new NativeFileStream(outputFilePath, NativeFileMode.Create, NativeFileAccess.Write, NativeFileShare.Write))
                        codeWriter.Write(compilerResult.EffectData, new StreamWriter(stream, Encoding.UTF8));
                }
                else
                {
                    compilerResult.EffectData.Save(outputFilePath);
                }
            }

            return compilerResult.Logger;
        }
예제 #2
0
파일: Program.cs 프로젝트: Nezz/SharpDX
        void Run(string[] args)
        {
            var assemblyUri = new Uri(Assembly.GetEntryAssembly().CodeBase);
            var assemblyPath = Path.GetDirectoryName(assemblyUri.LocalPath);

            var newPath = Path.GetFullPath(Path.Combine(assemblyPath, @"..\Redist\D3D\" + (IntPtr.Size == 4 ? "x86" : "x64"))) + ";" + Environment.GetEnvironmentVariable("PATH");
            Environment.SetEnvironmentVariable("PATH", newPath);

            // Print the exe header
            PrintHeader();

            // Parse the command line
            if (!ParseCommandLine(args))
                Environment.Exit(-1);

            var options = this;

            // ----------------------------------------------------------------
            // Process macros
            // ----------------------------------------------------------------
            var macros = new List<ShaderMacro>();
            foreach (var define in options.Defines)
            {
                var nameValue = define.Split('=');
                string name = nameValue[0];
                string value = null;
                if (nameValue.Length > 1)
                {
                    value = nameValue[1];
                }
                macros.Add(new ShaderMacro(name, value));
            }

            // ----------------------------------------------------------------
            // Setup compiler flags
            // ----------------------------------------------------------------
            var flags = EffectCompilerFlags.None;
            if (options.Debug)
                flags |= EffectCompilerFlags.Debug;

            switch (options.OptimizationLevel)
            {
                case 0:
                    flags |= EffectCompilerFlags.OptimizationLevel0;
                    break;
                case 1:
                    flags |= EffectCompilerFlags.OptimizationLevel1;
                    break;
                case 2:
                    flags |= EffectCompilerFlags.OptimizationLevel2;
                    break;
                case 3:
                    flags |= EffectCompilerFlags.OptimizationLevel3;
                    break;
            }

            if (options.PackRowMajor)
                flags |= EffectCompilerFlags.PackMatrixRowMajor;

            if (options.PackColumnMajor)
                flags |= EffectCompilerFlags.PackMatrixColumnMajor;

            var archiveBytecode = new EffectData();
            bool hasErrors = false;
            bool isFileUpToDate = CompileOnlyIfNewer;

            // ----------------------------------------------------------------
            // Pre check files
            // ----------------------------------------------------------------
            var outputTime = new DateTime();
            var outputFileName = OutputClassFile ?? OutputFile;
            if (!ViewOnly && CompileOnlyIfNewer)
            {
                if (OutputClassFile != null)
                {
                    if (File.Exists(OutputClassFile))
                        outputTime = File.GetLastWriteTime(OutputClassFile);
                }
                else if (OutputFile != null)
                {
                    if (File.Exists(OutputFile))
                        outputTime = File.GetLastWriteTime(OutputFile);
                }
                else
                {
                    ErrorColor();
                    Console.WriteLine("Missing /Fo OutputFile or /Fc OutputClassFile");
                    ResetColor();
                    Environment.Exit(-1);
                }


                // If the assembly is more recent than the ouput file, then regenerate it
                var assemblyTime = File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location);
                if (assemblyTime > outputTime)
                {
                    isFileUpToDate = false;
                }
                else
                {
                    // Else check that all files are not more recent.
                    foreach (var fxFile in options.FxFiles)
                    {
                        var filePath = Path.Combine(Environment.CurrentDirectory, fxFile);

                        if (!File.Exists(filePath))
                        {
                            isFileUpToDate = false;
                            break;
                        }

                        if (File.GetLastWriteTime(filePath) > outputTime)
                        {
                            isFileUpToDate = false;
                            break;
                        }
                    }
                }            
            }

            if (!ViewOnly && isFileUpToDate)
            {
                Console.WriteLine("Nothing to compile, output file is up to date [{0}]", outputFileName);
                Environment.Exit(0);
            }

            // ----------------------------------------------------------------
            // Process each fx files / tkfxo files
            // ----------------------------------------------------------------
            foreach (var fxFile in options.FxFiles)
            {
                var filePath = Path.Combine(Environment.CurrentDirectory, fxFile);

                if (!File.Exists(filePath))
                {
                    ErrorColor();
                    Console.Error.WriteLine("File [{0}] does not exist", fxFile);
                    ResetColor();
                    hasErrors = true;
                    continue;
                }

                EffectData effectData = null;

                // Try to load this file as a precompiled file
                effectData = EffectData.Load(fxFile);
                if (effectData != null)
                {
                    Console.WriteLine("Load Compiled File [{0}]", fxFile);                    
                }
                else
                {
                    // Compile the fx file
                    Console.WriteLine("Compile Effect File [{0}]", filePath);
                    var effectBytecode = EffectCompiler.Compile(File.ReadAllText(filePath), filePath, flags, macros, options.IncludeDirs);

                    // If there is any warning, errors, turn Error color on
                    if (effectBytecode.Logger.Messages.Count > 0)
                    {
                        ErrorColor();
                    }

                    // Show a message error for the current file
                    if (effectBytecode.HasErrors)
                    {
                        Console.Error.WriteLine("Error when compiling file [{0}]:", fxFile);
                        hasErrors = true;
                    }

                    // Print all messages (warning and errors)
                    foreach (var logMessage in effectBytecode.Logger.Messages)
                    {
                        Console.WriteLine(logMessage);
                    }

                    // If we have some messages, reset the color back
                    if (effectBytecode.Logger.Messages.Count > 0)
                    {
                        ResetColor();
                    }

                    effectData = effectBytecode.EffectData;
                }

                // If there is no errors, merge the result to the final archive
                if (!hasErrors)
                {
                    if (ProcessBytecode(effectData, archiveBytecode))
                        hasErrors = true;
                }
            }

            if (hasErrors)
            {
                ErrorColor();
                Console.Error.WriteLine("Compilation has errors. Process aborted.");
                ResetColor();
                Environment.Exit(-1);
            }
            else if (!ViewOnly)
            {
                Console.WriteLine();

                if (OutputClassFile != null)
                {
                    var codeWriter = new EffectDataCodeWriter
                                         {
                                             Namespace = OutputNamespace, 
                                             ClassName = OutputClassname ?? Path.GetFileNameWithoutExtension(OutputClassFile),
                                             FieldName = OutputFieldName,
                                         };

                    Console.WriteLine("Save C# code output to [{0}]", OutputClassFile);
                    using (var stream = new NativeFileStream(OutputClassFile, NativeFileMode.Create, NativeFileAccess.Write, NativeFileShare.Write))
                        codeWriter.Write(archiveBytecode, new StreamWriter(stream, Encoding.UTF8));
                }
                else
                {
                    Console.WriteLine("Save output to [{0}]", options.OutputFile);
                    // Save the result
                    archiveBytecode.Save(options.OutputFile);
                }
            }
        }
예제 #3
0
        void Run(string[] args)
        {
            var assemblyUri  = new Uri(Assembly.GetEntryAssembly().CodeBase);
            var assemblyPath = Path.GetDirectoryName(assemblyUri.LocalPath);

            var newPath = Path.GetFullPath(Path.Combine(assemblyPath, @"..\Redist\D3D\" + (IntPtr.Size == 4 ? "x86" : "x64"))) + ";" + Environment.GetEnvironmentVariable("PATH");

            Environment.SetEnvironmentVariable("PATH", newPath);

            // Print the exe header
            PrintHeader();

            // Parse the command line
            if (!ParseCommandLine(args))
            {
                Environment.Exit(-1);
            }

            var options = this;

            // ----------------------------------------------------------------
            // Process macros
            // ----------------------------------------------------------------
            var macros = new List <EffectData.ShaderMacro>();

            foreach (var define in options.Defines)
            {
                var    nameValue = define.Split('=');
                string name      = nameValue[0];
                string value     = null;
                if (nameValue.Length > 1)
                {
                    value = nameValue[1];
                }
                macros.Add(new EffectData.ShaderMacro(name, value));
            }

            // ----------------------------------------------------------------
            // Setup compiler flags
            // ----------------------------------------------------------------
            var flags = EffectCompilerFlags.None;

            if (options.Debug)
            {
                flags |= EffectCompilerFlags.Debug;
            }

            switch (options.OptimizationLevel)
            {
            case 0:
                flags |= EffectCompilerFlags.OptimizationLevel0;
                break;

            case 1:
                flags |= EffectCompilerFlags.OptimizationLevel1;
                break;

            case 2:
                flags |= EffectCompilerFlags.OptimizationLevel2;
                break;

            case 3:
                flags |= EffectCompilerFlags.OptimizationLevel3;
                break;
            }

            if (options.PackRowMajor)
            {
                flags |= EffectCompilerFlags.PackMatrixRowMajor;
            }

            if (options.PackColumnMajor)
            {
                flags |= EffectCompilerFlags.PackMatrixColumnMajor;
            }

            if (options.AvoidFlowControl)
            {
                flags |= EffectCompilerFlags.AvoidFlowControl;
            }

            if (options.PreferFlowControl)
            {
                flags |= EffectCompilerFlags.PreferFlowControl;
            }

            if (options.EnableStrictness)
            {
                flags |= EffectCompilerFlags.EnableStrictness;
            }

            if (options.EnableBackwardsCompatibility)
            {
                flags |= EffectCompilerFlags.EnableBackwardsCompatibility;
            }

            if (options.IeeeStrictness)
            {
                flags |= EffectCompilerFlags.IeeeStrictness;
            }

            hasErrors = false;

            // ----------------------------------------------------------------
            // Process each fx files / tkfxo files
            // ----------------------------------------------------------------
            var fxFile   = options.FxFile;
            var filePath = Path.Combine(Environment.CurrentDirectory, fxFile);

            // Check that input file exists
            if (!File.Exists(filePath))
            {
                ErrorColor();
                Console.Error.WriteLine("File [{0}] does not exist", fxFile);
                ResetColor();
                Abort();
            }

            // ----------------------------------------------------------------
            // Pre check files
            // ----------------------------------------------------------------
            if (options.OutputClassFile == null && options.OutputFile == null)
            {
                options.OutputFile = Path.GetFileNameWithoutExtension(options.FxFile) + ".tkb";
            }

            // Check for output files
            bool outputFileExist = options.OutputClassFile != null && File.Exists(options.OutputClassFile);

            if (options.OutputFile != null && !File.Exists(options.OutputFile))
            {
                outputFileExist = false;
            }

            // New Compiler
            var compiler = new EffectCompiler();

            string outputDependencyDirPath  = Path.Combine(Environment.CurrentDirectory, OutputDependencyDirectory);
            string outputDependencyFilePath = Path.Combine(outputDependencyDirPath, compiler.GetDependencyFileNameFromSourcePath(options.FxFile));

            if (AllowDynamicCompiling)
            {
                CompileOnlyIfNewer = true;
            }

            if (CompileOnlyIfNewer)
            {
                if (!compiler.CheckForChanges(outputDependencyFilePath) && outputFileExist)
                {
                    Console.Error.WriteLine("Nothing to compile. Output file [{0}] is up-to-date", options.OutputFile);
                    Environment.Exit(0);
                }
            }

            var viewOnly = false;
            // Try to load this file as a precompiled file
            var effectData = EffectData.Load(fxFile);
            EffectCompilerResult compilerResult = null;

            if (effectData != null)
            {
                Console.WriteLine("Load Compiled File [{0}]", fxFile);
                viewOnly = true;
            }
            else
            {
                // Compile the fx file
                Console.WriteLine("Compile Effect File [{0}]", filePath);
                compilerResult = compiler.Compile(File.ReadAllText(filePath), filePath, flags, macros, options.IncludeDirs, AllowDynamicCompiling, CompileOnlyIfNewer ? outputDependencyFilePath : null);

                // If there is any warning, errors, turn Error color on
                if (compilerResult.Logger.Messages.Count > 0)
                {
                    ErrorColor();
                }

                // Show a message error for the current file
                if (compilerResult.HasErrors)
                {
                    Console.Error.WriteLine("Error when compiling file [{0}]:", fxFile);
                    hasErrors = true;
                }

                // Print all messages (warning and errors)
                foreach (var logMessage in compilerResult.Logger.Messages)
                {
                    Console.WriteLine(logMessage);
                }

                // If we have some messages, reset the color back
                if (compilerResult.Logger.Messages.Count > 0)
                {
                    ResetColor();
                }

                effectData = compilerResult.EffectData;
            }

            if (!NoDisassembly && effectData != null)
            {
                DumpBytecode(compiler, effectData);
            }

            if (hasErrors)
            {
                Abort();
            }

            if (!viewOnly)
            {
                Console.WriteLine();

                if (CompileOnlyIfNewer && compilerResult.DependencyFilePath != null)
                {
                    // Dependency file save to
                    Console.WriteLine("Save dependency list to [{0}]", outputDependencyFilePath);
                }

                if (OutputClassFile != null)
                {
                    var codeWriter = new EffectDataCodeWriter
                    {
                        Namespace = OutputNamespace,
                        ClassName = OutputClassname ?? Path.GetFileNameWithoutExtension(OutputClassFile),
                        FieldName = OutputFieldName,
                    };

                    Console.WriteLine("Save C# code output to [{0}]", OutputClassFile);
                    using (var stream = new NativeFileStream(OutputClassFile, NativeFileMode.Create, NativeFileAccess.Write, NativeFileShare.Write)) codeWriter.Write(effectData, new StreamWriter(stream, Encoding.UTF8));
                }

                if (options.OutputFile != null)
                {
                    Console.WriteLine("Save binary output to [{0}]", options.OutputFile);
                    // Save the result
                    effectData.Save(options.OutputFile);
                }
            }
        }
예제 #4
0
        void Run(string[] args)
        {
            var assemblyUri = new Uri(Assembly.GetEntryAssembly().CodeBase);
            var assemblyPath = Path.GetDirectoryName(assemblyUri.LocalPath);

            var newPath = Path.GetFullPath(Path.Combine(assemblyPath, @"..\Redist\D3D\" + (IntPtr.Size == 4 ? "x86" : "x64"))) + ";" + Environment.GetEnvironmentVariable("PATH");
            Environment.SetEnvironmentVariable("PATH", newPath);

            // Print the exe header
            PrintHeader();

            // Parse the command line
            if (!ParseCommandLine(args))
                Environment.Exit(-1);

            var options = this;

            // ----------------------------------------------------------------
            // Process macros
            // ----------------------------------------------------------------
            var macros = new List<EffectData.ShaderMacro>();
            foreach (var define in options.Defines)
            {
                var nameValue = define.Split('=');
                string name = nameValue[0];
                string value = null;
                if (nameValue.Length > 1)
                {
                    value = nameValue[1];
                }
                macros.Add(new EffectData.ShaderMacro(name, value));
            }

            // ----------------------------------------------------------------
            // Setup compiler flags
            // ----------------------------------------------------------------
            var flags = EffectCompilerFlags.None;
            if (options.Debug)
                flags |= EffectCompilerFlags.Debug;

            switch (options.OptimizationLevel)
            {
                case 0:
                    flags |= EffectCompilerFlags.OptimizationLevel0;
                    break;
                case 1:
                    flags |= EffectCompilerFlags.OptimizationLevel1;
                    break;
                case 2:
                    flags |= EffectCompilerFlags.OptimizationLevel2;
                    break;
                case 3:
                    flags |= EffectCompilerFlags.OptimizationLevel3;
                    break;
            }

            if (options.PackRowMajor)
                flags |= EffectCompilerFlags.PackMatrixRowMajor;

            if (options.PackColumnMajor)
                flags |= EffectCompilerFlags.PackMatrixColumnMajor;

            hasErrors = false;

            // ----------------------------------------------------------------
            // Pre check files
            // ----------------------------------------------------------------
            if (options.OutputClassFile == null && options.OutputFile == null)
            {
                options.OutputFile = "output.tkfxo";
            }

            // Check for output files
            bool outputFileExist = options.OutputClassFile != null && File.Exists(options.OutputClassFile);
            if (options.OutputFile != null && !File.Exists(options.OutputFile))
            {
                outputFileExist = false;
            }

            // ----------------------------------------------------------------
            // Process each fx files / tkfxo files
            // ----------------------------------------------------------------
            var fxFile = options.FxFile;
            var filePath = Path.Combine(Environment.CurrentDirectory, fxFile);

            // Check that input file exists
            if (!File.Exists(filePath))
            {
                ErrorColor();
                Console.Error.WriteLine("File [{0}] does not exist", fxFile);
                ResetColor();
                Abort();
            }
            
            // New Compiler
            var compiler = new EffectCompiler();

            string outputDependencyDirPath = Path.Combine(Environment.CurrentDirectory, OutputDependencyDirectory);
            string outputDependencyFilePath = Path.Combine(outputDependencyDirPath,  compiler.GetDependencyFileNameFromEffectPath(options.FxFile));

            if (AllowDynamicCompiling)
            {
                CompileOnlyIfNewer = true;
            }

            if (CompileOnlyIfNewer)
            {
                if (!compiler.CheckForChanges(outputDependencyFilePath) && outputFileExist)
                {
                    Console.Error.WriteLine("Nothing to compile. Output file [{0}] is up-to-date", options.OutputFile);
                    Environment.Exit(0);
                }
            }

            var viewOnly = false;
            // Try to load this file as a precompiled file
            var effectData = EffectData.Load(fxFile);
            EffectCompilerResult compilerResult = null;

            if (effectData != null)
            {
                Console.WriteLine("Load Compiled File [{0}]", fxFile);
                viewOnly = true;
            }
            else
            {
                // Compile the fx file
                Console.WriteLine("Compile Effect File [{0}]", filePath);
                compilerResult = compiler.Compile(File.ReadAllText(filePath), filePath, flags, macros, options.IncludeDirs, AllowDynamicCompiling, CompileOnlyIfNewer ? outputDependencyFilePath : null);

                // If there is any warning, errors, turn Error color on
                if (compilerResult.Logger.Messages.Count > 0)
                {
                    ErrorColor();
                }

                // Show a message error for the current file
                if (compilerResult.HasErrors)
                {
                    Console.Error.WriteLine("Error when compiling file [{0}]:", fxFile);
                    hasErrors = true;
                }

                // Print all messages (warning and errors)
                foreach (var logMessage in compilerResult.Logger.Messages)
                {
                    Console.WriteLine(logMessage);
                }

                // If we have some messages, reset the color back
                if (compilerResult.Logger.Messages.Count > 0)
                {
                    ResetColor();
                }

                effectData = compilerResult.EffectData;
            }

            if (!NoDisassembly && effectData != null)
            {
                DumpBytecode(compiler, effectData);
            }

            if (hasErrors)
            {
                Abort();
            }

            if (!viewOnly)
            {
                Console.WriteLine();

                if (CompileOnlyIfNewer && compilerResult.DependencyFilePath != null)
                {
                    // Dependency file save to 
                    Console.WriteLine("Save dependency list to [{0}]", outputDependencyFilePath);
                }

                if (OutputClassFile != null)
                {
                    var codeWriter = new EffectDataCodeWriter
                                         {
                                             Namespace = OutputNamespace,
                                             ClassName = OutputClassname ?? Path.GetFileNameWithoutExtension(OutputClassFile),
                                             FieldName = OutputFieldName,
                                         };

                    Console.WriteLine("Save C# code output to [{0}]", OutputClassFile);
                    using (var stream = new NativeFileStream(OutputClassFile, NativeFileMode.Create, NativeFileAccess.Write, NativeFileShare.Write)) codeWriter.Write(effectData, new StreamWriter(stream, Encoding.UTF8));
                }

                if (options.OutputFile != null)
                {
                    Console.WriteLine("Save binary output to [{0}]", options.OutputFile);
                    // Save the result
                    effectData.Save(options.OutputFile);
                }
            }
        }
예제 #5
0
        protected override bool ProcessItem(TkFxcItem item)
        {
            bool hasErrors = false;

            var inputFilePath = item.InputFilePath;
            var outputFilePath = item.OutputFilePath;

            var dependencyFilePath = Path.Combine(Path.Combine(ProjectDirectory.ItemSpec, IntermediateDirectory.ItemSpec), compiler.GetDependencyFileNameFromEffectPath(item.LinkName));

            // Creates the dependency directory if it does no exist yet.
            var dependencyDirectoryPath = Path.GetDirectoryName(dependencyFilePath);
            if (!Directory.Exists(dependencyDirectoryPath))
            {
                Directory.CreateDirectory(dependencyDirectoryPath);
            }

            Log.LogMessage(MessageImportance.High, "Check Toolkit FX file to compile {0} with dependency file {1}", inputFilePath, dependencyFilePath);

            if (compiler.CheckForChanges(dependencyFilePath) || !File.Exists(outputFilePath))
            {
                Log.LogMessage(MessageImportance.High, "Start to compile {0}", inputFilePath);

                var compilerResult = compiler.CompileFromFile(inputFilePath, Debug ? EffectCompilerFlags.Debug : EffectCompilerFlags.None, null, null, item.DynamicCompiling, dependencyFilePath);

                if (compilerResult.HasErrors)
                {
                    hasErrors = true;
                }
                else
                {
                    Log.LogMessage(MessageImportance.High, "Compiled successfull {0} to {1}", inputFilePath, outputFilePath);
                }

                foreach (var message in compilerResult.Logger.Messages)
                {
                    var text = message.ToString();

                    string line = null;
                    var textReader = new StringReader(text);
                    while ((line = textReader.ReadLine()) != null)
                    {
                        var match = parseMessage.Match(line);
                        if (match.Success)
                        {
                            var filePath = match.Groups[1].Value;
                            var lineNumber = int.Parse(match.Groups[2].Value);
                            var colNumberText = match.Groups[3].Value;
                            int colStartNumber;
                            int colEndNumber;
                            var colMatch = matchNumberRange.Match(colNumberText);
                            if (colMatch.Success)
                            {
                                int.TryParse(colMatch.Groups[1].Value, out colStartNumber);
                                int.TryParse(colMatch.Groups[2].Value, out colEndNumber);
                            }
                            else
                            {
                                int.TryParse(colNumberText, out colStartNumber);
                                colEndNumber = colStartNumber;
                            }
                            var msgType = match.Groups[4].Value;
                            var msgCode = match.Groups[5].Value;
                            var msgText = match.Groups[6].Value;
                            if (string.Compare(msgType, "error", StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                Log.LogError(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText);
                            }
                            else if (string.Compare(msgType, "warning", StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                Log.LogWarning(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText);
                            }
                            else if (string.Compare(msgType, "info", StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                Log.LogWarning(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText);
                            }
                            else
                            {
                                Log.LogWarning(line);
                            }
                        }
                        else
                        {
                            Log.LogWarning(line);
                        }
                    }
                }

                if (!compilerResult.HasErrors && compilerResult.EffectData != null)
                {
                    try
                    {
                        var directoryName = Path.GetDirectoryName(outputFilePath);
                        if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName))
                        {
                            Directory.CreateDirectory(directoryName);
                        }

                        if (item.OutputCs)
                        {
                            var codeWriter = new EffectDataCodeWriter
                            {
                                Namespace = item.OutputNamespace,
                                ClassName = item.OutputClassName,
                                FieldName = item.OutputFieldName,
                            };

                            using (var stream = new NativeFileStream(outputFilePath, NativeFileMode.Create, NativeFileAccess.Write, NativeFileShare.Write))
                            {
                                codeWriter.Write(compilerResult.EffectData, new StreamWriter(stream, Encoding.UTF8));
                            }
                        }
                        else
                        {
                            compilerResult.EffectData.Save(outputFilePath);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.LogError("Cannot write compiled file to {0} : {1}", inputFilePath, ex.Message);
                        hasErrors = true;
                    }
                }
            }

            return !hasErrors;
        }