From 3936222583d455aec4d42bd684818283b876773e Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Tue, 17 Dec 2024 00:18:19 +0100 Subject: [PATCH] Use cc_library from rules_cc instead of native. --- MODULE.bazel | 4 +++- extensions.bzl | 2 +- qt.bzl | 16 ++++++++++------ qt_linux_x86_64.BUILD | 1 + qt_mac_aarch64.BUILD | 1 + qt_windows_x86_64.BUILD | 1 + tests/MODULE.bazel | 4 ++-- tests/hello_world/BUILD.bazel | 3 --- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 139dd81..590233a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,15 +6,17 @@ module( bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.17") qt = use_extension("@rules_qt//:extensions.bzl", "qt") qt.fetch() use_repo( qt, "qt_linux_x86_64", - "qt_windows_x86_64", "qt_mac_aarch64", + "qt_windows_x86_64", ) + register_toolchains( "@rules_qt//tools:all", dev_dependency = True, diff --git a/extensions.bzl b/extensions.bzl index 287b415..e95fd70 100644 --- a/extensions.bzl +++ b/extensions.bzl @@ -12,4 +12,4 @@ qt = module_extension( tag_classes = { "fetch": _fetch, }, -) \ No newline at end of file +) diff --git a/qt.bzl b/qt.bzl index 4e8d205..3a57e66 100644 --- a/qt.bzl +++ b/qt.bzl @@ -1,5 +1,9 @@ """qt common rules""" +load("@rules_cc//cc:cc_binary.bzl", "cc_binary") +load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@rules_cc//cc:cc_test.bzl", "cc_test") + def _gen_ui_header(ctx): info = ctx.toolchains["@rules_qt//tools:toolchain_type"].qtinfo @@ -46,7 +50,7 @@ def qt_ui_library(name, ui, deps, target_compatible_with = [], **kwargs): target_compatible_with = target_compatible_with, tags = ["local"], ) - native.cc_library( + cc_library( name = name, hdrs = [":%s_uic" % name], deps = deps, @@ -170,7 +174,7 @@ def qt_resource_via_qrc(name, qrc_file, files, target_compatible_with = [], **kw target_compatible_with = target_compatible_with, tags = ["local"], ) - native.cc_library( + cc_library( name = name, srcs = [outfile], alwayslink = 1, @@ -207,7 +211,7 @@ def qt_resource(name, files, target_compatible_with = [], **kwargs): "local", ], ) - native.cc_library( + cc_library( name = name, srcs = [outfile], alwayslink = 1, @@ -252,7 +256,7 @@ def qt_cc_library(name, srcs, hdrs, normal_hdrs = [], deps = None, copts = [], t target_compatible_with = target_compatible_with, ) _moc_srcs.append(":" + moc_name) - native.cc_library( + cc_library( name = name, srcs = srcs + _moc_srcs, hdrs = hdrs + normal_hdrs, @@ -350,7 +354,7 @@ def qt_cc_binary(name, srcs, deps = None, copts = [], data = [], env = {}, **kwa }), ) env_file.append("qt_env.ini") - native.cc_binary( + cc_binary( name = name, srcs = srcs, deps = deps, @@ -384,7 +388,7 @@ def qt_cc_test(name, srcs, deps = None, copts = [], data = [], env = {}, **kwarg mac_x64_env_data = update_dict(MAC_X64_ENV_DATA, env) windows_env_data = update_dict(WINDOWS_ENV_DATA, env) mac_m1_env_data = update_dict(MAC_M1_ENV_DATA, env) - native.cc_test( + cc_test( name = name, srcs = srcs, deps = deps, diff --git a/qt_linux_x86_64.BUILD b/qt_linux_x86_64.BUILD index fbaa861..804f519 100644 --- a/qt_linux_x86_64.BUILD +++ b/qt_linux_x86_64.BUILD @@ -1,3 +1,4 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") [ diff --git a/qt_mac_aarch64.BUILD b/qt_mac_aarch64.BUILD index 2751343..7c909a9 100644 --- a/qt_mac_aarch64.BUILD +++ b/qt_mac_aarch64.BUILD @@ -1,3 +1,4 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") [ diff --git a/qt_windows_x86_64.BUILD b/qt_windows_x86_64.BUILD index ca1d760..3933e06 100644 --- a/qt_windows_x86_64.BUILD +++ b/qt_windows_x86_64.BUILD @@ -1,3 +1,4 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") [ diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 044022c..7fbeb09 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -1,5 +1,4 @@ bazel_dep(name = "platforms", version = "0.0.10") - bazel_dep(name = "rules_qt") local_path_override( module_name = "rules_qt", @@ -11,9 +10,10 @@ qt.fetch() use_repo( qt, "qt_linux_x86_64", - "qt_windows_x86_64", "qt_mac_aarch64", + "qt_windows_x86_64", ) + register_toolchains( "@rules_qt//tools:all", dev_dependency = True, diff --git a/tests/hello_world/BUILD.bazel b/tests/hello_world/BUILD.bazel index f9a2b55..d18c054 100644 --- a/tests/hello_world/BUILD.bazel +++ b/tests/hello_world/BUILD.bazel @@ -7,7 +7,4 @@ qt_cc_binary( "@rules_qt//:qt_core", "@rules_qt//:qt_widgets", ], - copts = [ - "-std=c++17", - ], )