Update firefox to 69 and create a buildstream plugin to fetch translations

parent 1b736c23
This diff is collapsed.
import json
with open("browser/locales/l10n-changesets.json", "r") as f:
changesets = json.load(f)
for locale, data in changesets.items():
if 'linux' not in data['platforms']:
assert 'linux64' not in data['platforms']
continue
assert 'linux64' in data['platforms']
revision = data['revision']
print(f'- kind: tar')
print(f' url: "https://hg.mozilla.org/l10n-central/{locale}/archive/{revision}.tar.bz2"')
print(f' directory: "locales/{locale}"')
commit 54e70b3085eb27c6ab6b6f9bf4064e70f5ff876f
Author: Emilio Cobos Álvarez <[email protected]>
Date: Fri Feb 22 20:52:42 2019 -0800
Work-around https://bugs.llvm.org/show_bug.cgi?id=40813.
This fixes a crash when using non-deductible auto types.
diff --git a/src/clang.rs b/src/clang.rs
index 10bf054a..40ba60e8 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -931,18 +931,37 @@ impl Type {
unsafe { clang_isConstQualifiedType(self.x) != 0 }
}
+ #[inline]
+ fn is_non_deductible_auto_type(&self) -> bool {
+ self.kind() == CXType_Auto && self.canonical_type() == *self
+ }
+
+ #[inline]
+ fn clang_size_of(&self) -> c_longlong {
+ if self.is_non_deductible_auto_type() {
+ return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
+ }
+ unsafe { clang_Type_getSizeOf(self.x) }
+ }
+
+ #[inline]
+ fn clang_align_of(&self) -> c_longlong {
+ if self.is_non_deductible_auto_type() {
+ return -6; // Work-around https://bugs.llvm.org/show_bug.cgi?id=40813
+ }
+ unsafe { clang_Type_getAlignOf(self.x) }
+ }
+
/// What is the size of this type? Paper over invalid types by returning `0`
/// for them.
pub fn size(&self) -> usize {
- unsafe {
- let val = clang_Type_getSizeOf(self.x);
- if val < 0 { 0 } else { val as usize }
- }
+ let val = self.clang_size_of();
+ if val < 0 { 0 } else { val as usize }
}
/// What is the size of this type?
pub fn fallible_size(&self) -> Result<usize, LayoutError> {
- let val = unsafe { clang_Type_getSizeOf(self.x) };
+ let val = self.clang_size_of();
if val < 0 {
Err(LayoutError::from(val as i32))
} else {
@@ -953,21 +972,17 @@ impl Type {
/// What is the alignment of this type? Paper over invalid types by
/// returning `0`.
pub fn align(&self) -> usize {
- unsafe {
- let val = clang_Type_getAlignOf(self.x);
- if val < 0 { 0 } else { val as usize }
- }
+ let val = self.clang_align_of();
+ if val < 0 { 0 } else { val as usize }
}
/// What is the alignment of this type?
pub fn fallible_align(&self) -> Result<usize, LayoutError> {
- unsafe {
- let val = clang_Type_getAlignOf(self.x);
- if val < 0 {
- Err(LayoutError::from(val as i32))
- } else {
- Ok(val as usize)
- }
+ let val = self.clang_align_of();
+ if val < 0 {
+ Err(LayoutError::from(val as i32))
+ } else {
+ Ok(val as usize)
}
}
diff --git a/tests/expectations/tests/bug-1529681.rs b/tests/expectations/tests/bug-1529681.rs
new file mode 100644
index 00000000..81a32093
--- /dev/null
+++ b/tests/expectations/tests/bug-1529681.rs
@@ -0,0 +1,27 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct BrowsingContext {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_BrowsingContext() {
+ assert_eq!(
+ ::std::mem::size_of::<BrowsingContext>(),
+ 1usize,
+ concat!("Size of: ", stringify!(BrowsingContext))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<BrowsingContext>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(BrowsingContext))
+ );
+}
diff --git a/tests/headers/bug-1529681.hpp b/tests/headers/bug-1529681.hpp
new file mode 100644
index 00000000..17fa849a
--- /dev/null
+++ b/tests/headers/bug-1529681.hpp
@@ -0,0 +1,8 @@
+// bindgen-flags: -- -std=c++14
+//
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1529681
+// https://bugs.llvm.org/show_bug.cgi?id=40813
+
+class BrowsingContext {
+ auto Tie(void* aUnused) const;
+};
from buildstream import Source, SourceError, SourceFetcher, Consistency, utils
import os
import urllib.error
import urllib.request
import json
import hashlib
import tarfile
class FirefoxLocaleFetcher(SourceFetcher):
def __init__(self, parent, locale, revision, sha256):
self.locale = locale
self.revision = revision
self.sha256 = sha256
self.parent = parent
super(FirefoxLocaleFetcher, self).__init__()
def fetch(self, alias_override=None, **kwargs):
self.parent._fetch_cache(self.locale, self.revision, sha256=self.sha256)
class FirefoxLocalesSource(Source):
BST_REQUIRED_VERSION_MAJOR = 1
BST_REQUIRED_VERSION_MINOR = 3
BST_REQUIRES_PREVIOUS_SOURCES_TRACK = True
def _cache_file_name(self, locale, revision):
return os.path.join(self.get_mirror_directory(), f'{locale}-{revision}.tar.bz2')
def _verify_cache(self, locale, revision, sha256):
h = hashlib.sha256()
try:
with open(self._cache_file_name(locale, revision), 'rb') as f:
while True:
data = f.read(4096)
if len(data) <= 0:
break
h.update(data)
return h.hexdigest() == sha256
except FileNotFoundError:
return False
def _fetch_cache(self, locale, revision, *, sha256=None):
h = hashlib.sha256()
uri = self.uri_template.format(locale=locale, revision=revision)
with utils.save_file_atomic(self._cache_file_name(locale, revision), mode='wb') as f:
try:
with urllib.request.urlopen(uri) as resp:
while True:
data = resp.read(4096)
if len(data) <= 0:
break
h.update(data)
f.write(data)
except (urllib.error.URLError, urllib.error.HTTPError) as e:
raise SourceError("{} failed: {}".format(uri, e.reason)) from e
if sha256:
if h.hexdigest() != sha256:
unexpected = h.hexdigest()
raise SourceError(f"{uri} returned data with unexpected hash '{unexpected}'. Expected '{sha256}'.")
return h.hexdigest()
def configure(self, node):
self.ref = self.node_get_member(node, list, 'ref', None)
self.uri_template = self.node_get_member(node, str, 'uri-template', 'https://hg.mozilla.org/l10n-central/{locale}/archive/{revision}.tar.bz2')
self.l10n_changesets_path = self.node_get_member(node, str, 'l10n-changesets', 'browser/locales/l10n-changesets.json')
self.l10n_changesets_path = os.path.relpath(os.path.join('/', self.l10n_changesets_path), '/')
self.node_validate(node, Source.COMMON_CONFIG_KEYS + ['ref', 'uri-template', 'l10n-changesets'])
if self.ref:
for r in self.ref:
self.node_validate(r, ['locale', 'revision', 'sha256'])
def get_unique_key(self):
return {
'ref': {r['locale']: (r['revision'], r['sha256']) for r in self.ref},
'uri-template': self.uri_template
}
def preflight(self):
pass
def load_ref(self, node):
self.ref = self.node_get_member(node, list, 'ref', None)
def get_ref(self):
return self.ref
def set_ref(self, ref, node):
node['ref'] = self.ref = ref
def track(self, previous_sources_dir):
with open(os.path.join(previous_sources_dir, self.l10n_changesets_path), 'r') as f:
changesets = json.load(f)
ref = []
for locale, data in changesets.items():
if 'linux' not in data['platforms']:
assert 'linux64' not in data['platforms']
continue
assert 'linux64' in data['platforms']
revision = data['revision']
self.info(f"Tracking {locale} {revision}")
sha256 = self._fetch_cache(locale, revision, sha256=None)
ref.append({'locale': locale,
'revision': revision,
'sha256': sha256})
return ref
def stage(self, directory):
for r in self.ref:
locale = r['locale']
revision = r['revision']
sha256 = r['sha256']
if not self._verify_cache(locale, revision, sha256):
raise SourceError(f"Locale {locale} has unexpected hash '{unexpected}'. Expected '{sha256}'.")
with tarfile.open(self._cache_file_name(locale, revision), mode='r:bz2') as tar:
tar.extractall(path=os.path.join(os.path.join(directory, f'locales/{locale}')))
def get_consistency(self):
if self.ref is None:
return Consistency.INCONSISTENT
for r in self.ref:
if not self._verify_cache(r['locale'], r['revision'], r['sha256']):
return Consistency.RESOLVED
return Consistency.CACHED
def get_source_fetchers(self):
for r in self.ref:
yield FirefoxLocaleFetcher(self, r['locale'], r['revision'], r['sha256'])
def setup():
return FirefoxLocalesSource
......@@ -25,6 +25,11 @@ options:
- x86_64
plugins:
- origin: local
path: plugins/sources
sources:
firefox_locales: 0
- origin: local
path: plugins/elements
elements:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment