From 92c95a919e290cef27b4d422499524978f4d2a70 Mon Sep 17 00:00:00 2001 From: Adrian Tobiszewski Date: Tue, 27 Feb 2024 16:26:00 +0100 Subject: [PATCH] Use bazel to build aws-sdk-cpp (#2334) Additionally bump aws-sdk-cpp version to 1.11.279 Encountered issues with bazel. Non ASCII filenames don't work inside bazel. Workaround is to remove test file from aws-sdk-cpp. bazelbuild/bazel#374 Building with rules_foreign cmake doesn't work with parallel builds. This is something we could optimize later, for now hardcode some low value: bazelbuild/rules_foreign_cc#329 On Redhat to properly build targets we now have to add: --//:distro=redhat By default distro is set to ubuntu. This is workaround for not bazel not being able to differentiate between the two. There is difference in aws-sdk-cpp static libraries location after build. Ideally we should find how to use select on aws-sdk-cpp repo BUILD file which would rely on main repo flag, but I didn't find way to support it there. JIRA:CVS-130367 --- .dockerignore | 2 + BUILD.bazel | 44 +- Dockerfile.redhat | 11 +- Dockerfile.ubuntu | 8 +- Makefile | 21 +- WORKSPACE | 8 +- ...common_settings.bzl => common_settings.bzl | 3 + distro.bzl | 36 ++ rununittest.sh | 4 +- src/BUILD | 64 ++- src/python/BUILD | 10 +- src/python/binding/BUILD | 10 +- src/test/mediapipe/calculators/BUILD | 4 +- tf.patch | 472 ------------------ third_party/aws-sdk-cpp/BUILD | 15 + third_party/aws-sdk-cpp/aws-sdk-cpp.bzl | 195 ++++++++ third_party/aws/BUILD | 58 --- 17 files changed, 329 insertions(+), 636 deletions(-) create mode 100644 .dockerignore rename src/common_settings.bzl => common_settings.bzl (95%) create mode 100644 distro.bzl delete mode 100644 tf.patch create mode 100644 third_party/aws-sdk-cpp/BUILD create mode 100644 third_party/aws-sdk-cpp/aws-sdk-cpp.bzl delete mode 100644 third_party/aws/BUILD diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0396671801 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.venv +.venv-style diff --git a/BUILD.bazel b/BUILD.bazel index 44c3ff2ff3..320edd0f8f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -23,33 +23,12 @@ exports_files([ load("@bazel_skylib//lib:selects.bzl", "selects") load("@mediapipe//mediapipe/framework:more_selects.bzl", "more_selects") - -config_setting( - name = "disable_mediapipe", - define_values = { - "MEDIAPIPE_DISABLE": "1", - }, - visibility = ["//visibility:public"], -) - -more_selects.config_setting_negation( - name = "not_disable_mediapipe", - negate = ":disable_mediapipe", -) +load("//:common_settings.bzl", + "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES", + "create_config_settings") +create_config_settings() #To build without python use flags - bazel build --define PYTHON_DISABLE=1 --cxxopt=-DPYTHON_DISABLE=1 //src:ovms -config_setting( - name = "disable_python", - define_values = { - "PYTHON_DISABLE": "1", - }, - visibility = ["//visibility:public"], -) - -more_selects.config_setting_negation( - name = "not_disable_python", - negate = ":disable_python", -) cc_library( name = "ovms_dependencies", @@ -62,9 +41,18 @@ cc_library( "@com_github_tencent_rapidjson//:rapidjson", "@com_github_gabime_spdlog//:spdlog", "@com_github_jarro2783_cxxopts//:cxxopts", - "@awssdk//:s3", - "@awssdk//:core", - "@awssdk//:deps", + + + ] + select({ + "//:ubuntu_build": [ + "@aws-sdk-cpp//:aws-sdk-cpp_ubuntu", + "@aws-sdk-cpp//:aws-sdk-cpp_cmake_ubuntu", + ], + "//:redhat_build": [ + "@aws-sdk-cpp//:aws-sdk-cpp_redhat", + "@aws-sdk-cpp//:aws-sdk-cpp_cmake_redhat", + ], + }) + [ "@azure//:storage", "@cpprest//:sdk", "@boost//:lib", diff --git a/Dockerfile.redhat b/Dockerfile.redhat index 5ebe8a781c..b9486a4288 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -80,17 +80,8 @@ RUN cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD WORKDIR /azure/azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release RUN CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON && make --jobs=$JOBS && make --jobs=$JOBS install - ####### End of Azure SDK -# Build AWS S3 SDK -RUN git clone https://github.com/aws/aws-sdk-cpp.git --branch 1.7.129 --single-branch --depth 1 /awssdk -WORKDIR /awssdk/build -RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=s3 -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_SHARED_CRT=OFF -DSIMPLE_INSTALL=OFF -DCMAKE_CXX_FLAGS=" -D_GLIBCXX_USE_CXX11_ABI=1 " .. && make --jobs=$JOBS -RUN mv .deps/install/lib64 .deps/install/lib - -####### End of AWS S3 SDK - ####### Build OpenCV WORKDIR /ovms/third_party/opencv RUN ./install_opencv.sh @@ -266,10 +257,10 @@ WORKDIR /ovms ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/runtime/lib/intel64/:/opt/opencv/lib/:/opt/intel/openvino/runtime/3rdparty/tbb/lib/ # hadolint ignore=DL3059 -RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework # Mediapipe COPY BUILD.bazel /ovms/ +COPY *\.bzl /ovms/ COPY yarn.lock /ovms/ COPY package.json /ovms/ diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 204186460e..1e40e6dda5 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -80,13 +80,6 @@ RUN CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC -Wno-erro # no-error flag related to https://github.com/aws/aws-sdk-cpp/issues/1582 ####### End of Azure SDK -# Build AWS S3 SDK -RUN git clone https://github.com/aws/aws-sdk-cpp.git --branch 1.7.129 --single-branch --depth 1 /awssdk -WORKDIR /awssdk/build -RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=s3 -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_SHARED_CRT=OFF -DSIMPLE_INSTALL=OFF -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=deprecated-declarations -Wuninitialized" .. && make --jobs=$JOBS - -####### End of AWS S3 SDK - ####### Build OpenCV WORKDIR /ovms/third_party/opencv RUN ./install_opencv.sh @@ -280,6 +273,7 @@ COPY third_party /ovms/third_party/ # Mediapipe COPY BUILD.bazel /ovms/ +COPY *\.bzl /ovms/ COPY yarn.lock /ovms/ COPY package.json /ovms/ diff --git a/Makefile b/Makefile index 96c972d8ef..0eb67ddf1d 100644 --- a/Makefile +++ b/Makefile @@ -104,12 +104,10 @@ endif STRIP = "always" BAZEL_DEBUG_BUILD_FLAGS ?= "" ifeq ($(BAZEL_BUILD_TYPE),dbg) - BAZEL_DEBUG_BUILD_FLAGS = " --copt=-g -c dbg" - STRIP = "never" + BAZEL_DEBUG_BUILD_FLAGS = " --copt=-g -c dbg" + STRIP = "never" endif -CAPI_FLAGS = "--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)" --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1" - ifeq ($(MINITRACE),ON) MINITRACE_FLAGS=" --copt=-DMTR_ENABLED" else @@ -117,13 +115,20 @@ else endif ifeq ($(OV_TRACING_ENABLE),1) - OV_TRACING_PARAMS = " --cxxopt=-DOV_TRACING=1" + OV_TRACING_PARAMS = " --cxxopt=-DOV_TRACING=1" else - OV_TRACING_PARAMS = "" + OV_TRACING_PARAMS = "" endif -BAZEL_DEBUG_FLAGS="--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)$(DISABLE_MEDIAPIPE_PARAMS)$(DISABLE_PYTHON_PARAMS)$(FUZZER_BUILD_PARAMS)$(OV_TRACING_PARAMS) - +ifeq ($(findstring ubuntu,$(BASE_OS)),ubuntu) + TARGET_DISTRO_PARAMS = " --//:distro=ubuntu" +else ifeq ($(findstring redhat,$(BASE_OS)),redhat) + TARGET_DISTRO_PARAMS = " --//:distro=redhat" +else + $(error BASE_OS must be either ubuntu or redhat) +endif +CAPI_FLAGS = "--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)" --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1"$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS) +BAZEL_DEBUG_FLAGS="--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)$(DISABLE_MEDIAPIPE_PARAMS)$(DISABLE_PYTHON_PARAMS)$(FUZZER_BUILD_PARAMS)$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS) # Option to Override release image. # Release image OS *must have* glibc version >= glibc version on BASE_OS: diff --git a/WORKSPACE b/WORKSPACE index 754e276302..db93348d0e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -294,12 +294,8 @@ workspace() load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") rules_pkg_dependencies() -# AWS S3 SDK -new_local_repository( - name = "awssdk", - build_file = "@//third_party/aws:BUILD", - path = "/awssdk", -) +load("@//third_party/aws-sdk-cpp:aws-sdk-cpp.bzl", "aws_sdk_cpp") +aws_sdk_cpp() # Azure Storage SDK new_local_repository( diff --git a/src/common_settings.bzl b/common_settings.bzl similarity index 95% rename from src/common_settings.bzl rename to common_settings.bzl index 54aca91ac9..382e76ae5a 100644 --- a/src/common_settings.bzl +++ b/common_settings.bzl @@ -19,7 +19,10 @@ #To build without mediapipe use flags - bazel build --define MEDIAPIPE_DISABLE=1 --cxxopt=-DMEDIAPIPE_DISABLE=1 //src:ovms load("@bazel_skylib//lib:selects.bzl", "selects") load("@mediapipe//mediapipe/framework:more_selects.bzl", "more_selects") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("//:distro.bzl", "distro_flag") def create_config_settings(): + distro_flag() native.config_setting( name = "disable_mediapipe", define_values = { diff --git a/distro.bzl b/distro.bzl new file mode 100644 index 0000000000..78e5b57a52 --- /dev/null +++ b/distro.bzl @@ -0,0 +1,36 @@ +# +# Copyright (c) 2024 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@mediapipe//mediapipe/framework:more_selects.bzl", "more_selects") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +def distro_flag(): + string_flag( + name = "distro", + values = ["redhat", "ubuntu"], + build_setting_default = "ubuntu", + ) + native.config_setting( + name = "redhat_build", + flag_values = { + "distro": "redhat", + }, + ) + native.config_setting( + name = "ubuntu_build", + flag_values = { + "distro": "ubuntu", + }, + ) diff --git a/rununittest.sh b/rununittest.sh index 0bde325166..8feb32436f 100755 --- a/rununittest.sh +++ b/rununittest.sh @@ -40,13 +40,13 @@ if [ "$RUN_TESTS" == "1" ] ; then if [ "$CHECK_COVERAGE" == "1" ] ; then { bazel coverage --instrumentation_filter="-src/test" --combined_report=lcov \ ${SHARED_OPTIONS} ${TEST_FILTER} \ - //src:ovms_test > ${TEST_LOG} 2>&1 || \ + //src:ovms_test ${BAZEL_OPTIONS} > ${TEST_LOG} 2>&1 || \ test_fail_procedure; } && \ generate_coverage_report; fi { bazel test \ ${SHARED_OPTIONS} "${TEST_FILTER}" \ - //src:ovms_test > ${TEST_LOG} 2>&1 || \ + //src:ovms_test ${BAZEL_OPTIONS} > ${TEST_LOG} 2>&1 || \ test_fail_procedure; } && \ test_success_procedure && \ rm -rf ${TEST_LOG}; diff --git a/src/BUILD b/src/BUILD index 71ad88f37a..bcd41b83c0 100644 --- a/src/BUILD +++ b/src/BUILD @@ -15,29 +15,23 @@ # load("@bazel_skylib//lib:selects.bzl", "selects") load("@mediapipe//mediapipe/framework:more_selects.bzl", "more_selects") -load("//src:common_settings.bzl", +load("//:common_settings.bzl", "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES", "create_config_settings") - -constraint_setting(name = "linux_distribution_family") -constraint_value(constraint_setting = "linux_distribution_family", name = "fedora") # like RHEL/CentOS -constraint_value(constraint_setting = "linux_distribution_family", name = "debian") # like Ubuntu - -create_config_settings() COPTS_ADJUSTED = COMMON_STATIC_LIBS_COPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_COPTS, + "//:fuzzer_build" : COMMON_FUZZER_COPTS, }) + select({ "//conditions:default": ["-DPYTHON_DISABLE=1"], - "//src:not_disable_python" : ["-DPYTHON_DISABLE=0"], + "//:not_disable_python" : ["-DPYTHON_DISABLE=0"], }) + select({ "//conditions:default": ["-DMEDIAPIPE_DISABLE=1"], - "//src:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], + "//:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], }) LINKOPTS_ADJUSTED = COMMON_STATIC_LIBS_LINKOPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_LINKOPTS, + "//:fuzzer_build" : COMMON_FUZZER_LINKOPTS, }) COPTS_TESTS = [ @@ -49,10 +43,10 @@ COPTS_TESTS = [ "-fvisibility=hidden",# Needed for pybind targets ] + select({ "//conditions:default": ["-DPYTHON_DISABLE=1"], - "//src:not_disable_python" : ["-DPYTHON_DISABLE=0"], + "//:not_disable_python" : ["-DPYTHON_DISABLE=0"], }) + select({ "//conditions:default": ["-DMEDIAPIPE_DISABLE=1"], - "//src:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], + "//:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], }) cc_library( @@ -80,7 +74,7 @@ cc_shared_library( "@com_github_gabime_spdlog//:__subpackages__", "@fmtlib//:__subpackages__", "@com_github_jarro2783_cxxopts//:__subpackages__", - "@awssdk//:__subpackages__", + "@aws-sdk-cpp//:__subpackages__", "@boost//:__subpackages__", "@com_github_googleapis_google_cloud_cpp//:__subpackages__", "@curl//:__subpackages__", @@ -342,7 +336,7 @@ cc_library( "tensor_conversion.hpp", "tensor_conversion.cpp", ] + select({ - "//src:not_disable_mediapipe": [ + "//:not_disable_mediapipe": [ "mediapipe_internal/mediapipefactory.cpp", "mediapipe_internal/mediapipefactory.hpp", "mediapipe_internal/mediapipegraphconfig.hpp", @@ -353,13 +347,13 @@ cc_library( "mediapipe_internal/mediapipegraphexecutor.hpp", "mediapipe_internal/packettypes.hpp", ], - "//src:disable_mediapipe" : [], + "//:disable_mediapipe" : [], }), deps = select({ - "//src:not_disable_python": [ + "//:not_disable_python": [ "//src/python:libovmspythonmodule", ], - "//src:disable_python": [] + "//:disable_python": [] }) + [ "cpp_headers", "libovmsfilesystem", @@ -385,17 +379,17 @@ cc_library( "@mediapipe//mediapipe/modules/holistic_landmark:holistic_landmark_cpu", "libovmsmediapipe_utils", ], - "//src:disable_mediapipe" : [], + "//:disable_mediapipe" : [], }), visibility = ["//visibility:public",], local_defines = COMMON_LOCAL_DEFINES, copts = COPTS_ADJUSTED, linkopts = LINKOPTS_ADJUSTED, data = select({ - "//src:not_disable_python": [ + "//:not_disable_python": [ "//src/python/binding:pyovms.so", ], - "//src:disable_python": [] + "//:disable_python": [] }), alwayslink = 1, ) @@ -864,10 +858,14 @@ cc_library( # make ovms_lib dependent, use share doptions srcs = [ "s3filesystem.cpp", ], - deps = [ - "@awssdk//:s3", - "@awssdk//:core", - "@awssdk//:deps", + deps = select({ + "//:ubuntu_build": [ + "@aws-sdk-cpp//:aws-sdk-cpp_ubuntu", + ], + "//:redhat_build": [ + "@aws-sdk-cpp//:aws-sdk-cpp_redhat", + ], + }) + [ "libovmsfilesystem", "libovmslogging", "libovmsstring_utils", @@ -991,13 +989,13 @@ cc_binary( "//conditions:default": [ "@mediapipe//mediapipe/calculators/ovms:ovms_calculator", ], - "//src:disable_mediapipe" : [], + "//:disable_mediapipe" : [], }), data = select({ - "//src:not_disable_python": [ + "//:not_disable_python": [ "//src/python/binding:pyovms.so", ], - "//src:disable_python": [] + "//:disable_python": [] }), # linkstatic = False, # Use for dynamic linking when necessary ) @@ -1081,7 +1079,7 @@ cc_test( "test/threadsafequeue_test.cpp", "test/unit_tests.cpp", ] + select({ - "//src:not_disable_mediapipe": [ + "//:not_disable_mediapipe": [ "test/get_mediapipe_graph_metadata_response_test.cpp", "test/mediapipe/inputsidepacketusertestcalc.cc", "test/mediapipeflow_test.cpp", @@ -1089,14 +1087,14 @@ cc_test( "test/mediapipe_validation_test.cpp", "test/streaming_test.cpp", ], - "//src:disable_mediapipe" : [], + "//:disable_mediapipe" : [], }) + select({ - "//src:not_disable_python": [ + "//:not_disable_python": [ "test/pythonnode_test.cpp", # OvmsPyTensor is currently not used in OVMS core and is just a base for the binding. # "test/python/ovms_py_tensor_test.cpp", ], - "//src:disable_python" : [], + "//:disable_python" : [], }), data = [ "test/add_two_inputs_model/1/add.xml", @@ -1220,7 +1218,7 @@ cc_test( "@mediapipe//mediapipe/calculators/ovms:ovms_calculator", "@mediapipe//mediapipe/framework:calculator_runner", ], - "//src:disable_mediapipe" : [], + "//:disable_mediapipe" : [], }), copts = COPTS_TESTS, ) diff --git a/src/python/BUILD b/src/python/BUILD index 68589a98f9..ad52aeb181 100644 --- a/src/python/BUILD +++ b/src/python/BUILD @@ -16,23 +16,23 @@ load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") load("@mediapipe//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library", "mediapipe_proto_library") -load("//src:common_settings.bzl", +load("//:common_settings.bzl", "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES", "PYBIND_DEPS") COPTS_ADJUSTED = COMMON_STATIC_LIBS_COPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_COPTS, + "//:fuzzer_build" : COMMON_FUZZER_COPTS, }) + select({ "//conditions:default": ["-DPYTHON_DISABLE=1"], - "//src:not_disable_python" : ["-DPYTHON_DISABLE=0"], + "//:not_disable_python" : ["-DPYTHON_DISABLE=0"], }) + select({ "//conditions:default": ["-DMEDIAPIPE_DISABLE=1"], - "//src:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], + "//:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], }) LINKOPTS_ADJUSTED = COMMON_STATIC_LIBS_LINKOPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_LINKOPTS, + "//:fuzzer_build" : COMMON_FUZZER_LINKOPTS, }) mediapipe_proto_library( diff --git a/src/python/binding/BUILD b/src/python/binding/BUILD index cfc3d0b3a9..a81b54dd82 100644 --- a/src/python/binding/BUILD +++ b/src/python/binding/BUILD @@ -16,23 +16,23 @@ load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") load("@mediapipe//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library", "mediapipe_proto_library") -load("//src:common_settings.bzl", +load("//:common_settings.bzl", "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES", "PYBIND_DEPS") COPTS_ADJUSTED = COMMON_STATIC_LIBS_COPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_COPTS, + "//:fuzzer_build" : COMMON_FUZZER_COPTS, }) + select({ "//conditions:default": ["-DPYTHON_DISABLE=1"], - "//src:not_disable_python" : ["-DPYTHON_DISABLE=0"], + "//:not_disable_python" : ["-DPYTHON_DISABLE=0"], }) + select({ "//conditions:default": ["-DMEDIAPIPE_DISABLE=1"], - "//src:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], + "//:not_disable_mediapipe" : ["-DMEDIAPIPE_DISABLE=0"], }) LINKOPTS_ADJUSTED = COMMON_STATIC_LIBS_LINKOPTS + select({ "//conditions:default": [], - "//src:fuzzer_build" : COMMON_FUZZER_LINKOPTS, + "//:fuzzer_build" : COMMON_FUZZER_LINKOPTS, }) load("@pip_deps//:requirements.bzl", "all_requirements") diff --git a/src/test/mediapipe/calculators/BUILD b/src/test/mediapipe/calculators/BUILD index 79491a6f97..02f50eb5bb 100644 --- a/src/test/mediapipe/calculators/BUILD +++ b/src/test/mediapipe/calculators/BUILD @@ -55,7 +55,7 @@ cc_library( ] + select({ "//conditions:default": [ ], - "//src:fuzzer_build" : [ + "//:fuzzer_build" : [ "-fsanitize=address", "-fprofile-generate", "-ftest-coverage", @@ -74,7 +74,7 @@ cc_library( linkopts = select({ "//conditions:default": [ ], - "//src:fuzzer_build" : [ + "//:fuzzer_build" : [ "-fprofile-generate", "-fsanitize=address", "-fsanitize-coverage=trace-pc", diff --git a/tf.patch b/tf.patch deleted file mode 100644 index 9854bb2209..0000000000 --- a/tf.patch +++ /dev/null @@ -1,472 +0,0 @@ -diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD -index b2998173b53..afd5f4eabfe 100644 ---- a/tensorflow/tools/proto_text/BUILD -+++ b/tensorflow/tools/proto_text/BUILD -@@ -39,7 +39,8 @@ cc_binary( - "//tensorflow/core:lib_proto_parsing", - "//tensorflow/tsl/platform:protobuf_compiler", - "@com_google_protobuf//:protobuf", -- ] + if_ios(["//tensorflow/core/platform:logging"]), -+ ] + ["//tensorflow/tsl/platform:logging", -+ "//tensorflow/tsl/platform/default:glog"], - ) - - cc_library( -diff --git a/tensorflow/tsl/platform/default/BUILD b/tensorflow/tsl/platform/default/BUILD -index 3542c8ae3e8..ea7b8e4db8f 100644 ---- a/tensorflow/tsl/platform/default/BUILD -+++ b/tensorflow/tsl/platform/default/BUILD -@@ -229,6 +229,19 @@ cc_library( - ], - ) - -+cc_library( -+ name = "log_macros", -+ hdrs = ["log_macros.h"], -+ visibility = ["//visibility:public"], -+) -+ -+cc_library( -+ name = "glog", -+ #hdrs = ["@com_github_glog_glog//:glog/logging.h",] -+ visibility = ["//visibility:public"], -+ deps = ["@com_github_glog_glog//:glog",], -+) -+ - cc_library( - name = "logging", - srcs = ["logging.cc"], -@@ -247,6 +260,8 @@ cc_library( - "//tensorflow/tsl/platform:types", - "@com_google_absl//absl/base", - "@com_google_absl//absl/strings", -+ ":glog", -+ ":log_macros", - ], - ) - -diff --git a/tensorflow/tsl/platform/default/log_macros.h b/tensorflow/tsl/platform/default/log_macros.h -new file mode 100644 -index 00000000000..31ba58594cc ---- /dev/null -+++ b/tensorflow/tsl/platform/default/log_macros.h -@@ -0,0 +1,99 @@ -+#pragma once -+#define LOG(severity) _TF_LOG_##severity -+ -+// An instance of `LOG_EVERY_N` increments a hidden zero-initialized counter -+// every time execution passes through it and logs the specified message when -+// the counter's value is a multiple of `n`, doing nothing otherwise. Each -+// instance has its own counter. The counter's value can be logged by streaming -+// the symbol `COUNTER`. `LOG_EVERY_N` is thread-safe. -+// Example: -+// -+// for (const auto& user : all_users) { -+// LOG_EVERY_N(INFO, 1000) << "Processing user #" << COUNTER; -+// ProcessUser(user); -+// } -+ -+// CHECK dies with a fatal error if condition is not true. It is *not* -+// controlled by NDEBUG, so the check will be executed regardless of -+// compilation mode. Therefore, it is safe to do things like: -+// CHECK(fp->Write(x) == 4) -+#define CHECK(condition) \ -+ if (TF_PREDICT_FALSE(!(condition))) \ -+ LOG(FATAL) << "Check failed: " #condition " " -+// `LOG_FIRST_N` behaves like `LOG_EVERY_N` except that the specified message is -+// logged when the counter's value is less than `n`. `LOG_FIRST_N` is -+// thread-safe. -+ -+#define VLOG(level) \ -+ TF_PREDICT_TRUE(!VLOG_IS_ON(level)) \ -+ ? (void)0 \ -+ : ::tsl::internal::Voidifier() & \ -+ ::tsl::internal::LogMessage(__FILE__, __LINE__, \ -+ tensorflow::INFO) -+ -+// `DVLOG` behaves like `VLOG` in debug mode (i.e. `#ifndef NDEBUG`). -+// Otherwise, it compiles away and does nothing. -+#ifndef NDEBUG -+#define DVLOG VLOG -+#else -+#ifndef DVLOG -+#define DVLOG(verbose_level) \ -+ while (false && (verbose_level) > 0) ::tsl::internal::LogMessageNull() -+#endif -+#endif -+ -+ -+// In optimized mode, use CheckOpString to hint to compiler that -+// the while condition is unlikely. -+#ifndef CHECK_OP_LOG -+#define CHECK_OP_LOG(name, op, val1, val2) \ -+ while (::tsl::internal::CheckOpString _result{ \ -+ ::tsl::internal::name##Impl( \ -+ ::tsl::internal::GetReferenceableValue(val1), \ -+ ::tsl::internal::GetReferenceableValue(val2), \ -+ #val1 " " #op " " #val2)}) \ -+ ::tsl::internal::LogMessageFatal(__FILE__, __LINE__) << *(_result.str_) -+#endif -+#ifndef CHECK_OP -+#define CHECK_OP(name, op, val1, val2) CHECK_OP_LOG(name, op, val1, val2) -+#endif -+ -+// CHECK_EQ/NE/... -+#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2) -+#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2) -+#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2) -+#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2) -+#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2) -+#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2) -+ -+ -+#ifndef NDEBUG -+// DCHECK_EQ/NE/... -+#define DCHECK(condition) CHECK(condition) -+#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2) -+#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2) -+#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2) -+#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2) -+#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2) -+#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2) -+ -+#else -+ -+#define DCHECK(condition) \ -+ while (false && (condition)) LOG(FATAL) -+ -+// NDEBUG is defined, so DCHECK_EQ(x, y) and so on do nothing. -+// However, we still want the compiler to parse x and y, because -+// we don't want to lose potentially useful errors and warnings. -+// _DCHECK_NOP is a helper, and should not be used outside of this file. -+#define _TF_DCHECK_NOP(x, y) \ -+ while (false && ((void)(x), (void)(y), 0)) LOG(FATAL) -+ -+#define DCHECK_EQ(x, y) _TF_DCHECK_NOP(x, y) -+#define DCHECK_NE(x, y) _TF_DCHECK_NOP(x, y) -+#define DCHECK_LE(x, y) _TF_DCHECK_NOP(x, y) -+#define DCHECK_LT(x, y) _TF_DCHECK_NOP(x, y) -+#define DCHECK_GE(x, y) _TF_DCHECK_NOP(x, y) -+#define DCHECK_GT(x, y) _TF_DCHECK_NOP(x, y) -+ -+#endif -diff --git a/tensorflow/tsl/platform/default/logging.cc b/tensorflow/tsl/platform/default/logging.cc -index 9f978e29599..429190a6218 100644 ---- a/tensorflow/tsl/platform/default/logging.cc -+++ b/tensorflow/tsl/platform/default/logging.cc -@@ -381,7 +381,6 @@ void LogString(const char* fname, int line, int severity, - LogMessage(fname, line, severity) << message; - } - --template <> - void MakeCheckOpValueString(std::ostream* os, const char& v) { - if (v >= 32 && v <= 126) { - (*os) << "'" << v << "'"; -@@ -390,7 +389,6 @@ void MakeCheckOpValueString(std::ostream* os, const char& v) { - } - } - --template <> - void MakeCheckOpValueString(std::ostream* os, const signed char& v) { - if (v >= 32 && v <= 126) { - (*os) << "'" << v << "'"; -@@ -399,7 +397,6 @@ void MakeCheckOpValueString(std::ostream* os, const signed char& v) { - } - } - --template <> - void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) { - if (v >= 32 && v <= 126) { - (*os) << "'" << v << "'"; -@@ -409,7 +406,6 @@ void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) { - } - - #if LANG_CXX11 --template <> - void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v) { - (*os) << "nullptr"; - } -diff --git a/tensorflow/tsl/platform/default/logging.h b/tensorflow/tsl/platform/default/logging.h -index 417d7d81f83..84f7e1d5c2f 100644 ---- a/tensorflow/tsl/platform/default/logging.h -+++ b/tensorflow/tsl/platform/default/logging.h -@@ -43,6 +43,7 @@ limitations under the License. - // Undef everything in case we're being mixed with some other Google library - // which already defined them itself. Presumably all Google libraries will - // support the same syntax for these so it should not be a big deal if they -+#define COMPACT_GOOGLE_LOG_QFATAL COMPACT_GOOGLE_LOG_ERROR - // end up using our definitions instead. - #undef LOG - #undef VLOG -@@ -63,6 +64,15 @@ limitations under the License. - #undef DCHECK_GT - #undef DCHECK_GE - -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wsign-compare" -+#include "glog/logging.h" -+#pragma GCC diagnostic pop -+ -+#ifndef LOG -+#include "log_macros.h" -+#endif -+ - namespace tsl { - const int INFO = 0; // base_logging::INFO; - const int WARNING = 1; // base_logging::WARNING; -@@ -142,42 +152,6 @@ class LogMessageNull : public std::basic_ostringstream { - - #define _TF_LOG_QFATAL _TF_LOG_FATAL - --#define LOG(severity) _TF_LOG_##severity -- --#ifdef IS_MOBILE_PLATFORM -- --// Turn VLOG off when under mobile devices for considerations of binary size. --#define VLOG_IS_ON(lvl) ((lvl) <= 0) -- --#else -- --// Otherwise, set TF_CPP_MAX_VLOG_LEVEL environment to update minimum log level --// of VLOG, or TF_CPP_VMODULE to set the minimum log level for individual --// translation units. --#define VLOG_IS_ON(lvl) \ -- (([](int level, const char* fname) { \ -- static const bool vmodule_activated = \ -- ::tsl::internal::LogMessage::VmoduleActivated(fname, level); \ -- return vmodule_activated; \ -- })(lvl, __FILE__)) -- --#endif -- --#define VLOG(level) \ -- TF_PREDICT_TRUE(!VLOG_IS_ON(level)) \ -- ? (void)0 \ -- : ::tsl::internal::Voidifier() & \ -- ::tsl::internal::LogMessage(__FILE__, __LINE__, tsl::INFO) -- --// `DVLOG` behaves like `VLOG` in debug mode (i.e. `#ifndef NDEBUG`). --// Otherwise, it compiles away and does nothing. --#ifndef NDEBUG --#define DVLOG VLOG --#else --#define DVLOG(verbose_level) \ -- while (false && (verbose_level) > 0) ::tsl::internal::LogMessageNull() --#endif -- - class LogEveryNState { - public: - bool ShouldLog(int n); -@@ -244,26 +218,6 @@ class LogEveryNSecState { - logging_internal_stateful_condition_do_log; \ - logging_internal_stateful_condition_do_log = false) - --// An instance of `LOG_EVERY_N` increments a hidden zero-initialized counter --// every time execution passes through it and logs the specified message when --// the counter's value is a multiple of `n`, doing nothing otherwise. Each --// instance has its own counter. The counter's value can be logged by streaming --// the symbol `COUNTER`. `LOG_EVERY_N` is thread-safe. --// Example: --// --// for (const auto& user : all_users) { --// LOG_EVERY_N(INFO, 1000) << "Processing user #" << COUNTER; --// ProcessUser(user); --// } --#define LOG_EVERY_N(severity, n) \ -- LOGGING_INTERNAL_STATEFUL_CONDITION(EveryN, true, n) \ -- LOG(severity) --// `LOG_FIRST_N` behaves like `LOG_EVERY_N` except that the specified message is --// logged when the counter's value is less than `n`. `LOG_FIRST_N` is --// thread-safe. --#define LOG_FIRST_N(severity, n) \ -- LOGGING_INTERNAL_STATEFUL_CONDITION(FirstN, true, n) \ -- LOG(severity) - // `LOG_EVERY_POW_2` behaves like `LOG_EVERY_N` except that the specified - // message is logged when the counter's value is a power of 2. - // `LOG_EVERY_POW_2` is thread-safe. -@@ -281,13 +235,6 @@ class LogEveryNSecState { - LOGGING_INTERNAL_STATEFUL_CONDITION(EveryNSec, true, n_seconds) \ - LOG(severity) - --// CHECK dies with a fatal error if condition is not true. It is *not* --// controlled by NDEBUG, so the check will be executed regardless of --// compilation mode. Therefore, it is safe to do things like: --// CHECK(fp->Write(x) == 4) --#define CHECK(condition) \ -- if (TF_PREDICT_FALSE(!(condition))) \ -- LOG(FATAL) << "Check failed: " #condition " " - - // Function is overloaded for integral types to allow static const - // integrals declared in classes and not defined to be used as arguments to -@@ -306,28 +253,6 @@ inline unsigned int GetReferenceableValue(unsigned int t) { return t; } - inline int64_t GetReferenceableValue(int64_t t) { return t; } - inline uint64 GetReferenceableValue(uint64 t) { return t; } - --// This formats a value for a failing CHECK_XX statement. Ordinarily, --// it uses the definition for operator<<, with a few special cases below. --template --inline void MakeCheckOpValueString(std::ostream* os, const T& v) { -- (*os) << v; --} -- --// Overrides for char types provide readable values for unprintable --// characters. --template <> --void MakeCheckOpValueString(std::ostream* os, const char& v); --template <> --void MakeCheckOpValueString(std::ostream* os, const signed char& v); --template <> --void MakeCheckOpValueString(std::ostream* os, const unsigned char& v); -- --#if LANG_CXX11 --// We need an explicit specialization for std::nullptr_t. --template <> --void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v); --#endif -- - // A container for a string pointer which can be evaluated to a bool - - // true iff the pointer is non-NULL. - struct CheckOpString { -@@ -338,17 +263,6 @@ struct CheckOpString { - string* str_; - }; - --// Build the error message string. Specify no inlining for code size. --template --string* MakeCheckOpString(const T1& v1, const T2& v2, -- const char* exprtext) TF_ATTRIBUTE_NOINLINE; -- --// A helper class for formatting "expr (V1 vs. V2)" in a CHECK_XX --// statement. See MakeCheckOpString for sample usage. Other --// approaches were considered: use of a template method (e.g., --// base::BuildCheckOpString(exprtext, base::Print, &v1, --// base::Print, &v2), however this approach has complications --// related to volatile arguments and function-pointer arguments). - class CheckOpMessageBuilder { - public: - // Inserts "exprtext" and " (" to the stream. -@@ -366,14 +280,6 @@ class CheckOpMessageBuilder { - std::ostringstream* stream_; - }; - --template --string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) { -- CheckOpMessageBuilder comb(exprtext); -- MakeCheckOpValueString(comb.ForVar1(), v1); -- MakeCheckOpValueString(comb.ForVar2(), v2); -- return comb.NewString(); --} -- - // Helper functions for CHECK_OP macro. - // We use the full name Check_EQ, Check_NE, etc. in case the file including - // base/logging.h provides its own #defines for the simpler names EQ, NE, etc. -@@ -389,7 +295,8 @@ string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) { - if (TF_PREDICT_TRUE(v1 op v2)) \ - return NULL; \ - else \ -- return ::tsl::internal::MakeCheckOpString(v1, v2, exprtext); \ -+ /*return ::tsl::internal::MakeCheckOpString(v1, v2, exprtext);*/ \ -+ return google::MakeCheckOpString(v1, v2, exprtext); \ - } \ - inline string* name##Impl(int v1, int v2, const char* exprtext) { \ - return name##Impl(v1, v2, exprtext); \ -@@ -404,7 +311,7 @@ TF_DEFINE_CHECK_OP_IMPL(Check_EQ, ==) - - inline string* Check_EQImpl(int v1, size_t v2, const char* exprtext) { - if (TF_PREDICT_FALSE(v1 < 0)) -- ::tsl::internal::MakeCheckOpString(v1, v2, exprtext); -+ google::MakeCheckOpString(v1, v2, exprtext); - - return Check_EQImpl(size_t(v1), v2, exprtext); - } -@@ -435,7 +342,7 @@ inline string* Check_LEImpl(int v1, size_t v2, const char* exprtext) { - - inline string* Check_LEImpl(size_t v1, int v2, const char* exprtext) { - if (TF_PREDICT_FALSE(v2 < 0)) -- return ::tsl::internal::MakeCheckOpString(v1, v2, exprtext); -+ return google::MakeCheckOpString(v1, v2, exprtext); - return Check_LEImpl(v1, size_t(v2), exprtext); - } - -@@ -448,7 +355,7 @@ inline string* Check_LTImpl(int v1, size_t v2, const char* exprtext) { - } - - inline string* Check_LTImpl(size_t v1, int v2, const char* exprtext) { -- if (v2 < 0) return ::tsl::internal::MakeCheckOpString(v1, v2, exprtext); -+ if (v2 < 0) return google::MakeCheckOpString(v1, v2, exprtext); - return Check_LTImpl(v1, size_t(v2), exprtext); - } - -@@ -465,58 +372,6 @@ inline string* Check_GTImpl(const T1& v1, const T2& v2, const char* exprtext) { - - #undef TF_DEFINE_CHECK_OP_IMPL - --// In optimized mode, use CheckOpString to hint to compiler that --// the while condition is unlikely. --#define CHECK_OP_LOG(name, op, val1, val2) \ -- while (::tsl::internal::CheckOpString _result{::tsl::internal::name##Impl( \ -- ::tsl::internal::GetReferenceableValue(val1), \ -- ::tsl::internal::GetReferenceableValue(val2), #val1 " " #op " " #val2)}) \ -- ::tsl::internal::LogMessageFatal(__FILE__, __LINE__) << *(_result.str_) -- --#define CHECK_OP(name, op, val1, val2) CHECK_OP_LOG(name, op, val1, val2) -- --// CHECK_EQ/NE/... --#define CHECK_EQ(val1, val2) CHECK_OP(Check_EQ, ==, val1, val2) --#define CHECK_NE(val1, val2) CHECK_OP(Check_NE, !=, val1, val2) --#define CHECK_LE(val1, val2) CHECK_OP(Check_LE, <=, val1, val2) --#define CHECK_LT(val1, val2) CHECK_OP(Check_LT, <, val1, val2) --#define CHECK_GE(val1, val2) CHECK_OP(Check_GE, >=, val1, val2) --#define CHECK_GT(val1, val2) CHECK_OP(Check_GT, >, val1, val2) --#define CHECK_NOTNULL(val) \ -- ::tsl::internal::CheckNotNull(__FILE__, __LINE__, \ -- "'" #val "' Must be non NULL", (val)) -- --#ifndef NDEBUG --// DCHECK_EQ/NE/... --#define DCHECK(condition) CHECK(condition) --#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2) --#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2) --#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2) --#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2) --#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2) --#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2) -- --#else -- --#define DCHECK(condition) \ -- while (false && (condition)) LOG(FATAL) -- --// NDEBUG is defined, so DCHECK_EQ(x, y) and so on do nothing. --// However, we still want the compiler to parse x and y, because --// we don't want to lose potentially useful errors and warnings. --// _DCHECK_NOP is a helper, and should not be used outside of this file. --#define _TF_DCHECK_NOP(x, y) \ -- while (false && ((void)(x), (void)(y), 0)) LOG(FATAL) -- --#define DCHECK_EQ(x, y) _TF_DCHECK_NOP(x, y) --#define DCHECK_NE(x, y) _TF_DCHECK_NOP(x, y) --#define DCHECK_LE(x, y) _TF_DCHECK_NOP(x, y) --#define DCHECK_LT(x, y) _TF_DCHECK_NOP(x, y) --#define DCHECK_GE(x, y) _TF_DCHECK_NOP(x, y) --#define DCHECK_GT(x, y) _TF_DCHECK_NOP(x, y) -- --#endif -- - // These are for when you don't want a CHECK failure to print a verbose - // stack trace. The implementation of CHECK* in this file already doesn't. - #define QCHECK(condition) CHECK(condition) -diff --git a/tensorflow/tsl/platform/logging.h b/tensorflow/tsl/platform/logging.h -index 68c209fa491..dfe5c45700c 100644 ---- a/tensorflow/tsl/platform/logging.h -+++ b/tensorflow/tsl/platform/logging.h -@@ -21,7 +21,8 @@ limitations under the License. - #if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID) || \ - defined(PLATFORM_GOOGLE_IOS) || defined(GOOGLE_LOGGING) || \ - defined(__EMSCRIPTEN__) || defined(PLATFORM_CHROMIUMOS) --#include "tensorflow/tsl/platform/google/logging.h" // IWYU pragma: export -+#include "tensorflow/tsl/platform/default/logging.h" // IWYU pragma: export -+//#include "tensorflow/tsl/platform/google/logging.h" // IWYU pragma: export - #else - #include "tensorflow/tsl/platform/default/logging.h" // IWYU pragma: export - #endif diff --git a/third_party/aws-sdk-cpp/BUILD b/third_party/aws-sdk-cpp/BUILD new file mode 100644 index 0000000000..9c4ccf9af2 --- /dev/null +++ b/third_party/aws-sdk-cpp/BUILD @@ -0,0 +1,15 @@ +# +# Copyright (c) 2024 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/third_party/aws-sdk-cpp/aws-sdk-cpp.bzl b/third_party/aws-sdk-cpp/aws-sdk-cpp.bzl new file mode 100644 index 0000000000..09fd2f04db --- /dev/null +++ b/third_party/aws-sdk-cpp/aws-sdk-cpp.bzl @@ -0,0 +1,195 @@ +# +# Copyright (c) 2024 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") +def aws_sdk_cpp(): + aws_sdk_cpp_repository(name="_aws_sdk_cpp") + new_git_repository( + name = "aws-sdk-cpp", + remote = "https://github.com/aws/aws-sdk-cpp.git", + build_file = "@_aws_sdk_cpp//:BUILD", + tag = "1.11.268", + init_submodules = True, + recursive_init_submodules = True, + # https://github.com/bazelbuild/bazel/issues/374 + # issues with ASCI handling of file_test.c *xample file.txt in bazel + patch_cmds = ["find . -name '*xample.txt' -delete"], + ) + + +def _impl(repository_ctx): + http_proxy = repository_ctx.os.environ.get("http_proxy", "") + https_proxy = repository_ctx.os.environ.get("https_proxy", "") + # Note we need to escape '{/}' by doubling them due to call to format + build_file_content = """ +load("@rules_foreign_cc//foreign_cc:cmake.bzl", "cmake") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") + +visibility = ["//visibility:public"] + +config_setting( + name = "dbg", + values = {{"compilation_mode": "dbg"}}, +) + +config_setting( + name = "opt", + values = {{"compilation_mode": "opt"}}, +) + +filegroup( + name = "all_srcs", + srcs = glob(["**"]), + visibility = ["//visibility:public"], +) + +cmake( + name = "aws-sdk-cpp_cmake_ubuntu", + build_args = [ + "--verbose", + "--", # <- Pass remaining options to the native tool. + # https://github.com/bazelbuild/rules_foreign_cc/issues/329 + # there is no elegant paralell compilation support + "VERBOSE=1", + "-j 4", + ], + cache_entries = {{ + "CMAKE_BUILD_TYPE": "Release", + "BUILD_ONLY": "s3", # core builds always + "ENABLE_TESTING": "OFF", + "AUTORUN_UNIT_TESTS": "OFF", + "BUILD_SHARED_LIBS": "OFF", + "MINIMIZE_SIZE": "ON", + "CMAKE_POSITION_INDEPENDENT_CODE": "ON", + "FORCE_SHARED_CRT": "OFF", + "SIMPLE_INSTALL": "OFF", + "CMAKE_CXX_FLAGS": "-D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=deprecated-declarations -Wuninitialized\", + }}, + env = {{ + "HTTP_PROXY": "{http_proxy}", + "HTTPS_PROXY": "{https_proxy}", + }}, + lib_source = ":all_srcs", + out_lib_dir = "lib", + # linking order + out_static_libs = select({{ + "//conditions:default": [ + "linux/intel64/Release/libaws-cpp-sdk-s3.a", + "linux/intel64/Release/libaws-cpp-sdk-core.a", + ], + ":dbg": [ + "linux/intel64/Debug/libaws-cpp-sdk-s3.a", + "linux/intel64/Debug/libaws-cpp-sdk-core.a", + ], + }}) + [ + "libaws-crt-cpp.a", + "libaws-c-s3.a", + "libaws-c-auth.a", + "libaws-c-cal.a", + "libaws-c-http.a", + "libaws-c-io.a", + "libs2n.a", + "libaws-c-compression.a", + "libaws-c-sdkutils.a", + "libaws-c-mqtt.a", + "libaws-c-event-stream.a", + "libaws-checksums.a", + "libaws-c-common.a", + ], + tags = ["requires-network"], + alwayslink = False, + visibility = ["//visibility:public"], +) + +cc_library( + name = "aws-sdk-cpp_ubuntu", + deps = [ + ":aws-sdk-cpp_cmake_ubuntu", + ], + visibility = ["//visibility:public"], + alwayslink = False, +) +cmake( + name = "aws-sdk-cpp_cmake_redhat", + build_args = [ + "--verbose", + "--", # <- Pass remaining options to the native tool. + # https://github.com/bazelbuild/rules_foreign_cc/issues/329 + # there is no elegant paralell compilation support + "VERBOSE=1", + "-j 4", + ], + cache_entries = {{ + "CMAKE_BUILD_TYPE": "Release", + "BUILD_ONLY": "s3", # core builds always + "ENABLE_TESTING": "OFF", + "AUTORUN_UNIT_TESTS": "OFF", + "BUILD_SHARED_LIBS": "OFF", + "MINIMIZE_SIZE": "ON", + "CMAKE_POSITION_INDEPENDENT_CODE": "ON", + "FORCE_SHARED_CRT": "OFF", + "SIMPLE_INSTALL": "OFF", + "CMAKE_CXX_FLAGS": "-D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=deprecated-declarations -Wuninitialized\", + }}, + env = {{ + "HTTP_PROXY": "{http_proxy}", + "HTTPS_PROXY": "{https_proxy}", + }}, + lib_source = ":all_srcs", + out_lib_dir = "lib64", + # linking order + out_static_libs = select({{ + "//conditions:default": [ + "linux/intel64/Release/libaws-cpp-sdk-s3.a", + "linux/intel64/Release/libaws-cpp-sdk-core.a", + ], + ":dbg": [ + "linux/intel64/Debug/libaws-cpp-sdk-s3.a", + "linux/intel64/Debug/libaws-cpp-sdk-core.a", + ], + }}) + [ + "libaws-crt-cpp.a", + "libaws-c-s3.a", + "libaws-c-auth.a", + "libaws-c-cal.a", + "libaws-c-http.a", + "libaws-c-io.a", + "libs2n.a", + "libaws-c-compression.a", + "libaws-c-sdkutils.a", + "libaws-c-mqtt.a", + "libaws-c-event-stream.a", + "libaws-checksums.a", + "libaws-c-common.a", + ], + tags = ["requires-network"], + alwayslink = False, + visibility = ["//visibility:public"], +) +cc_library( + name = "aws-sdk-cpp_redhat", + deps = [ + ":aws-sdk-cpp_cmake_redhat", + ], + visibility = ["//visibility:public"], + alwayslink = False, +) +""" + repository_ctx.file("BUILD", build_file_content.format(http_proxy=http_proxy, https_proxy=https_proxy)) + +aws_sdk_cpp_repository = repository_rule( + implementation = _impl, + local=False, +) diff --git a/third_party/aws/BUILD b/third_party/aws/BUILD deleted file mode 100644 index b02fd412b2..0000000000 --- a/third_party/aws/BUILD +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (c) 2020 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package( - default_visibility = ["//visibility:public"], -) - -# TODO: Decide if we want to switch to genrule cmake for all docker compilations -# | sed -E 's:(/sandbox/.+)::g') -#genrule( -# name = "aws_cmake", -# outs = ["build"], -# cmd = 'cd external/awssdk && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=s3 -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_SHARED_CRT=OFF -DSIMPLE_INSTALL=OFF -DCMAKE_CXX_FLAGS=" -D_GLIBCXX_USE_CXX11_ABI=1 " .. && make', -#) - -cc_library( - name = "core", - srcs = ["build/aws-cpp-sdk-core/libaws-cpp-sdk-core.a"], - hdrs = glob([ - "aws-cpp-sdk-core/include/**/*.h", - ]), - strip_include_prefix = "aws-cpp-sdk-core/include", -) - -cc_library( - name = "s3", - srcs = ["build/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.a"], - hdrs = glob([ - "aws-cpp-sdk-s3/include/**/*.h", - ]), - strip_include_prefix = "aws-cpp-sdk-s3/include", -) - -cc_library( - name = "deps", - srcs = [ - "build/.deps/install/lib/libaws-c-event-stream.a", - "build/.deps/install/lib/libaws-checksums.a", - "build/.deps/install/lib/libaws-c-common.a" - ], - hdrs = glob([ - "build/.deps/install/include/**/*.*", - ]), - strip_include_prefix = "build/.deps/install/include", -)