Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bazel to build aws-sdk-cpp #2334

Merged
merged 18 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
.venv-style
44 changes: 16 additions & 28 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions Dockerfile.redhat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/

Expand Down
8 changes: 1 addition & 7 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/

Expand Down
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,31 @@ 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
MINITRACE_FLAGS=""
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:
Expand Down
8 changes: 2 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions src/common_settings.bzl → common_settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
36 changes: 36 additions & 0 deletions distro.bzl
Original file line number Diff line number Diff line change
@@ -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",
},
)
4 changes: 2 additions & 2 deletions rununittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading