Skip to content

Commit

Permalink
Bazel: add no_match_error for select, free compilation tips at build …
Browse files Browse the repository at this point in the history
…step
  • Loading branch information
mickeyouyou authored and xiaoxq committed Nov 14, 2019
1 parent 1bde80b commit 741b3e3
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 63 deletions.
19 changes: 11 additions & 8 deletions cyber/croutine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ cc_library(

cc_library(
name = "swap",
srcs = select({
":x86_mode": [
"detail/swap_x86_64.S",
],
":arm_mode": [
"detail/swap_aarch64.S",
],
}),
srcs = select(
{
":x86_mode": [
"detail/swap_x86_64.S",
],
":arm_mode": [
"detail/swap_aarch64.S",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
)

cc_test(
Expand Down
67 changes: 38 additions & 29 deletions modules/drivers/camera/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,48 @@ cc_library(

cc_library(
name = "camera",
srcs = select({
":x86_mode": [
"usb_cam.cc",
"util.cc",
],
":arm_mode": [
"usb_cam.cc",
],
}),
hdrs = select({
":x86_mode": [
"usb_cam.h",
"util.h",
],
":arm_mode": [
"usb_cam.h",
],
}),
srcs = select(
{
":x86_mode": [
"usb_cam.cc",
"util.cc",
],
":arm_mode": [
"usb_cam.cc",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
hdrs = select(
{
":x86_mode": [
"usb_cam.h",
"util.h",
],
":arm_mode": [
"usb_cam.h",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
copts = select({
":x86_mode": ["-mavx2"],
":arm_mode": [""],
}),
deps = select({
":x86_mode": [
"//cyber",
"//modules/drivers/camera/proto:camera_proto",
"@adv_plat",
],
":arm_mode": [
"//cyber",
"//modules/drivers/camera/proto:camera_proto",
],
}),
deps = select(
{
":x86_mode": [
"//cyber",
"//modules/drivers/camera/proto:camera_proto",
"@adv_plat",
],
":arm_mode": [
"//cyber",
"//modules/drivers/camera/proto:camera_proto",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
)

config_setting(
Expand Down
19 changes: 11 additions & 8 deletions third_party/can_card_library/hermes_can/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ licenses(["notice"])

cc_library(
name = "hermes_can",
srcs = select({
":x86_mode": [
"lib_x86_64/libbcan.so",
],
":arm_mode": [
"lib_aarch64/libbcan.so",
],
}),
srcs = select(
{
":x86_mode": [
"lib_x86_64/libbcan.so",
],
":arm_mode": [
"lib_aarch64/libbcan.so",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
hdrs = [
"include/bcan.h",
],
Expand Down
23 changes: 21 additions & 2 deletions third_party/cuda.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ licenses(["notice"])
cc_library(
name = "cuda",
includes = ["include"],
linkopts = [
"-L/usr/lib/x86_64-linux-gnu/",
linkopts = select(
{
":x86_mode": [
"-L/usr/lib/x86_64-linux-gnu/",
],
":arm_mode": [
"-L/usr/lib/aarch64-linux-gnu/",
],
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
) + [
"-lgomp",
"-L/usr/local/cuda/lib64",
"-lOpenCL",
Expand Down Expand Up @@ -61,3 +70,13 @@ cc_library(
"-lnvrtc",
],
)

config_setting(
name = "x86_mode",
values = {"cpu": "k8"},
)

config_setting(
name = "arm_mode",
values = {"cpu": "arm"},
)
19 changes: 11 additions & 8 deletions third_party/python27.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ licenses(["notice"])

cc_library(
name = "python27",
srcs = select({
":x86_mode": glob([
"lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so",
]),
":arm_mode": glob([
"lib/python2.7/config-aarch64-linux-gnu/libpython2.7.so",
]),
}),
srcs = select(
{
":x86_mode": glob([
"lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so",
]),
":arm_mode": glob([
"lib/python2.7/config-aarch64-linux-gnu/libpython2.7.so",
]),
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
hdrs = glob([
"include/python2.7/*.h",
]),
Expand Down
19 changes: 11 additions & 8 deletions third_party/python3.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ licenses(["notice"])

cc_library(
name = "python3",
srcs = select({
":x86_mode": glob([
"lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so",
]),
":arm_mode": glob([
"lib/python3.6/config-3.6m-aarch64-linux-gnu/libpython3.6.so",
]),
}),
srcs = select(
{
":x86_mode": glob([
"lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so",
]),
":arm_mode": glob([
"lib/python3.6/config-3.6m-aarch64-linux-gnu/libpython3.6.so",
]),
},
no_match_error = "Please Build with an ARM or Linux x86_64 platform",
),
hdrs = glob([
"include/python3.6/*.h",
]),
Expand Down

0 comments on commit 741b3e3

Please sign in to comment.