diff --git a/.github/workflows/bazel_build.yml b/.github/workflows/bazel_build.yml index 6cdad07..a233f89 100644 --- a/.github/workflows/bazel_build.yml +++ b/.github/workflows/bazel_build.yml @@ -10,13 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - uses: actions/checkout@v4.2.2 - name: Build run: | @@ -24,35 +18,35 @@ jobs: bazelisk build --config=gcc9 //... build_and_test_ubuntu22: - name: Linux Ubuntu 22.04 build + name: Linux Ubuntu 22.04 build runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel-ubuntu22 + - uses: actions/checkout@v4.2.2 - name: Build run: | cd tests bazelisk build --config=gcc11 //... + build_and_test_ubuntu24: + name: Linux Ubuntu 24.04 build + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build + run: | + cd tests + bazelisk build --config=gcc13 //... + build_and_test_windows10: name: Windows Server 2019 build runs-on: windows-2019 steps: - - uses: actions/checkout@v3 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - uses: actions/checkout@v4.2.2 - name: Build run: | @@ -64,87 +58,59 @@ jobs: runs-on: windows-2022 steps: - - uses: actions/checkout@v3 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - uses: actions/checkout@v4.2.2 - name: Build run: | cd tests bazelisk build --config=vs2022 //... - build_and_test_macos11: - name: macOS 11 Bazel build - runs-on: macOS-11 + build_and_test_macos13: + name: macOS 13 Bazel build + runs-on: macOS-13 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4.2.2 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - name: Print info + run: | + echo "OS info:" + sw_vers + uname + echo "Compiler info:" + clang --version - - name: Print info - run: | - echo "OS info:" - sw_vers - uname - echo "Compiler info:" - clang --version - - - name: Build - run: | - brew install qt@6 - #brew link qt@6 - cd tests - bazelisk build --config=macos //... + - name: Build + run: | + cd tests + bazelisk build --config=macos //... - build_and_test_macos12: - name: macOS 12 Bazel build - runs-on: macOS-12 + build_and_test_macos14: + name: macOS 14 Bazel build + runs-on: macOS-14 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4.2.2 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - name: Print info + run: | + echo "OS info:" + sw_vers + uname + echo "Compiler info:" + clang --version - - name: Print info - run: | - echo "OS info:" - sw_vers - uname - echo "Compiler info:" - clang --version - - - name: Build - run: | - brew install qt@6 - #brew link qt@6 - cd tests - bazelisk build --config=macos //... + - name: Build + run: | + cd tests + bazelisk build --config=macos //... - build_and_test_macos13: - name: macOS 13 Bazel build - runs-on: macOS-13 + build_and_test_macos15: + name: macOS 15 Bazel build + runs-on: macOS-15 steps: - - uses: actions/checkout@v3 - - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + - uses: actions/checkout@v4.2.2 - name: Print info run: | @@ -156,7 +122,5 @@ jobs: - name: Build run: | - brew install qt@6 - #brew link qt@6 cd tests bazelisk build --config=macos //... diff --git a/.gitignore b/.gitignore index a32ed4b..641d828 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bazel-* .vscode +*.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..590233a --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,23 @@ +module( + name = "rules_qt", + version = "1.0.0", + compatibility_level = 1, +) + +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_mac_aarch64", + "qt_windows_x86_64", +) + +register_toolchains( + "@rules_qt//tools:all", + dev_dependency = True, +) diff --git a/README.md b/README.md index bed8eeb..d1c3820 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ The following tools should be installed: *All platforms:* ```shell -git clone https://github.com/Vertexwahn/rules_qt6 && +git clone https://github.com/Vertexwahn/rules_qt6 cd rules_qt6/tests ``` @@ -59,6 +59,12 @@ bazel run --config=gcc9 //hello_world:hello_world bazel run --config=gcc11 //hello_world:hello_world ``` +*Run Hello World demo with Ubuntu 24.04:* + +```shell +bazel run --config=gcc13 //hello_world:hello_world +``` + *Run Hello World demo with macOS 11/12:* ```shell diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel deleted file mode 100644 index d7fd2b8..0000000 --- a/WORKSPACE.bazel +++ /dev/null @@ -1 +0,0 @@ -workspace(name = "rules_qt") diff --git a/extensions.bzl b/extensions.bzl new file mode 100644 index 0000000..e95fd70 --- /dev/null +++ b/extensions.bzl @@ -0,0 +1,15 @@ +load("@rules_qt//:fetch_qt.bzl", "fetch_qt6") + +def _qt_impl(ctx): + for mod in ctx.modules: + if mod.name == "rules_qt": + fetch_qt6() + +_fetch = tag_class(attrs = {}) + +qt = module_extension( + implementation = _qt_impl, + tag_classes = { + "fetch": _fetch, + }, +) diff --git a/fetch_qt.bzl b/fetch_qt.bzl index 263672b..9af5b02 100644 --- a/fetch_qt.bzl +++ b/fetch_qt.bzl @@ -16,12 +16,6 @@ def fetch_qt6(): build_file = "@rules_qt//:qt_windows_x86_64.BUILD", ) - #native.new_local_repository( - # name = "qt_windows_x86_64", - # path = "C:\\Qt\\6.4.0\\msvc2019_64", - # build_file = "@rules_qt//:qt_windows_x86_64.BUILD", - #) - http_archive( name = "qt_linux_x86_64", urls = [ @@ -32,28 +26,12 @@ def fetch_qt6(): build_file = "@rules_qt//:qt_linux_x86_64.BUILD", ) - #http_archive( - # name = "qt_mac_x86_64", - # urls = ["https://vertexwahn.de/lfs/v1/qt_mac_x86_64.zip"], - # sha256 = "9543aa178a6fe6aa138e4319fb07a106375b7fef11be150d154d5c1b8a321721", - # strip_prefix = "6.2.4/macos", - # build_file = "@rules_qt////:qt_mac_x86_64.BUILD", - #) - - # On macOS we make use of an system installed Qt6 - # installation works via: - # $ brew install qt@6 - # $ brew link qt@6 - - # Check if path exists - native.new_local_repository( - name = "qt_mac_x86_64", - path = "/usr/local/opt/qt@6", #"/usr/local/opt/qt@6", - build_file = "@rules_qt//:qt_mac_x86_64.BUILD", - ) - - native.new_local_repository( + http_archive( name = "qt_mac_aarch64", - path = "/opt/homebrew/", # after brew link, is't ok just use /opt/homebrew + urls = [ + "https://dl.dropboxusercontent.com/scl/fi/8io4wc9cx2kd2vfwswjmg/qt_6.8.0_mac_aarch64_gamepad.tar.xz?rlkey=afkk9qrub9i1gmelv7vktgtci&dl=0", + ], + sha256 = "07be3436bfb31b3a2e629907ca39a8652febe563046094cdc7373b7ff28228c4", + strip_prefix = "Qt-6.8.0", build_file = "@rules_qt//:qt_mac_aarch64.BUILD", ) diff --git a/qt.bzl b/qt.bzl index 1ae71c0..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, @@ -232,11 +236,11 @@ def qt_cc_library(name, srcs, hdrs, normal_hdrs = [], deps = None, copts = [], t _moc_srcs = [] for hdr in hdrs: header_path = "%s/%s" % (native.package_name(), hdr) if len(native.package_name()) > 0 else hdr - moc_name = "%s_moc" % hdr.replace(".", "_") + moc_name = "moc_%s" % hdr.rsplit(".", 1)[0] native.genrule( name = moc_name, srcs = [hdr], - outs = [moc_name + ".cc"], + outs = [moc_name + ".cpp"], cmd = select({ "@platforms//os:linux": "$(location @qt_linux_x86_64//:moc) $(locations %s) -o $@ -f'%s'" % (hdr, header_path), "@platforms//os:windows": "$(location @qt_windows_x86_64//:moc) $(locations %s) -o $@ -f'%s'" % (hdr, header_path), @@ -252,10 +256,11 @@ 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, + textual_hdrs = _moc_srcs, deps = deps, copts = copts + select({ "@platforms//os:windows": [], @@ -266,10 +271,15 @@ def qt_cc_library(name, srcs, hdrs, normal_hdrs = [], deps = None, copts = [], t ) qt_plugin_data = select({ - "@platforms//os:linux": ["@qt_linux_x86_64//:plugin_files", "@qt_linux_x86_64//:qml_files"], - "@rules_qt//:osx_x86_64": ["@qt_mac_x86_64//:plugin_files", "@qt_mac_x86_64//:qml_files"], - "@rules_qt//:osx_arm64": ["@qt_mac_aarch64//:plugin_files", "@qt_mac_aarch64//:qml_files"], - "@platforms//os:windows": ["@qt_windows_x86_64//:plugin_files", "@qt_windows_x86_64//:qml_files"], + "@platforms//os:linux": ["@qt_linux_x86_64//:qml", "@qt_linux_x86_64//:plugins", "@qt_linux_x86_64//:lib"], + "@rules_qt//:osx_x86_64": ["@qt_mac_x86_64//:plugins", "@qt_mac_x86_64//:qml", "@qt_mac_x86_64//:lib"], + "@rules_qt//:osx_arm64": ["@qt_mac_aarch64//:plugins", "@qt_mac_aarch64//:qml", "@qt_mac_aarch64//:lib"], + "@platforms//os:windows": [ + "@qt_windows_x86_64//:plugins", + "@qt_windows_x86_64//:qml", + "@qt_windows_x86_64//:plugin_files", + "@qt_windows_x86_64//:qml_files", + ], }) def update_dict(source, env): @@ -279,27 +289,27 @@ def update_dict(source, env): return result LINUX_ENV_DATA = { - "QT_QPA_PLATFORM_PLUGIN_PATH": "external/qt_linux_x86_64/plugins/platforms", - "QML2_IMPORT_PATH": "external/qt_linux_x86_64/qml", - "QT_PLUGIN_PATH": "external/qt_linux_x86_64/plugins", + "QT_QPA_PLATFORM_PLUGIN_PATH": "$(location @qt_linux_x86_64//:plugins)/platforms", + "QML2_IMPORT_PATH": "$(location @qt_linux_x86_64//:qml)", + "QT_PLUGIN_PATH": "$(location @qt_linux_x86_64//:plugins)", } MAC_X64_ENV_DATA = { - "QT_QPA_PLATFORM_PLUGIN_PATH": "external/qt_mac_x86_64/share/qt/plugins/platforms", - "QML2_IMPORT_PATH": "external/qt_mac_x86_64/qml", - "QT_PLUGIN_PATH": "external/qt_mac_x86_64/share/qt/plugins", + "QT_QPA_PLATFORM_PLUGIN_PATH": "$(location @qt_mac_x86_64//:plugins)/platforms", + "QML2_IMPORT_PATH": "$(location @qt_mac_x86_64//:qml)", + "QT_PLUGIN_PATH": "$(location @qt_mac_x86_64//:plugins)", } WINDOWS_ENV_DATA = { - "QT_QPA_PLATFORM_PLUGIN_PATH": "external/qt_windows_x86_64/plugins/platforms", - "QML2_IMPORT_PATH": "external/qt_windows_x86_64/qml", - "QT_PLUGIN_PATH": "external/qt_windows_x86_64/plugins", + "QT_QPA_PLATFORM_PLUGIN_PATH": "$(location @qt_windows_x86_64//:plugins)/platforms", + "QML2_IMPORT_PATH": "$(location @qt_windows_x86_64//:qml)", + "QT_PLUGIN_PATH": "$(location @qt_windows_x86_64//:plugins)", } MAC_M1_ENV_DATA = { - "QT_QPA_PLATFORM_PLUGIN_PATH": "external/qt_mac_aarch64/share/qt/plugins/platforms", - "QML2_IMPORT_PATH": "external/qt_mac_aarch64/qml", - "QT_PLUGIN_PATH": "external/qt_mac_aarch64/share/qt/plugins", + "QT_QPA_PLATFORM_PLUGIN_PATH": "$(location @qt_mac_aarch64//:plugins)/platforms", + "QML2_IMPORT_PATH": "$(location @qt_mac_aarch64//:qml)", + "QT_PLUGIN_PATH": "$(location @qt_mac_aarch64//:plugins)", } def qt_cc_binary(name, srcs, deps = None, copts = [], data = [], env = {}, **kwargs): @@ -318,7 +328,33 @@ def qt_cc_binary(name, srcs, deps = None, copts = [], data = [], env = {}, **kwa 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_binary( + env_file = [] + native.genrule( + name = name + "_env", + tools = qt_plugin_data, + outs = ["qt_env.ini"], + cmd = select({ + "@platforms//os:linux": + "echo $$\"LD_LIBRARY_PATH: $(location @qt_linux_x86_64//:lib)\" > $@ \ + $$\"\r\nQT_QPA_PLATFORM_PLUGIN_PATH: $(location @qt_linux_x86_64//:plugins)/platforms\" > $@ \ + $$\"\r\nQML2_IMPORT_PATH: $(location @qt_linux_x86_64//:qml)\" > $@ \ + $$\"\r\nQT_PLUGIN_PATH: $(location @qt_linux_x86_64//:plugins)\" > $@", + "@rules_qt//:osx_x86_64": + "echo $$\"QT_QPA_PLATFORM_PLUGIN_PATH: $(location @qt_mac_x86_64//:plugins)/platforms\" > $@ \ + $$\"\r\nQML2_IMPORT_PATH: $(location @qt_mac_x86_64//:qml)\" > $@ \ + $$\"\r\nQT_PLUGIN_PATH: $(location @qt_mac_x86_64//:plugins)\" > $@", + "@rules_qt//:osx_arm64": + "echo $$\"QT_QPA_PLATFORM_PLUGIN_PATH: $(location @qt_mac_aarch64//:plugins)/platforms\" > $@ \ + $$\"\r\nQML2_IMPORT_PATH: $(location @qt_mac_aarch64//:qml)\" > $@ \ + $$\"\r\nQT_PLUGIN_PATH: $(location @qt_mac_aarch64//:plugins)\" > $@", + "@platforms//os:windows": + "echo $$\"QT_QPA_PLATFORM_PLUGIN_PATH: $(location @qt_windows_x86_64//:plugins)/platforms\" > $@ \ + $$\"\r\nQML2_IMPORT_PATH: $(location @qt_windows_x86_64//:qml)\" > $@ \ + $$\"\r\nQT_PLUGIN_PATH: $(location @qt_windows_x86_64//:plugins)\" > $@", + }), + ) + env_file.append("qt_env.ini") + cc_binary( name = name, srcs = srcs, deps = deps, @@ -326,7 +362,7 @@ def qt_cc_binary(name, srcs, deps = None, copts = [], data = [], env = {}, **kwa "@platforms//os:windows": [], "//conditions:default": ["-fPIC"], }), - data = qt_plugin_data + data, + data = qt_plugin_data + env_file + data, env = select({ "@platforms//os:linux": linux_env_data, "@rules_qt//:osx_x86_64": mac_x64_env_data, @@ -352,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_libraries.bzl b/qt_libraries.bzl index 39305a1..76631fc 100644 --- a/qt_libraries.bzl +++ b/qt_libraries.bzl @@ -15,6 +15,7 @@ QT_LIBRARIES = [ ("designer", "QtDesigner", "Qt6Designer", [":qt_xml", ":qt_opengl_widgets", ":qt_widgets", ":qt_gui", ":qt_core"]), ("designer_components", "QtDesigner", "Qt6Designer", [":qt_designer", ":qt_xml", ":qt_widgets", ":qt_gui", ":qt_core"]), ("help", "QtHelp", "Qt6Help", [":qt_sql", ":qt_widgets", ":qt_gui", ":qt_core"]), + #("location", "QtLocation", "Qt6Location", [":qt_core"]), # ("json_rpc", "QtJsonRpc", "Qt6JsonRpc", [":qt_core"]), # ("language_server", "QtLanguageServer", "Qt6LanguageServer", [":qt_json_rpc", ":qt_core"]), ("multimedia", "QtMultimedia", "Qt6Multimedia", [":qt_network", ":qt_gui", ":qt_core"]), @@ -68,6 +69,7 @@ QT_LIBRARIES = [ ("qml_remote_objects", "QtRemoteObjectsQml", "Qt6RemoteObjectsQml", [":qt_remote_objects", ":qt_qml", ":qt_core"]), ("qml_scxml", "QtScxmlQml", "Qt6ScxmlQml", [":qt_scxml", ":qt_qml", ":qt_core"]), ("qml_state_machine", "QtStateMachineQml", "Qt6StateMachineQml", [":qt_state_machine", ":qt_qml", ":qt_core"]), + #("qml_meta", "QtQmlMeta", "Qt6QmlMeta", [":qt_qml"]), ## qt quick ("quick", "QtQuick", "Qt6Quick", [":qt_gui", ":qt_qml"]), # ("quick_pdf", "QtPdfQuick", "Qt6PdfQuick", [":qt_quick", ":qt_pdf", ":qt_gui", ":qt_qml", ":qt_core"]), @@ -80,6 +82,9 @@ QT_LIBRARIES = [ ("quick_web_engine", "QtWebEngineQuick", "Qt6WebEngineQuick", [ ":qt_web_engine_core", ":qt_quick", ":qt_gui", ":qt_web_channel", ":qt_qml", ":qt_network", ":qt_core" ]), + #("quick_web_channel", "QtWebChannelQuick", "Qt6WebChannelQuick", [ + # ":qt_web_engine_core", ":qt_quick", ":qt_gui", ":qt_web_channel", ":qt_qml", ":qt_network", ":qt_core" + #]), ("quick_3d_effects", "QtQuick3DEffects", "Qt6Quick3DEffects", [":qt_qml", ":qt_core"]), # ("quick_3d_glsl_parser", "QtQuick3DGlslParser", "Qt6Quick3DGlslParser", [":qt_core"]), ("quick_3d_helpers", "QtQuick3DHelpers", "Qt6Quick3DHelpers", [":qt_quick_3d", ":qt_gui", ":qt_qml", ":qt_core"]), @@ -90,13 +95,17 @@ QT_LIBRARIES = [ ("quick_3d_runtime_render", "QtQuick3DRuntimeRender", "Qt6Quick3DRuntimeRender", [":qt_quick_3d_utils", ":qt_quick", ":qt_shader_tools", ":qt_gui", ":qt_core"]), ("quick_3d_utils", "QtQuick3DUtils", "Qt6Quick3DUtils", [":qt_gui", ":qt_core"]), ("quick_controls2", "QtQuickControls2", "Qt6QuickControls2", [":qt_quick_templates2", ":qt_gui", ":qt_qml", ":qt_core"]), + #("quick_controls2_basic", "QtQuickControls2Basic", "Qt6QuickControls2Basic", [":qt_quick_templates2", ":qt_gui", ":qt_qml", ":qt_core"]), + #("quick_controls2_fusion", "QtQuickControls2Fusion", "Qt6QuickControls2Fusion", [":qt_quick_templates2", ":qt_gui", ":qt_qml", ":qt_core"]), + #("quick_controls2_material", "QtQuickControls2Material", "Qt6QuickControls2Material", [":qt_quick_templates2", ":qt_gui", ":qt_qml", ":qt_core"]), + #("quick_controls2_material_style_impl", "QtQuickControls2MaterialStyleImpl", "Qt6QuickControls2MaterialStyleImpl", [":qt_quick_templates2", ":qt_gui", ":qt_qml", ":qt_core"]), ("quick_controls2_impl", "QtQuickControls2Impl", "Qt6QuickControls2Impl", [":qt_quick_templates2", ":qt_quick", ":qt_gui", ":qt_qml", ":qt_core"]), - ("quick_dialogs2", "QtQuickDialogs2", "Qt6QuickDialogs2", [":qt_quick_dialogs2_quick_impl", ":qt_quick_dialogs2_utils", ":qt_quick", ":qt_gui", ":qt_qml", ":qt_core"]), - ("quick_dialogs2_quick_impl", "Qt6QuickDialogs2QuickImpl", "Qt6QuickDialogs2QuickImpl", [ - ":qt_quick_templates2", - ":qt_quick_controls2_impl", - ":qt_quick", ":qt_gui", ":qt_qml", ":qt_quick_dialogs2_utils", ":qt_core", - ]), + #("quick_dialogs2", "QtQuickDialogs2", "Qt6QuickDialogs2", [":qt_quick_dialogs2_quick_impl", ":qt_quick_dialogs2_utils", ":qt_quick", ":qt_gui", ":qt_qml", ":qt_core"]), + #("quick_dialogs2_quick_impl", "Qt6QuickDialogs2QuickImpl", "Qt6QuickDialogs2QuickImpl", [ + # ":qt_quick_templates2", + # ":qt_quick_controls2_impl", + # ":qt_quick", ":qt_gui", ":qt_qml", ":qt_quick_dialogs2_utils", ":qt_core", + #]), ("quick_dialogs2_utils", "QtQuickDialogs2Utils", "Qt6QuickDialogs2Utils", [":qt_gui", ":qt_core"]), ("quick_layouts", "QtQuickLayouts", "Qt6QuickLayouts", [":qt_quick", ":qt_qml", ":qt_gui", ":qt_core"]), ("quick_particles", "Qt6QuickParticles", "Qt6QuickParticles", [":qt_quick", ":qt_qml", ":qt_gui", ":qt_core"]), @@ -123,4 +132,7 @@ QT_LIBRARIES = [ ("labs_settings", "QtLabsSettings", "Qt6LabsSettings", [":qt_qml", ":qt_core"]), ("labs_shared_image", "QtLabsSharedImage", "Qt6LabsSharedImage", [":qt_quick", ":qt_qml", ":qt_gui", ":qt_core"]), ("labs_wave_front_mesh", "QtLabsWavefrontMesh", "Qt6LabsWavefrontMesh", [":qt_quick", ":qt_qml", ":qt_gui", ":qt_core"]), + ## legacy + #("gamepad_legacy", "QtGamepadLegacy", "Qt6GamepadLegacy", [":qt_core"]), + #("gamepad_legacy_quick", "QtGamepadLegacyQuick", "Qt6GamepadLegacyQuick", [":qt_quick", ":qt_qml"]), ] diff --git a/qt_linux_x86_64.BUILD b/qt_linux_x86_64.BUILD index c7a003d..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") [ @@ -7,7 +8,9 @@ load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") "lib/lib%s.so*" % library_name, "lib/libicu*.so*", ]), - hdrs = glob(["include/%s/**" % include_folder]), + hdrs = glob([ + "include/%s/**" % include_folder, + ]), includes = [ "include", "include/%s" % include_folder, @@ -20,7 +23,9 @@ load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") cc_library( name = "qt_hdrs", - hdrs = glob(["include/**"]), + hdrs = glob([ + "include/**", + ]), includes = [ "include", ], @@ -56,3 +61,8 @@ filegroup( srcs = glob(["qml/**/*"]), visibility = ["//visibility:public"], ) + +exports_files( + ["qml", "plugins", "lib"], + visibility = ["//visibility:public"], +) diff --git a/qt_mac_aarch64.BUILD b/qt_mac_aarch64.BUILD index 1e02f86..b6aebd4 100644 --- a/qt_mac_aarch64.BUILD +++ b/qt_mac_aarch64.BUILD @@ -1,16 +1,20 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") [ cc_library( name = "qt_%s_mac" % name, - hdrs = glob(["include/%s/**" % include_folder]), # allow_empty = True + hdrs = glob(["lib/%s.framework/Headers/**" % include_folder]), # allow_empty = True includes = [ - "include", - "include/%s" % include_folder, + "lib/%s.framework/Headers" % include_folder, ], - linkopts = ["-F/opt/homebrew/lib"] + [ + additional_linker_inputs = [":lib"], + linkopts = ["-F $(location :lib)"] + [ "-framework %s" % library_name.replace("6", ""), # macOS qt libs do not contain a 6 - e.g. instead of Qt6Core the lib is called QtCore + "-rpath $(rootpath :lib)", ], + include_prefix = "%s" % include_folder, + strip_include_prefix = "lib/%s.framework/Headers" % include_folder, target_compatible_with = ["@platforms//os:osx"], visibility = ["//visibility:public"], ) @@ -28,25 +32,25 @@ cc_library( filegroup( name = "uic", - srcs = ["share/qt/libexec/uic"], + srcs = ["libexec/uic"], visibility = ["//visibility:public"], ) filegroup( name = "moc", - srcs = ["share/qt/libexec/moc"], + srcs = ["libexec/moc"], visibility = ["//visibility:public"], ) filegroup( name = "rcc", - srcs = ["share/qt/libexec/rcc"], + srcs = ["libexec/rcc"], visibility = ["//visibility:public"], ) filegroup( name = "plugin_files", - srcs = glob(["share/qt/plugins/**/*"]), + srcs = glob(["plugins/**/*"]), visibility = ["//visibility:public"], ) @@ -55,3 +59,8 @@ filegroup( srcs = glob(["qml/**/*"]), visibility = ["//visibility:public"], ) + +exports_files( + ["qml", "plugins", "lib"], + visibility = ["//visibility:public"], +) diff --git a/qt_mac_x86_64.BUILD b/qt_mac_x86_64.BUILD deleted file mode 100644 index d58641a..0000000 --- a/qt_mac_x86_64.BUILD +++ /dev/null @@ -1,57 +0,0 @@ -load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") - -[ - cc_library( - name = "qt_%s_mac" % name, - hdrs = glob(["include/%s/**" % include_folder]), # allow_empty = True - includes = [ - "include", - "include/%s" % include_folder, - ], - linkopts = ["-F/usr/local/opt/qt@6/lib"] + [ - "-framework %s" % library_name.replace("6", ""), # macOS qt libs do not contain a 6 - e.g. instead of Qt6Core the lib is called QtCore - ], - target_compatible_with = ["@platforms//os:osx"], - visibility = ["//visibility:public"], - ) - for name, include_folder, library_name, _ in QT_LIBRARIES -] - -cc_library( - name = "qt_hdrs", - hdrs = glob(["include/**"]), - includes = [ - "include", - ], - visibility = ["//visibility:public"], -) - -filegroup( - name = "uic", - srcs = ["share/qt/libexec/uic"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "moc", - srcs = ["share/qt/libexec/moc"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "rcc", - srcs = ["share/qt/libexec/rcc"], - visibility = ["//visibility:public"], -) - -filegroup( - name = "plugin_files", - srcs = glob(["share/qt/plugins/**/*"]), - visibility = ["//visibility:public"], -) - -filegroup( - name = "qml_files", - srcs = glob(["qml/**/*"]), - visibility = ["//visibility:public"], -) diff --git a/qt_windows_x86_64.BUILD b/qt_windows_x86_64.BUILD index 1c49417..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") [ @@ -72,3 +73,8 @@ filegroup( srcs = glob(["qml/**/*"]), visibility = ["//visibility:public"], ) + +exports_files( + ["qml", "plugins", "lib"], + visibility = ["//visibility:public"], +) diff --git a/tests/.bazelrc b/tests/.bazelrc index 247910a..b45f9dd 100644 --- a/tests/.bazelrc +++ b/tests/.bazelrc @@ -1,3 +1,5 @@ +build --noincompatible_disallow_empty_glob + # Setup compiler flags - required for Qt6 is at least C++17 build:gcc9 --cxxopt=-std=c++2a build:gcc9 --cxxopt=-Wall @@ -11,6 +13,12 @@ build:gcc11 --cxxopt=-Wall #build:gcc11 --cxxopt=-Wno-error=volatile # blocked by emsdk ##build:gcc11 --cxxopt=-Wextra +# GCC 13 +build:gcc13 --cxxopt=-std=c++20 +build:gcc13 --cxxopt=-Wall +build:gcc13 --define compiler=gcc13 +build:gcc13 --cxxopt=-fpermissive # Needed for fmt + # Visual Studio 2019 build:vs2019 --cxxopt=/std:c++20 build:vs2019 --cxxopt=/Zc:__cplusplus # Untested diff --git a/tests/.bazelversion b/tests/.bazelversion index 91e4a9f..fa5fce0 100644 --- a/tests/.bazelversion +++ b/tests/.bazelversion @@ -1 +1 @@ -6.3.2 +8.0.0 \ No newline at end of file diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel new file mode 100644 index 0000000..7fbeb09 --- /dev/null +++ b/tests/MODULE.bazel @@ -0,0 +1,20 @@ +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_qt") +local_path_override( + module_name = "rules_qt", + path = "..", +) + +qt = use_extension("@rules_qt//:extensions.bzl", "qt") +qt.fetch() +use_repo( + qt, + "qt_linux_x86_64", + "qt_mac_aarch64", + "qt_windows_x86_64", +) + +register_toolchains( + "@rules_qt//tools:all", + dev_dependency = True, +) diff --git a/tests/WORKSPACE.bazel b/tests/WORKSPACE.bazel deleted file mode 100644 index 63e9c6c..0000000 --- a/tests/WORKSPACE.bazel +++ /dev/null @@ -1,12 +0,0 @@ -local_repository( - name = "rules_qt", - path = "..", -) - -load("@rules_qt//:fetch_qt.bzl", "fetch_qt6") - -fetch_qt6() - -load("@rules_qt//tools:qt_toolchain.bzl", "register_qt_toolchains") - -register_qt_toolchains() diff --git a/tests/hello_world/README.md b/tests/hello_world/README.md new file mode 100644 index 0000000..0b3d85e --- /dev/null +++ b/tests/hello_world/README.md @@ -0,0 +1,7 @@ +# How to run? + +## Visual Studio 2022 + +```shell +bazel run --config=vs2022 //hello_world:hello_world +``` diff --git a/tests/horch/README.md b/tests/horch/README.md new file mode 100644 index 0000000..c7d60a4 --- /dev/null +++ b/tests/horch/README.md @@ -0,0 +1,8 @@ +# How to run? + +## Visual Studio 2022 + +```shell +bazel run --config=vs2022 //horch:main +``` + diff --git a/tests/qml_demo/README.md b/tests/qml_demo/README.md new file mode 100644 index 0000000..45b9399 --- /dev/null +++ b/tests/qml_demo/README.md @@ -0,0 +1,7 @@ +# How to run? + +## Visual Studio 2022 + +```shell +bazel run --config=vs2022 //qml_demo:qt_demo +``` diff --git a/tests/uic_demo/README.md b/tests/uic_demo/README.md new file mode 100644 index 0000000..a199ac3 --- /dev/null +++ b/tests/uic_demo/README.md @@ -0,0 +1,7 @@ +# How to run? + +## Visual Studio 2022 + +```shell +bazel run --config=vs2022 //uic_demo:main +```