diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000000..2062c74d10 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,2 @@ +build --strategy=Genrule=local +build --apple_platform_type=ios diff --git a/Config/objc_module_provider.bzl b/Config/objc_module_provider.bzl index dfa41c95c7..a09f214a85 100644 --- a/Config/objc_module_provider.bzl +++ b/Config/objc_module_provider.bzl @@ -25,7 +25,7 @@ objc_module = rule( attrs = { "module_name": attr.string(mandatory = True), "headers": attr.label_list( - allow_files = [".h", ".hpp"], + allow_files = [".h"], ), }, ) diff --git a/Wallet.makefile b/Wallet.makefile index 707bcffd39..c5c09f8340 100644 --- a/Wallet.makefile +++ b/Wallet.makefile @@ -18,6 +18,8 @@ WALLET_BUCK_OPTIONS=\ --config custom.appStoreId="${APPSTORE_ID}" \ --config custom.appSpecificUrlScheme="${APP_SPECIFIC_URL_SCHEME}" +BAZEL=$(shell which bazel) + wallet_deps: check_env $(BUCK) query "deps(//Wallet:AppPackage)" --output-attribute buck.type \ ${WALLET_BUCK_OPTIONS} ${BUCK_RELEASE_OPTIONS} @@ -48,3 +50,5 @@ wallet_package: wallet_app: build_wallet wallet_package +tulsi_project: + ${HOME}/Applications/Tulsi.app/Contents/MacOS/Tulsi -- --genconfig Wallet/Wallet.tulsiproj:Default --bazel "${BAZEL}" diff --git a/Wallet/BUILD b/Wallet/BUILD index 1cf3f04dcc..a6e26e767f 100644 --- a/Wallet/BUILD +++ b/Wallet/BUILD @@ -46,6 +46,7 @@ swift_library( "//submodules/ActivityIndicator:ActivityIndicator", "//submodules/OverlayStatusController:OverlayStatusController", "//submodules/openssl:openssl", + "//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider", ], ) diff --git a/Wallet/Wallet.tulsiproj/Configs/Default.tulsigen b/Wallet/Wallet.tulsiproj/Configs/Default.tulsigen index d8a9004445..48cf94fa8c 100644 --- a/Wallet/Wallet.tulsiproj/Configs/Default.tulsigen +++ b/Wallet/Wallet.tulsiproj/Configs/Default.tulsigen @@ -9,7 +9,7 @@ ], "optionSet" : { "BazelBuildOptionsDebug" : { - "p" : "$(inherited) -k --features=swift.use_global_module_cache --features=swift.swift.no_generated_header --spawn_strategy=standalone --strategy=SwiftCompile=standalone -s" + "p" : "$(inherited) --features=swift.use_global_module_cache --features=swift.swift.no_generated_header --spawn_strategy=standalone --strategy=SwiftCompile=standalone" }, "BazelBuildOptionsRelease" : { "p" : "$(inherited)" diff --git a/build-system/bazel-rules/apple_support b/build-system/bazel-rules/apple_support index 9605c3da1c..501b4afb27 160000 --- a/build-system/bazel-rules/apple_support +++ b/build-system/bazel-rules/apple_support @@ -1 +1 @@ -Subproject commit 9605c3da1c5bcdddc20d1704b52415a6f3a5f422 +Subproject commit 501b4afb27745c4813a88ffa28acd901408014e4 diff --git a/build-system/bazel-rules/rules_apple b/build-system/bazel-rules/rules_apple index f6a95e8d0c..8dc8e519df 160000 --- a/build-system/bazel-rules/rules_apple +++ b/build-system/bazel-rules/rules_apple @@ -1 +1 @@ -Subproject commit f6a95e8d0c2bd6fa9f0a6280ef3c4d34c9594513 +Subproject commit 8dc8e519df3ab06c9842a9e6396edf592104c46b diff --git a/build-system/bazel-rules/rules_swift b/build-system/bazel-rules/rules_swift index e7ce2d1393..46d309a56e 160000 --- a/build-system/bazel-rules/rules_swift +++ b/build-system/bazel-rules/rules_swift @@ -1 +1 @@ -Subproject commit e7ce2d13936a1fe234317f228ef7194f27f8520a +Subproject commit 46d309a56e638830a9844e65d5531262a8afab99 diff --git a/submodules/EncryptionProvider/BUILD b/submodules/EncryptionProvider/BUILD new file mode 100644 index 0000000000..7eef074060 --- /dev/null +++ b/submodules/EncryptionProvider/BUILD @@ -0,0 +1,15 @@ +objc_library( + name = "EncryptionProvider", + srcs = glob([ + "Sources/**/*.m", + ]), + hdrs = glob([ + "Sources/**/*.h", + ]), + includes = [ + "Sources/Public", + ], + deps = [ + ], + visibility = ["//visibility:public"], +) diff --git a/submodules/EncryptionProvider/Sources/EncryptionProvider.h b/submodules/EncryptionProvider/Sources/Public/EncryptionProvider/EncryptionProvider.h similarity index 100% rename from submodules/EncryptionProvider/Sources/EncryptionProvider.h rename to submodules/EncryptionProvider/Sources/Public/EncryptionProvider/EncryptionProvider.h diff --git a/submodules/OpenSSLEncryptionProvider/BUILD b/submodules/OpenSSLEncryptionProvider/BUILD new file mode 100644 index 0000000000..b6eca063e5 --- /dev/null +++ b/submodules/OpenSSLEncryptionProvider/BUILD @@ -0,0 +1,14 @@ +objc_library( + name = "OpenSSLEncryptionProvider", + srcs = glob([ + "Sources/**/*.m", + ]), + hdrs = glob([ + "Sources/**/*.h", + ]), + deps = [ + "//submodules/EncryptionProvider:EncryptionProvider", + "//submodules/openssl:openssl", + ], + visibility = ["//visibility:public"], +) diff --git a/submodules/openssl/BUILD b/submodules/openssl/BUILD index 7820d80098..89e571933e 100644 --- a/submodules/openssl/BUILD +++ b/submodules/openssl/BUILD @@ -1,3 +1,7 @@ +load( + "//Config/objc_module_provider.bzl", + "objc_module", +) openssl_headers = [ "aes.h", @@ -106,9 +110,11 @@ openssl_headers = [ "x509v3err.h", ] -openssl_header_paths = ["openssl/" + header for header in openssl_headers] +openssl_libs = [ + "libcrypto.a", +] -archs = ["arm64"]#, "armv7", "x86_64"] +archs = ["arm64", "armv7", "x86_64"] rules = [ genrule( @@ -119,36 +125,58 @@ rules = [ "patch-conf.patch", "patch-include.patch", ], - cmd_bash = "cp $(SRCS) $(RULEDIR)/ && sh $(RULEDIR)/build-openssl.sh $(RULEDIR) $(RULEDIR) " + arch, - outs = openssl_headers, + cmd_bash = + "mkdir -p $(RULEDIR)/{} && cp $(SRCS) $(RULEDIR)/{}/ && sh $(RULEDIR)/{}/build-openssl.sh $(RULEDIR)/{} $(RULEDIR)/{} ".format(arch, arch, arch, arch, arch) + arch + "\n" + + ("\n".join(["cp \"$(RULEDIR)/{}/build/arm64/include/openssl/{}\" \"$(location :{})\"\n".format(arch, x, x) for x in openssl_headers]) if arch == "arm64" else "") + + "\n".join([ + "cp \"$(RULEDIR)/{}/build/{}/lib/{}\" \"$(location :{})\"\n".format(arch, arch, x, arch + "_" + x) for x in openssl_libs + ]), + outs = + (openssl_headers if arch == "arm64" else []) + + [arch + "_" + x for x in openssl_libs], visibility = [ "//visibility:public", ] ) for arch in archs ] -''' genrule( - name = "openssl_build_merged", - srcs = [ - "pack-openssl.sh", - ], - bash = "sh $SRCDIR/pack-openssl.sh $OUT $(location :openssl_build_arm64)/out/include " + " ".join(["$(location :openssl_build_" + arch + ")/out/lib/libcrypto.a" for arch in archs]), - out = "openssl", + name = "openssl_fat_libraries", + srcs = [":" + arch + "_" + openssl_libs[0] for arch in archs], + cmd_bash = "xcrun lipo {} -output {} -create".format(" ".join(["$(location :" + arch + "_" + openssl_libs[0] + ")" for arch in archs]), "$(location " + openssl_libs[0] + ")"), + outs = openssl_libs, visibility = [ - "PUBLIC", - ] + "//visibility:public", + ], ) -''' -#openssl_header_targets = gen_header_targets(openssl_header_paths, "openssl_header_", "", "openssl_build_arm64", "out/include") +genrule( + name = "openssl_include", + srcs = [":" + x for x in openssl_headers], + outs = ["Public/openssl/" + x for x in openssl_headers], + cmd_bash = " && ".join(["cp $(location :{}) $(location Public/openssl/{})".format(x, x) for x in openssl_headers]), + visibility = [ + "//visibility:public", + ], +) + +cc_library( + name = "openssl_lib", + srcs = [":" + x for x in openssl_libs], +) objc_library( name = "openssl", module_name = "openssl", enable_modules = True, - hdrs = [":" + x for x in openssl_headers], - deps = [], + hdrs = ["Public/openssl/" + x for x in openssl_headers], + includes = [ + "Public/openssl", + ], + deps = [ + ":openssl_lib", + ], + , visibility = [ "//visibility:public", ] diff --git a/submodules/openssl/build-openssl.sh b/submodules/openssl/build-openssl.sh index e44fdbb751..527b8bfe52 100644 --- a/submodules/openssl/build-openssl.sh +++ b/submodules/openssl/build-openssl.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -x +set -e + OUT_DIR="$1" SRC_DIR="$2" ARCH="$3" @@ -26,7 +29,9 @@ fi mkdir -p "$OUT_DIR" -TMP_DIR="$OUT_DIR/build" +TMP_DIR_NAME="build" +TMP_DIR="$OUT_DIR/$TMP_DIR_NAME" +ABS_TMP_DIR="$(pwd)/$TMP_DIR" rm -rf "$TMP_DIR" mkdir -p "$TMP_DIR" @@ -61,6 +66,7 @@ function build_for () export CROSS_SDK="${!CROSS_SDK_ENV}" MINIMAL_FLAGS=(\ + "no-shared" \ "no-afalgeng" \ "no-aria" \ "no-asan" \ @@ -151,17 +157,17 @@ function build_for () ) DEFAULT_FLAGS=(\ + "no-shared" \ "no-asm" \ "no-ssl3" \ "no-comp" \ "no-hw" \ "no-engine" \ "no-async" \ + "no-tests" \ ) - ADDITIONAL_FLAGS=$DEFAULT_FLAGS - - ./Configure $PLATFORM "-arch $ARCH" ${ADDITIONAL_FLAGS[@]} --prefix="$(pwd)/${TMP_DIR}/${ARCH}" || exit 1 + ./Configure $PLATFORM "-arch $ARCH" ${DEFAULT_FLAGS[@]} --prefix="${ABS_TMP_DIR}/${ARCH}" || exit 1 make && make install_sw || exit 2 unset CROSS_TOP @@ -184,7 +190,9 @@ else fi cp -r "${TMP_DIR}/$ARCH/include" "${TMP_DIR}/" -patch -p3 "${TMP_DIR}/include/openssl/opensslconf.h" < "$SRC_DIR/patch-include.patch" || exit 1 +if [ "$ARCH" == "arm64" ]; then + patch -p3 "${TMP_DIR}/include/openssl/opensslconf.h" < "$SRC_DIR/patch-include.patch" || exit 1 +fi DFT_DIST_DIR="$OUT_DIR/out" rm -rf "$DFT_DIST_DIR" diff --git a/submodules/openssl/patch-include.patch b/submodules/openssl/patch-include.patch index 3b177feac6..e4b46becaa 100644 --- a/submodules/openssl/patch-include.patch +++ b/submodules/openssl/patch-include.patch @@ -1,19 +1,19 @@ ---- armv7s/include/openssl/opensslconf.h 2017-01-08 02:25:43.000000000 -0800 -+++ arm64/include/openssl/opensslconf.h 2017-01-08 03:44:44.000000000 -0800 -@@ -158,11 +158,21 @@ +--- opensslconf.h 2020-01-06 02:41:46.000000000 +0400 ++++ opensslconf_updated.h 2020-01-06 02:51:12.000000000 +0400 +@@ -205,11 +205,21 @@ * The following are cipher-specific, but are part of the public API. */ #if !defined(OPENSSL_SYS_UEFI) --# define BN_LLONG +-# undef BN_LLONG +# ifdef __LP64__ +# undef BN_LLONG +# else +# define BN_LLONG +# endif /* Only one for the following should be defined */ --# undef SIXTY_FOUR_BIT_LONG +-# define SIXTY_FOUR_BIT_LONG -# undef SIXTY_FOUR_BIT --# define THIRTY_TWO_BIT +-# undef THIRTY_TWO_BIT +# ifdef __LP64__ +# define SIXTY_FOUR_BIT_LONG +# undef SIXTY_FOUR_BIT