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):
25 for os, deps_section in ([(None, deps)] +
26 [(os, deps_os[os]) for os in deps_os]):
29 for dep, dep_url in deps_section.iteritems():
30 # Skip 'None' exclusion entries.
34 url, rev = SplitScmUrl(dep_url)
36 # Some m27 DEPS have blink entries that are just paths. Prepend the host
37 # info so the rest of the processing can proceed as normal.
38 m = re.match('/branches/chromium/[^/]+/'
39 '(LayoutTests|Source|Tools)(/.*)?$', url)
41 dep_url = 'https://src.chromium.org/blink' + dep_url
42 deps_section[dep] = dep_url
43 url, rev = SplitScmUrl(dep_url)
45 # During m29 (and maybe earlier), there was some fetching (and branching)
46 # of just blink LayoutTests, rather than the whole repo, with entries to
47 # checkout a bunch of individual sub-paths to
48 # 'src/content/test/data/layout_tests/*'.
49 # Consolidate all of those deps into a single, top-level 'layout_tests'
50 # entry so the whole blink repo can be checkout out there (putting
51 # LayoutTests in the expected 'layout_tests/LayoutTests/' path).
52 m = re.match('^https?://src.chromium.org/blink/'
53 '(trunk|branches/chromium/[^/]+)/LayoutTests(/.*)?', url)
55 if not add_deps.get('src/content/test/data/layout_tests'):
56 add_deps['src/content/test/data/layout_tests'] = dep_url
60 # Ignore webkit sub-path entries since git checks out all in one repo,
62 if url.startswith('/trunk/deps/third_party/WebKit/'):
65 m = re.match('https?://(svn.webkit.org/repository/webkit|'
66 'src.chromium.org/blink)'
67 '/(trunk|branches/chromium/[^/]+)/', url)
69 # Don't remove 'ios' sub-path entries, which are set explicitly to
70 # just pull the headers or something. Unfortunately, the sub-path
71 # repos don't mirror the branches, so if the dep is for a branch, even
72 # 'ios' will have to pull the full WebKit.
73 if os == 'ios' and m.group(2) == 'trunk':
76 # If svn DEPS refers to the webkit.org repo, rather than blink, use
77 # the old mirror of that repo instead of blink.git.
78 if 'svn.webkit.org' in m.group(1):
79 webkit_git = GIT_HOST + 'external/WebKit_trimmed.git'
84 # All the sub-path repos should be pinned to the same revision. If
85 # they're not, then not sure how to decide what revision to use for
86 # the umbrella git repo.
88 raise Exception('WebKit entry revision mismatch: %s != %s' %
93 # Some older DEPS have a split selenium py/test|selenium checkout but the
94 # git selenium py repo encompasses both, so delete everything except the
95 # base checkout to python/selenium.
96 if dep.startswith('src/third_party/webdriver/python/selenium/'):
100 # Ugh. For a while during m29, there was an entry with an incomplete URL
101 # and incorrect path. How this worked even once, let alone through
102 # multiple releases, is a mystery.
103 if url.startswith('sctp-refimpl'):
104 dep_url = 'https://' + dep_url.replace('/snv/', '/svn/')
105 deps_section[dep] = dep_url
109 del deps_section[dep]
110 deps_section.update(add_deps)
112 # Make sure the top-level webkit entry that's left refers to the common
113 # revision from the sub-path entries, and not to the revision of the
114 # top-level "placeholder" repository. webkit_rev won't be set for recent
115 # DEPS, since they use the blink repo and have no webkit sub-path entries.
117 dep_url = deps['src/third_party/WebKit']
118 url, rev = SplitScmUrl(dep_url)
119 deps['src/third_party/WebKit'] = '%s@%s' % (url, webkit_rev)
121 def SvnUrlToGitUrl(path, svn_url):
122 """Convert a chromium SVN URL to a chromium Git URL."""
125 '(https?://src.chromium.org/svn|svn://svn.chromium.org/chrome)(/.*)',
128 svn_url = match.group(2)
130 # Handle the main 'src' repo which only appears in buildspecs.
131 match = re.match('/(branches/(?P<branch>[^/]+)|trunk)/src$', svn_url)
133 if match.groupdict().get('branch'):
134 return (path, GIT_HOST + 'chromium/src.git', GIT_HOST,
135 match.groupdict().get('branch'))
137 return (path, GIT_HOST + 'chromium/src.git', GIT_HOST)
139 # libvpx branches in the chrome branches area.
140 match = re.match('/branches/libvpx/(?P<branch>[^/]+)', svn_url)
142 return (path, GIT_HOST + 'chromium/deps/libvpx.git', GIT_HOST,
143 match.group('branch'))
145 # Since the ffmpeg overrides are gone, we can't use the upstream git repo
146 # (which is what those overrides referenced), so use the mirror of the svn
148 if svn_url == '/trunk/deps/third_party/ffmpeg':
149 return (path, GIT_HOST + 'chromium/deps/ffmpeg.git', GIT_HOST)
151 match = re.match('/branches/ffmpeg/(?P<branch>[^/]+)', svn_url)
153 return (path, GIT_HOST + 'chromium/deps/ffmpeg.git', GIT_HOST,
154 match.group('branch'))
157 match = re.match('/branches/third_party/openssl/(?P<branch>[^/]+)', svn_url)
159 return (path, GIT_HOST + 'chromium/deps/openssl.git', GIT_HOST,
160 match.group('branch'))
162 # The webrtc repo used to be mirrored into multiple stable/trunk repos,
163 # but branches were mirrored to both, so either would work here.
164 match = re.match('^https?://webrtc.googlecode.com/svn/branches/([^/]+)/(.*)',
167 branch = match.group(1)
168 if match.group(2) == 'src':
169 repo = 'webrtc/src.git'
171 repo = 'webrtc/trunk/%s.git' % match.group(2)
172 return (path, GIT_HOST + 'external/%s' % repo, GIT_HOST, branch)
174 # Skia also split into multiple repos, and has unusual chrome-specific branch
176 # https://chromium.googlesource.com/external/skia/m25_1364/src.git
177 match = re.match('^https?://skia.googlecode.com/svn/branches/'
178 'chrome/([^/]+)/(?:trunk/)?(.*)', svn_url)
180 branch = match.group(1)
181 repo = 'skia/%s.git' % match.group(2)
182 return (path, GIT_HOST + 'external/%s' % repo, GIT_HOST, 'chrome/' + branch)
184 # Make the top-level webkit entry checkout the full webkit git repository,
185 # which replaces all the (non-iOS) sub-path entries.
186 if svn_url == '/trunk/deps/third_party/WebKit':
187 return (path, webkit_git, GIT_HOST)
189 # Make the top-level python/selenium entry checkout the full selenium/py git
190 # repository, which replaces all the sub-path entries.
191 if svn_url == 'http://selenium.googlecode.com/svn/trunk/py/selenium':
192 return (path, GIT_HOST + 'external/selenium/py.git', GIT_HOST)
194 # Projects that are subdirectories of the native_client repository.
195 match = re.match('^https?://src.chromium.org/native_client/branches/'
196 '(?P<branch>[^/]+)/(?P<path>.*)',
199 if match.group('path'):
200 repo = '%s.git' % match.group('path')
202 repo = 'src/native_client.git'
203 return (path, GIT_HOST + 'native_client/%s' % repo, GIT_HOST,
204 match.group('branch'))
207 match = re.match('^https?://src.chromium.org/blink/'
208 '(trunk|branches/(?P<branch>chromium/[^/]+))/'
212 repo = GIT_HOST + 'chromium/blink.git'
213 if match.group('branch'):
214 return (path, repo, GIT_HOST, match.group('branch'))
216 return (path, repo, GIT_HOST)
219 match = re.match('^https?://src.chromium.org/blink/branches/'
220 '(?P<branch>chromium/[^/]+)(?P<path>/public)?/?$',
223 # ios has a special headers-only repo
224 if match.group('path'):
225 repo = GIT_HOST + 'chromium/blink-public.git'
227 repo = GIT_HOST + 'chromium/blink.git'
228 return (path, repo, GIT_HOST, match.group('branch'))
231 if svn_url.startswith('/trunk/deps/reference_builds/chrome'):
232 return (path, GIT_HOST + 'chromium/reference_builds/chrome.git',