bazel 不复制二进制文件来构建输出文件夹

问题描述

使用 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

这是示例工作区文件: 工作区(名称=“项目”)

load("@project//:qt_con@R_502[email protected]","local_qt_path")

new_local_repository(
    name = "qt",build_file = "//:qt.BUILD",path = "./",)

qt.BUILD:

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_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,includes = ["include"],# Available from Bazel 4.0.0
        # target_compatible_with = ["@platforms//os:windows"],deps = [":qt_%s_windows_import" % name],_,_ 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],}),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/**",],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"],)

filegroup(
    name = "moc",srcs = ["bin/moc.exe"],)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)