summaryrefslogtreecommitdiffstats
path: root/site_scons
diff options
context:
space:
mode:
authorsgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 20:01:55 +0000
committersgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 20:01:55 +0000
commitf588ba31e1455dcde737e158520eba35911aadc9 (patch)
tree525b402db51e2d78a6da81ac65c89a841e1a0429 /site_scons
parent6c50fc5e707429c227493f565e05fbc1e7a4b9b9 (diff)
downloadchromium_src-f588ba31e1455dcde737e158520eba35911aadc9.zip
chromium_src-f588ba31e1455dcde737e158520eba35911aadc9.tar.gz
chromium_src-f588ba31e1455dcde737e158520eba35911aadc9.tar.bz2
Prep for gyp conversion: cut-and-paste the FileList base class that chromium_builders.py was using from the (soon-to-be-removed) module that generates VisualStudio files from the SCons configuration.
Review URL: http://codereview.chromium.org/53107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/site_tools/chromium_builders.py75
1 files changed, 71 insertions, 4 deletions
diff --git a/site_scons/site_tools/chromium_builders.py b/site_scons/site_tools/chromium_builders.py
index 52c06c7..4d1e428 100644
--- a/site_scons/site_tools/chromium_builders.py
+++ b/site_scons/site_tools/chromium_builders.py
@@ -29,7 +29,74 @@ class Null(object):
def __delattr__(self, name): return self
def __getitem__(self, name): return self
-class ChromeFileList(MSVS.FileList):
+class FileList(object):
+ def __init__(self, entries=None):
+ if isinstance(entries, FileList):
+ entries = entries.entries
+ self.entries = entries or []
+ def __getitem__(self, i):
+ return self.entries[i]
+ def __setitem__(self, i, item):
+ self.entries[i] = item
+ def __delitem__(self, i):
+ del self.entries[i]
+ def __add__(self, other):
+ if isinstance(other, FileList):
+ return self.__class__(self.entries + other.entries)
+ elif isinstance(other, type(self.entries)):
+ return self.__class__(self.entries + other)
+ else:
+ return self.__class__(self.entries + list(other))
+ def __radd__(self, other):
+ if isinstance(other, FileList):
+ return self.__class__(other.entries + self.entries)
+ elif isinstance(other, type(self.entries)):
+ return self.__class__(other + self.entries)
+ else:
+ return self.__class__(list(other) + self.entries)
+ def __iadd__(self, other):
+ if isinstance(other, FileList):
+ self.entries += other.entries
+ elif isinstance(other, type(self.entries)):
+ self.entries += other
+ else:
+ self.entries += list(other)
+ return self
+ def append(self, item):
+ return self.entries.append(item)
+ def extend(self, item):
+ return self.entries.extend(item)
+ def index(self, item, *args):
+ return self.entries.index(item, *args)
+ def remove(self, item):
+ return self.entries.remove(item)
+
+def FileListWalk(top, topdown=True, onerror=None):
+ """
+ """
+ try:
+ entries = top.entries
+ except AttributeError, err:
+ if onerror is not None:
+ onerror(err)
+ return
+
+ dirs, nondirs = [], []
+ for entry in entries:
+ if hasattr(entry, 'entries'):
+ dirs.append(entry)
+ else:
+ nondirs.append(entry)
+
+ if topdown:
+ yield top, dirs, nondirs
+ for entry in dirs:
+ for x in FileListWalk(entry, topdown, onerror):
+ yield x
+ if not topdown:
+ yield top, dirs, nondirs
+
+class ChromeFileList(FileList):
def Append(self, *args):
for element in args:
self.append(element)
@@ -37,14 +104,14 @@ class ChromeFileList(MSVS.FileList):
for element in args:
self.extend(element)
def Remove(self, *args):
- for top, lists, nonlists in MSVS.FileListWalk(self, topdown=False):
+ for top, lists, nonlists in FileListWalk(self, topdown=False):
for element in args:
try:
top.remove(element)
except ValueError:
pass
def Replace(self, old, new):
- for top, lists, nonlists in MSVS.FileListWalk(self, topdown=False):
+ for top, lists, nonlists in FileListWalk(self, topdown=False):
try:
i = top.index(old)
except ValueError:
@@ -116,7 +183,7 @@ def compilable_files(env, sources):
if not hasattr(sources, 'entries'):
return [x for x in sources if compilable(env, x)]
result = []
- for top, folders, nonfolders in MSVS.FileListWalk(sources):
+ for top, folders, nonfolders in FileListWalk(sources):
result.extend([x for x in nonfolders if compilable(env, x)])
return result