Skip to content

Commit

Permalink
Revert "Revert "Revert "bazel: update rules_foreign_cc (#17445)" (#17780
Browse files Browse the repository at this point in the history
)" (#17799)" (#17875)

This reverts commit 4b3f4a5.

Signed-off-by: Keith Smiley <[email protected]>
  • Loading branch information
keith authored Aug 27, 2021
1 parent f30c289 commit 7760bc0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion bazel/EXTERNAL_DEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The name of the dependency can be found in
[the repository locations file.](https://github.com/envoyproxy/envoy/blob/main/bazel/repository_locations.bzl)
The path of the local copy has to be absolute path.

For repositories built by `envoy_cmake()` in `bazel/foreign_cc/BUILD`,
For repositories built by `envoy_cmake_external()` in `bazel/foreign_cc/BUILD`,
it is necessary to populate the local copy with some additional Bazel machinery
to support `--override_repository`:
1. Place an empty `WORKSPACE` in the root.
Expand Down
5 changes: 2 additions & 3 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@envoy_build_tools//toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config")
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict", "custom_exec_properties")
Expand All @@ -14,8 +14,7 @@ load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_depend
GO_VERSION = "1.15.5"

def envoy_dependency_imports(go_version = GO_VERSION):
# TODO: allow building of tools for easier onboarding
rules_foreign_cc_dependencies(register_default_tools = False, register_built_tools = False)
rules_foreign_cc_dependencies()
go_rules_dependencies()
go_register_toolchains(go_version)
rbe_toolchains_config()
Expand Down
16 changes: 9 additions & 7 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The main Envoy bazel file. Load this file for all Envoy-specific build macros
# and rules that you'd like to use in your BUILD files.
load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake")
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
load(":envoy_binary.bzl", _envoy_cc_binary = "envoy_cc_binary")
load(":envoy_internal.bzl", "envoy_external_dep_path")
load(
Expand Down Expand Up @@ -91,12 +91,15 @@ envoy_directory_genrule = rule(

# External CMake C++ library targets should be specified with this function. This defaults
# to building the dependencies with ninja
def envoy_cmake(
def envoy_cmake_external(
name,
cache_entries = {},
debug_cache_entries = {},
cmake_options = ["-GNinja"],
make_commands = ["ninja -v", "ninja -v install"],
lib_source = "",
postfix_script = "",
static_libraries = [],
copy_pdb = False,
pdb_name = "",
cmake_files_dir = "$BUILD_TMPDIR/CMakeFiles",
Expand Down Expand Up @@ -124,23 +127,22 @@ def envoy_cmake(
else:
pf = postfix_script

cmake(
cmake_external(
name = name,
cache_entries = select({
"@envoy//bazel:dbg_build": cache_entries_debug,
"//conditions:default": cache_entries,
}),
generate_args = ["-GNinja"],
targets = ["", "install"],
# TODO: Remove install target and make this work
install = False,
cmake_options = cmake_options,
# TODO(lizan): Make this always true
generate_crosstool_file = select({
"@envoy//bazel:windows_x86_64": True,
"//conditions:default": generate_crosstool_file,
}),
lib_source = lib_source,
make_commands = make_commands,
postfix_script = pf,
static_libraries = static_libraries,
**kwargs
)

Expand Down
67 changes: 33 additions & 34 deletions bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:envoy_build_system.bzl", "envoy_cmake", "envoy_package")
load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")
load("//bazel:envoy_build_system.bzl", "envoy_cmake_external", "envoy_package")
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")

licenses(["notice"]) # Apache 2

Expand All @@ -20,14 +20,12 @@ configure_make(
}),
lib_source = "@com_github_gperftools_gperftools//:all",
linkopts = ["-lpthread"],
out_static_libs = select({
make_commands = ["make install-libLTLIBRARIES install-perftoolsincludeHEADERS"],
static_libraries = select({
"//bazel:debug_tcmalloc": ["libtcmalloc_debug.a"],
"//conditions:default": ["libtcmalloc_and_profiler.a"],
}),
tags = ["skip_on_windows"],
targets = [
"install-libLTLIBRARIES install-perftoolsincludeHEADERS",
],
)

# Workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/227
Expand All @@ -42,7 +40,7 @@ cc_library(
configure_make(
name = "luajit",
configure_command = "build.py",
env = select({
configure_env_vars = select({
# This shouldn't be needed! See
# https://github.com/envoyproxy/envoy/issues/6084
# TODO(htuch): Remove when #6084 is fixed
Expand All @@ -52,18 +50,18 @@ configure_make(
"//conditions:default": {},
}),
lib_source = "@com_github_luajit_luajit//:all",
make_commands = [],
out_include_dir = "include/luajit-2.1",
out_static_libs = select({
static_libraries = select({
"//bazel:windows_x86_64": ["lua51.lib"],
"//conditions:default": ["libluajit-5.1.a"],
}),
targets = [],
)

configure_make(
name = "moonjit",
configure_command = "build.py",
env = select({
configure_env_vars = select({
# This shouldn't be needed! See
# https://github.com/envoyproxy/envoy/issues/6084
# TODO(htuch): Remove when #6084 is fixed
Expand All @@ -72,12 +70,13 @@ configure_make(
"//conditions:default": {},
}),
lib_source = "@com_github_moonjit_moonjit//:all",
make_commands = [],
out_include_dir = "include/moonjit-2.2",
out_static_libs = ["libluajit-5.1.a"],
static_libraries = ["libluajit-5.1.a"],
tags = ["skip_on_windows"],
)

envoy_cmake(
envoy_cmake_external(
name = "ares",
cache_entries = {
"CARES_BUILD_TOOLS": "no",
Expand All @@ -92,17 +91,17 @@ envoy_cmake(
"//bazel:apple": ["-lresolv"],
"//conditions:default": [],
}),
out_static_libs = select({
"//bazel:windows_x86_64": ["cares.lib"],
"//conditions:default": ["libcares.a"],
}),
postfix_script = select({
"//bazel:windows_x86_64": "cp -L $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares/src/lib/ares_nameser.h $INSTALLDIR/include/ares_nameser.h && cp -L $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares/include/ares_dns.h $INSTALLDIR/include/ares_dns.h",
"//conditions:default": "rm -f $INSTALLDIR/include/ares_dns.h && cp -L $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares/include/ares_dns.h $INSTALLDIR/include/ares_dns.h",
"//conditions:default": "cp -L $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares/include/ares_dns.h $INSTALLDIR/include/ares_dns.h",
}),
static_libraries = select({
"//bazel:windows_x86_64": ["cares.lib"],
"//conditions:default": ["libcares.a"],
}),
)

envoy_cmake(
envoy_cmake_external(
name = "curl",
cache_entries = {
"BUILD_CURL_EXE": "off",
Expand Down Expand Up @@ -143,7 +142,7 @@ envoy_cmake(
defines = ["CURL_STATICLIB"],
generate_crosstool_file = True,
lib_source = "@com_github_curl//:all",
out_static_libs = select({
static_libraries = select({
"//bazel:windows_x86_64": ["libcurl.lib"],
"//conditions:default": ["libcurl.a"],
}),
Expand All @@ -155,7 +154,7 @@ envoy_cmake(
],
)

envoy_cmake(
envoy_cmake_external(
name = "event",
cache_entries = {
"EVENT__DISABLE_OPENSSL": "on",
Expand All @@ -172,7 +171,7 @@ envoy_cmake(
"_GNU_SOURCE": "on",
},
lib_source = "@com_github_libevent_libevent//:all",
out_static_libs = select({
static_libraries = select({
# macOS organization of libevent is different from Windows/Linux.
# Including libevent_core is a requirement on those platforms, but
# results in duplicate symbols when built on macOS.
Expand All @@ -193,7 +192,7 @@ envoy_cmake(
}),
)

envoy_cmake(
envoy_cmake_external(
name = "llvm",
cache_entries = {
# Disable both: BUILD and INCLUDE, since some of the INCLUDE
Expand Down Expand Up @@ -224,15 +223,15 @@ envoy_cmake(
# using -l:libstdc++.a.
"CMAKE_CXX_FLAGS": "-lstdc++",
},
env = {
env_vars = {
# Workaround for the -DDEBUG flag added in fastbuild on macOS,
# which conflicts with DEBUG macro used in LLVM.
"CFLAGS": "-UDEBUG",
"CXXFLAGS": "-UDEBUG",
"ASMFLAGS": "-UDEBUG",
},
lib_source = "@org_llvm_llvm//:all",
out_static_libs = select({
static_libraries = select({
"//conditions:default": [
# Order from llvm-config --libnames asmparser core debuginfodwarf
# engine lto mcparser mirparser orcjit passes runtimedyld
Expand Down Expand Up @@ -293,7 +292,7 @@ envoy_cmake(
alwayslink = True,
)

envoy_cmake(
envoy_cmake_external(
name = "nghttp2",
cache_entries = {
"ENABLE_LIB_ONLY": "on",
Expand All @@ -306,13 +305,13 @@ envoy_cmake(
debug_cache_entries = {"ENABLE_DEBUG": "on"},
defines = ["NGHTTP2_STATICLIB"],
lib_source = "@com_github_nghttp2_nghttp2//:all",
out_static_libs = select({
static_libraries = select({
"//bazel:windows_x86_64": ["nghttp2.lib"],
"//conditions:default": ["libnghttp2.a"],
}),
)

envoy_cmake(
envoy_cmake_external(
name = "wamr",
cache_entries = {
"LLVM_DIR": "$EXT_BUILD_DEPS/copy_llvm/llvm/lib/cmake/llvm",
Expand All @@ -325,13 +324,14 @@ envoy_cmake(
"WAMR_BUILD_TAIL_CALL": "1",
},
lib_source = "@com_github_wamr//:all",
out_static_libs = ["libvmlib.a"],
static_libraries = ["libvmlib.a"],
tags = ["skip_on_windows"],
deps = [":llvm"],
)

envoy_cmake(
envoy_cmake_external(
name = "wavm",
binaries = ["wavm"],
cache_entries = {
"LLVM_DIR": "$EXT_BUILD_DEPS/copy_llvm/llvm/lib/cmake/llvm",
"WAVM_ENABLE_STATIC_LINKING": "on",
Expand All @@ -341,16 +341,15 @@ envoy_cmake(
# using -l:libstdc++.a.
"CMAKE_CXX_FLAGS": "-lstdc++ -Wno-unused-command-line-argument",
},
env = {
env_vars = {
# Workaround for the -DDEBUG flag added in fastbuild on macOS,
# which conflicts with DEBUG macro used in LLVM.
"CFLAGS": "-UDEBUG",
"CXXFLAGS": "-UDEBUG",
"ASMFLAGS": "-UDEBUG",
},
lib_source = "@com_github_wavm_wavm//:all",
out_binaries = ["wavm"],
out_static_libs = select({
static_libraries = select({
"//conditions:default": [
"libWAVM.a",
"libWAVMUnwind.a",
Expand All @@ -360,7 +359,7 @@ envoy_cmake(
deps = [":llvm"],
)

envoy_cmake(
envoy_cmake_external(
name = "zlib",
cache_entries = {
"CMAKE_CXX_COMPILER_FORCED": "on",
Expand Down Expand Up @@ -393,7 +392,7 @@ envoy_cmake(
"//bazel:zlib_ng": "@com_github_zlib_ng_zlib_ng//:all",
"//conditions:default": "@net_zlib//:all",
}),
out_static_libs = select({
static_libraries = select({
"//bazel:windows_x86_64": ["zlib.lib"],
"//conditions:default": ["libz.a"],
}),
Expand Down
8 changes: 4 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,12 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "Rules for using foreign build systems in Bazel",
project_desc = "Rules for using foreign build systems in Bazel",
project_url = "https://github.com/bazelbuild/rules_foreign_cc",
version = "da8952e27c46659866b455de58f5eb3a86185507",
sha256 = "5d1e34fc0f4ab4af0e595ee4d9a03f4127701d95c1d521296bf892b8aff903a2",
version = "d54c78ab86b40770ee19f0949db9d74a831ab9f0",
sha256 = "e7446144277c9578141821fc91c55a61df7ae01bda890902f7286f5fd2f6ae46",
strip_prefix = "rules_foreign_cc-{version}",
urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/{version}.tar.gz"],
release_date = "2021-08-21",
use_category = ["build", "dataplane_core", "controlplane"],
release_date = "2020-10-26",
use_category = ["build"],
),
rules_python = dict(
project_name = "Python rules for Bazel",
Expand Down

0 comments on commit 7760bc0

Please sign in to comment.