我正在学习Bazel,并试图建造一些第三方图书馆。 我有时使用我的马奇,有时使用我的班子计算机。 因此,当我建立<代码>开放式<> 我想根据平台使用不同的<条码>连接点代码>。
从我所读到的内容来看,应当使用<条码> 。 这是我拥有的,但当我依靠我的无赖机器时,我会:
ERROR: Target //thirdparty/opencv:opencv is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//thirdparty/opencv:opencv (442d8d)
//thirdparty/opencv:opencv_deps (442d8d) <-- target platform (@local_config_platform//:host) didn t satisfy constraint @platforms//os:osx
INFO: Elapsed time: 0.284s
就像它不尊重选择吗?
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
cc_library(
name = "opencv_deps",
linkopts = select({
"@platforms//os:macos": [
"-ldl",
"-lz",
"-lpthread",
"-lavutil",
"-lavformat",
"-lavcodec",
"-lswscale",
"-L/opt/homebrew/opt/ffmpeg/lib",
"-L/opt/homebrew/Cellar/libx11/1.8.6/lib",
"-framework Cocoa",
"-framework Accelerate",
],
"@platforms//os:linux": [
"-ldl",
"-lz",
"-lpthread"
],
}),
target_compatible_with = [
"@platforms//os:macos",
"@platforms//os:linux"
],
)
cmake(
name = "opencv",
build_args = [
"-j3",
],
cache_entries = {
"OPENCV_FORCE_3RDPARTY_BUILD": "ON",
"BUILD_SHARED_LIBS": "OFF",
"BUILD_TESTS": "OFF",
"BUILD_PERF_TESTS": "OFF",
"BUILD_opencv_apps": "OFF",
"BUILD_opencv_calib3d": "OFF",
"BUILD_opencv_core": "ON",
"BUILD_opencv_dnn": "OFF",
"BUILD_opencv_features2d": "OFF",
"BUILD_opencv_flann": "OFF",
"BUILD_opencv_gapi": "OFF",
"BUILD_opencv_highgui": "ON",
"BUILD_opencv_imgcodecs": "ON",
"BUILD_opencv_imgproc": "ON",
"BUILD_opencv_java_bindings_generator": "OFF",
"BUILD_opencv_js": "OFF",
"BUILD_opencv_ml": "OFF",
"BUILD_opencv_objdetect": "OFF",
"BUILD_opencv_photo": "OFF",
"BUILD_opencv_python_bindings_generator": "OFF",
"BUILD_opencv_stitching": "OFF",
"BUILD_opencv_ts": "OFF",
"BUILD_opencv_video": "OFF",
"BUILD_opencv_videoio": "ON",
"BUILD_opencv_world": "ON",
"BUILD_IPP_IW": "ON",
"WITH_ADE": "OFF",
"WITH_CAROTENE": "OFF",
"WITH_IPP": "OFF",
"WITH_ITT": "ON",
"WITH_OPENEXR": "OFF",
"WITH_JASPER": "OFF",
"WITH_JPEG": "OFF",
"WITH_OPENJPEG": "ON",
"WITH_TIFF": "OFF",
"WITH_WEBP": "ON",
"WITH_QUIRC": "ON",
"WITH_GTK": "OFF",
"WITH_OPENBLAS": "ON",
"WITH_OPENCL": "OFF",
},
env = {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_BUILD_PARALLEL_LEVEL": "16",
},
lib_source = "@opencv//:opencv_all",
out_include_dir = "include/opencv4",
out_static_libs = [
"libopencv_world.a",
"opencv4/3rdparty/libittnotify.a",
"opencv4/3rdparty/liblibopenjp2.a",
"opencv4/3rdparty/liblibwebp.a",
"opencv4/3rdparty/liblibpng.a",
],
targets = [
"install",
],
visibility = ["//visibility:public"],
deps = [":opencv_deps"]
)