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
var over = GetOverrideImporterFor(relative, overrides);
if (over != null) {
// copy special case
if (over == "Copy") {
CopyFile(content, relative);
changed = true;
continue;
}
importer = Array.Find(importers, i => i.Type.Name == over);
if (importer == null) {
Console.WriteLine($"Override importer {over} not found for file {relative}");
@ -171,10 +178,16 @@ namespace Contentless {
content.Add($"/processor:{importer.Importer.DefaultProcessor}");
content.Add($"/build:{relative}");
content.Add("");
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) {
if (!relativeTo.EndsWith(Path.DirectorySeparatorChar.ToString()))
relativeTo += Path.DirectorySeparatorChar;

View file

@ -21,14 +21,12 @@ To add a configuration file to Contentless, simply create a file named `Contentl
"obj/",
"bin/"
],
// If any files that were skipped without errors should be logged
// (Files that already have entries or files that were ignored)
// If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored)
"logSkipped": true,
// The list of files that should use a different importer than the one
// that Contentless automatically determined. Can use regex
// The list of files that should use a different importer than the one that Contentless automatically determined. Can use regex
"overrides": [
// Entries are arrays containing the file regex and importer, e.g.
// [".json", "JsonImporter"]
// Entries are arrays containing the file regex and importer, for example [".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 ---------------------------------#
#begin Json/Test.json
/importer:JsonContentImporter
/processor:JsonContentProcessor
/build:Json/Test.json
#begin Locale/Interface.xml
/importer:XmlImporter
/processor:PassThroughProcessor
@ -70,3 +65,11 @@
/processor:TiledMapTilesetProcessor
/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,
"overrides": [
["Copy.*", "Copy"],
[".json", "JsonContentImporter"]
]
}

View file

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