Skip to content

Commit

Permalink
Use cc_library from rules_cc instead of native.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vertexwahn committed Dec 16, 2024
1 parent 929ddee commit 3936222
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
4 changes: 3 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ qt = module_extension(
tag_classes = {
"fetch": _fetch,
},
)
)
16 changes: 10 additions & 6 deletions qt.bzl
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions qt_linux_x86_64.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")

[
Expand Down
1 change: 1 addition & 0 deletions qt_mac_aarch64.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")

[
Expand Down
1 change: 1 addition & 0 deletions qt_windows_x86_64.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")

[
Expand Down
4 changes: 2 additions & 2 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
bazel_dep(name = "platforms", version = "0.0.10")

bazel_dep(name = "rules_qt")
local_path_override(
module_name = "rules_qt",
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions tests/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ qt_cc_binary(
"@rules_qt//:qt_core",
"@rules_qt//:qt_widgets",
],
copts = [
"-std=c++17",
],
)

0 comments on commit 3936222

Please sign in to comment.