mirror of
https://github.com/Ellpeck/Contentless.git
synced 2024-11-22 15:28:34 +01:00
Compare commits
7 commits
22730c7aa2
...
ebe033ef91
Author | SHA1 | Date | |
---|---|---|---|
ebe033ef91 | |||
d5640bc250 | |||
7803628ece | |||
d1ad37feb8 | |||
c2755ef290 | |||
f64f554f35 | |||
b410b81bca |
6 changed files with 25 additions and 32 deletions
|
@ -7,7 +7,7 @@ namespace Contentless;
|
|||
public class Config {
|
||||
|
||||
[JsonProperty("exclude")]
|
||||
public string[] ExcludedFiles = {"bin/", "obj/"};
|
||||
public string[] ExcludedFiles = {"bin/*", "obj/*"};
|
||||
|
||||
[JsonProperty("logSkipped")]
|
||||
public bool LogSkipped = true;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<repository type="git" url="https://github.com/Ellpeck/Contentless" />
|
||||
<readme>README.md</readme>
|
||||
<icon>Logo.png</icon>
|
||||
<version>3.2.1</version>
|
||||
<version>4.0.0</version>
|
||||
<dependencies>
|
||||
<group targetFramework="net8.0" />
|
||||
</dependencies>
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Contentless;
|
||||
|
||||
public class OverrideInfo {
|
||||
|
||||
public readonly Regex Regex;
|
||||
public readonly string Expression;
|
||||
public readonly Override Override;
|
||||
|
||||
public OverrideInfo(Regex regex, Override over) {
|
||||
this.Regex = regex;
|
||||
public OverrideInfo(string expression, Override over) {
|
||||
this.Expression = expression;
|
||||
this.Override = over;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Enumeration;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -143,7 +143,6 @@ public static class Program {
|
|||
Console.WriteLine($"Found possible importer types {string.Join(", ", importers)}");
|
||||
Console.WriteLine($"Found possible processor types {string.Join(", ", processors)}");
|
||||
|
||||
var excluded = config.ExcludedFiles.Select(Program.GlobbyRegex).ToArray();
|
||||
var overrides = Program.GetOverrides(config.Overrides).ToArray();
|
||||
foreach (var file in contentFile.Directory.EnumerateFiles("*", SearchOption.AllDirectories)) {
|
||||
// is the file the content or config file?
|
||||
|
@ -152,7 +151,7 @@ public static class Program {
|
|||
var relative = Path.GetRelativePath(contentFile.DirectoryName, file.FullName).Replace('\\', '/');
|
||||
|
||||
// is the file in an excluded directory?
|
||||
if (excluded.Any(e => e.IsMatch(relative))) {
|
||||
if (config.ExcludedFiles.Any(e => FileSystemName.MatchesSimpleExpression(e, relative))) {
|
||||
if (config.LogSkipped)
|
||||
Console.WriteLine($"Skipping excluded file {relative}");
|
||||
continue;
|
||||
|
@ -271,12 +270,12 @@ public static class Program {
|
|||
|
||||
private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) {
|
||||
foreach (var entry in config)
|
||||
yield return new OverrideInfo(Program.GlobbyRegex(entry.Key), entry.Value);
|
||||
yield return new OverrideInfo(entry.Key, entry.Value);
|
||||
}
|
||||
|
||||
private static OverrideInfo GetOverrideFor(string file, IEnumerable<OverrideInfo> overrides) {
|
||||
foreach (var over in overrides) {
|
||||
if (over.Regex.IsMatch(file))
|
||||
if (FileSystemName.MatchesSimpleExpression(over.Expression, file))
|
||||
return over;
|
||||
}
|
||||
return null;
|
||||
|
@ -327,8 +326,4 @@ public static class Program {
|
|||
Console.WriteLine($"Adding file {relative} with the Copy build action");
|
||||
}
|
||||
|
||||
private static Regex GlobbyRegex(string s) {
|
||||
return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", "."));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
14
README.md
14
README.md
|
@ -26,10 +26,10 @@ If you want to change the way Contentless works, you can use a configuration fil
|
|||
{
|
||||
// The list of files that should be excluded.
|
||||
// Can use simple glob-style patterns including "*" to match any number of any character, and "?" to match any single character.
|
||||
// Default: ["obj/", "bin/"]
|
||||
// Default: ["obj/*", "bin/*"]
|
||||
"exclude": [
|
||||
"obj/",
|
||||
"bin/"
|
||||
"obj/*",
|
||||
"bin/*"
|
||||
],
|
||||
// If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored)
|
||||
// Default: true
|
||||
|
@ -39,20 +39,20 @@ If you want to change the way Contentless works, you can use a configuration fil
|
|||
// Default: {}
|
||||
"overrides": {
|
||||
// Example: Make all files matching ".json" use the importer "JsonImporter"
|
||||
".json": {
|
||||
"*/*.json": {
|
||||
"importer": "JsonImporter"
|
||||
},
|
||||
// Example: Specifying both an importer and a processor
|
||||
".ogg": {
|
||||
"*/*.ogg": {
|
||||
"importer": "OggImporter",
|
||||
"processor": "SongProcessor"
|
||||
},
|
||||
// Example: Only specifying a processor
|
||||
".wav": {
|
||||
"*/*.wav": {
|
||||
"processor": "SoundEffectProcessor"
|
||||
},
|
||||
// Example: Setting a file to the Copy build action
|
||||
".txt": {
|
||||
"*/*.txt": {
|
||||
"copy": true
|
||||
},
|
||||
// Example: Adding processor parameters for files
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
{
|
||||
"exclude": [
|
||||
"obj/",
|
||||
"bin/",
|
||||
"Ex*.png",
|
||||
"obj/*",
|
||||
"bin/*",
|
||||
"*/Ex*.png",
|
||||
"Tiled/*.png"
|
||||
],
|
||||
"logSkipped": true,
|
||||
"references": ["MonoGame.Extended.Content.Pipeline"],
|
||||
"overrides": {
|
||||
"Copy.*": {
|
||||
"*/Copy.*": {
|
||||
"copy": true
|
||||
},
|
||||
".json": {
|
||||
"*/*.json": {
|
||||
"copy": true
|
||||
},
|
||||
".ogg": {
|
||||
"*/*.ogg": {
|
||||
"importer": "OggImporter",
|
||||
"processor": "SongProcessor"
|
||||
},
|
||||
".png": {
|
||||
"*/*.png": {
|
||||
"processorParams": {
|
||||
"TextureFormat": "NoChange"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue