# HG changeset patch # User Aziz K?ksal # Date 1201880435 -3600 # Node ID 8955296dd8079359b78173bd10d8c53aa89cfe3c # Parent 74cdbb25c7c804c330149bce056d1fa8fba4108a Added ddoc_files option to config.d diff -r 74cdbb25c7c8 -r 8955296dd807 trunk/src/config.d --- a/trunk/src/config.d Fri Feb 01 15:40:32 2008 +0100 +++ b/trunk/src/config.d Fri Feb 01 16:40:35 2008 +0100 @@ -3,7 +3,9 @@ // Path to the language file. var langfile = "lang_en.d"; // An array of import paths to look for modules. -var import_paths = []; +var import_paths = []; // E.g.: ["src/", "import/"] +// DDoc macro file paths. +var ddoc_files = []; // E.g.: ["src/mymacros.ddoc", "othermacros.ddoc"] /* Customizing error messages. 0: file path to the source text. diff -r 74cdbb25c7c8 -r 8955296dd807 trunk/src/dil/Settings.d --- a/trunk/src/dil/Settings.d Fri Feb 01 15:40:32 2008 +0100 +++ b/trunk/src/dil/Settings.d Fri Feb 01 16:40:35 2008 +0100 @@ -16,6 +16,8 @@ string[] messages; /// Array of import paths to look for modules. string[] importPaths; + /// Array of DDoc macro file paths. + string[] ddocFilePaths; string lexerErrorFormat = "{0}({1},{2})L: {3}"; string parserErrorFormat = "{0}({1},{2})P: {3}"; string semanticErrorFormat = "{0}({1},{2})S: {3}"; diff -r 74cdbb25c7c8 -r 8955296dd807 trunk/src/dil/SettingsLoader.d --- a/trunk/src/dil/SettingsLoader.d Fri Feb 01 15:40:32 2008 +0100 +++ b/trunk/src/dil/SettingsLoader.d Fri Feb 01 16:40:35 2008 +0100 @@ -15,9 +15,10 @@ void loadSettings() { scope execPath = new FilePath(GetExecutableFilePath()); + execPath = new FilePath(execPath.folder()); // Load config.d - auto filePath = execPath.file("config.d").toString(); + auto filePath = resolvePath(execPath, "config.d"); auto modul = new Module(filePath); modul.parse(); @@ -51,6 +52,16 @@ else throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer."); break; + case "ddoc_files": + if (auto array = e.Is!(ArrayInitExpression)) + { + foreach (value; array.values) + if (auto str = value.Is!(StringExpression)) + GlobalSettings.ddocFilePaths ~= str.getString(); + } + else + throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer."); + break; case "lexer_error": if (auto val = e.Is!(StringExpression)) GlobalSettings.lexerErrorFormat = val.getString(); @@ -68,7 +79,7 @@ } // Load language file. - filePath = execPath.file(GlobalSettings.langFile).toString(); + filePath = resolvePath(execPath, GlobalSettings.langFile); modul = new Module(filePath); modul.parse(); @@ -118,6 +129,13 @@ dil.Messages.SetMessages(messages); } +string resolvePath(FilePath execPath, string filePath) +{ + if ((new FilePath(filePath)).isAbsolute()) + return filePath; + return execPath.dup.append(filePath).toString(); +} + version(Windows) { private extern(Windows) uint GetModuleFileNameA(void*, char*, uint);