Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for ressources in the dirrectory of the environement #2157

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading