Mercurial > projects > dil
changeset 721:8955296dd807
Added ddoc_files option to config.d
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 01 Feb 2008 16:40:35 +0100 |
parents | 74cdbb25c7c8 |
children | ceaac6a24258 |
files | trunk/src/config.d trunk/src/dil/Settings.d trunk/src/dil/SettingsLoader.d |
diffstat | 3 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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}";
--- 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);