gecko-dev/tools/vcs/mach_commands.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

205 строки
8.0 KiB
Python
Исходник Обычный вид История

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals
import os
import re
import subprocess
import sys
import logging
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
from mozbuild.base import MachCommandBase
import mozpack.path as mozpath
import json
GITHUB_ROOT = 'https://github.com/'
PR_REPOSITORIES = {
'webrender': {
'github': 'servo/webrender',
'path': 'gfx/wr',
'bugzilla_product': 'Core',
'bugzilla_component': 'Graphics: WebRender',
},
Bug 1575008 - WebGPU implementation basis r=baku,bzbarsky This change vendors `wgpu` library in-tree and hooks up the initialization bits. It implements adapter and device initialization and adds a simple test. Complementary ecosystem tracker - https://github.com/gfx-rs/wgpu/issues/374 Current status: - [x] General - [x] figure out the IPC story - [ ] move wgpu crates into a dedicated folder (postponed as https://bugzilla.mozilla.org/show_bug.cgi?id=1594182) - [x] neko rebasing disaster - [x] Linux - [x] avoid depending on spirv_cross - [x] macOS - [x] due to cross-compiling shaders - [x] need the dependency update - [x] stop using gcc - [x] unexpected SSL header collision - https://phabricator.services.mozilla.com/D51148 - [x] undefined Metal symbols - [x] missing webrtc headers for IPDL magic - https://phabricator.services.mozilla.com/D51558 - [x] spirv-cross linking failure in ASAN - https://phabricator.services.mozilla.com/D52688 - [x] Windows - [x] due to "ipc-channel" not supporting Windows yet - [x] due to some exceptional stuff - [x] undefined symbol: `D3D12CreateDevice` - [x] d3d12.dll is not found, dxgi1_4 doesn't present - [x] d3d11.dll and dxgi.dll need to be explicitly loaded on win32 mingw - [x] libbacktrace fails to link on win32 mingw - [x] cc mislinking C++ standard library - [x] Android - [x] spirv-cross fails to build due to exceptions Update-1: We decided to go with IPDL mechanism instead of Rust based ipc-channel (or any alternatives), which unblocks Windows build. Update-2: It appears that WebGPUThreading isn't needed any more as the child thread (and its event loop) is now managed by IPDL infrastructure. This PR removes it 🎉 . Update-3: InstanceProvider is also removed. Update-4: All set, the try is green, waiting for dependent changes to go in. Differential Revision: https://phabricator.services.mozilla.com/D49458 --HG-- rename : dom/webgpu/Adapter.cpp => dom/webgpu/ipc/WebGPUTypes.h rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/ash/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/atom/Cargo.toml rename : third_party/rust/core-graphics/Cargo.toml => third_party/rust/cocoa/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/cocoa/LICENSE-MIT rename : third_party/rust/core-graphics/src/lib.rs => third_party/rust/cocoa/src/lib.rs rename : third_party/rust/uluru/Cargo.toml => third_party/rust/colorful/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/copyless/Cargo.toml rename : third_party/rust/crossbeam-utils/.cargo-checksum.json => third_party/rust/crossbeam-utils-0.6.5/.cargo-checksum.json rename : third_party/rust/crossbeam-utils/CHANGELOG.md => third_party/rust/crossbeam-utils-0.6.5/CHANGELOG.md rename : third_party/rust/crossbeam-utils/Cargo.toml => third_party/rust/crossbeam-utils-0.6.5/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/crossbeam-utils-0.6.5/LICENSE-MIT rename : third_party/rust/crossbeam-utils/README.md => third_party/rust/crossbeam-utils-0.6.5/README.md rename : third_party/rust/crossbeam-utils/benches/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/benches/atomic_cell.rs rename : third_party/rust/crossbeam-utils/src/atomic/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/src/atomic/atomic_cell.rs rename : third_party/rust/crossbeam-utils/src/atomic/mod.rs => third_party/rust/crossbeam-utils-0.6.5/src/atomic/mod.rs rename : third_party/rust/crossbeam-utils/src/backoff.rs => third_party/rust/crossbeam-utils-0.6.5/src/backoff.rs rename : third_party/rust/crossbeam-utils/src/cache_padded.rs => third_party/rust/crossbeam-utils-0.6.5/src/cache_padded.rs rename : third_party/rust/crossbeam-utils/src/lib.rs => third_party/rust/crossbeam-utils-0.6.5/src/lib.rs rename : third_party/rust/crossbeam-utils/src/thread.rs => third_party/rust/crossbeam-utils-0.6.5/src/thread.rs rename : third_party/rust/crossbeam-utils/tests/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/tests/atomic_cell.rs rename : third_party/rust/crossbeam-utils/tests/parker.rs => third_party/rust/crossbeam-utils-0.6.5/tests/parker.rs rename : third_party/rust/crossbeam-utils/tests/sharded_lock.rs => third_party/rust/crossbeam-utils-0.6.5/tests/sharded_lock.rs rename : third_party/rust/crossbeam-utils/tests/thread.rs => third_party/rust/crossbeam-utils-0.6.5/tests/thread.rs rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/gfx-auxil/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/gfx-backend-empty/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/hibitset/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/hibitset/LICENSE-MIT rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/metal/LICENSE-MIT rename : third_party/rust/uluru/Cargo.toml => third_party/rust/range-alloc/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/raw-window-handle/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/relevant/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/relevant/LICENSE-MIT rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/rendy-descriptor/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/shared_library/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/shared_library/LICENSE-MIT rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/storage-map/Cargo.toml rename : third_party/rust/core-graphics/Cargo.toml => third_party/rust/x11/Cargo.toml extra : moz-landing-system : lando
2019-11-14 07:59:56 +03:00
'webgpu': {
'github': 'gfx-rs/wgpu',
Bug 1594182 - Move wgpu stuff under gfx/wgpu r=jgilbert,remote-protocol-reviewers This change moves wgpu mirror into a dedicated folder and also registers it in a few metadata files for proper treating. Differential Revision: https://phabricator.services.mozilla.com/D51921 --HG-- rename : dom/webgpu/wgpu-native/Cargo.toml => gfx/wgpu/wgpu-native/Cargo.toml rename : dom/webgpu/wgpu-remote/cbindgen.toml => gfx/wgpu/wgpu-native/cbindgen.toml rename : dom/webgpu/wgpu-native/src/binding_model.rs => gfx/wgpu/wgpu-native/src/binding_model.rs rename : dom/webgpu/wgpu-native/src/command/allocator.rs => gfx/wgpu/wgpu-native/src/command/allocator.rs rename : dom/webgpu/wgpu-native/src/command/bind.rs => gfx/wgpu/wgpu-native/src/command/bind.rs rename : dom/webgpu/wgpu-native/src/command/compute.rs => gfx/wgpu/wgpu-native/src/command/compute.rs rename : dom/webgpu/wgpu-native/src/command/mod.rs => gfx/wgpu/wgpu-native/src/command/mod.rs rename : dom/webgpu/wgpu-native/src/command/render.rs => gfx/wgpu/wgpu-native/src/command/render.rs rename : dom/webgpu/wgpu-native/src/command/transfer.rs => gfx/wgpu/wgpu-native/src/command/transfer.rs rename : dom/webgpu/wgpu-native/src/conv.rs => gfx/wgpu/wgpu-native/src/conv.rs rename : dom/webgpu/wgpu-native/src/device.rs => gfx/wgpu/wgpu-native/src/device.rs rename : dom/webgpu/wgpu-native/src/hub.rs => gfx/wgpu/wgpu-native/src/hub.rs rename : dom/webgpu/wgpu-native/src/id.rs => gfx/wgpu/wgpu-native/src/id.rs rename : dom/webgpu/wgpu-native/src/instance.rs => gfx/wgpu/wgpu-native/src/instance.rs rename : dom/webgpu/wgpu-native/src/lib.rs => gfx/wgpu/wgpu-native/src/lib.rs rename : dom/webgpu/wgpu-native/src/pipeline.rs => gfx/wgpu/wgpu-native/src/pipeline.rs rename : dom/webgpu/wgpu-native/src/resource.rs => gfx/wgpu/wgpu-native/src/resource.rs rename : dom/webgpu/wgpu-native/src/swap_chain.rs => gfx/wgpu/wgpu-native/src/swap_chain.rs rename : dom/webgpu/wgpu-native/src/track/buffer.rs => gfx/wgpu/wgpu-native/src/track/buffer.rs rename : dom/webgpu/wgpu-native/src/track/mod.rs => gfx/wgpu/wgpu-native/src/track/mod.rs rename : dom/webgpu/wgpu-native/src/track/range.rs => gfx/wgpu/wgpu-native/src/track/range.rs rename : dom/webgpu/wgpu-native/src/track/texture.rs => gfx/wgpu/wgpu-native/src/track/texture.rs rename : dom/webgpu/wgpu-remote/Cargo.toml => gfx/wgpu/wgpu-remote/Cargo.toml rename : dom/webgpu/wgpu-remote/cbindgen.toml => gfx/wgpu/wgpu-remote/cbindgen.toml rename : dom/webgpu/wgpu-remote/src/lib.rs => gfx/wgpu/wgpu-remote/src/lib.rs rename : dom/webgpu/wgpu-remote/src/server.rs => gfx/wgpu/wgpu-remote/src/server.rs extra : moz-landing-system : lando
2019-11-15 03:29:53 +03:00
'path': 'gfx/wgpu',
Bug 1575008 - WebGPU implementation basis r=baku,bzbarsky This change vendors `wgpu` library in-tree and hooks up the initialization bits. It implements adapter and device initialization and adds a simple test. Complementary ecosystem tracker - https://github.com/gfx-rs/wgpu/issues/374 Current status: - [x] General - [x] figure out the IPC story - [ ] move wgpu crates into a dedicated folder (postponed as https://bugzilla.mozilla.org/show_bug.cgi?id=1594182) - [x] neko rebasing disaster - [x] Linux - [x] avoid depending on spirv_cross - [x] macOS - [x] due to cross-compiling shaders - [x] need the dependency update - [x] stop using gcc - [x] unexpected SSL header collision - https://phabricator.services.mozilla.com/D51148 - [x] undefined Metal symbols - [x] missing webrtc headers for IPDL magic - https://phabricator.services.mozilla.com/D51558 - [x] spirv-cross linking failure in ASAN - https://phabricator.services.mozilla.com/D52688 - [x] Windows - [x] due to "ipc-channel" not supporting Windows yet - [x] due to some exceptional stuff - [x] undefined symbol: `D3D12CreateDevice` - [x] d3d12.dll is not found, dxgi1_4 doesn't present - [x] d3d11.dll and dxgi.dll need to be explicitly loaded on win32 mingw - [x] libbacktrace fails to link on win32 mingw - [x] cc mislinking C++ standard library - [x] Android - [x] spirv-cross fails to build due to exceptions Update-1: We decided to go with IPDL mechanism instead of Rust based ipc-channel (or any alternatives), which unblocks Windows build. Update-2: It appears that WebGPUThreading isn't needed any more as the child thread (and its event loop) is now managed by IPDL infrastructure. This PR removes it 🎉 . Update-3: InstanceProvider is also removed. Update-4: All set, the try is green, waiting for dependent changes to go in. Differential Revision: https://phabricator.services.mozilla.com/D49458 --HG-- rename : dom/webgpu/Adapter.cpp => dom/webgpu/ipc/WebGPUTypes.h rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/ash/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/atom/Cargo.toml rename : third_party/rust/core-graphics/Cargo.toml => third_party/rust/cocoa/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/cocoa/LICENSE-MIT rename : third_party/rust/core-graphics/src/lib.rs => third_party/rust/cocoa/src/lib.rs rename : third_party/rust/uluru/Cargo.toml => third_party/rust/colorful/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/copyless/Cargo.toml rename : third_party/rust/crossbeam-utils/.cargo-checksum.json => third_party/rust/crossbeam-utils-0.6.5/.cargo-checksum.json rename : third_party/rust/crossbeam-utils/CHANGELOG.md => third_party/rust/crossbeam-utils-0.6.5/CHANGELOG.md rename : third_party/rust/crossbeam-utils/Cargo.toml => third_party/rust/crossbeam-utils-0.6.5/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/crossbeam-utils-0.6.5/LICENSE-MIT rename : third_party/rust/crossbeam-utils/README.md => third_party/rust/crossbeam-utils-0.6.5/README.md rename : third_party/rust/crossbeam-utils/benches/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/benches/atomic_cell.rs rename : third_party/rust/crossbeam-utils/src/atomic/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/src/atomic/atomic_cell.rs rename : third_party/rust/crossbeam-utils/src/atomic/mod.rs => third_party/rust/crossbeam-utils-0.6.5/src/atomic/mod.rs rename : third_party/rust/crossbeam-utils/src/backoff.rs => third_party/rust/crossbeam-utils-0.6.5/src/backoff.rs rename : third_party/rust/crossbeam-utils/src/cache_padded.rs => third_party/rust/crossbeam-utils-0.6.5/src/cache_padded.rs rename : third_party/rust/crossbeam-utils/src/lib.rs => third_party/rust/crossbeam-utils-0.6.5/src/lib.rs rename : third_party/rust/crossbeam-utils/src/thread.rs => third_party/rust/crossbeam-utils-0.6.5/src/thread.rs rename : third_party/rust/crossbeam-utils/tests/atomic_cell.rs => third_party/rust/crossbeam-utils-0.6.5/tests/atomic_cell.rs rename : third_party/rust/crossbeam-utils/tests/parker.rs => third_party/rust/crossbeam-utils-0.6.5/tests/parker.rs rename : third_party/rust/crossbeam-utils/tests/sharded_lock.rs => third_party/rust/crossbeam-utils-0.6.5/tests/sharded_lock.rs rename : third_party/rust/crossbeam-utils/tests/thread.rs => third_party/rust/crossbeam-utils-0.6.5/tests/thread.rs rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/gfx-auxil/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/gfx-backend-empty/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/hibitset/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/hibitset/LICENSE-MIT rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/metal/LICENSE-MIT rename : third_party/rust/uluru/Cargo.toml => third_party/rust/range-alloc/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/raw-window-handle/Cargo.toml rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/relevant/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/relevant/LICENSE-MIT rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/rendy-descriptor/Cargo.toml rename : third_party/rust/uluru/Cargo.toml => third_party/rust/shared_library/Cargo.toml rename : third_party/rust/crossbeam-deque/LICENSE-MIT => third_party/rust/shared_library/LICENSE-MIT rename : third_party/rust/blake2b_simd/Cargo.toml => third_party/rust/storage-map/Cargo.toml rename : third_party/rust/core-graphics/Cargo.toml => third_party/rust/x11/Cargo.toml extra : moz-landing-system : lando
2019-11-14 07:59:56 +03:00
'bugzilla_product': 'Core',
'bugzilla_component': 'Graphics: WebGPU',
},
'debugger': {
'github': 'firefox-devtools/debugger',
'path': 'devtools/client/debugger',
'bugzilla_product': 'DevTools',
'bugzilla_component': 'Debugger'
},
}
@CommandProvider
class PullRequestImporter(MachCommandBase):
@Command('import-pr', category='misc',
description='Import a pull request from Github to the local repo.')
@CommandArgument('-b', '--bug-number',
help='Bug number to use in the commit messages.')
@CommandArgument('-t', '--bugzilla-token',
help='Bugzilla API token used to file a new bug if no bug number is '
'provided.')
@CommandArgument('-r', '--reviewer',
help='Reviewer nick to apply to commit messages.')
@CommandArgument('pull_request',
help='URL to the pull request to import (e.g. '
'https://github.com/servo/webrender/pull/3665).')
def import_pr(self, pull_request, bug_number=None, bugzilla_token=None, reviewer=None):
import requests
pr_number = None
repository = None
for r in PR_REPOSITORIES.values():
if pull_request.startswith(GITHUB_ROOT + r['github'] + '/pull/'):
# sanitize URL, dropping anything after the PR number
pr_number = int(re.search('/pull/([0-9]+)', pull_request).group(1))
pull_request = GITHUB_ROOT + r['github'] + '/pull/' + str(pr_number)
repository = r
break
if repository is None:
self.log(logging.ERROR, 'unrecognized_repo', {},
'The pull request URL was not recognized; add it to the list of '
'recognized repos in PR_REPOSITORIES in %s' % __file__)
sys.exit(1)
self.log(logging.INFO, 'import_pr', {'pr_url': pull_request},
'Attempting to import {pr_url}')
dirty = [f for f in self.repository.get_changed_files(mode='all')
if f.startswith(repository['path'])]
if dirty:
self.log(logging.ERROR, 'dirty_tree', repository,
'Local {path} tree is dirty; aborting!')
sys.exit(1)
target_dir = mozpath.join(self.topsrcdir, os.path.normpath(repository['path']))
if bug_number is None:
if bugzilla_token is None:
self.log(logging.WARNING, 'no_token', {},
'No bug number or bugzilla API token provided; bug number will not '
'be added to commit messages.')
else:
bug_number = self._file_bug(bugzilla_token, repository, pr_number)
elif bugzilla_token is not None:
self.log(logging.WARNING, 'too_much_bug', {},
'Providing a bugzilla token is unnecessary when a bug number is provided. '
'Using bug number; ignoring token.')
pr_patch = requests.get(pull_request + '.patch')
pr_patch.raise_for_status()
for patch in self._split_patches(pr_patch.content, bug_number, pull_request, reviewer):
self.log(logging.INFO, 'commit_msg', patch,
'Processing commit [{commit_summary}] by [{author}] at [{date}]')
patch_cmd = subprocess.Popen(['patch', '-p1', '-s'], stdin=subprocess.PIPE,
cwd=target_dir)
patch_cmd.stdin.write(patch['diff'].encode('utf-8'))
patch_cmd.stdin.close()
patch_cmd.wait()
if patch_cmd.returncode != 0:
self.log(logging.ERROR, 'commit_fail', {},
'Error applying diff from commit via "patch -p1 -s". Aborting...')
sys.exit(patch_cmd.returncode)
self.repository.commit(patch['commit_msg'], patch['author'], patch['date'],
[target_dir])
self.log(logging.INFO, 'commit_pass', {},
'Committed successfully.')
def _file_bug(self, token, repo, pr_number):
import requests
bug = requests.post('https://bugzilla.mozilla.org/rest/bug?api_key=%s' % token,
json={
'product': repo['bugzilla_product'],
'component': repo['bugzilla_component'],
'summary': 'Land %s#%s in mozilla-central' %
(repo['github'], pr_number),
'version': 'unspecified',
})
bug.raise_for_status()
self.log(logging.DEBUG, 'new_bug', {}, bug.content)
bugnumber = json.loads(bug.content)['id']
self.log(logging.INFO, 'new_bug', {'bugnumber': bugnumber},
'Filed bug {bugnumber}')
return bugnumber
def _split_patches(self, patchfile, bug_number, pull_request, reviewer):
INITIAL = 0
HEADERS = 1
STAT_AND_DIFF = 2
patch = b''
state = INITIAL
for line in patchfile.splitlines():
if state == INITIAL:
if line.startswith(b'From '):
state = HEADERS
elif state == HEADERS:
patch += line + b'\n'
if line == b'---':
state = STAT_AND_DIFF
elif state == STAT_AND_DIFF:
if line.startswith(b'From '):
yield self._parse_patch(patch, bug_number, pull_request, reviewer)
patch = b''
state = HEADERS
else:
patch += line + b'\n'
if len(patch) > 0:
yield self._parse_patch(patch, bug_number, pull_request, reviewer)
return
def _parse_patch(self, patch, bug_number, pull_request, reviewer):
import email
from email import (
header,
policy,
)
parse_policy = policy.compat32.clone(max_line_length=None)
parsed_mail = email.message_from_bytes(patch, policy=parse_policy)
def header_as_unicode(key):
decoded = header.decode_header(parsed_mail[key])
return str(header.make_header(decoded))
author = header_as_unicode('From')
date = header_as_unicode('Date')
commit_summary = header_as_unicode('Subject')
email_body = parsed_mail.get_payload(decode=True).decode('utf-8')
(commit_body, diff) = ('\n' + email_body).rsplit('\n---\n', 1)
bug_prefix = ''
if bug_number is not None:
bug_prefix = 'Bug %s - ' % bug_number
commit_summary = re.sub(r'^\[PATCH[0-9 /]*\] ', bug_prefix, commit_summary)
if reviewer is not None:
commit_summary += ' r=' + reviewer
commit_msg = commit_summary + '\n'
if len(commit_body) > 0:
commit_msg += commit_body + '\n'
commit_msg += '\n[import_pr] From ' + pull_request + '\n'
patch_obj = {
'author': author,
'date': date,
'commit_summary': commit_summary,
'commit_msg': commit_msg,
'diff': diff,
}
return patch_obj