This commit is contained in:
Alex Beattie 2023-05-06 01:34:06 +08:00 committed by GitHub
commit b80c209e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -46,11 +46,12 @@ http_archive(
http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-0.1.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.1.0.zip",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
strip_prefix = "rules_foreign_cc-0.9.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.9.0.tar.gz",
)
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()

20
third_party/BUILD vendored
View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
licenses(["notice"]) # Apache License 2.0
@ -70,8 +71,6 @@ alias(
visibility = ["//visibility:public"],
)
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
# Note: this determines the order in which the libraries are passed to the
# linker, so if library A depends on library B, library B must come _after_.
# Hence core is at the bottom.
@ -93,8 +92,9 @@ OPENCV_MODULES = [
OPENCV_SHARED_LIBS = True
OPENCV_SO_VERSION = "3.4"
OPENCV_DLL_VERSION = "3410"
cmake_external(
cmake(
name = "opencv_cmake",
# Values to be passed as -Dkey=value on the CMake command line;
# here are serving to provide some CMake script configuration options
@ -112,6 +112,7 @@ cmake_external(
"WITH_JPEG": "ON",
"WITH_PNG": "ON",
"WITH_TIFF": "ON",
"WITH_OPENEXR": "OFF",
"WITH_OPENCL": "OFF",
"WITH_WEBP": "OFF",
# Optimization flags
@ -140,6 +141,8 @@ cmake_external(
# ccache would be able to work across sandboxed Bazel builds, either.
# In any case, Bazel does its own caching of the rule's outputs.
"ENABLE_CCACHE": "OFF",
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
"CMAKE_OSX_DEPLOYMENT_TARGET": "10.15",
},
lib_source = "@opencv//:all",
linkopts = [] if OPENCV_SHARED_LIBS else [
@ -170,18 +173,19 @@ cmake_external(
"-lpthread",
"-lrt",
],
shared_libraries = select({
out_shared_libs = select({
"@bazel_tools//src/conditions:darwin": ["libopencv_%s.%s.dylib" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
"@bazel_tools//src/conditions:windows": ["opencv_%s%s.dll" % (module, OPENCV_DLL_VERSION) for module in OPENCV_MODULES],
# Only the shared objects listed here will be linked in the directory
# that Bazel adds to the RUNPATH of dependent executables. You cannot
# list both the versioned and unversioned name of the .so, and the
# versioned name is the one that the executables actually reference.
"//conditions:default": ["libopencv_%s.so.%s" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
}) if OPENCV_SHARED_LIBS else None,
static_libraries = [
"libopencv_%s.a" % module
for module in OPENCV_MODULES
] if not OPENCV_SHARED_LIBS else None,
out_static_libs = select({
"@bazel_tools//src/conditions:windows": ["opencv_%s%s.lib" % (module, OPENCV_DLL_VERSION) for module in OPENCV_MODULES],
"//conditions:default": ["libopencv_%s.a" % module for module in OPENCV_MODULES] if not OPENCV_SHARED_LIBS else [],
}),
)
alias(