Esempio n. 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;
        }
Esempio n. 2
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerOptions = new ModelCompilerOptions()
                                  {
                                      DependencyFile = dependencyFilePath,
                                      Quality = Debug ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum
                                  };

            var compilerResult = ModelCompiler.CompileAndSave(inputFilePath, outputFilePath, compilerOptions);

            return compilerResult.Logger;
        }
Esempio n. 3
0
        protected override Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            // the audio files can be in a subdirectory - make sure it exists before copying there:
            CreateDirectoryIfNotExists(outputFilePath);

            // For the AudioCompilerTask, simply copy input to output without performing any transformations
            // but a future version will introduce this
            File.Copy(inputFilePath, outputFilePath, true);

            // Save the dependency file
            var dependencies = new FileDependencyList();
            dependencies.AddDefaultDependencies();
            dependencies.AddDependencyPath(inputFilePath);
            dependencies.Save(dependencyFilePath);

            return new Logger();
        }
Esempio n. 4
0
        protected sealed override bool ProcessItem(TkItem item)
        {
            var hasErrors = false;

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

            try
            {
                var dependencyFilePath = Path.Combine(Path.Combine(ProjectDirectory.ItemSpec, IntermediateDirectory.ItemSpec),
                                                      FileDependencyList.GetDependencyFileNameFromSourcePath(item.LinkName));

                CreateDirectoryIfNotExists(dependencyFilePath);

                Log.LogMessage(MessageImportance.Low, "Check Toolkit file to compile {0} with dependency file {1}", inputFilePath, dependencyFilePath);
                if (FileDependencyList.CheckForChanges(dependencyFilePath) || !File.Exists(outputFilePath))
                {
                    Log.LogMessage(MessageImportance.Low, "Starting compilation of {0}", inputFilePath);

                    var logger = ProcessFileAndGetLogResults(inputFilePath, outputFilePath, dependencyFilePath, item);

                    LogLogger(logger);

                    if (logger.HasErrors)
                    {
                        hasErrors = true;
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.High, "Compilation successful of {0} to {1}", inputFilePath, outputFilePath);
                        if (item.OutputCs)
                        {
                            Log.LogWarning("Compilation to CS not yet supported");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.LogError("Cannot process file '{0}' : {1}", inputFilePath, ex.Message);
                hasErrors = true;
            }

            return(!hasErrors);
        }
Esempio n. 5
0
        private TkItem GetTkItem(ITaskItem item)
        {
            var data = new TkItem
            {
                Name             = item.ItemSpec,
                DynamicCompiling = item.GetMetadata("DynamicCompiling", DynamicCompiling),
                LinkName         = item.GetMetadata("Link", item.ItemSpec),
                OutputNamespace  = item.GetMetadata("OutputNamespace", RootNamespace),
                OutputFieldName  = item.GetMetadata("OutputFieldName", "bytecode"),
                OutputCs         = item.GetMetadata("OutputCs", false),
                ParentTaskItem   = item
            };

            data.OutputClassName = item.GetMetadata("OutputClassName", Path.GetFileNameWithoutExtension(data.LinkName));
            data.OutputCsFile    = item.GetMetadata("OutputCsFileName", Path.GetFileNameWithoutExtension(data.LinkName) + ".Generated.cs");

            var outputCsFile = item.GetMetadata <string>("LastGenOutput", null);

            if (outputCsFile != null && outputCsFile.EndsWith(".cs", StringComparison.InvariantCultureIgnoreCase))
            {
                data.OutputCsFile = outputCsFile;
            }

            // Full path to the generated Output FilePath either
            // For fxo: $(ProjectDir)/obj/Debug/XXX/YYY.fxo
            // For cs: $(ProjectDir)/XXX/YYY.cs
            if (data.OutputCs)
            {
                data.OutputFilePath = Path.Combine(IntermediateDirectory.ItemSpec, Path.Combine(Path.GetDirectoryName(data.Name) ?? string.Empty, data.OutputCsFile));
            }
            else
            {
                data.OutputLink     = Path.ChangeExtension(data.LinkName, "tkb");
                data.OutputFilePath = Path.Combine(IntermediateDirectory.ItemSpec, data.OutputLink);
            }

            // Prefix by ProjectDirectory
            data.OutputFilePath = Path.Combine(ProjectDirectory.ItemSpec, data.OutputFilePath);

            // Full path to the input file
            data.InputFilePath = Path.Combine(ProjectDirectory.ItemSpec, data.Name);

            return(data);
        }
Esempio n. 6
0
        protected sealed override bool ProcessItem(TkItem item)
        {
            var hasErrors = false;

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

            try
            {
                var dependencyFilePath = Path.Combine(Path.Combine(ProjectDirectory.ItemSpec, IntermediateDirectory.ItemSpec),
                                                      FileDependencyList.GetDependencyFileNameFromSourcePath(item.LinkName));

                CreateDirectoryIfNotExists(dependencyFilePath);

                Log.LogMessage(MessageImportance.Low, "Check Toolkit file to compile {0} with dependency file {1}", inputFilePath, dependencyFilePath);
                if (FileDependencyList.CheckForChanges(dependencyFilePath) || !File.Exists(outputFilePath))
                {
                    Log.LogMessage(MessageImportance.Low, "Starting compilation of {0}", inputFilePath);

                    var logger = ProcessFileAndGetLogResults(inputFilePath, outputFilePath, dependencyFilePath, item);

                    LogLogger(logger);

                    if (logger.HasErrors)
                    {
                        hasErrors = true;
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.High, "Compilation successfull of {0} to {1}", inputFilePath, outputFilePath);
                        if (item.OutputCs)
                            Log.LogWarning("Compilation to CS not yet supported");
                    }
                }

            }
            catch (Exception ex)
            {
                Log.LogError("Cannot process file '{0}' : {1}", inputFilePath, ex.Message);
                hasErrors = true;
            }

            return !hasErrors;
        }
 protected virtual bool ProcessItem(TkItem item)
 {
     return true;
 }
        private TkItem GetTkItem(ITaskItem item)
        {

            var data = new TkItem
                       {
                           Name = item.ItemSpec,
                           DynamicCompiling = item.GetMetadata("DynamicCompiling", DynamicCompiling),
                           LinkName = item.GetMetadata("Link", item.ItemSpec),
                           OutputNamespace = item.GetMetadata("OutputNamespace", RootNamespace),
                           OutputFieldName = item.GetMetadata("OutputFieldName", "bytecode"),
                           OutputCs = item.GetMetadata("OutputCs", false),
                           ParentTaskItem = item
                       };

            data.OutputClassName = item.GetMetadata("OutputClassName", Path.GetFileNameWithoutExtension(data.LinkName));
            data.OutputCsFile = item.GetMetadata("OutputCsFileName", Path.GetFileNameWithoutExtension(data.LinkName) + ".Generated.cs");

            var outputCsFile = item.GetMetadata<string>("LastGenOutput", null);
            if (outputCsFile != null && outputCsFile.EndsWith(".cs", StringComparison.InvariantCultureIgnoreCase))
            {
                data.OutputCsFile = outputCsFile;
            }

            // Full path to the generated Output FilePath either 
            // For fxo: $(ProjectDir)/obj/Debug/XXX/YYY.fxo 
            // For cs: $(ProjectDir)/XXX/YYY.cs
            if (data.OutputCs)
            {
                data.OutputFilePath = Path.Combine(IntermediateDirectory.ItemSpec, Path.Combine(Path.GetDirectoryName(data.Name) ?? string.Empty, data.OutputCsFile));
            }
            else
            {
                data.OutputLink = Path.ChangeExtension(data.LinkName, "tkb");
                data.OutputFilePath = Path.Combine(IntermediateDirectory.ItemSpec, data.OutputLink);
            }

            // Prefix by ProjectDirectory
            data.OutputFilePath = Path.Combine(ProjectDirectory.ItemSpec, data.OutputFilePath);

            // Full path to the input file
            data.InputFilePath = Path.Combine(ProjectDirectory.ItemSpec, data.Name);

            return data;
        }
Esempio n. 9
0
 protected virtual bool ProcessItem(TkItem item)
 {
     return(true);
 }
Esempio n. 10
0
 protected abstract Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item);
Esempio n. 11
0
 protected abstract Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item);
Esempio n. 12
0
 /// <summary>Processes the file and get log results.</summary>
 /// <param name="inputFilePath">The input file path.</param>
 /// <param name="outputFilePath">The output file path.</param>
 /// <param name="dependencyFilePath">The dependency file path.</param>
 /// <param name="item">The item.</param>
 /// <returns>Diagnostics.Logger.</returns>
 protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
 {
     var compilerResult = FontCompiler.CompileAndSave(inputFilePath, outputFilePath, dependencyFilePath);
     return compilerResult.Logger;
 }
Esempio n. 13
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerFlags = Debug ? EffectCompilerFlags.Debug : EffectCompilerFlags.None;

            if (!string.IsNullOrEmpty(CompilerFlags))
            {
                compilerFlags |= (EffectCompilerFlags)Enum.Parse(typeof(EffectCompilerFlags), CompilerFlags);
            }

            var compilerResult = compiler.CompileFromFile(inputFilePath,
                                                          compilerFlags,
                                                          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);
        }
Esempio n. 14
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerResult = FontCompiler.CompileAndSave(inputFilePath, outputFilePath, dependencyFilePath);

            return(compilerResult.Logger);
        }
Esempio n. 15
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            // the textures can be in a subdirectory - make sure it exists before copying there:
            CreateDirectoryIfNotExists(outputFilePath);

            // For the TextureCompilerTask, simply copy input to output without performing any resize/compression
            // but a future version will introduce this
            File.Copy(inputFilePath, outputFilePath, true);

            // Save the dependency file
            var dependencies = new FileDependencyList();

            dependencies.AddDefaultDependencies();
            dependencies.AddDependencyPath(inputFilePath);
            dependencies.Save(dependencyFilePath);

            return(new Logger());
        }
Esempio n. 16
0
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerOptions = new ModelCompilerOptions()
            {
                DependencyFile = dependencyFilePath,
                Quality        = Debug ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum
            };

            var compilerResult = ModelCompiler.CompileAndSave(inputFilePath, outputFilePath, compilerOptions);

            return(compilerResult.Logger);
        }