git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #53848 from veprbl/pr/qtwebengine_darwin_fix

qt511.qtwebengine: fix on darwin

commitddcf01bca6c7a7a7f096bec836a1e6a707ad473d authorSilvan Mosberger <infinisil@icloud.com> dateMon 28 Jan 2019, 02:41 (8 years ago) parentd5881eb56dcf6e
5 files changed+263−12
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+69−12 pkgs/development/tools/xcbuild/toolchains.nix+1
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+69−12
@@ -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
@@ -42,7 +43,7 @@ qtModule {
4243 ( cd src/3rdparty/chromium; patchShebangs . )
4344 ''
4445 # Patch Chromium build files
45− + optionalString (builtins.compareVersions qtCompatVersion "5.12" < 0) ''
46+ + optionalString (lib.versionOlder qtCompatVersion "5.12") ''
4647 substituteInPlace ./src/3rdparty/chromium/build/common.gypi --replace /bin/echo ${coreutils}/bin/echo
4748 substituteInPlace ./src/3rdparty/chromium/v8/${if qt56 then "build" else "gypfiles"}/toolchain.gypi \
4849 --replace /bin/echo ${coreutils}/bin/echo
@@ -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 lib.versionOlder qtCompatVersion "5.11" 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
@@ -173,8 +210,28 @@ EOF
173210 libunwind
174211 ]);
175212
213+ buildInputs = optionals stdenv.isDarwin (with darwin; [
214+ cups
215+
216+ # For sandbox.h include
217+ (runCommand "MacOS_SDK_sandbox.h" {} ''
218+ install -Dm444 "${lib.getDev darwin.apple_sdk.sdk}"/include/sandbox.h "$out"/include/sandbox.h
219+ '')
220+
221+ # For:
222+ # _NSDefaultRunLoopMode
223+ # _OBJC_CLASS_$_NSDate
224+ # _OBJC_CLASS_$_NSDictionary
225+ # _OBJC_CLASS_$_NSRunLoop
226+ # _OBJC_CLASS_$_NSURL
227+ darwin.cf-private
228+ ]);
229+
230+ __impureHostDeps = optional stdenv.isDarwin "/usr/lib/libsandbox.1.dylib";
231+
176232 dontUseNinjaBuild = true;
177233 dontUseNinjaInstall = true;
234+ dontUseXcbuild = true;
178235
179236 postInstall = lib.optionalString stdenv.isLinux ''
180237 cat > $out/libexec/qt.conf <<EOF
pkgs/development/tools/xcbuild/toolchains.nix+1
@@ -67,5 +67,6 @@ runCommand "Toolchains" {} (''
6767 done
6868
6969 ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/bin
70+ ln -s ${buildPackages.darwin.bootstrap_cmds}/libexec/migcom $toolchain/libexec
7071 ln -s ${mkdep-darwin-src} $toolchain/bin/mkdep
7172'')