Compare commits

..

No commits in common. "ebe033ef9121f662de006fc10ac9fea9187df4f3" and "22730c7aa29bb7f3651499ef0ca73a38f4f52a94" have entirely different histories.

6 changed files with 32 additions and 25 deletions

View file

@ -7,7 +7,7 @@ namespace Contentless;
public class Config { public class Config {
[JsonProperty("exclude")] [JsonProperty("exclude")]
public string[] ExcludedFiles = {"bin/*", "obj/*"}; public string[] ExcludedFiles = {"bin/", "obj/"};
[JsonProperty("logSkipped")] [JsonProperty("logSkipped")]
public bool LogSkipped = true; public bool LogSkipped = true;

View file

@ -10,7 +10,7 @@
<repository type="git" url="https://github.com/Ellpeck/Contentless" /> <repository type="git" url="https://github.com/Ellpeck/Contentless" />
<readme>README.md</readme> <readme>README.md</readme>
<icon>Logo.png</icon> <icon>Logo.png</icon>
<version>4.0.0</version> <version>3.2.1</version>
<dependencies> <dependencies>
<group targetFramework="net8.0" /> <group targetFramework="net8.0" />
</dependencies> </dependencies>

View file

@ -1,13 +1,15 @@
namespace Contentless; using System.Text.RegularExpressions;
namespace Contentless;
public class OverrideInfo { public class OverrideInfo {
public readonly string Expression; public readonly Regex Regex;
public readonly Override Override; public readonly Override Override;
public OverrideInfo(string expression, Override over) { public OverrideInfo(Regex regex, Override over) {
this.Expression = expression; this.Regex = regex;
this.Override = over; this.Override = over;
} }
} }

View file

@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Enumeration;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.Build.Construction; using Microsoft.Build.Construction;
using Microsoft.Xna.Framework.Content.Pipeline; using Microsoft.Xna.Framework.Content.Pipeline;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -143,6 +143,7 @@ public static class Program {
Console.WriteLine($"Found possible importer types {string.Join(", ", importers)}"); Console.WriteLine($"Found possible importer types {string.Join(", ", importers)}");
Console.WriteLine($"Found possible processor types {string.Join(", ", processors)}"); Console.WriteLine($"Found possible processor types {string.Join(", ", processors)}");
var excluded = config.ExcludedFiles.Select(Program.GlobbyRegex).ToArray();
var overrides = Program.GetOverrides(config.Overrides).ToArray(); var overrides = Program.GetOverrides(config.Overrides).ToArray();
foreach (var file in contentFile.Directory.EnumerateFiles("*", SearchOption.AllDirectories)) { foreach (var file in contentFile.Directory.EnumerateFiles("*", SearchOption.AllDirectories)) {
// is the file the content or config file? // is the file the content or config file?
@ -151,7 +152,7 @@ public static class Program {
var relative = Path.GetRelativePath(contentFile.DirectoryName, file.FullName).Replace('\\', '/'); var relative = Path.GetRelativePath(contentFile.DirectoryName, file.FullName).Replace('\\', '/');
// is the file in an excluded directory? // is the file in an excluded directory?
if (config.ExcludedFiles.Any(e => FileSystemName.MatchesSimpleExpression(e, relative))) { if (excluded.Any(e => e.IsMatch(relative))) {
if (config.LogSkipped) if (config.LogSkipped)
Console.WriteLine($"Skipping excluded file {relative}"); Console.WriteLine($"Skipping excluded file {relative}");
continue; continue;
@ -270,12 +271,12 @@ public static class Program {
private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) { private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) {
foreach (var entry in config) foreach (var entry in config)
yield return new OverrideInfo(entry.Key, entry.Value); yield return new OverrideInfo(Program.GlobbyRegex(entry.Key), entry.Value);
} }
private static OverrideInfo GetOverrideFor(string file, IEnumerable<OverrideInfo> overrides) { private static OverrideInfo GetOverrideFor(string file, IEnumerable<OverrideInfo> overrides) {
foreach (var over in overrides) { foreach (var over in overrides) {
if (FileSystemName.MatchesSimpleExpression(over.Expression, file)) if (over.Regex.IsMatch(file))
return over; return over;
} }
return null; return null;
@ -326,4 +327,8 @@ public static class Program {
Console.WriteLine($"Adding file {relative} with the Copy build action"); Console.WriteLine($"Adding file {relative} with the Copy build action");
} }
private static Regex GlobbyRegex(string s) {
return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", "."));
}
} }

View file

@ -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. // 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. // 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": [ "exclude": [
"obj/*", "obj/",
"bin/*" "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)
// Default: true // Default: true
@ -39,20 +39,20 @@ If you want to change the way Contentless works, you can use a configuration fil
// Default: {} // Default: {}
"overrides": { "overrides": {
// Example: Make all files matching ".json" use the importer "JsonImporter" // Example: Make all files matching ".json" use the importer "JsonImporter"
"*/*.json": { ".json": {
"importer": "JsonImporter" "importer": "JsonImporter"
}, },
// Example: Specifying both an importer and a processor // Example: Specifying both an importer and a processor
"*/*.ogg": { ".ogg": {
"importer": "OggImporter", "importer": "OggImporter",
"processor": "SongProcessor" "processor": "SongProcessor"
}, },
// Example: Only specifying a processor // Example: Only specifying a processor
"*/*.wav": { ".wav": {
"processor": "SoundEffectProcessor" "processor": "SoundEffectProcessor"
}, },
// Example: Setting a file to the Copy build action // Example: Setting a file to the Copy build action
"*/*.txt": { ".txt": {
"copy": true "copy": true
}, },
// Example: Adding processor parameters for files // Example: Adding processor parameters for files

View file

@ -1,24 +1,24 @@
{ {
"exclude": [ "exclude": [
"obj/*", "obj/",
"bin/*", "bin/",
"*/Ex*.png", "Ex*.png",
"Tiled/*.png" "Tiled/*.png"
], ],
"logSkipped": true, "logSkipped": true,
"references": ["MonoGame.Extended.Content.Pipeline"], "references": ["MonoGame.Extended.Content.Pipeline"],
"overrides": { "overrides": {
"*/Copy.*": { "Copy.*": {
"copy": true "copy": true
}, },
"*/*.json": { ".json": {
"copy": true "copy": true
}, },
"*/*.ogg": { ".ogg": {
"importer": "OggImporter", "importer": "OggImporter",
"processor": "SongProcessor" "processor": "SongProcessor"
}, },
"*/*.png": { ".png": {
"processorParams": { "processorParams": {
"TextureFormat": "NoChange" "TextureFormat": "NoChange"
} }