Skip to content

Commit

Permalink
fix compile error on darwin
Browse files Browse the repository at this point in the history
N/A

Signed-off-by: Luxuhui <luxuhui@xiaomi.com>
  • Loading branch information
lu229 committed May 10, 2019
1 parent d085fec commit 8618a43
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
8 changes: 8 additions & 0 deletions mace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
config_setting(
name = "linux_base",
define_values = {
"linux_base": "true",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "android",
values = {
Expand Down
12 changes: 8 additions & 4 deletions mace/libmace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ load(
"if_hexagon_enabled",
"if_hta_enabled",
"if_linux",
"if_linux_base",
"if_neon_enabled",
"if_opencl_enabled",
"if_openmp_enabled",
Expand Down Expand Up @@ -99,9 +100,10 @@ genrule(
"//mace/public",
"//mace/utils",
"//mace/proto:mace_cc",
"//mace/port/linux_base:port_linux_base",
"@com_google_protobuf//:protobuf_lite",
] + if_android([
] + if_linux_base([
"//mace/port/linux_base:port_linux_base",
]) + if_android([
"//mace/port/android:port_android",
]) + if_linux([
"//mace/port/linux:port_linux",
Expand Down Expand Up @@ -134,13 +136,15 @@ genrule(
"$(locations //mace/libmace:libmace) " +
"$(locations //mace/port:port_base) " +
"$(locations //mace/port/posix:port_posix) " +
if_linux_base(
"$(locations //mace/port/linux_base:port_linux_base) ",
default_value = "",
) +
if_android(
"$(locations //mace/port/linux_base:port_linux_base) " +
"$(locations //mace/port/android:port_android) ",
default_value = "",
) +
if_linux(
"$(locations //mace/port/linux_base:port_linux_base) " +
"$(locations //mace/port/linux:port_linux) ",
default_value = "",
) +
Expand Down
6 changes: 6 additions & 0 deletions mace/mace.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# -*- Python -*-

def if_linux_base(a, default_value = []):
return select({
"//mace:linux_base": a,
"//conditions:default": default_value,
})

def if_android(a, default_value = []):
return select({
"//mace:android": a,
Expand Down
4 changes: 4 additions & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build --copt=-DGEMMLOWP_USE_MACE_THREAD_POOL
build --copt=-DMACE_DEPTHWISE_U8_USE_MULTI_THREAD

# Usage example: bazel build --config android
build:android --define linux_base=true
build:android --linkopt=-pie
build:android --linkopt=-ldl
build:android --linkopt=-llog
Expand All @@ -24,6 +25,7 @@ build:android --copt -Wno-mismatched-tags
build:android --copt -Wno-missing-braces

# Linux host build, --config linux
build:linux --define linux_base=true
build:linux --define linux=true

# MacOS host build, --config darwin
Expand All @@ -44,6 +46,7 @@ build:ios --copt -Wno-missing-braces
# Used to fix library not find linking issue, see also:
# https://github.com/bazelbuild/bazel/issues/6653,
# https://github.com/bazelbuild/bazel/issues/6189
build:arm_linux_gnueabihf --define linux_base=true
build:arm_linux_gnueabihf --define linux=true
build:arm_linux_gnueabihf --spawn_strategy=standalone
build:arm_linux_gnueabihf --distinct_host_configuration=true
Expand All @@ -58,6 +61,7 @@ build:arm_linux_gnueabihf --copt -Wno-sequence-point
build:arm_linux_gnueabihf --copt -Wno-implicit-fallthrough

# Usage example: bazel build --config aarch64_linux_gnu
build:aarch64_linux_gnu --define linux_base=true
build:aarch64_linux_gnu --define linux=true
build:aarch64_linux_gnu --spawn_strategy=standalone
build:aarch64_linux_gnu --distinct_host_configuration=true
Expand Down

0 comments on commit 8618a43

Please sign in to comment.