From 44573323dd6ec4fa27b22a422fe5b302426341e0 Mon Sep 17 00:00:00 2001 From: storypku Date: Mon, 5 Oct 2020 14:43:57 +0800 Subject: [PATCH] Build: set use_esd_can to False for arm64 --- apollo.sh | 10 ++++++---- modules/drivers/canbus/can_client/esd/BUILD | 16 +++++++++------- third_party/can_card_library/esd_can/BUILD | 10 +++------- tools/platform/build_defs.bzl | 6 ++++++ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apollo.sh b/apollo.sh index 289692b410..82322cf187 100755 --- a/apollo.sh +++ b/apollo.sh @@ -26,7 +26,7 @@ function check_architecture_support() { function check_platform_support() { local platform="$(uname -s)" - if [ "$platform" != "Linux" ]; then + if [[ "${platform}" != "Linux" ]]; then error "Unsupported platform: ${platform}." error "${TAB}Apollo is expected to run on Linux systems (E.g., Debian/Ubuntu)." exit 1 @@ -45,8 +45,9 @@ function check_minimal_memory_requirement() { function determine_esdcan_use() { local esdcan_dir="${APOLLO_ROOT_DIR}/third_party/can_card_library/esd_can" local use_esd=false - if [ -f "${esdcan_dir}/include/ntcan.h" ] && - [ -f "${esdcan_dir}/lib/libntcan.so.4" ]; then + if [[ "${ARCH}" == "x86_64" ]] && + [[ -f "${esdcan_dir}/include/ntcan.h" ]] && + [[ -f "${esdcan_dir}/lib/libntcan.so.4" ]]; then use_esd=true fi USE_ESD_CAN="${use_esd}" @@ -160,7 +161,8 @@ function main() { local coverage_sh="${APOLLO_ROOT_DIR}/scripts/apollo_coverage.sh" local ci_sh="${APOLLO_ROOT_DIR}/scripts/apollo_ci.sh" - local cmd="$1"; shift + local cmd="$1" + shift case "${cmd}" in config) env ${APOLLO_ENV} bash "${APOLLO_ROOT_DIR}/scripts/apollo_config.sh" "$@" diff --git a/modules/drivers/canbus/can_client/esd/BUILD b/modules/drivers/canbus/can_client/esd/BUILD index 9fdcd8a174..a4143a4850 100644 --- a/modules/drivers/canbus/can_client/esd/BUILD +++ b/modules/drivers/canbus/can_client/esd/BUILD @@ -1,28 +1,30 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("//tools/platform:build_defs.bzl", "if_esd_can") load("//tools:cpplint.bzl", "cpplint") package(default_visibility = ["//visibility:public"]) cc_library( name = "esd_can_client", - srcs = ["esd_can_client.cc"], - hdrs = ["esd_can_client.h"], - deps = [ + srcs = if_esd_can(["esd_can_client.cc"]), + hdrs = if_esd_can(["esd_can_client.h"]), + deps = if_esd_can([ "//modules/common/proto:error_code_cc_proto", "//modules/drivers/canbus:sensor_gflags", "//modules/drivers/canbus/can_client", "//third_party/can_card_library/esd_can", - ], + ]), ) cc_test( name = "esd_can_client_test", size = "small", - srcs = ["esd_can_client_test.cc"], - deps = [ + srcs = if_esd_can(["esd_can_client_test.cc"]), + deps = if_esd_can([ + ":esd_can_client", "//cyber", - "//modules/drivers/canbus/can_client/esd:esd_can_client", "//modules/drivers/canbus/common:canbus_common", + ]) + [ "@com_google_googletest//:gtest_main", ], ) diff --git a/third_party/can_card_library/esd_can/BUILD b/third_party/can_card_library/esd_can/BUILD index 42c9a7cf0e..b0365f2c76 100644 --- a/third_party/can_card_library/esd_can/BUILD +++ b/third_party/can_card_library/esd_can/BUILD @@ -1,16 +1,12 @@ load("@rules_cc//cc:defs.bzl", "cc_library") - +load("//tools/platform:build_defs.bzl", "if_esd_can") package(default_visibility = ["//visibility:public"]) licenses(["notice"]) cc_library( name = "esd_can", - srcs = [ - "lib/libntcan.so.4", - ], - hdrs = [ - "include/ntcan.h", - ], + srcs = if_esd_can(["lib/libntcan.so.4"]), + hdrs = if_esd_can(["include/ntcan.h"]), include_prefix = "esd_can", ) diff --git a/tools/platform/build_defs.bzl b/tools/platform/build_defs.bzl index 0a538b66d6..678598ef3c 100644 --- a/tools/platform/build_defs.bzl +++ b/tools/platform/build_defs.bzl @@ -32,3 +32,9 @@ def if_aarch64_mode(if_true, if_false = []): "//tools/platform:aarch64_mode": if_true, "//conditions:default": if_false, }) + +def if_esd_can(if_true, if_false = []): + return select({ + "//tools/platform:use_esd_can": if_true, + "//conditions:default": if_false, + }) -- GitLab