class Envoy < Formula desc "Cloud-native high-performance edge/middle/service proxy" homepage "https://www.envoyproxy.io/index.html" url "https://github.com/envoyproxy/envoy/archive/refs/tags/v1.27.2.tar.gz" sha256 "4844a2fb5f6c5609e908bbb0e2ae71d13e4a677efc6cccaf39677e2ee5972e8f" license "Apache-2.0" head "https://github.com/envoyproxy/envoy.git", branch: "main" livecheck do url :stable regex(/^v?(\d+(?:\.\d+)+)$/i) end bottle do sha256 cellar: :any_skip_relocation, arm64_sonoma: "cb571e6f053eab5ccc2acb5e4a39147f510591b69bc2ab35a535b6e8847cf0b8" sha256 cellar: :any_skip_relocation, arm64_ventura: "31870f5b6f7ee935ec09c238bc61358ab500eaa131df086213595a4f45adcf10" sha256 cellar: :any_skip_relocation, arm64_monterey: "c4c8aafbd969788066d5fbf65ba5b1b0f9cf3fa1fea56e780d52c2a48e0afe5f" sha256 cellar: :any_skip_relocation, sonoma: "d9576cc92d8d13d83d1f9a3a16193c11215a53b1c2907af4774cd16bc2653a89" sha256 cellar: :any_skip_relocation, ventura: "6106a757119d5c0917020798cfce4cf58afdc47fa3bbf387500212bc70727f9f" sha256 cellar: :any_skip_relocation, monterey: "dc09e84657742e6da02230b21bfc94a311d0738f8db998355f0fab7101dd452d" sha256 cellar: :any_skip_relocation, x86_64_linux: "50eaefcf6a95b2e39444a1950b94b1f44f269af11235c3ee6c3f3a7303062b30" end depends_on "automake" => :build depends_on "bazelisk" => :build depends_on "cmake" => :build depends_on "libtool" => :build depends_on "ninja" => :build # Starting with 1.21, envoy requires a full Xcode installation, not just # command-line tools. See envoyproxy/envoy#16482 depends_on xcode: :build depends_on macos: :catalina uses_from_macos "python" => :build on_macos do depends_on "coreutils" => :build end # https://github.com/envoyproxy/envoy/tree/main/bazel#supported-compiler-versions fails_with :gcc do version "8" cause "C++17 support and tcmalloc requirement" end def install # Per https://luajit.org/install.html: If MACOSX_DEPLOYMENT_TARGET # is not set then it's forced to 10.4, which breaks compile on Mojave. ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version.to_s env_path = "#{HOMEBREW_PREFIX}/bin:/usr/bin:/bin" args = %W[ --compilation_mode=opt --curses=no --verbose_failures --action_env=PATH=#{env_path} --host_action_env=PATH=#{env_path} ] if OS.linux? # Build fails with GCC 10+ at external/com_google_absl/absl/container/internal/inlined_vector.h:448:5: # error: '.absl::inlined_vector_internal::Storage >::data_' # is used uninitialized in this function [-Werror=uninitialized] # Try to remove in a release that uses a newer abseil args << "--cxxopt=-Wno-uninitialized" args << "--host_cxxopt=-Wno-uninitialized" else # The clang available on macOS catalina has a warning that isn't clean on v8 code. # The warning doesn't show up with more recent clangs, so disable it for now. args << "--cxxopt=-Wno-range-loop-analysis" args << "--host_cxxopt=-Wno-range-loop-analysis" # To suppress warning on deprecated declaration on v8 code. For example: # external/v8/src/base/platform/platform-darwin.cc:56:22: 'getsectdatafromheader_64' # is deprecated: first deprecated in macOS 13.0. # https://bugs.chromium.org/p/v8/issues/detail?id=13428. # Reference: https://github.com/envoyproxy/envoy/pull/23707. args << "--cxxopt=-Wno-deprecated-declarations" args << "--host_cxxopt=-Wno-deprecated-declarations" end # Write the current version SOURCE_VERSION. system "python3", "tools/github/write_current_source_version.py", "--skip_error_in_git" system Formula["bazelisk"].opt_bin/"bazelisk", "build", *args, "//source/exe:envoy-static.stripped" bin.install "bazel-bin/source/exe/envoy-static.stripped" => "envoy" pkgshare.install "configs", "examples" end test do port = free_port cp pkgshare/"configs/envoyproxy_io_proxy.yaml", testpath/"envoy.yaml" inreplace "envoy.yaml" do |s| s.gsub! "port_value: 9901", "port_value: #{port}" s.gsub! "port_value: 10000", "port_value: #{free_port}" end fork do exec bin/"envoy", "-c", "envoy.yaml" end sleep 10 assert_match "HEALTHY", shell_output("curl -s 127.0.0.1:#{port}/clusters?format=json") end end