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(); }
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()); }
private FileDependencyList CalculateDependencies(EffectParserResult parserResult) { var keys = new List<string>(parserResult.IncludeHandler.FileResolved.Keys); keys.Sort(StringComparer.InvariantCultureIgnoreCase); var dependency = new FileDependencyList(); dependency.AddDefaultDependencies(); foreach (var fileKey in keys) { var fileItem = parserResult.IncludeHandler.FileResolved[fileKey]; dependency.AddDependencyPath(fileItem.FilePath); } return dependency; }
/// <summary> /// Compiles an XML font file description to a file. Optionally output dependency file. /// </summary> /// <param name="sourceXmlFile">The source XML file.</param> /// <param name="outputFile">The output file.</param> /// <param name="dependencyFile">The dependency file.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> public static ContentCompilerResult CompileAndSave(string sourceXmlFile, string outputFile, string dependencyFile = null) { var logger = new Logger(); var result = new ContentCompilerResult { Logger = logger }; try { var fontDescription = FontDescription.Load(sourceXmlFile); var defaultOutputFile = Path.GetFileNameWithoutExtension(sourceXmlFile); // Compiles to SpriteData outputFile = outputFile ?? defaultOutputFile; result.IsContentGenerated = true; if(dependencyFile != null) { if(!FileDependencyList.CheckForChanges(dependencyFile)) { result.IsContentGenerated = false; } } if(result.IsContentGenerated) { // Make sure that directory name doesn't collide with filename var directoryName = Path.GetDirectoryName(outputFile + ".tmp"); if(!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } using(var stream = new NativeFileStream(outputFile, NativeFileMode.Create, NativeFileAccess.Write)) { Compile(fontDescription, stream); if(dependencyFile != null) { var dependencies = new FileDependencyList(); dependencies.AddDefaultDependencies(); dependencies.AddDependencyPath(sourceXmlFile); dependencies.Save(dependencyFile); } } } } catch(FontException ex) { logger.Error(ex.Message); } catch (Exception ex) { logger.Error(ex.ToString()); } return result; }
/// <summary>Compiles the and save.</summary> /// <param name="fileName">Name of the file.</param> /// <param name="outputFile">The output file.</param> /// <param name="compilerOptions">The compiler options.</param> /// <returns>ContentCompilerResult.</returns> /// <exception cref="System.ArgumentNullException"> /// fileName /// or /// outputFile /// or /// compilerOptions /// </exception> public static ContentCompilerResult CompileAndSave(string fileName, string outputFile, ModelCompilerOptions compilerOptions) { if (fileName == null) { throw new ArgumentNullException("fileName"); } if (outputFile == null) { throw new ArgumentNullException("outputFile"); } if (compilerOptions == null) { throw new ArgumentNullException("compilerOptions"); } bool contentToUpdate = true; if (compilerOptions.DependencyFile != null) { if (!FileDependencyList.CheckForChanges(compilerOptions.DependencyFile)) { contentToUpdate = false; } } var result = new ContentCompilerResult { Logger = new Logger() }; if (contentToUpdate) { try { result = CompileFromFile(fileName, compilerOptions); if (result.HasErrors) { return result; } var modelData = result.ModelData; // Make sure that directory name doesn't collide with filename var directoryName = Path.GetDirectoryName(outputFile + ".tmp"); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } // Save the model modelData.Save(outputFile); if (compilerOptions.DependencyFile != null) { // Save the dependency var dependencyList = new FileDependencyList(); dependencyList.AddDefaultDependencies(); dependencyList.AddDependencyPath(fileName); dependencyList.Save(compilerOptions.DependencyFile); } result.IsContentGenerated = true; } catch (Exception ex) { result.Logger.Error("Unexpected exception while converting {0} : {1}", fileName, ex.ToString()); } } return result; }
public static ContentCompilerResult CompileAndSave(string fileName, string outputFile, ModelCompilerOptions compilerOptions) { Contract.Requires <ArgumentNullException>(fileName != null, "fileName"); Contract.Requires <ArgumentNullException>(outputFile != null, "outputFile"); Contract.Requires <ArgumentNullException>(compilerOptions != null, "compilerOptions"); bool contentToUpdate = true; if (compilerOptions.DependencyFile != null) { if (!FileDependencyList.CheckForChanges(compilerOptions.DependencyFile)) { contentToUpdate = false; } } var result = new ContentCompilerResult(); if (contentToUpdate) { try { result = CompileFromFile(fileName, compilerOptions); if (result.HasErrors) { return(result); } var modelData = result.ModelData; // Make sure that directory name doesn't collide with filename var directoryName = Path.GetDirectoryName(outputFile + ".tmp"); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } // Save the model modelData.Save(outputFile); if (compilerOptions.DependencyFile != null) { // Save the dependency var dependencyList = new FileDependencyList(); dependencyList.AddDefaultDependencies(); dependencyList.AddDependencyPath(fileName); dependencyList.Save(compilerOptions.DependencyFile); } result.IsContentGenerated = true; } catch (Exception ex) { result.HasErrors = true; LogEvent.Tool.Error("Unexpected exception while converting {0} : {1}", fileName, ex.ToString()); } } return(result); }