diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 15d27c69bb..ba1f88f059 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-18.04 timeout-minutes: 45 container: - image: envoyproxy/envoy-build-ubuntu:5a096881181dbe478f642b7ac02a68e9591e933d + image: envoyproxy/envoy-build-ubuntu:04f06115b6ee7cfea74930353fb47a41149cbec3 steps: - uses: actions/checkout@v1 with: diff --git a/BUILD b/BUILD index 3d391031b4..9bb5d78437 100644 --- a/BUILD +++ b/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@io_bazel_rules_kotlin//kotlin/internal:toolchains.bzl", "define_kt_toolchain") +licenses(["notice"]) # Apache 2 + alias( name = "ios_framework", actual = "//library/swift/src:ios_framework", diff --git a/bazel/BUILD b/bazel/BUILD index 4322708988..0185b275a3 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -1,8 +1,8 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") +licenses(["notice"]) # Apache 2 + envoy_package() kt_jvm_library( diff --git a/bazel/aar_with_jni.bzl b/bazel/aar_with_jni.bzl index 3c4d3402b7..e9240b33c2 100644 --- a/bazel/aar_with_jni.bzl +++ b/bazel/aar_with_jni.bzl @@ -1,3 +1,5 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@build_bazel_rules_android//android:rules.bzl", "android_binary") load("@google_bazel_common//tools/maven:pom_file.bzl", "pom_file") # This file is based on https://github.com/aj-michael/aar_with_jni which is @@ -63,13 +65,13 @@ EOF # We wrap our native so dependencies in a cc_library because android_binaries # require a library target as dependencies in order to generate the appropriate # architectures in the directory `lib/` - native.cc_library( + cc_library( name = cc_lib_name, srcs = native_deps, ) # This outputs {jni_archive_name}_unsigned.apk which will contain the base files for our aar - native.android_binary( + android_binary( name = jni_archive_name, manifest = archive_name + "_generated_AndroidManifest.xml", custom_package = "does.not.matter", @@ -79,7 +81,7 @@ EOF # This creates bazel-bin/library/kotlin/src/io/envoyproxy/envoymobile/name_bin_deploy.jar # This jar has all the classes needed for our aar and will be our `classes.jar` - native.android_binary( + android_binary( name = android_binary_name, manifest = manifest, srcs = [], diff --git a/bazel/envoy_mobile_repositories.bzl b/bazel/envoy_mobile_repositories.bzl index 49b8e5ece2..7353113acd 100644 --- a/bazel/envoy_mobile_repositories.bzl +++ b/bazel/envoy_mobile_repositories.bzl @@ -11,6 +11,7 @@ def envoy_mobile_repositories(): upstream_envoy_overrides() swift_repos() kotlin_repos() + android_repos() def upstream_envoy_overrides(): # Patch protobuf to prevent duplicate symbols: https://github.com/lyft/envoy-mobile/issues/617 @@ -122,3 +123,11 @@ def kotlin_repos(): sha256 = "4c73eee92dd652ea8e2afd7b20732cf863d4938a30f634d12c88fe64def89fd8", url = "https://github.com/Kotlin/dokka/releases/download/0.9.18/dokka-fatjar-0.9.18.jar", ) + +def android_repos(): + http_archive( + name = "build_bazel_rules_android", + urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"], + sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + strip_prefix = "rules_android-0.1.1", + ) diff --git a/bazel/kotlin_lib.bzl b/bazel/kotlin_lib.bzl index 1b2bf455a8..34c2babbe7 100644 --- a/bazel/kotlin_lib.bzl +++ b/bazel/kotlin_lib.bzl @@ -1,4 +1,4 @@ -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library", "kt_jvm_library") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") def envoy_mobile_kt_library(name, visibility = None, srcs = [], deps = []): # These source files must be re-exported to the kotlin custom library rule to ensure their diff --git a/dist/BUILD b/dist/BUILD index 5ba2f5b5f6..a0c1c0d9d3 100644 --- a/dist/BUILD +++ b/dist/BUILD @@ -1,7 +1,8 @@ -licenses(["notice"]) # Apache 2 - +load("@build_bazel_rules_android//android:rules.bzl", "aar_import") load("@build_bazel_rules_apple//apple:apple.bzl", "apple_static_framework_import") +licenses(["notice"]) # Apache 2 + # NOTE: You must first build the top-level targets //:ios_dist and //:android_dist to use the # artifacts referenced here. # You can also download the distributables referenced here from envoy-mobile's releases page: diff --git a/envoy b/envoy index 48a5b21d94..ff40a02a83 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit 48a5b21d9483e7eddac79aeff7daac178d7b7462 +Subproject commit ff40a02a838d123f4bf018858c61c983e1c5cce9 diff --git a/examples/java/hello_world/BUILD b/examples/java/hello_world/BUILD index cd109a0e13..d272161670 100644 --- a/examples/java/hello_world/BUILD +++ b/examples/java/hello_world/BUILD @@ -1,7 +1,8 @@ -licenses(["notice"]) # Apache 2 - +load("@build_bazel_rules_android//android:rules.bzl", "android_binary") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +licenses(["notice"]) # Apache 2 + android_binary( name = "hello_envoy", custom_package = "io.envoyproxy.envoymobile.helloenvoy", diff --git a/examples/kotlin/hello_world/BUILD b/examples/kotlin/hello_world/BUILD index dd86d37d29..07bee885f2 100644 --- a/examples/kotlin/hello_world/BUILD +++ b/examples/kotlin/hello_world/BUILD @@ -1,8 +1,9 @@ -licenses(["notice"]) # Apache 2 - +load("@build_bazel_rules_android//android:rules.bzl", "android_binary") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_detekt//detekt:defs.bzl", "detekt") +licenses(["notice"]) # Apache 2 + android_binary( name = "hello_envoy_kt", custom_package = "io.envoyproxy.envoymobile.helloenvoykotlin", diff --git a/examples/kotlin/shared/BUILD b/examples/kotlin/shared/BUILD index e9e02c68d9..beab458412 100644 --- a/examples/kotlin/shared/BUILD +++ b/examples/kotlin/shared/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +licenses(["notice"]) # Apache 2 + kt_android_library( name = "hello_envoy_shared_lib", srcs = [ diff --git a/examples/objective-c/hello_world/BUILD b/examples/objective-c/hello_world/BUILD index 9d221180bc..141c86fa37 100644 --- a/examples/objective-c/hello_world/BUILD +++ b/examples/objective-c/hello_world/BUILD @@ -1,7 +1,8 @@ -licenses(["notice"]) # Apache 2 - +load("@rules_cc//cc:defs.bzl", "objc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") +licenses(["notice"]) # Apache 2 + objc_library( name = "appmain", srcs = glob([ diff --git a/examples/swift/hello_world/BUILD b/examples/swift/hello_world/BUILD index aa5ca57164..2e76332990 100644 --- a/examples/swift/hello_world/BUILD +++ b/examples/swift/hello_world/BUILD @@ -1,8 +1,8 @@ -licenses(["notice"]) # Apache 2 - load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") +licenses(["notice"]) # Apache 2 + swift_library( name = "appmain", srcs = glob(["*.swift"]), diff --git a/library/common/BUILD b/library/common/BUILD index e5aae2cd99..7e4c1910c4 100644 --- a/library/common/BUILD +++ b/library/common/BUILD @@ -1,7 +1,8 @@ -licenses(["notice"]) # Apache 2 - +load("@rules_cc//cc:defs.bzl", "cc_binary") load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/common/buffer/BUILD b/library/common/buffer/BUILD index 41dde2c366..633e0d7179 100644 --- a/library/common/buffer/BUILD +++ b/library/common/buffer/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/common/extensions/BUILD b/library/common/extensions/BUILD index 7f5e95ee1b..d9f51000ed 100644 --- a/library/common/extensions/BUILD +++ b/library/common/extensions/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( @@ -12,6 +12,7 @@ envoy_cc_library( hdrs = ["registry.h"], repository = "@envoy", deps = [ + "@envoy//source/common/network:socket_lib", "@envoy//source/common/upstream:logical_dns_cluster_lib", "@envoy//source/extensions/clusters/dynamic_forward_proxy:cluster", "@envoy//source/extensions/compression/gzip/decompressor:config", diff --git a/library/common/extensions/registry.cc b/library/common/extensions/registry.cc index 84ce3da404..a6a28dabc9 100644 --- a/library/common/extensions/registry.cc +++ b/library/common/extensions/registry.cc @@ -1,5 +1,7 @@ #include "library/common/extensions/registry.h" +#include "common/network/socket_interface_impl.h" + namespace Envoy { void ExtensionRegistry::registerFactories() { @@ -14,6 +16,16 @@ void ExtensionRegistry::registerFactories() { Envoy::Extensions::StatSinks::MetricsService::forceRegisterMetricsServiceSinkFactory(); Envoy::Extensions::TransportSockets::Tls::forceRegisterUpstreamSslSocketFactory(); Envoy::Upstream::forceRegisterLogicalDnsClusterFactory(); + + // TODO: add a "force initialize" function to the upstream code, or clean up the upstream code + // in such a way that does not depend on the statically initialized variable. + // The current setup exposes in iOS the same problem as the one described in: + // https://github.com/envoyproxy/envoy/pull/7185 with the static variable declared in: + // https://github.com/envoyproxy/envoy/pull/11380/files#diff-8a5c90e5a39b2ea975170edc4434345bR138. + // For now force the compilation unit to run by creating an instance of the class declared in + // socket_interface_impl.h and immediately destroy. + auto ptr = std::make_unique(); + ptr.reset(nullptr); } } // namespace Envoy diff --git a/library/common/http/BUILD b/library/common/http/BUILD index 3b3f8b16ba..99cfe05011 100644 --- a/library/common/http/BUILD +++ b/library/common/http/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/common/network/BUILD b/library/common/network/BUILD index fd40032b9b..8c297125d7 100644 --- a/library/common/network/BUILD +++ b/library/common/network/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/common/network/synthetic_address_impl.h b/library/common/network/synthetic_address_impl.h index 6a89d9577c..ee588cd870 100644 --- a/library/common/network/synthetic_address_impl.h +++ b/library/common/network/synthetic_address_impl.h @@ -31,19 +31,13 @@ class SyntheticAddressImpl : public Instance { const std::string& logicalName() const { return address_; } - Api::SysCallIntResult bind(int) const { - // a socket should never be bound to a synthetic address. - return {-1, EADDRNOTAVAIL}; - } + const Ip* ip() const { return nullptr; } - Api::SysCallIntResult connect(int) const { - // a socket should never connect to a synthetic address. - return {-1, EPROTOTYPE}; - } + const Pipe* pipe() const { return nullptr; } - const Ip* ip() const { return nullptr; } + const sockaddr* sockAddr() const { return nullptr; } - IoHandlePtr socket(SocketType) const { return nullptr; } + socklen_t sockAddrLen() const { return 0; } Type type() const { // TODO(junr03): consider adding another type of address. diff --git a/library/common/thread/BUILD b/library/common/thread/BUILD index 030af50c60..ac067df88e 100644 --- a/library/common/thread/BUILD +++ b/library/common/thread/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/common/types/BUILD b/library/common/types/BUILD index e2281f3b56..e4a61c2cdb 100644 --- a/library/common/types/BUILD +++ b/library/common/types/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_library( diff --git a/library/java/src/io/envoyproxy/envoymobile/engine/BUILD b/library/java/src/io/envoyproxy/envoymobile/engine/BUILD index 4ae16964d1..9fa90eab32 100644 --- a/library/java/src/io/envoyproxy/envoymobile/engine/BUILD +++ b/library/java/src/io/envoyproxy/envoymobile/engine/BUILD @@ -1,3 +1,6 @@ +load("@rules_java//java:defs.bzl", "java_library") +load("@build_bazel_rules_android//android:rules.bzl", "android_library") + licenses(["notice"]) # Apache 2 android_library( diff --git a/library/java/src/io/envoyproxy/envoymobile/engine/types/BUILD b/library/java/src/io/envoyproxy/envoymobile/engine/types/BUILD index 73e92edaaa..74a09e6012 100644 --- a/library/java/src/io/envoyproxy/envoymobile/engine/types/BUILD +++ b/library/java/src/io/envoyproxy/envoymobile/engine/types/BUILD @@ -1,3 +1,5 @@ +load("@rules_java//java:defs.bzl", "java_library") + licenses(["notice"]) # Apache 2 java_library( diff --git a/library/java/test/io/envoyproxy/envoymobile/engine/BUILD b/library/java/test/io/envoyproxy/envoymobile/engine/BUILD index 6e79dabacd..8e5b044711 100644 --- a/library/java/test/io/envoyproxy/envoymobile/engine/BUILD +++ b/library/java/test/io/envoyproxy/envoymobile/engine/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("//bazel:kotlin_test.bzl", "envoy_mobile_kt_test") +licenses(["notice"]) # Apache 2 + envoy_mobile_kt_test( name = "envoy_configuration_test", srcs = [ diff --git a/library/kotlin/src/io/envoyproxy/envoymobile/BUILD b/library/kotlin/src/io/envoyproxy/envoymobile/BUILD index 4282f6f3ce..289a912e04 100644 --- a/library/kotlin/src/io/envoyproxy/envoymobile/BUILD +++ b/library/kotlin/src/io/envoyproxy/envoymobile/BUILD @@ -1,10 +1,10 @@ -licenses(["notice"]) # Apache 2 - load("//bazel:aar_with_jni.bzl", "aar_with_jni") load("//bazel:kotlin_lib.bzl", "envoy_mobile_kt_library") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_detekt//detekt:defs.bzl", "detekt") +licenses(["notice"]) # Apache 2 + aar_with_jni( name = "android_aar", android_library = ":envoy_lib", diff --git a/library/kotlin/test/io/envoyproxy/envoymobile/BUILD b/library/kotlin/test/io/envoyproxy/envoymobile/BUILD index a12ec6feee..a6eccc385d 100644 --- a/library/kotlin/test/io/envoyproxy/envoymobile/BUILD +++ b/library/kotlin/test/io/envoyproxy/envoymobile/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("//bazel:kotlin_test.bzl", "envoy_mobile_kt_test") +licenses(["notice"]) # Apache 2 + envoy_mobile_kt_test( name = "request_builder_test", srcs = [ diff --git a/library/objective-c/BUILD b/library/objective-c/BUILD index ee13413674..5990b9240b 100644 --- a/library/objective-c/BUILD +++ b/library/objective-c/BUILD @@ -1,3 +1,5 @@ +load("@rules_cc//cc:defs.bzl", "objc_library") + licenses(["notice"]) # Apache 2 exports_files([ diff --git a/library/swift/test/BUILD b/library/swift/test/BUILD index 90b50a756e..3ebb95bc32 100644 --- a/library/swift/test/BUILD +++ b/library/swift/test/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("//bazel:swift_test.bzl", "envoy_mobile_swift_test") +licenses(["notice"]) # Apache 2 + envoy_mobile_swift_test( name = "envoy_client_tests", srcs = [ diff --git a/test/common/BUILD b/test/common/BUILD index 67c0af6c51..eb2e037b88 100644 --- a/test/common/BUILD +++ b/test/common/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/common/buffer/BUILD b/test/common/buffer/BUILD index 6ed984bdeb..fe14f77453 100644 --- a/test/common/buffer/BUILD +++ b/test/common/buffer/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/common/http/BUILD b/test/common/http/BUILD index 736a6be03e..e7fecd8e11 100644 --- a/test/common/http/BUILD +++ b/test/common/http/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/common/network/BUILD b/test/common/network/BUILD index 25d13549fd..eb8da00aff 100644 --- a/test/common/network/BUILD +++ b/test/common/network/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/common/network/synthetic_address_impl_test.cc b/test/common/network/synthetic_address_impl_test.cc index 8f24540574..12fdd82388 100644 --- a/test/common/network/synthetic_address_impl_test.cc +++ b/test/common/network/synthetic_address_impl_test.cc @@ -18,23 +18,12 @@ TEST(SyntheticAddressImplTest, Names) { ASSERT_EQ(address.logicalName(), "synthetic"); } -TEST(SyntheticAddressImplTest, Syscalls) { - SyntheticAddressImpl address; - - const Api::SysCallIntResult bind_rc = address.bind(0); - ASSERT_EQ(bind_rc.rc_, -1); - ASSERT_EQ(bind_rc.errno_, EADDRNOTAVAIL); - - const Api::SysCallIntResult connect_rc = address.connect(0); - ASSERT_EQ(connect_rc.rc_, -1); - ASSERT_EQ(connect_rc.errno_, EPROTOTYPE); -} - TEST(SyntheticAddressImplTest, Accessors) { SyntheticAddressImpl address; ASSERT_EQ(address.ip(), nullptr); - ASSERT_EQ(address.socket(SocketType::Datagram), nullptr); - ASSERT_EQ(address.socket(SocketType::Stream), nullptr); + ASSERT_EQ(address.pipe(), nullptr); + ASSERT_EQ(address.sockAddr(), nullptr); + ASSERT_EQ(address.sockAddrLen(), 0); } TEST(SyntheticAddressImplTest, Type) { diff --git a/test/common/thread/BUILD b/test/common/thread/BUILD index 0d0caaffc2..a4d283d0ff 100644 --- a/test/common/thread/BUILD +++ b/test/common/thread/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/integration/BUILD b/test/integration/BUILD index 6d1d89ad48..a29be7cc64 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_test( diff --git a/test/performance/BUILD b/test/performance/BUILD index d5aa55c38d..3b5b3c9b56 100644 --- a/test/performance/BUILD +++ b/test/performance/BUILD @@ -1,7 +1,7 @@ -licenses(["notice"]) # Apache 2 - load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_binary", "envoy_package") +licenses(["notice"]) # Apache 2 + envoy_package() envoy_cc_binary(