1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Public buildspec to GIT mapping."""
8 from deps2git import SplitScmUrl
10 GIT_HOST = 'https://chromium.googlesource.com/'
11 webkit_git = GIT_HOST + 'chromium/blink.git'
13 # Remove the ffmpeg overrides, since the buildspec DEPS have stripped out these
14 # (and other) vars that they don't use, and without them in the DEPS, deps2git
15 # complains about missing vars.
17 'src/third_party/ffmpeg': None
21 # pylint: disable=W0613
22 def CleanDeps(deps, deps_os, include_rules, skip_child_includes, hooks,
26 for os, deps_section in ([(None, deps)] +
27 [(os, deps_os[os]) for os in deps_os]):
30 for dep, dep_url in deps_section.iteritems():
31 # Skip 'None' exclusion entries.
35 url, rev = SplitScmUrl(dep_url)
37 # Some m27 DEPS have blink entries that are just paths. Prepend the host
38 # info so the rest of the processing can proceed as normal.
39 m = re.match('/branches/chromium/[^/]+/'
40 '(LayoutTests|Source|Tools)(/.*)?$', url)
42 dep_url = 'https://src.chromium.org/blink' + dep_url
43 deps_section[dep] = dep_url
44 url, rev = SplitScmUrl(dep_url)
46 # During m29 (and maybe earlier), there was some fetching (and branching)
47 # of just blink LayoutTests, rather than the whole repo, with entries to
48 # checkout a bunch of individual sub-paths to
49 # 'src/content/test/data/layout_tests/*'.
50 # Consolidate all of those deps into a single, top-level 'layout_tests'
51 # entry so the whole blink repo can be checkout out there (putting
52 # LayoutTests in the expected 'layout_tests/LayoutTests/' path).
53 m = re.match('^https?://src.chromium.org/blink/'
54 '(trunk|branches/chromium/[^/]+)/LayoutTests(/.*)?', url)
56 if not add_deps.get('src/content/test/data/layout_tests'):
57 add_deps['src/content/test/data/layout_tests'] = dep_url
61 # Ignore webkit sub-path entries since git checks out all in one repo,
63 if url.startswith('/trunk/deps/third_party/WebKit/'):
66 m = re.match('https?://(svn.webkit.org/repository/webkit|'
67 'src.chromium.org/blink)'
68 '/(trunk|branches/chromium/[^/]+)/', url)
70 # Don't remove 'ios' sub-path entries, which are set explicitly to
71 # just pull the headers or something. Unfortunately, the sub-path
72 # repos don't mirror the branches, so if the dep is for a branch, even
73 # 'ios' will have to pull the full WebKit.
74 if os == 'ios' and m.group(2) == 'trunk':
77 # If svn DEPS refers to the webkit.org repo, rather than blink, use
78 # the old mirror of that repo instead of blink.git.
79 if 'svn.webkit.org' in m.group(1):
80 webkit_git = GIT_HOST + 'external/WebKit_trimmed.git'
85 # All the sub-path repos should be pinned to the same revision. If
86 # they're not, then not sure how to decide what revision to use for
87 # the umbrella git repo.
89 raise Exception('WebKit entry revision mismatch: %s != %s' %
94 # Some older DEPS have a split selenium py/test|selenium checkout but the
95 # git selenium py repo encompasses both, so delete everything except the
96 # base checkout to python/selenium.
97 if dep.startswith('src/third_party/webdriver/python/selenium/'):
101 # Ugh. For a while during m29, there was an entry with an incomplete URL
102 # and incorrect path. How this worked even once, let alone through
103 # multiple releases, is a mystery.
104 if url.startswith('sctp-refimpl'):
105 dep_url = 'https://' + dep_url.replace('/snv/', '/svn/')
106 deps_section[dep] = dep_url
110 del deps_section[dep]
111 deps_section.update(add_deps)
113 # Make sure the top-level webkit entry that's left refers to the common
114 # revision from the sub-path entries, and not to the revision of the
115 # top-level "placeholder" repository. webkit_rev won't be set for recent
116 # DEPS, since they use the blink repo and have no webkit sub-path entries.
118 dep_url = deps['src/third_party/WebKit']
119 url, rev = SplitScmUrl(dep_url)
120 deps['src/third_party/WebKit'] = '%s@%s' % (url, webkit_rev)
122 def SvnUrlToGitUrl(path, svn_url):
123 """Convert a chromium SVN URL to a chromium Git URL."""
126 '(https?://src.chromium.org/svn|svn://svn.chromium.org/chrome)(/.*)',
129 svn_url = match.group(2)
131 # Handle the main 'src' repo which only appears in buildspecs.
132 match = re.match('/(branches/(?P<branch>[^/]+)|trunk)/src', svn_url)
134 if match.groupdict().get('branch'):
135 return (path, GIT_HOST + 'chromium/src.git', GIT_HOST,
136 match.groupdict().get('branch'))
138 return (path, GIT_HOST + 'chromium/src.git', GIT_HOST)
140 # libvpx branches in the chrome branches area.
141 match = re.match('/branches/libvpx/(?P<branch>[^/]+)', svn_url)
143 return (path, GIT_HOST + 'chromium/deps/libvpx.git', GIT_HOST,
144 match.group('branch'))
146 # Since the ffmpeg overrides are gone, we can't use the upstream git repo
147 # (which is what those overrides referenced), so use the mirror of the svn
149 if svn_url == '/trunk/deps/third_party/ffmpeg':
150 return (path, GIT_HOST + 'chromium/deps/ffmpeg.git', GIT_HOST)
152 match = re.match('/branches/ffmpeg/(?P<branch>[^/]+)', svn_url)
154 return (path, GIT_HOST + 'chromium/deps/ffmpeg.git', GIT_HOST,
155 match.group('branch'))
158 match = re.match('/branches/third_party/openssl/(?P<branch>[^/]+)', svn_url)
160 return (path, GIT_HOST + 'chromium/deps/openssl.git', GIT_HOST,
161 match.group('branch'))
163 # The webrtc repo used to be mirrored into multiple stable/trunk repos,
164 # but branches were mirrored to both, so either would work here.
165 match = re.match('^https?://webrtc.googlecode.com/svn/branches/([^/]+)/(.*)',
168 branch = match.group(1)
169 if match.group(2) == 'src':
170 repo = 'webrtc/src.git'
172 repo = 'webrtc/trunk/%s.git' % match.group(2)
173 return (path, GIT_HOST + 'external/%s' % repo, GIT_HOST, branch)
175 # Skia also split into multiple repos, and has unusual chrome-specific branch
177 # https://chromium.googlesource.com/external/skia/m25_1364/src.git
178 match = re.match('^https?://skia.googlecode.com/svn/branches/'
179 'chrome/([^/]+)/(?:trunk/)?(.*)', svn_url)
181 branch = match.group(1)
182 repo = 'skia/%s.git' % match.group(2)
183 return (path, GIT_HOST + 'external/%s' % repo, GIT_HOST, 'chrome/' + branch)
185 # Make the top-level webkit entry checkout the full webkit git repository,
186 # which replaces all the (non-iOS) sub-path entries.
187 if svn_url == '/trunk/deps/third_party/WebKit':
188 return (path, webkit_git, GIT_HOST)
190 # Make the top-level python/selenium entry checkout the full selenium/py git
191 # repository, which replaces all the sub-path entries.
192 if svn_url == 'http://selenium.googlecode.com/svn/trunk/py/selenium':
193 return (path, GIT_HOST + 'external/selenium/py.git', GIT_HOST)
195 # Projects that are subdirectories of the native_client repository.
196 match = re.match('^https?://src.chromium.org/native_client/branches/'
197 '(?P<branch>[^/]+)/(?P<path>.*)',
200 if match.group('path'):
201 repo = '%s.git' % match.group('path')
203 repo = 'src/native_client.git'
204 return (path, GIT_HOST + 'native_client/%s' % repo, GIT_HOST,
205 match.group('branch'))
208 match = re.match('^https?://src.chromium.org/blink/'
209 '(trunk|branches/(?P<branch>chromium/[^/]+))/'
213 repo = GIT_HOST + 'chromium/blink.git'
214 if match.group('branch'):
215 return (path, repo, GIT_HOST, match.group('branch'))
217 return (path, repo, GIT_HOST)
220 match = re.match('^https?://src.chromium.org/blink/branches/'
221 '(?P<branch>chromium/[^/]+)(?P<path>/public)?/?$',
224 # ios has a special headers-only repo
225 if match.group('path'):
226 repo = GIT_HOST + 'chromium/blink-public.git'
228 repo = GIT_HOST + 'chromium/blink.git'
229 return (path, repo, GIT_HOST, match.group('branch'))
232 if svn_url.startswith('/trunk/deps/reference_builds/chrome'):
233 return (path, GIT_HOST + 'chromium/reference_builds/chrome.git',