From adc5668f356ad08931afc8b5cecbd97973d401a6 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 01:48:27 +0000 Subject: [PATCH 1/8] build: use foreign_cc for luajit Signed-off-by: Lizan Zhou --- bazel/foreign_cc/BUILD | 11 ++++ .../foreign_cc/luajit.patch | 57 +++++++++---------- bazel/repositories.bzl | 18 ++++++ bazel/repository_locations.bzl | 5 ++ bazel/target_recipes.bzl | 1 - ci/prebuilt/BUILD | 12 ---- 6 files changed, 61 insertions(+), 43 deletions(-) rename ci/build_container/build_recipes/luajit.sh => bazel/foreign_cc/luajit.patch (64%) delete mode 100644 ci/prebuilt/BUILD diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index 84961a04eb924..5549ed6bce9ac 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -29,6 +29,17 @@ cc_library( ], ) +configure_make( + name = "luajit", + configure_command = "build.py", + lib_source = "@com_github_luajit_luajit//:all", + make_commands = [], + static_libraries = [ + "libluajit-5.1.a", + ], +) + + envoy_cmake_external( name = "ares", cache_entries = { diff --git a/ci/build_container/build_recipes/luajit.sh b/bazel/foreign_cc/luajit.patch similarity index 64% rename from ci/build_container/build_recipes/luajit.sh rename to bazel/foreign_cc/luajit.patch index 00546892f29b6..c7890f5ccdb57 100644 --- a/ci/build_container/build_recipes/luajit.sh +++ b/bazel/foreign_cc/luajit.patch @@ -1,25 +1,3 @@ -#!/bin/bash - -set -e - -if [[ "${OS}" == "Windows_NT" ]]; then - exit 0 -fi - -SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" - -$($SCRIPT_DIR/versions.py luajit) - -FILE_NAME=$(basename "$FILE_URL") - -curl "$FILE_URL" -sLo "$FILE_NAME" \ - && echo "$FILE_SHA256" "$FILE_NAME" | sha256sum --check -tar xf "$FILE_NAME" - -cd "$FILE_PREFIX" - -# Fixup Makefile with things that cannot be set via env var. -cat > luajit_make.diff << 'EOF' diff --git a/src/Makefile b/src/Makefile index f56465d..3f4f2fa 100644 --- a/src/Makefile @@ -65,11 +43,30 @@ index f56465d..3f4f2fa 100644 ############################################################################## EOF - -patch -p1 < luajit_make.diff - -# Default MACOSX_DEPLOYMENT_TARGET is 10.4, which will fail the build at link time on macOS 10.14: -# ld: library not found for -lgcc_s.10.4 -# This doesn't affect other platforms -MACOSX_DEPLOYMENT_TARGET=10.6 DEFAULT_CC=${CC} TARGET_CFLAGS=${CFLAGS} TARGET_LDFLAGS=${CFLAGS} \ - CFLAGS="" make V=1 PREFIX="$THIRDPARTY_BUILD" install +diff --git a/build.py b/build.py +new file mode 100755 +index 0000000..b069ef6 +--- /dev/null ++++ b/build.py +@@ -0,0 +1,21 @@ ++#!/usr/bin/env python3 ++ ++import argparse ++import os ++ ++def main(): ++ parser = argparse.ArgumentParser() ++ parser.add_argument("--prefix") ++ args = parser.parse_args() ++ os.chdir(os.path.dirname(os.path.realpath(__file__))) ++ ++ os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.6" ++ os.environ["DEFAULT_CC"] = os.environ.get("CC", "") ++ os.environ["TARGET_CFLAGS"] = os.environ.get("CFLAGS", "") ++ os.environ["TARGET_LDFLAGS"] = os.environ.get("CFLAGS", "") ++ os.environ["CFLAGS"] = "" ++ ++ os.system('make V=1 PREFIX="{}" install'.format(args.prefix)) ++ ++main() ++ diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index bb6ba134eb2f2..a40f298582c11 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -267,6 +267,7 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): _com_github_gperftools_gperftools() _com_github_jbeder_yaml_cpp() _com_github_libevent_libevent() + _com_github_luajit_luajit() _com_github_madler_zlib() _com_github_nanopb_nanopb() _com_github_nghttp2_nghttp2() @@ -697,6 +698,23 @@ def _com_github_google_jwt_verify(): actual = "@com_github_google_jwt_verify//:jwt_verify_lib", ) +def _com_github_luajit_luajit(): + location = REPOSITORY_LOCATIONS["com_github_luajit_luajit"] + http_archive( + name = "com_github_luajit_luajit", + build_file_content = BUILD_ALL_CONTENT, + patches = ["@envoy//bazel/foreign_cc:luajit.patch"], + patch_args = ["-p1"], + patch_cmds = ["chmod u+x build.py"], + **location + ) + + native.bind( + name = "luajit", + actual = "@envoy//bazel/foreign_cc:luajit", + ) + + def _com_github_gperftools_gperftools(): location = REPOSITORY_LOCATIONS["com_github_gperftools_gperftools"] http_archive( diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index f691833d54244..aef8d0fa9a1e6 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -86,6 +86,11 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "grpc-1.16.1", urls = ["https://github.com/grpc/grpc/archive/v1.16.1.tar.gz"], ), + com_github_luajit_luajit = dict( + sha256 = "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8", + strip_prefix = "LuaJIT-2.1.0-beta3", + urls = ["https://github.com/LuaJIT/LuaJIT/archive/v2.1.0-beta3.tar.gz"], + ), com_github_nanopb_nanopb = dict( sha256 = "b8dd5cb0d184d424ddfea13ddee3f7b0920354334cbb44df434d55e5f0086b12", strip_prefix = "nanopb-0.3.9.2", diff --git a/bazel/target_recipes.bzl b/bazel/target_recipes.bzl index 802b940704933..99b585d52c6a7 100644 --- a/bazel/target_recipes.bzl +++ b/bazel/target_recipes.bzl @@ -2,5 +2,4 @@ # target in //ci/prebuilt/BUILD to the underlying build recipe in # ci/build_container/build_recipes. TARGET_RECIPES = { - "luajit": "luajit", } diff --git a/ci/prebuilt/BUILD b/ci/prebuilt/BUILD deleted file mode 100644 index 97f8f37a9d3bc..0000000000000 --- a/ci/prebuilt/BUILD +++ /dev/null @@ -1,12 +0,0 @@ -licenses(["notice"]) # Apache 2 - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "luajit", - srcs = ["thirdparty_build/lib/libluajit-5.1.a"], - hdrs = glob(["thirdparty_build/include/luajit-2.1/*"]), - includes = ["thirdparty_build/include"], - # TODO(mattklein123): We should strip luajit-2.1 here for consumers. However, if we do that - # the headers get included using -I vs. -isystem which then causes old-style-cast warnings. -) From 4eb270d47cff92cf84212dd4301c56c1e9b60239 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 03:00:50 +0000 Subject: [PATCH 2/8] fix format, fix mac build Signed-off-by: Lizan Zhou --- bazel/foreign_cc/BUILD | 1 - bazel/foreign_cc/luajit.patch | 2 +- bazel/repositories.bzl | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index 5549ed6bce9ac..3791c8f3adbdf 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -39,7 +39,6 @@ configure_make( ], ) - envoy_cmake_external( name = "ares", cache_entries = { diff --git a/bazel/foreign_cc/luajit.patch b/bazel/foreign_cc/luajit.patch index c7890f5ccdb57..448955cbb7f0b 100644 --- a/bazel/foreign_cc/luajit.patch +++ b/bazel/foreign_cc/luajit.patch @@ -49,7 +49,7 @@ index 0000000..b069ef6 --- /dev/null +++ b/build.py @@ -0,0 +1,21 @@ -+#!/usr/bin/env python3 ++#!/usr/bin/env python + +import argparse +import os diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index a40f298582c11..e6d9037a59517 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -714,7 +714,6 @@ def _com_github_luajit_luajit(): actual = "@envoy//bazel/foreign_cc:luajit", ) - def _com_github_gperftools_gperftools(): location = REPOSITORY_LOCATIONS["com_github_gperftools_gperftools"] http_archive( From a26bea4cdfd5c5a54f498dd87d29fee5886bc07b Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 03:23:50 +0000 Subject: [PATCH 3/8] don't fail with LSAN buildvm Signed-off-by: Lizan Zhou --- bazel/foreign_cc/luajit.patch | 1 + 1 file changed, 1 insertion(+) diff --git a/bazel/foreign_cc/luajit.patch b/bazel/foreign_cc/luajit.patch index 448955cbb7f0b..4b74e66ea9fc9 100644 --- a/bazel/foreign_cc/luajit.patch +++ b/bazel/foreign_cc/luajit.patch @@ -65,6 +65,7 @@ index 0000000..b069ef6 + os.environ["TARGET_CFLAGS"] = os.environ.get("CFLAGS", "") + os.environ["TARGET_LDFLAGS"] = os.environ.get("CFLAGS", "") + os.environ["CFLAGS"] = "" ++ os.environ["LSAN_OPTIONS"] = "exitcode=0" + + os.system('make V=1 PREFIX="{}" install'.format(args.prefix)) + From 0ac281ca387cc70251d1fe104f82d078f5f1ad9c Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 20:45:47 +0000 Subject: [PATCH 4/8] comment Signed-off-by: Lizan Zhou --- bazel/foreign_cc/luajit.patch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bazel/foreign_cc/luajit.patch b/bazel/foreign_cc/luajit.patch index 4b74e66ea9fc9..5fba15265565d 100644 --- a/bazel/foreign_cc/luajit.patch +++ b/bazel/foreign_cc/luajit.patch @@ -65,6 +65,9 @@ index 0000000..b069ef6 + os.environ["TARGET_CFLAGS"] = os.environ.get("CFLAGS", "") + os.environ["TARGET_LDFLAGS"] = os.environ.get("CFLAGS", "") + os.environ["CFLAGS"] = "" ++ # LuaJIT compile process build a tool `buildvm` and use it, building `buildvm` with ASAN ++ # will cause LSAN detect its leak and fail the build, set exitcode to 0 to make LSAN doesn't ++ # fail on it. + os.environ["LSAN_OPTIONS"] = "exitcode=0" + + os.system('make V=1 PREFIX="{}" install'.format(args.prefix)) From 40855b493dc82dbb5ae27caf6b934cae67da1dfb Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 21:02:35 +0000 Subject: [PATCH 5/8] delete old recipe rules Signed-off-by: Lizan Zhou --- bazel/EXTERNAL_DEPS.md | 15 ---- bazel/repositories.bzl | 87 +------------------- bazel/repositories.sh | 42 ---------- ci/build_container/BUILD | 13 --- ci/build_container/Dockerfile-centos | 3 +- ci/build_container/Dockerfile-ubuntu | 3 +- ci/build_container/Makefile | 67 --------------- ci/build_container/build_and_install_deps.sh | 28 ------- ci/build_container/build_container_common.sh | 7 -- ci/build_container/recipe_wrapper.sh | 14 ---- 10 files changed, 3 insertions(+), 276 deletions(-) delete mode 100755 bazel/repositories.sh delete mode 100644 ci/build_container/BUILD delete mode 100644 ci/build_container/Makefile delete mode 100755 ci/build_container/build_and_install_deps.sh delete mode 100755 ci/build_container/recipe_wrapper.sh diff --git a/bazel/EXTERNAL_DEPS.md b/bazel/EXTERNAL_DEPS.md index e6d2c67545e6c..c5b75ceae957c 100644 --- a/bazel/EXTERNAL_DEPS.md +++ b/bazel/EXTERNAL_DEPS.md @@ -54,21 +54,6 @@ Dependencies between external libraries can use the standard Bazel dependency resolution logic, using the `$(location)` shell extension to resolve paths to binaries, libraries, headers, etc. -# Adding external dependencies to Envoy (build recipe) - -This is the older style of adding dependencies. It uses shell scripts to build and install -dependencies into a shared directory prefix. This should no longer be used unless there are -extenuating circumstances. - -1. Add a build recipe X in [`ci/build_container/build_recipes`](../ci/build_container/build_recipes) - for developer-local and CI external dependency build flows. -2. Add a build target Y in [`ci/prebuilt/BUILD`](../ci/prebuilt/BUILD) to consume the headers and - libraries produced by the build recipe X. -3. Add a map from target Y to build recipe X in [`target_recipes.bzl`](target_recipes.bzl). -4. Reference your new external dependency in some `envoy_cc_library` via Y in the `external_deps` - attribute. -5. `bazel test //test/...` - # Updating an external dependency version 1. If the dependency is a build recipe, update the build recipe in diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index e6d9037a59517..89977c6fae413 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -27,45 +27,6 @@ def _repository_impl(name, **kwargs): **kwargs ) -def _build_recipe_repository_impl(ctxt): - # on Windows, all deps use rules_foreign_cc - if ctxt.os.name.upper().startswith("WINDOWS"): - return - - # modify the recipes list based on the build context - recipes = _apply_dep_blacklist(ctxt, ctxt.attr.recipes) - - # Setup the build directory with links to the relevant files. - ctxt.symlink(Label("//bazel:repositories.sh"), "repositories.sh") - ctxt.symlink( - Label("//ci/build_container:build_and_install_deps.sh"), - "build_and_install_deps.sh", - ) - ctxt.symlink(Label("//ci/build_container:recipe_wrapper.sh"), "recipe_wrapper.sh") - ctxt.symlink(Label("//ci/build_container:Makefile"), "Makefile") - for r in recipes: - ctxt.symlink( - Label("//ci/build_container/build_recipes:" + r + ".sh"), - "build_recipes/" + r + ".sh", - ) - ctxt.symlink(Label("//ci/prebuilt:BUILD"), "BUILD") - - # Run the build script. - print("Fetching external dependencies...") - result = ctxt.execute( - ["./repositories.sh"] + recipes, - quiet = False, - ) - print(result.stdout) - print(result.stderr) - print("External dep build exited with return code: %d" % result.return_code) - if result.return_code != 0: - print("\033[31;1m\033[48;5;226m External dependency build failed, check above log " + - "for errors and ensure all prerequisites at " + - "https://github.com/envoyproxy/envoy/blob/master/bazel/README.md#quick-start-bazel-build-for-developers are met.") - - # This error message doesn't appear to the user :( https://github.com/bazelbuild/bazel/issues/3683 - fail("External dep build failed") def _default_envoy_build_config_impl(ctx): ctx.file("WORKSPACE", "") @@ -191,43 +152,7 @@ def _envoy_api_deps(): actual = "@six_archive//:six", ) -def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): - envoy_repository = repository_rule( - implementation = _build_recipe_repository_impl, - environ = [ - "CC", - "CXX", - "CFLAGS", - "CXXFLAGS", - "LD_LIBRARY_PATH", - ], - # Don't pretend we're in the sandbox, we do some evil stuff with envoy_dep_cache. - local = True, - attrs = { - "recipes": attr.string_list(), - }, - ) - - # Ideally, we wouldn't have a single repository target for all dependencies, but instead one per - # dependency, as suggested in #747. However, it's much faster to build all deps under a single - # recursive make job and single make jobserver. - recipes = depset() - for t in TARGET_RECIPES: - if t not in skip_targets: - recipes += depset([TARGET_RECIPES[t]]) - - envoy_repository( - name = "envoy_deps", - recipes = recipes.to_list(), - ) - - for t in TARGET_RECIPES: - if t not in skip_targets: - native.bind( - name = t, - actual = path + ":" + t, - ) - +def envoy_dependencies(skip_targets = []): # Treat Envoy's overall build config as an external repo, so projects that # build Envoy as a subcomponent can easily override the config. if "envoy_build_config" not in native.existing_rules().keys(): @@ -731,16 +656,6 @@ def _com_github_gperftools_gperftools(): def _foreign_cc_dependencies(): _repository_impl("rules_foreign_cc") -def _apply_dep_blacklist(ctxt, recipes): - newlist = [] - skip_list = [] - if _is_linux_ppc(ctxt): - skip_list += PPC_SKIP_TARGETS.keys() - for t in recipes: - if t not in skip_list: - newlist.append(t) - return newlist - def _is_linux(ctxt): return ctxt.os.name == "linux" diff --git a/bazel/repositories.sh b/bazel/repositories.sh deleted file mode 100755 index 6919a4b2c94d1..0000000000000 --- a/bazel/repositories.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e - -if [[ `uname` == "Darwin" ]] -then - function md5sum { - gmd5sum $@ - } -fi - -# Tell build_and_install_deps.sh to build sequentially when performance debugging. -# export BUILD_CONCURRENCY=0 - -# Hash environment variables we care about to force rebuilds when they change. -ENV_HASH=$(echo "${CC} ${CXX} ${LD_LIBRARY_PATH}" | md5sum | cut -f 1 -d\ ) - -# Don't build inside the directory Bazel believes the repository_rule output goes. Instead, do so in -# a parallel directory. This allows the build artifacts to survive Bazel clobbering the repostory -# directory when a small change to repositories.bzl or a build recipe happens. We then rely on make -# dependency analysis to detect when stuff needs to be rebuilt. -BASEDIR="${PWD}_cache_${ENV_HASH}" - ->&2 echo "External dependency cache directory ${BASEDIR}" -mkdir -p "${BASEDIR}" - -export THIRDPARTY_DEPS="${BASEDIR}" -export THIRDPARTY_SRC="${BASEDIR}/thirdparty" -export THIRDPARTY_BUILD="${BASEDIR}/thirdparty_build" - -DEPS="" -for r in "$@" -do - DEPS="${DEPS} ${THIRDPARTY_DEPS}/$r.dep" -done - -set -o pipefail -BUILD_LOG="${BASEDIR}"/build.log -(time ./build_and_install_deps.sh ${DEPS}) 2>&1 | tee "${BUILD_LOG}" >&2 - -ln -sf "$(realpath "${THIRDPARTY_SRC}")" thirdparty -ln -sf "$(realpath "${THIRDPARTY_BUILD}")" thirdparty_build diff --git a/ci/build_container/BUILD b/ci/build_container/BUILD deleted file mode 100644 index 9c7fd8d73f9a9..0000000000000 --- a/ci/build_container/BUILD +++ /dev/null @@ -1,13 +0,0 @@ -licenses(["notice"]) # Apache 2 - -load( - "//bazel:envoy_build_system.bzl", - "envoy_package", -) - -envoy_package() - -exports_files([ - "build_and_install_deps.sh", - "Makefile", -]) diff --git a/ci/build_container/Dockerfile-centos b/ci/build_container/Dockerfile-centos index c98d7a52fcdbc..b8fb1abaf527a 100644 --- a/ci/build_container/Dockerfile-centos +++ b/ci/build_container/Dockerfile-centos @@ -1,10 +1,9 @@ FROM centos:7 -COPY ./build_and_install_deps.sh ./recipe_wrapper.sh ./Makefile ./build_container_common.sh / +COPY ./build_container_common.sh / COPY WORKSPACE /bazel-prebuilt/ COPY ./api /bazel-prebuilt/api COPY ./bazel /bazel-prebuilt/bazel -COPY ./build_recipes/*.sh /build_recipes/ COPY ./build_container_centos.sh / diff --git a/ci/build_container/Dockerfile-ubuntu b/ci/build_container/Dockerfile-ubuntu index 2a0ed6355ebe8..8c70abd297d3d 100644 --- a/ci/build_container/Dockerfile-ubuntu +++ b/ci/build_container/Dockerfile-ubuntu @@ -1,10 +1,9 @@ FROM ubuntu:xenial -COPY ./build_and_install_deps.sh ./recipe_wrapper.sh ./Makefile ./build_container_common.sh / +COPY ./build_container_common.sh / COPY WORKSPACE /bazel-prebuilt/ COPY ./api /bazel-prebuilt/api COPY ./bazel /bazel-prebuilt/bazel -COPY ./build_recipes /build_recipes COPY ./build_container_ubuntu.sh / diff --git a/ci/build_container/Makefile b/ci/build_container/Makefile deleted file mode 100644 index 2aaca46d28e11..0000000000000 --- a/ci/build_container/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# The individual build recipe scripts must contain sufficient information (e.g. SHA, URL, repo, -# version number, etc.) to uniquely identify the revision of the upstream dependency. This allows -# make to pick up changes with a simple direct dependency on the build recipe. - -RECIPES := build_recipes - -# Make sure we use a consistent compiler across all deps. -CC ?= gcc -CXX ?= g++ - -# Common compiler flags -CXXFLAGS += -ggdb3 -fno-omit-frame-pointer -O2 -CFLAGS += -ggdb3 -fno-omit-frame-pointer -O2 -CPPFLAGS ?= -DNDEBUG - -# Keep track of the env vars we depend upon for $(THIRDPARTY_DEPS)/%.dep.env. If the list (captured -# above) of flags changes, this should be updated. -ENV_STR := $(CC) $(CXX) $(CXXFLAGS) $(CFLAGS) $(CPPFLAGS) - -# If $(BUILD_DISTINCT) is set in the make environment, the artifacts are built and installed in -# distinct directories under $(THIRDPARTY_BUILD) and $(THIRDPARTY_SRC). They end up looking like -# $(THIRDPARTY_BUILD)/protobuf.dep/include, etc. instead of all being under -# $(THIRDPARTY_BUILD)/include. -DISTINCT_PATH = $(if $(BUILD_DISTINCT),$(@F),) - -build-setup = rm -rf "$@.build" && \ - $(if $(BUILD_DISTINCT),rm -rf "$(THIRDPARTY_BUILD)/$(DISTINCT_PATH)" &&,) \ - $(if $(BUILD_DISTINCT),rm -rf "$(THIRDPARTY_SRC)/$(DISTINCT_PATH)" &&,) \ - mkdir -p "$@.build" && \ - mkdir -p "$(THIRDPARTY_BUILD)/$(DISTINCT_PATH)/lib" && \ - mkdir -p "$(THIRDPARTY_BUILD)/$(DISTINCT_PATH)/include" && \ - cd "$@.build" && \ - echo "Building in $@.build, logs at $@.log" - -build-complete = rm -rf "$@.build" && \ - echo "Successful build of $@" && \ - touch $@ - -# This needs to be invoked with $(call build-recipe,DEFS) where DEFS are additional environment -# definitions that are to be injected into the build recipe execution environment. -build-recipe = cd "$(THIRDPARTY_SRC)" && \ - $(build-setup) && \ - (((THIRDPARTY_SRC="$(THIRDPARTY_SRC)/$(DISTINCT_PATH)" \ - THIRDPARTY_BUILD="$(THIRDPARTY_BUILD)/$(DISTINCT_PATH)" \ - CC="$(CC)" \ - CXX="$(CXX)" \ - CFLAGS="$(CFLAGS)" \ - CXXFLAGS="$(CXXFLAGS)" \ - CPPFLAGS="$(CPPFLAGS)" \ - $(1) \ - bash -c "time $(CURDIR)/recipe_wrapper.sh $(realpath $<)" 2>&1) > $@.log) || (cat $@.log; exit 1)) && \ - $(build-complete) - -# Simplify wildcard phony with FORCE target. -.PHONY: FORCE -FORCE: - -# Capture $(ENV_STR) deps to retrigger build when they change. -.PRECIOUS: $(THIRDPARTY_DEPS)/%.dep.env -$(THIRDPARTY_DEPS)/%.dep.env: FORCE - @[ "$$(cat $@)" != "$(ENV_STR)" ] && echo "$(ENV_STR)" > $@ || echo "No need to rebuild $@" - -$(THIRDPARTY_DEPS)/%.dep: $(RECIPES)/%.sh $(THIRDPARTY_DEPS)/%.dep.env - @+$(call build-recipe,) - -# Special support for targets that need protobuf, and hence take a dependency on protobuf.dep. -PROTOBUF_BUILD ?= $(THIRDPARTY_BUILD)/$(if $(BUILD_DISTINCT),protobuf.dep,) diff --git a/ci/build_container/build_and_install_deps.sh b/ci/build_container/build_and_install_deps.sh deleted file mode 100755 index 610776a49568a..0000000000000 --- a/ci/build_container/build_and_install_deps.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -e - -mkdir -p "${THIRDPARTY_DEPS}" -mkdir -p "${THIRDPARTY_BUILD}" -mkdir -p "${THIRDPARTY_SRC}" - -if [ -z "$NUM_CPUS" ]; then - case `uname` in - Darwin) - NUM_CPUS=`/usr/sbin/sysctl hw.physicalcpu | cut -f 2 -d' '`;; - *) - NUM_CPUS=`grep -c ^processor /proc/cpuinfo`;; - esac -fi - -# Invokers can set BUILD_CONCURRENCY=0 to ensure each build recipe is invoked sequentially, with all -# CPU resources available. This is useful when debugging build performance. -if [[ "${BUILD_CONCURRENCY}" == "0" ]] -then - for dep in "$@" - do - make -C "$(dirname "$0")" -j "${NUM_CPUS}" "$dep" - done -else - make -C "$(dirname "$0")" -j "${NUM_CPUS}" "$@" -fi diff --git a/ci/build_container/build_container_common.sh b/ci/build_container/build_container_common.sh index e914a2a0eb1cd..de71d0fa79649 100755 --- a/ci/build_container/build_container_common.sh +++ b/ci/build_container/build_container_common.sh @@ -16,13 +16,6 @@ export THIRDPARTY_SRC=/thirdparty DEPS=$(python <(cat /bazel-prebuilt/bazel/target_recipes.bzl; \ echo "print ' '.join(\"${THIRDPARTY_DEPS}/%s.dep\" % r for r in set(TARGET_RECIPES.values()))")) -# TODO(htuch): We build twice as a workaround for https://github.com/google/protobuf/issues/3322. -# Fix this. This will be gone real soon now. -export THIRDPARTY_BUILD=/thirdparty_build -export CPPFLAGS="-DNDEBUG" -echo "Building opt deps ${DEPS}" -"$(dirname "$0")"/build_and_install_deps.sh ${DEPS} - echo "Building Bazel-managed deps (//bazel/external:all_external)" mkdir /bazel-prebuilt-root /bazel-prebuilt-output BAZEL_OPTIONS="--output_user_root=/bazel-prebuilt-root --output_base=/bazel-prebuilt-output" diff --git a/ci/build_container/recipe_wrapper.sh b/ci/build_container/recipe_wrapper.sh deleted file mode 100755 index cdea29f8d1c8a..0000000000000 --- a/ci/build_container/recipe_wrapper.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -PS4='+ $(date "+%s.%N") ' -set -x - -if [[ `uname` == "Darwin" ]]; then - function sha256sum { - gsha256sum $@ - } -fi - -. $1 - -echo DONE From 1aa030d677cefd4f8d41110c2d60735b793fd369 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Mar 2019 21:17:46 +0000 Subject: [PATCH 6/8] fix format Signed-off-by: Lizan Zhou --- bazel/repositories.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 89977c6fae413..34328b1335284 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -27,7 +27,6 @@ def _repository_impl(name, **kwargs): **kwargs ) - def _default_envoy_build_config_impl(ctx): ctx.file("WORKSPACE", "") ctx.file("BUILD.bazel", "") From d598dd14f0cbc8135c3ea1d5da869e177b783299 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Mar 2019 01:51:08 +0000 Subject: [PATCH 7/8] fix patch Signed-off-by: Lizan Zhou --- bazel/foreign_cc/luajit.patch | 4 ++-- ci/build_setup.sh | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bazel/foreign_cc/luajit.patch b/bazel/foreign_cc/luajit.patch index 5fba15265565d..0f075e7bd02ed 100644 --- a/bazel/foreign_cc/luajit.patch +++ b/bazel/foreign_cc/luajit.patch @@ -45,10 +45,10 @@ index f56465d..3f4f2fa 100644 EOF diff --git a/build.py b/build.py new file mode 100755 -index 0000000..b069ef6 +index 0000000..9c71271 --- /dev/null +++ b/build.py -@@ -0,0 +1,21 @@ +@@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import argparse diff --git a/ci/build_setup.sh b/ci/build_setup.sh index 5bd8cfb601be8..6e969f272c652 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -77,8 +77,6 @@ export BAZEL_TEST_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HOME --test_env=PYT --test_env=UBSAN_OPTIONS=print_stacktrace=1 \ --cache_test_results=no --test_output=all ${BAZEL_EXTRA_TEST_OPTIONS}" [[ "${BAZEL_EXPUNGE}" == "1" ]] && "${BAZEL}" clean --expunge -ln -sf /thirdparty "${ENVOY_SRCDIR}"/ci/prebuilt -ln -sf /thirdparty_build "${ENVOY_SRCDIR}"/ci/prebuilt # Replace the existing Bazel output cache with a copy of the image's prebuilt deps. if [[ -d /bazel-prebuilt-output && ! -d "${TEST_TMPDIR}/_bazel_${USER}" ]]; then From 325ea7cead75c9af40e525c861a87c962088b883 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Mar 2019 01:53:14 +0000 Subject: [PATCH 8/8] fix ci/WORKSPACE Signed-off-by: Lizan Zhou --- ci/WORKSPACE | 4 +--- ci/WORKSPACE.filter.example | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ci/WORKSPACE b/ci/WORKSPACE index 2f2197641d11f..682ff00973cac 100644 --- a/ci/WORKSPACE +++ b/ci/WORKSPACE @@ -9,9 +9,7 @@ local_repository( path = "/source", ) -envoy_dependencies( - path = "@envoy//ci/prebuilt", -) +envoy_dependencies() # TODO(htuch): Roll this into envoy_dependencies() load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") diff --git a/ci/WORKSPACE.filter.example b/ci/WORKSPACE.filter.example index 388747003df8a..05f3cb1fbe4fc 100644 --- a/ci/WORKSPACE.filter.example +++ b/ci/WORKSPACE.filter.example @@ -8,9 +8,8 @@ local_repository( load("@envoy//bazel:repositories.bzl", "envoy_dependencies", "GO_VERSION") load("@envoy//bazel:cc_configure.bzl", "cc_configure") -envoy_dependencies( - path = "@envoy//ci/prebuilt", -) +envoy_dependencies() + # TODO(htuch): Roll this into envoy_dependencies() load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") rules_foreign_cc_dependencies()