From 825db58ddf1e17f84bd0a02eccca1dfb230a51a6 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 24 Aug 2014 05:53:02 +0300 Subject: [PATCH] added 'systemdir' key to rgdc.rc; we don't need to exclude 'std.' and company unconditionally anymore --- rgdc.d | 44 ++++++++++++++++++++++++++++++++++++-------- rgdc.rc | 6 ++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/rgdc.d b/rgdc.d index 8be216d..e1c9a90 100644 --- a/rgdc.d +++ b/rgdc.d @@ -39,7 +39,6 @@ private enum altDirSeparator = ""; private bool chatty, buildOnly, dryRun, force; private string exe; -private string[] exclusions = ["std", "etc", "core", "tango"]; // packages that are to be excluded private string compilerBinary = "gdc"; @@ -60,6 +59,7 @@ private void yap(size_t line=__LINE__, T...) (auto ref T stuff) { //////////////////////////////////////////////////////////////////////////////// private string[] includeDirs; // -I private string[] importDirs; // -J +private bool[string] systemDirs; // to ignore private string expandString (string s) { @@ -89,16 +89,22 @@ private void readRC (string fname) { foreach (string line; lines(reader)) { if (line.startsWith("include=")) { auto val = expandString(line[8..$].strip); + val = buildNormalizedPath(val); if (val.length > 0) { val = "-I"~val; if (!includeDirs.canFind(val)) includeDirs ~= val; } } else if (line.startsWith("import=")) { auto val = expandString(line[7..$].strip); + val = buildNormalizedPath(val); if (val.length > 0) { val = "-J"~val; if (!importDirs.canFind(val)) importDirs ~= val; } + } else if (line.startsWith("systemdir=")) { + auto val = expandString(line[10..$].strip); + val = buildNormalizedPath(val); + if (val.length > 0) systemDirs[val] = true; } } } @@ -308,11 +314,9 @@ private int rebuild (string root, string fullExe, //////////////////////////////////////////////////////////////////////////////// -private bool inALibrary (string source, string object) { - if (object.endsWith(".di") || source == "object" || source == "gcstats") return true; - foreach (string exclusion; exclusions) if (source.startsWith(exclusion~'.')) return true; - return false; -} +// we don't need std exclusions anymore, we have 'systemdir' key in .rc file for that +//private string[] exclusions = ["std", "etc", "core", "tango"]; // packages that are to be excluded +private string[] exclusions = []; // packages that are to be excluded // Given module rootModule, returns a mapping of all dependees .d @@ -323,6 +327,29 @@ private string[string] getDependencies (string rootModule, string workDir, strin immutable depsFilename = buildPath(workDir, "rgdc.deps"); string[string] readDepsFile (/*string depsFilename, string objDir="."*/) { + + bool[string] sysDirCache; // cache all modules that are in systemdirs + + bool inALibrary (string source, string object) { + if (object.endsWith(".di") || source == "object" || source == "gcstats") return true; + foreach (string exclusion; exclusions) if (source.startsWith(exclusion~'.')) return true; + return false; + } + + bool isInSystemDir (string path) { + path = buildNormalizedPath(path); + if (path in sysDirCache) return true; + //writeln("isInSystemDir: path=", path, "; dirs=", systemDirs); + foreach (auto k; systemDirs.byKey) { + if (path.length > k.length && path.startsWith(k) && path[k.length] == '/') { + sysDirCache[path.idup] = true; + //writeln("in system dir: ", path); + return true; + } + } + return false; + } + string d2obj (string dfile) { return buildPath(objDir, dfile.baseName.chomp(".d")~objExt); } string findLib (string libName) { @@ -375,8 +402,9 @@ private string[string] getDependencies (string rootModule, string workDir, strin modPath = modImportCaps[2]; filePath = modImportCaps[3]; } - if (filePath.length) result[filePath] = null; - if (inALibrary(modName, modPath)) continue; + if (filePath.length && !isInSystemDir(filePath)) result[filePath] = null; + //if (inALibrary(modName, modPath) || isInSystemDir(modPath)) continue; + if (isInSystemDir(modPath)) continue; result[modPath] = d2obj(modPath); } return result; diff --git a/rgdc.rc b/rgdc.rc index 3788b0e..02bbd32 100644 --- a/rgdc.rc +++ b/rgdc.rc @@ -1,3 +1,9 @@ +# modules and imported files from $(systemdir) will be ignored +systemdir=/opt/gdc/include + +# all $(include) records will be added as -I include=$(HOME)/.D/k8dmd + +# all $(import) records will be added as -J import=$(HOME)/.D/k8dmd import=$(HOME)/.D/k8dmd/k8 -- 2.11.4.GIT