added the ability to copy files instead of building them

This commit is contained in:
Ellpeck 2019-10-28 23:54:06 +01:00
parent 6a623ceec6
commit 69d50cbb1a
5 changed files with 30 additions and 12 deletions

View file

@ -87,6 +87,13 @@ namespace Contentless {
// override importers // override importers
var over = GetOverrideImporterFor(relative, overrides); var over = GetOverrideImporterFor(relative, overrides);
if (over != null) { if (over != null) {
// copy special case
if (over == "Copy") {
CopyFile(content, relative);
changed = true;
continue;
}
importer = Array.Find(importers, i => i.Type.Name == over); importer = Array.Find(importers, i => i.Type.Name == over);
if (importer == null) { if (importer == null) {
Console.WriteLine($"Override importer {over} not found for file {relative}"); Console.WriteLine($"Override importer {over} not found for file {relative}");
@ -171,10 +178,16 @@ namespace Contentless {
content.Add($"/processor:{importer.Importer.DefaultProcessor}"); content.Add($"/processor:{importer.Importer.DefaultProcessor}");
content.Add($"/build:{relative}"); content.Add($"/build:{relative}");
content.Add(""); content.Add("");
Console.WriteLine($"Adding file {relative} with importer {importer.Type.Name} and processor {importer.Importer.DefaultProcessor}"); Console.WriteLine($"Adding file {relative} with importer {importer.Type.Name} and processor {importer.Importer.DefaultProcessor}");
} }
private static void CopyFile(List<string> content, string relative) {
content.Add($"#begin {relative}");
content.Add($"/copy:{relative}");
content.Add("");
Console.WriteLine($"Adding file {relative} with the Copy build action");
}
private static string GetRelativePath(string relativeTo, string path) { private static string GetRelativePath(string relativeTo, string path) {
if (!relativeTo.EndsWith(Path.DirectorySeparatorChar.ToString())) if (!relativeTo.EndsWith(Path.DirectorySeparatorChar.ToString()))
relativeTo += Path.DirectorySeparatorChar; relativeTo += Path.DirectorySeparatorChar;

View file

@ -21,14 +21,12 @@ To add a configuration file to Contentless, simply create a file named `Contentl
"obj/", "obj/",
"bin/" "bin/"
], ],
// If any files that were skipped without errors should be logged // If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored)
// (Files that already have entries or files that were ignored)
"logSkipped": true, "logSkipped": true,
// The list of files that should use a different importer than the one // The list of files that should use a different importer than the one that Contentless automatically determined. Can use regex
// that Contentless automatically determined. Can use regex
"overrides": [ "overrides": [
// Entries are arrays containing the file regex and importer, e.g. // Entries are arrays containing the file regex and importer, for example [".json", "JsonImporter"]
// [".json", "JsonImporter"] // If you specify "Copy" as the importer, the file's Build Mode will be set to Copy rather than Build
] ]
} }
``` ```

View file

@ -14,11 +14,6 @@
#---------------------------------- Content ---------------------------------# #---------------------------------- Content ---------------------------------#
#begin Json/Test.json
/importer:JsonContentImporter
/processor:JsonContentProcessor
/build:Json/Test.json
#begin Locale/Interface.xml #begin Locale/Interface.xml
/importer:XmlImporter /importer:XmlImporter
/processor:PassThroughProcessor /processor:PassThroughProcessor
@ -70,3 +65,11 @@
/processor:TiledMapTilesetProcessor /processor:TiledMapTilesetProcessor
/build:Tiled/Tileset.tsx /build:Tiled/Tileset.tsx
#begin Json/Test.json
/importer:JsonContentImporter
/processor:JsonContentProcessor
/build:Json/Test.json
#begin Json/Copy.json
/copy:Json/Copy.json

View file

@ -6,6 +6,7 @@
], ],
"logSkipped": false, "logSkipped": false,
"overrides": [ "overrides": [
["Copy.*", "Copy"],
[".json", "JsonContentImporter"] [".json", "JsonContentImporter"]
] ]
} }

View file

@ -0,0 +1,3 @@
{
"test": "copy!"
}