git.iko.soy/typeable/nixpkgs
on master help sign in
qt511.qtwebengine: fix build on darwin

Co-Authored-By: Josef Kemetmüller <josef.kemetmueller@gmail.com>

commit45ab55e6e2af0c48a5be4ae13baeabf121d2d6be authorDmitry Kalinkin <dmitry.kalinkin@gmail.com> dateSat 12 Jan 2019, 09:28 (8 years ago) parent7a6d18c
4 files changed+260−11
pkgs/development/libraries/qt-5/5.11/default.nix+3 pkgs/development/libraries/qt-5/5.11/qtwebengine-clang-fix.patch+30 pkgs/development/libraries/qt-5/5.11/qtwebengine-darwin-sdk-10.10.patch+160 pkgs/development/libraries/qt-5/modules/qtwebengine.nix+67−11
pkgs/development/libraries/qt-5/5.11/default.nix+3
@@ -61,6 +61,9 @@ let
6161 qtscript = [ ./qtscript.patch ];
6262 qtserialport = [ ./qtserialport.patch ];
6363 qttools = [ ./qttools.patch ];
64+ qtwebengine =
65+ optional stdenv.cc.isClang ./qtwebengine-clang-fix.patch
66+ ++ optional stdenv.isDarwin ./qtwebengine-darwin-sdk-10.10.patch;
6467 qtwebkit = [ ./qtwebkit.patch ];
6568 };
6669
pkgs/development/libraries/qt-5/5.11/qtwebengine-clang-fix.patchnew file+30
@@ -0,0 +1,30 @@
1+Fix a following build error:
2+
3+In file included from ../../3rdparty/chromium/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm:7:
4+../../3rdparty/chromium/base/bind.h:59:3: error: static_assert failed "Bound argument |i| of type |Arg| cannot be forwarded as |Unwrapped| to the bound functor, which declares it as |Param|."
5+ static_assert(
6+ ^
7+../../3rdparty/chromium/base/bind.h:91:7: note: in instantiation of template class 'base::internal::AssertConstructible<1, long, long, const long &, NSError *>' requested here
8+ : AssertConstructible<Ns, Args, std::decay_t<Args>, Unwrapped, Params>... {
9+ ^
10+../../3rdparty/chromium/base/bind.h:213:27: note: in instantiation of template class 'base::internal::AssertBindArgsValidity<std::__1::integer_sequence<unsigned long, 0, 1>, base::internal::TypeList<base::WeakPtr<device::BluetoothRemoteGattCharacteristicMac>, long>, base::internal::TypeList<device::BluetoothRemoteGattCharacteristicMac *, const long &>, base::internal::TypeList<device::BluetoothRemoteGattCharacteristicMac *, NSError *> >' requested here
11+ static_assert(internal::AssertBindArgsValidity<
12+ ^
13+../../3rdparty/chromium/base/bind.h:242:16: note: in instantiation of function template specialization 'base::BindRepeating<void (device::BluetoothRemoteGattCharacteristicMac::*)(NSError *), base::WeakPtr<device::BluetoothRemoteGattCharacteristicMac>, long>' requested here
14+ return base::BindRepeating(std::forward<Functor>(functor),
15+ ^
16+../../3rdparty/chromium/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm:211:15: note: in instantiation of function template specialization 'base::Bind<void (device::BluetoothRemoteGattCharacteristicMac::*)(NSError *), base::WeakPtr<device::BluetoothRemoteGattCharacteristicMac>, long>' requested here
17+ base::Bind(&BluetoothRemoteGattCharacteristicMac::DidWriteValue,
18+ ^
19+
20+--- a/src/3rdparty/chromium/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
21++++ b/src/3rdparty/chromium/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
22+@@ -209,7 +209,7 @@ void BluetoothRemoteGattCharacteristicMac::WriteRemoteCharacteristic(
23+ base::ThreadTaskRunnerHandle::Get()->PostTask(
24+ FROM_HERE,
25+ base::Bind(&BluetoothRemoteGattCharacteristicMac::DidWriteValue,
26+- weak_ptr_factory_.GetWeakPtr(), nil));
27++ weak_ptr_factory_.GetWeakPtr(), nullptr));
28+ }
29+ }
30+
pkgs/development/libraries/qt-5/5.11/qtwebengine-darwin-sdk-10.10.patchnew file+160
@@ -0,0 +1,160 @@
1+Fix build against 10.10 SDK
2+
3+The SecKey part perhaps could be fixed by implementing a revert to
4+https://chromium.googlesource.com/chromium/src.git/+/8418e098b9cbedf884878b61dcd3292c515845cf%5E%21/#F0
5+
6+--- a/src/3rdparty/chromium/content/browser/renderer_host/input/web_input_event_builders_mac.mm
7++++ b/src/3rdparty/chromium/content/browser/renderer_host/input/web_input_event_builders_mac.mm
8+@@ -1,3 +1,4 @@
9++#define NSEventTypeScrollWheel 22
10+ // Copyright 2015 The Chromium Authors. All rights reserved.
11+ // Use of this source code is governed by a BSD-style license that can be
12+ // found in the LICENSE file.
13+--- a/src/3rdparty/chromium/net/ssl/ssl_platform_key_mac.cc
14++++ b/src/3rdparty/chromium/net/ssl/ssl_platform_key_mac.cc
15+@@ -48,21 +48,6 @@ namespace net {
16+
17+ namespace {
18+
19+-// TODO(davidben): Remove this when we switch to building to the 10.13
20+-// SDK. https://crbug.com/780980
21+-#if !defined(MAC_OS_X_VERSION_10_13) || \
22+- MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
23+-API_AVAILABLE(macosx(10.13))
24+-const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA256 =
25+- CFSTR("algid:sign:RSA:digest-PSS:SHA256:SHA256:32");
26+-API_AVAILABLE(macosx(10.13))
27+-const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA384 =
28+- CFSTR("algid:sign:RSA:digest-PSS:SHA384:SHA384:48");
29+-API_AVAILABLE(macosx(10.13))
30+-const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureDigestPSSSHA512 =
31+- CFSTR("algid:sign:RSA:digest-PSS:SHA512:SHA512:64");
32+-#endif
33+-
34+ class ScopedCSSM_CC_HANDLE {
35+ public:
36+ ScopedCSSM_CC_HANDLE() : handle_(0) {}
37+@@ -187,109 +172,6 @@ class SSLPlatformKeyCSSM : public ThreadedSSLPrivateKey::Delegate {
38+ DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyCSSM);
39+ };
40+
41+-// Returns the corresponding SecKeyAlgorithm or nullptr if unrecognized.
42+-API_AVAILABLE(macosx(10.12))
43+-SecKeyAlgorithm GetSecKeyAlgorithm(uint16_t algorithm) {
44+- switch (algorithm) {
45+- case SSL_SIGN_RSA_PKCS1_SHA512:
46+- return kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512;
47+- case SSL_SIGN_RSA_PKCS1_SHA384:
48+- return kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384;
49+- case SSL_SIGN_RSA_PKCS1_SHA256:
50+- return kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256;
51+- case SSL_SIGN_RSA_PKCS1_SHA1:
52+- return kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1;
53+- case SSL_SIGN_RSA_PKCS1_MD5_SHA1:
54+- return kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw;
55+- case SSL_SIGN_ECDSA_SECP521R1_SHA512:
56+- return kSecKeyAlgorithmECDSASignatureDigestX962SHA512;
57+- case SSL_SIGN_ECDSA_SECP384R1_SHA384:
58+- return kSecKeyAlgorithmECDSASignatureDigestX962SHA384;
59+- case SSL_SIGN_ECDSA_SECP256R1_SHA256:
60+- return kSecKeyAlgorithmECDSASignatureDigestX962SHA256;
61+- case SSL_SIGN_ECDSA_SHA1:
62+- return kSecKeyAlgorithmECDSASignatureDigestX962SHA1;
63+- }
64+-
65+- if (base::mac::IsAtLeastOS10_13()) {
66+- switch (algorithm) {
67+- case SSL_SIGN_RSA_PSS_SHA512:
68+- return kSecKeyAlgorithmRSASignatureDigestPSSSHA512;
69+- case SSL_SIGN_RSA_PSS_SHA384:
70+- return kSecKeyAlgorithmRSASignatureDigestPSSSHA384;
71+- case SSL_SIGN_RSA_PSS_SHA256:
72+- return kSecKeyAlgorithmRSASignatureDigestPSSSHA256;
73+- }
74+- }
75+-
76+- return nullptr;
77+-}
78+-
79+-class API_AVAILABLE(macosx(10.12)) SSLPlatformKeySecKey
80+- : public ThreadedSSLPrivateKey::Delegate {
81+- public:
82+- SSLPlatformKeySecKey(int type, size_t max_length, SecKeyRef key)
83+- : key_(key, base::scoped_policy::RETAIN) {
84+- // Determine the algorithms supported by the key.
85+- for (uint16_t algorithm : SSLPrivateKey::DefaultAlgorithmPreferences(
86+- type, true /* include PSS */)) {
87+- SecKeyAlgorithm sec_algorithm = GetSecKeyAlgorithm(algorithm);
88+- if (sec_algorithm &&
89+- SecKeyIsAlgorithmSupported(key_.get(), kSecKeyOperationTypeSign,
90+- sec_algorithm)) {
91+- preferences_.push_back(algorithm);
92+- }
93+- }
94+- }
95+-
96+- ~SSLPlatformKeySecKey() override {}
97+-
98+- std::vector<uint16_t> GetAlgorithmPreferences() override {
99+- return preferences_;
100+- }
101+-
102+- Error Sign(uint16_t algorithm,
103+- base::span<const uint8_t> input,
104+- std::vector<uint8_t>* signature) override {
105+- SecKeyAlgorithm sec_algorithm = GetSecKeyAlgorithm(algorithm);
106+- if (!sec_algorithm) {
107+- NOTREACHED();
108+- return ERR_FAILED;
109+- }
110+-
111+- const EVP_MD* md = SSL_get_signature_algorithm_digest(algorithm);
112+- uint8_t digest[EVP_MAX_MD_SIZE];
113+- unsigned digest_len;
114+- if (!md || !EVP_Digest(input.data(), input.size(), digest, &digest_len, md,
115+- nullptr)) {
116+- return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
117+- }
118+-
119+- base::ScopedCFTypeRef<CFDataRef> digest_ref(CFDataCreateWithBytesNoCopy(
120+- kCFAllocatorDefault, digest, base::checked_cast<CFIndex>(digest_len),
121+- kCFAllocatorNull));
122+-
123+- base::ScopedCFTypeRef<CFErrorRef> error;
124+- base::ScopedCFTypeRef<CFDataRef> signature_ref(SecKeyCreateSignature(
125+- key_, sec_algorithm, digest_ref, error.InitializeInto()));
126+- if (!signature_ref) {
127+- LOG(ERROR) << error;
128+- return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
129+- }
130+-
131+- signature->assign(
132+- CFDataGetBytePtr(signature_ref),
133+- CFDataGetBytePtr(signature_ref) + CFDataGetLength(signature_ref));
134+- return OK;
135+- }
136+-
137+- private:
138+- std::vector<uint16_t> preferences_;
139+- base::ScopedCFTypeRef<SecKeyRef> key_;
140+-
141+- DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeySecKey);
142+-};
143+-
144+ scoped_refptr<SSLPrivateKey> CreateSSLPrivateKeyForSecKey(
145+ const X509Certificate* certificate,
146+ SecKeyRef private_key) {
147+@@ -298,13 +180,6 @@ scoped_refptr<SSLPrivateKey> CreateSSLPrivateKeyForSecKey(
148+ if (!GetClientCertInfo(certificate, &key_type, &max_length))
149+ return nullptr;
150+
151+- if (base::mac::IsAtLeastOS10_12()) {
152+- return base::MakeRefCounted<ThreadedSSLPrivateKey>(
153+- std::make_unique<SSLPlatformKeySecKey>(key_type, max_length,
154+- private_key),
155+- GetSSLPlatformKeyTaskRunner());
156+- }
157+-
158+ const CSSM_KEY* cssm_key;
159+ OSStatus status = SecKeyGetCSSMKey(private_key, &cssm_key);
160+ if (status != noErr) {
pkgs/development/libraries/qt-5/modules/qtwebengine.nix+67−11
@@ -12,7 +12,8 @@
1212, pciutils
1313, systemd
1414, enableProprietaryCodecs ? true
15−, gn, darwin, openbsm
15+, gn
16+, cups, darwin, openbsm, runCommand, xcbuild
1617, ffmpeg ? null
1718, lib, stdenv
1819}:
@@ -26,7 +27,7 @@ qtModule {
2627 qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ];
2728 nativeBuildInputs = [
2829 bison coreutils flex git gperf ninja pkgconfig python2 which gn
29− ];
30+ ] ++ optional stdenv.isDarwin xcbuild;
3031 doCheck = true;
3132 outputs = [ "bin" "dev" "out" ];
3233
@@ -65,33 +66,46 @@ qtModule {
6566 sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
6667 src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
6768 ''
68− + optionalString stdenv.isDarwin ''
69+ + optionalString stdenv.isDarwin (''
6970 # Remove annoying xcode check
7071 substituteInPlace mkspecs/features/platform.prf \
71− --replace "lessThan(QMAKE_XCODE_VERSION, 7.3)" false
72+ --replace "lessThan(QMAKE_XCODE_VERSION, 7.3)" false \
73+ --replace "/usr/bin/xcodebuild" "xcodebuild"
74+
75+ substituteInPlace src/3rdparty/chromium/build/mac_toolchain.py \
76+ --replace "/usr/bin/xcode-select" "xcode-select"
77+
7278 substituteInPlace src/core/config/mac_osx.pri \
7379 --replace /usr ${stdenv.cc} \
7480 --replace "isEmpty(QMAKE_MAC_SDK_VERSION)" false
7581
76− # FIXME Needed with old Apple SDKs
77− # Abandon all hope ye who try to make sense of this.
82+ ''
83+ # TODO remove when new Apple SDK is in
84+ + (if builtins.compareVersions qtCompatVersion "5.11" < 0 then ''
7885 substituteInPlace src/3rdparty/chromium/base/mac/foundation_util.mm \
7986 --replace "NSArray<NSString*>*" "NSArray*"
8087 substituteInPlace src/3rdparty/chromium/base/mac/sdk_forward_declarations.h \
8188 --replace "NSDictionary<VNImageOption, id>*" "NSDictionary*" \
8289 --replace "NSArray<VNRequest*>*" "NSArray*" \
8390 --replace "typedef NSString* VNImageOption NS_STRING_ENUM" "typedef NSString* VNImageOption"
91+ '' else ''
92+ substituteInPlace src/3rdparty/chromium/third_party/webrtc/sdk/objc/Framework/Classes/Common/RTCFieldTrials.mm \
93+ --replace "NSDictionary<NSString *, NSString *> *" "NSDictionary*"
94+ substituteInPlace src/3rdparty/chromium/third_party/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCFieldTrials.h \
95+ --replace "NSDictionary<NSString *, NSString *> *" "NSDictionary*"
96+ '')
97+ + ''
8498
8599 cat <<EOF > src/3rdparty/chromium/build/mac/find_sdk.py
86100#!/usr/bin/env python
101+print("${darwin.apple_sdk.sdk}")
87102print("10.10.0")
88−print("")
89103EOF
90104
91105 cat <<EOF > src/3rdparty/chromium/build/config/mac/sdk_info.py
92106#!/usr/bin/env python
93−print('xcode_version="9.1"')
94−print('xcode_version_int=9')
107+print('xcode_version="0910"')
108+print('xcode_version_int=910')
95109print('xcode_build="9B55"')
96110print('machine_os_build="17E199"')
97111print('sdk_path=""')
@@ -100,12 +114,32 @@ print('sdk_platform_path=""')
100114print('sdk_build="17B41"')
101115EOF
102116
117+ substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
118+ --replace '$sysroot/usr' "${darwin.xnu}"
119+
103120 # Apple has some secret stuff they don't share with OpenBSM
104121 substituteInPlace src/3rdparty/chromium/base/mac/mach_port_broker.mm \
105122 --replace "audit_token_to_pid(msg.trailer.msgh_audit)" "msg.trailer.msgh_audit.val[5]"
106− '';
107123
108− NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10 -DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10";
124+ substituteInPlace src/3rdparty/chromium/sandbox/mac/BUILD.gn \
125+ --replace 'libs = [ "sandbox" ]' 'libs = [ "/usr/lib/libsandbox.1.dylib" ]'
126+ '');
127+
128+ NIX_CFLAGS_COMPILE =
129+ lib.optionalString stdenv.isDarwin [
130+ "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10"
131+ "-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10"
132+
133+ #
134+ # Prevent errors like
135+ # /nix/store/xxx-apple-framework-CoreData/Library/Frameworks/CoreData.framework/Headers/NSEntityDescription.h:51:7:
136+ # error: pointer to non-const type 'id' with no explicit ownership
137+ # id** _kvcPropertyAccessors;
138+ #
139+ # TODO remove when new Apple SDK is in
140+ #
141+ "-fno-objc-arc"
142+ ];
109143
110144 preConfigure = ''
111145 export NINJAFLAGS=-j$NIX_BUILD_CORES
@@ -160,7 +194,10 @@ EOF
160194
161195 # frameworks
162196 ApplicationServices
197+ AVFoundation
163198 Foundation
199+ ForceFeedback
200+ GameController
164201 AppKit
165202 ImageCaptureCore
166203 CoreBluetooth
@@ -169,12 +206,31 @@ EOF
169206 Quartz
170207 Cocoa
171208
209+ cups
172210 openbsm
173211 libunwind
174212 ]);
175213
214+ buildInputs = optionals stdenv.isDarwin (with darwin; [
215+ # For sandbox.h include
216+ (runCommand "MacOS_SDK_sandbox.h" {} ''
217+ install -Dm444 "${lib.getDev darwin.apple_sdk.sdk}"/include/sandbox.h "$out"/include/sandbox.h
218+ '')
219+
220+ # For:
221+ # _NSDefaultRunLoopMode
222+ # _OBJC_CLASS_$_NSDate
223+ # _OBJC_CLASS_$_NSDictionary
224+ # _OBJC_CLASS_$_NSRunLoop
225+ # _OBJC_CLASS_$_NSURL
226+ darwin.cf-private
227+ ]);
228+
229+ __impureHostDeps = optional stdenv.isDarwin "/usr/lib/libsandbox.1.dylib";
230+
176231 dontUseNinjaBuild = true;
177232 dontUseNinjaInstall = true;
233+ dontUseXcbuild = true;
178234
179235 postInstall = lib.optionalString stdenv.isLinux ''
180236 cat > $out/libexec/qt.conf <<EOF