Skip to content

Commit

Permalink
Look for ressources in the dirrectory of the environement (#2157)
Browse files Browse the repository at this point in the history
Co-authored-by: ritorizo <ritorizo@localhost>
Co-authored-by: wixoa <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent 8184f3f commit d85fadf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions DMCompiler/DMCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public void AddResourceDirectory(string dir) {
preproc.IncludeFile(includeDir, fileName, false);
}

// Adds the root of the DM project to FILE_DIR
compiler.AddResourceDirectory(Path.GetDirectoryName(files[0]) ?? "/");

string compilerDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
string dmStandardDirectory = Path.Join(compilerDirectory, "DMStandard");

Expand All @@ -139,15 +142,15 @@ public void AddResourceDirectory(string dir) {
// Push the pragma config file to the tippy-top of the stack, super-duper prioritizing it, since it governs some compiler behaviour.
string pragmaName;
string pragmaDirectory;
if(Settings.PragmaFileOverride is not null) {
if (Settings.PragmaFileOverride is not null) {
pragmaDirectory = Path.GetDirectoryName(Settings.PragmaFileOverride);
pragmaName = Path.GetFileName(Settings.PragmaFileOverride);
} else {
pragmaDirectory = dmStandardDirectory;
pragmaName = "DefaultPragmaConfig.dm";
}

if(!File.Exists(Path.Join(pragmaDirectory,pragmaName))) {
if (!File.Exists(Path.Join(pragmaDirectory, pragmaName))) {
ForcedError($"Configuration file '{pragmaName}' not found.");
return null;
}
Expand Down Expand Up @@ -336,7 +339,7 @@ private string SaveJson(List<DreamMapJson> maps, string interfaceFile, string ou

try {
JsonSerializer.Serialize(outputFileHandle, compiledDream,
new JsonSerializerOptions() {DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault});
new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault });

return $"Saved to {outputFile}";
} catch (Exception e) {
Expand All @@ -349,7 +352,7 @@ private string SaveJson(List<DreamMapJson> maps, string interfaceFile, string ou

public void DefineFatalErrors() {
foreach (WarningCode code in Enum.GetValues<WarningCode>()) {
if((int)code < 1_000) {
if ((int)code < 1_000) {
Config.ErrorConfig[code] = ErrorLevel.Error;
}
}
Expand All @@ -359,7 +362,7 @@ public void DefineFatalErrors() {
/// This method also enforces the rule that all emissions with codes less than 1000 are mandatory errors.
/// </summary>
public void CheckAllPragmasWereSet() {
foreach(WarningCode code in Enum.GetValues<WarningCode>()) {
foreach (WarningCode code in Enum.GetValues<WarningCode>()) {
if (!Config.ErrorConfig.ContainsKey(code)) {
ForcedWarning($"Warning #{(int)code:d4} '{code.ToString()}' was never declared as error, warning, notice, or disabled.");
Config.ErrorConfig.Add(code, ErrorLevel.Disabled);
Expand Down

0 comments on commit d85fadf

Please sign in to comment.