From 261db3836286af02200cce70481b89e9f85a50a6 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Tue, 30 Mar 2021 14:27:44 -0700 Subject: [PATCH] Remove compiler:exceptions config and add indirectly sources, visibility and include_rules to bitcoin-core --- .github/CODEOWNERS | 3 + DEPS | 1 + .../third_party/bitcoin-core/src/src/DEPS | 3 + .../bitcoin-core/src/src/serialize.h | 28 ++++++++ components/brave_wallet/browser/DEPS | 3 + third_party/bitcoin-core/BUILD.gn | 64 +++++++++++++++++-- 6 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 chromium_src/brave/third_party/bitcoin-core/src/src/DEPS create mode 100644 chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e1a560b0cb4..6541c19fffe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -72,3 +72,6 @@ components/brave_perf_predictor/ @iefremov # Java patching build/android/bytecode/ @samartnik patches/*.java.patch @samartnik + +# Bitcoin-core +third_party/bitcoin-core/BUILD.gn @orspetol diff --git a/DEPS b/DEPS index 621aa653ce2..2cb08578ba5 100644 --- a/DEPS +++ b/DEPS @@ -74,6 +74,7 @@ include_rules = [ "-brave/renderer", "-brave/services", "-ios", + "-brave/third_party/bitcoin-core", ] # Temporary workaround for massive nummber of incorrect test includes diff --git a/chromium_src/brave/third_party/bitcoin-core/src/src/DEPS b/chromium_src/brave/third_party/bitcoin-core/src/src/DEPS new file mode 100644 index 00000000000..ea6ab9663b6 --- /dev/null +++ b/chromium_src/brave/third_party/bitcoin-core/src/src/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+../../../../../../third_party/bitcoin-core/src/src", +] diff --git a/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h b/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h new file mode 100644 index 00000000000..6ba55656674 --- /dev/null +++ b/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2021 The Brave Authors. All rights reserved. + * 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/. */ + +#ifndef BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ +#define BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ + +#include +#include + +#include "base/check.h" + +namespace std { +namespace brave { +using string = ::std::string; +} +} // namespace std + +#define throw CHECK(false) << +#define ios_base brave +#define failure string +#include "../../../../../../third_party/bitcoin-core/src/src/serialize.h" +#undef throw +#undef ios_base +#undef string + +#endif // BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ diff --git a/components/brave_wallet/browser/DEPS b/components/brave_wallet/browser/DEPS index 4539c4fa495..35cfcbc4fa8 100644 --- a/components/brave_wallet/browser/DEPS +++ b/components/brave_wallet/browser/DEPS @@ -6,4 +6,7 @@ include_rules = [ "+extensions/common", "+services/network/public/cpp", "+third_party/boringssl", + "+brave/third_party/bitcoin-core/src/src/base58.h", + "+brave/third_party/bitcoin-core/src/src/crypto/ripemd160.h", + "+brave/third_party/bitcoin-core/src/src/secp256k1/include/secp256k1.h", ] diff --git a/third_party/bitcoin-core/BUILD.gn b/third_party/bitcoin-core/BUILD.gn index b3112c5b8ed..139bc99e57d 100644 --- a/third_party/bitcoin-core/BUILD.gn +++ b/third_party/bitcoin-core/BUILD.gn @@ -6,28 +6,49 @@ config("warnings") { } } -config("bitcoin-core_config") { - include_dirs = [ "src/src" ] +config("external_config") { + # Use full path for the override location because the include looks in the + # root + include_dirs = [ + "//brave/chromium_src/brave/third_party/bitcoin-core/src/src", + "src/src", + ] } static_library("bitcoin-core") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code", - "//build/config/compiler:exceptions", ":warnings", ] - public_configs = [ ":bitcoin-core_config" ] + public_configs = [ ":external_config" ] + visibility = [ "//brave/components/brave_wallet/browser" ] + + # Do NOT add any files here without security review sources = [ "src/src/base58.cpp", "src/src/base58.h", "src/src/crypto/ripemd160.cpp", "src/src/crypto/ripemd160.h", + ] + + sources += [ + "//brave/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h", + "src/src/attributes.h", + "src/src/crypto/common.h", + "src/src/crypto/hmac_sha512.cpp", + "src/src/crypto/hmac_sha512.h", "src/src/crypto/sha256.cpp", "src/src/crypto/sha256.h", + "src/src/hash.cpp", + "src/src/hash.h", + "src/src/span.h", + "src/src/util/strencodings.h", ] + + deps = [ "//base" ] } static_library("secp256k1") { @@ -46,9 +67,44 @@ static_library("secp256k1") { "ECMULT_GEN_PREC_BITS=4", ] + visibility = [ "//brave/components/brave_wallet/browser" ] + + # Do NOT add any files here without security review sources = [ "src/src/secp256k1/include/secp256k1.h", "src/src/secp256k1/include/secp256k1_preallocated.h", "src/src/secp256k1/src/secp256k1.c", ] + + sources += [ + "src/src/secp256k1/src/assumptions.h", + "src/src/secp256k1/src/ecdsa.h", + "src/src/secp256k1/src/ecdsa_impl.h", + "src/src/secp256k1/src/eckey.h", + "src/src/secp256k1/src/eckey_impl.h", + "src/src/secp256k1/src/ecmult.h", + "src/src/secp256k1/src/ecmult_const.h", + "src/src/secp256k1/src/ecmult_const_impl.h", + "src/src/secp256k1/src/ecmult_gen.h", + "src/src/secp256k1/src/ecmult_gen_impl.h", + "src/src/secp256k1/src/ecmult_impl.h", + "src/src/secp256k1/src/field.h", + "src/src/secp256k1/src/field_10x26.h", + "src/src/secp256k1/src/field_10x26_impl.h", + "src/src/secp256k1/src/field_impl.h", + "src/src/secp256k1/src/group.h", + "src/src/secp256k1/src/group_impl.h", + "src/src/secp256k1/src/hash.h", + "src/src/secp256k1/src/hash_impl.h", + "src/src/secp256k1/src/num.h", + "src/src/secp256k1/src/num_impl.h", + "src/src/secp256k1/src/scalar.h", + "src/src/secp256k1/src/scalar_8x32.h", + "src/src/secp256k1/src/scalar_8x32_impl.h", + "src/src/secp256k1/src/scalar_impl.h", + "src/src/secp256k1/src/scratch.h", + "src/src/secp256k1/src/scratch_impl.h", + "src/src/secp256k1/src/selftest.h", + "src/src/secp256k1/src/util.h", + ] }