diff --git a/BUILD.bazel b/BUILD.bazel index d97a019bee..e38ebd72d3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,14 +1,35 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + licenses(["notice"]) +config_setting( + name = "freebsd", + constraint_values = [ + "@platforms//os:freebsd", + ], + visibility = [":__subpackages__"], +) + +config_setting( + name = "openbsd", + constraint_values = [ + "@platforms//os:openbsd", + ], + visibility = [":__subpackages__"], +) + config_setting( name = "windows", - values = { - "cpu": "x64_windows", - }, + constraint_values = [ + "@platforms//os:windows", + ], visibility = [":__subpackages__"], ) -load("@rules_cc//cc:defs.bzl", "cc_library") +BSD_LINKOPTS = [ + "-pthread", + "-lm", +] cc_library( name = "benchmark", @@ -22,6 +43,8 @@ cc_library( hdrs = ["include/benchmark/benchmark.h"], linkopts = select({ ":windows": ["-DEFAULTLIB:shlwapi.lib"], + ":freebsd": BSD_LINKOPTS, + ":openbsd": BSD_LINKOPTS, "//conditions:default": ["-pthread"], }), strip_include_prefix = "include", diff --git a/WORKSPACE b/WORKSPACE index 5438ad3611..7f2612b3bd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,3 +35,8 @@ new_local_repository( path = "/usr/include/python3.6", # May be overwritten by setup.py. ) +http_archive( + name = "platforms", + strip_prefix = "platforms-master", + urls = ["https://github.com/bazelbuild/platforms/archive/master.zip"], +)