使用 bazel 进行初始构建设置,用于在一个最小示例(具有广泛的依赖关系)上测试通用 UI 库。构建设置包括该库的规则和配置。但是,当我扩展此构建时,将依赖项目作为包(BUILD)添加到子文件夹中并将库保留为 new_local_repository - bazel 吐出错误。
它不会将该库的共享二进制文件复制到构建输出。因此,它给出了共享库或所需二进制文件丢失的随机(依赖于任何二进制文件)错误:
ERROR: C:/users/ilya/source/repos/project-cross-platform/project/BUILD:28:10: Copying Execution Dynamic Library failed: missing input file 'external/qt/bin/Qt5Core.dll', owner: '@qt//:bin/Qt5Core.dll'
[5 / 49] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Target //project:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: C:/users/ilya/source/repos/project-cross-platform/project/BUILD:28:10 Copying Execution Dynamic Library failed: 1 input file(s) do not exist
INFO: Elapsed time: 4.681s, Critical Path: 0.04s
INFO: 1 process: 1 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
这是示例工作区文件:workspace(name = "project")
load("@project//:qt_configure.bzl", "local_qt_path")
new_local_repository(
name = "qt",
build_file = "//:qt.BUILD",
path = "./",
)
qt.构建:
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")
QT_LIBRARIES = [
("core", "QtCore", "Qt5Core", []),
("network", "QtNetwork", "Qt5Network", []),
("widgets", "QtWidgets", "Qt5Widgets", [":qt_core", ":qt_gui"]),
("quick", "QtQuick", "Qt5Quick", [":qt_gui", ":qt_qml", ":qt_qml_models"]),
("qml", "QtQml", "Qt5Qml", [":qt_core", ":qt_network"]),
("qml_models", "QtQmlModels", "Qt5QmlModels", []),
("gui", "QtGui", "Qt5Gui", [":qt_core"]),
("opengl", "QtOpenGL", "Qt5OpenGL", []),
]
[
cc_import(
name = "qt_%s_windows_import" % name,
# When being on Linux this glob will be empty
hdrs = glob(["include/%s/**" % include_folder], allow_empty=True),
interface_library = "lib/%s.lib" % library_name,
shared_library = "bin/%s.dll" % library_name,
# Not available in cc_import (See: https://github.com/bazelbuild/bazel/issues/12745)
# target_compatible_with = ["@platforms//os:windows"],
)
for name, include_folder, library_name, _ in QT_LIBRARIES
]
[
cc_library(
name = "qt_%s_windows" % name,
# When being on Linux this glob will be empty
hdrs = glob(["include/%s/**" % include_folder], allow_empty=True),
includes = ["include"],
# Available from Bazel 4.0.0
# target_compatible_with = ["@platforms//os:windows"],
deps = [":qt_%s_windows_import" % name],
)
for name, include_folder, _, _ in QT_LIBRARIES
]
[
cc_library(
name = "qt_%s" % name,
visibility = ["//visibility:public"],
deps = dependencies + select({
"@platforms//os:linux": [":qt_%s_linux" % name],
"@platforms//os:windows": [":qt_%s_windows" % name],
}),
)
for name, _, _, dependencies in QT_LIBRARIES
]
# TODO: Make available also for Windows
cc_library(
name = "qt_3d",
# When being on Windows this glob will be empty
hdrs = glob([
"Qt3DAnimation/**",
"Qt3DCore/**",
"Qt3DExtras/**",
"Qt3DInput/**",
"Qt3DLogic/**",
"Qt3DQuick/**",
"Qt3DQuickAnimation/**",
"Qt3DQuickExtras/**",
"Qt3DQuickInput/**",
"Qt3DQuickRender/**",
"Qt3DQuickScene2D/**",
"Qt3DRender/**",
], allow_empty=True),
includes = ["."],
linkopts = [
"-lQt53DAnimation",
"-lQt53DCore",
"-lQt53DExtras",
"-lQt53DInput",
"-lQt53DLogic",
"-lQt53DQuick",
"-lQt53DQuickAnimation",
"-lQt53DQuickExtras",
"-lQt53DQuickInput",
"-lQt53DQuickRender",
"-lQt53DQuickScene2D",
"-lQt53DRender",
],
# Available from Bazel 4.0.0
# target_compatible_with = ["@platforms//os:linux"],
)
filegroup(
name = "uic",
srcs = ["bin/uic.exe"],
visibility = ["//visibility:public"],
)
filegroup(
name = "moc",
srcs = ["bin/moc.exe"],
visibility = ["//visibility:public"],
)