Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: tools/BUILD_simulator.py

Issue 1401883005: Add dm target to BUILD and refactor BUILD file. Fix blaze compilation errors. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase and fix new issues in SkJpegCodec.cpp. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/codec/SkJpegCodec.cpp ('K') | « tools/BUILD.public.expected ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/BUILD_simulator.py
diff --git a/tools/BUILD_simulator.py b/tools/BUILD_simulator.py
index 46d3cd79e7008511d4b322b4153ef488565c5da4..bd4a832b7ba5b0e3f17798750549f9e5e0ecf203 100755
--- a/tools/BUILD_simulator.py
+++ b/tools/BUILD_simulator.py
@@ -11,18 +11,52 @@
# We start by adding some symbols to our namespace that BUILD.public calls.
import glob
+import os
import pprint
+import re
def noop(*args, **kwargs):
pass
+DOUBLE_STAR_RE = re.compile(r'/\*\*/')
+STAR_RE = re.compile(r'\*')
+DOUBLE_STAR_PLACEHOLDER = "xxxdoublestarxxx"
+STAR_PLACEHOLDER = "xxxstarxxx"
+
+# Returns a set of files that match pattern.
+def BUILD_glob_single(pattern):
+ if pattern.find('**') < 0:
+ # If pattern doesn't include **, glob.glob more-or-less does the right
+ # thing.
+ return glob.glob(pattern)
+ # First transform pattern into a regexp.
+ # Temporarily remove ** and *.
+ pattern2 = DOUBLE_STAR_RE.sub(DOUBLE_STAR_PLACEHOLDER, pattern)
+ pattern3 = STAR_RE.sub(STAR_PLACEHOLDER, pattern2)
+ # Replace any regexp special characters.
+ pattern4 = re.escape(pattern3)
+ # Replace * with [^/]* and ** with .*.
+ pattern5 = pattern4.replace(STAR_PLACEHOLDER, '[^/]*')
+ pattern6 = pattern5.replace(DOUBLE_STAR_PLACEHOLDER, '.*/')
+ # Anchor the match at the beginning and end.
+ pattern7 = "^" + pattern6 + "$"
+ pattern_re = re.compile(pattern7)
+ matches = set()
+ for root, _, files in os.walk('.'):
+ for fname in files:
+ # Remove initial "./".
+ path = os.path.join(root, fname)[2:]
+ if pattern_re.match(path):
+ matches.add(path)
+ return matches
+
# Simulates BUILD file glob().
def BUILD_glob(include, exclude=()):
files = set()
for pattern in include:
- files.update(glob.glob(pattern))
+ files.update(BUILD_glob_single(pattern))
for pattern in exclude:
- files.difference_update(glob.glob(pattern))
+ files.difference_update(BUILD_glob_single(pattern))
return list(sorted(files))
# With these namespaces, we can treat BUILD.public as if it were
@@ -30,7 +64,12 @@ def BUILD_glob(include, exclude=()):
# DEFINES, etc.) into local_names.
global_names = {
'exports_files': noop,
+ 'cc_library': noop,
+ 'cc_test': noop,
'glob': BUILD_glob,
+ 'EXTERNAL_DEPS': [],
+ 'BASE_DIR': "",
+ 'DM_EXTERNAL_DEPS': [],
}
local_names = {}
execfile('BUILD.public', global_names, local_names)
« src/codec/SkJpegCodec.cpp ('K') | « tools/BUILD.public.expected ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698