diff --git a/.github/workflows/bazel_build.yml b/.github/workflows/bazel_build.yml index 6cdad07..c36a295 100644 --- a/.github/workflows/bazel_build.yml +++ b/.github/workflows/bazel_build.yml @@ -5,23 +5,23 @@ on: push: {} jobs: - build_and_test_ubuntu20: - name: Linux Ubuntu 20.04 build - runs-on: ubuntu-20.04 + # build_and_test_ubuntu20: + # name: Linux Ubuntu 20.04 build + # runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 + # steps: + # - uses: actions/checkout@v3 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + # - name: Mount bazel cache + # uses: actions/cache@v3 + # with: + # path: "/home/runner/.cache/bazel" + # key: bazel - - name: Build - run: | - cd tests - bazelisk build --config=gcc9 //... + # - name: Build + # run: | + # cd tests + # bazelisk build --config=gcc9 //... build_and_test_ubuntu22: name: Linux Ubuntu 22.04 build @@ -41,23 +41,23 @@ jobs: cd tests bazelisk build --config=gcc11 //... - build_and_test_windows10: - name: Windows Server 2019 build - runs-on: windows-2019 + # build_and_test_windows10: + # name: Windows Server 2019 build + # runs-on: windows-2019 - steps: - - uses: actions/checkout@v3 + # steps: + # - uses: actions/checkout@v3 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel + # - name: Mount bazel cache + # uses: actions/cache@v3 + # with: + # path: "/home/runner/.cache/bazel" + # key: bazel - - name: Build - run: | - cd tests - bazelisk build --config=vs2019 //... + # - name: Build + # run: | + # cd tests + # bazelisk build --config=vs2019 //... build_and_test_windows11: name: Windows Server 2022 build @@ -77,61 +77,61 @@ jobs: cd tests bazelisk build --config=vs2022 //... - build_and_test_macos11: - name: macOS 11 Bazel build - runs-on: macOS-11 - - steps: - - uses: actions/checkout@v3 - - - 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 + # build_and_test_macos11: + # name: macOS 11 Bazel build + # runs-on: macOS-11 + + # steps: + # - uses: actions/checkout@v3 + + # - 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: Build - run: | - brew install qt@6 - #brew link qt@6 - cd tests - bazelisk build --config=macos //... - - build_and_test_macos12: - name: macOS 12 Bazel build - runs-on: macOS-12 - - steps: - - uses: actions/checkout@v3 - - - 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: Build + # run: | + # brew install qt@6 + # #brew link qt@6 + # cd tests + # bazelisk build --config=macos //... + + # build_and_test_macos12: + # name: macOS 12 Bazel build + # runs-on: macOS-12 + + # steps: + # - uses: actions/checkout@v3 + + # - 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: Build - run: | - brew install qt@6 - #brew link qt@6 - cd tests - bazelisk build --config=macos //... + # - name: Build + # run: | + # brew install qt@6 + # #brew link qt@6 + # cd tests + # bazelisk build --config=macos //... build_and_test_macos13: name: macOS 13 Bazel build 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..51e8c22 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,21 @@ +module( + name = "rules_qt", + version = "1.0.0", + compatibility_level = 1, +) + +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "bazel_skylib", version = "1.7.1") + +qt = use_extension("@rules_qt//:extensions.bzl", "qt") +qt.fetch() +use_repo( + qt, + "qt_linux_x86_64", + "qt_windows_x86_64", + "qt_mac_aarch64", +) +register_toolchains( + "@rules_qt//tools:all", + dev_dependency = True, +) diff --git a/README.md b/README.md index cac853b..bed8eeb 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ The following tools should be installed: *All platforms:* ```shell -git clone https://github.com/Vertexwahn/rules_qt6 -cd tests +git clone https://github.com/Vertexwahn/rules_qt6 && +cd rules_qt6/tests ``` *Run Hello World demo with Windows 10/11 x64 with Visual Studio 2019:* diff --git a/extensions.bzl b/extensions.bzl new file mode 100644 index 0000000..287b415 --- /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, + }, +) \ No newline at end of file diff --git a/fetch_qt.bzl b/fetch_qt.bzl index 263672b..f978b5c 100644 --- a/fetch_qt.bzl +++ b/fetch_qt.bzl @@ -9,51 +9,28 @@ def fetch_qt6(): http_archive( name = "qt_windows_x86_64", urls = [ - "https://vertexwahn.de/lfs/v1/qt_6.4.0_windows_desktop_win64_msvc2019_64.zip", + "https://dl.dropboxusercontent.com/scl/fi/a75eyqtu0542t203eyie2/qt_6.8.0_windows_msvc2022_64_gamepad.zip?rlkey=l2ucxa4by8c8tp3xioqoamm89&dl=0", ], - sha256 = "e3c20b441ddd8bb803e46de32bf2fc5563fda125409d62dcd12b5647ae5a9c7e", - strip_prefix = "6.4.0/msvc2019_64", + sha256 = "59aa42d34a1b5f15dfc915830a1dbebd90c7b418cf1b726eff8d0fa2766d9827", 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 = [ - "https://vertexwahn.de/lfs/v1/qt_6.4.0_linux_desktop_gcc_64.tar.xz", + "https://dl.dropboxusercontent.com/scl/fi/n5aelrs4qg6lweuitb795/qt_6.8.0_linux_desktop_gcc_64_gamepad.tar.xz?rlkey=miuhkfeat53z7xk85y8abi7o3&dl=0", ], - sha256 = "809919895e2ac0567df9290676d4ec6cd1ed39c432dc5da0722b3104681fd376", - strip_prefix = "6.4.0/gcc_64", + sha256 = "fc18569262fa23c19009a66cfe39ce5761c8e99bc161820cb971be0beec0bb8b", + strip_prefix = "Qt-6.8.0", 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..4e8d205 100644 --- a/qt.bzl +++ b/qt.bzl @@ -232,11 +232,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), @@ -256,6 +256,7 @@ def qt_cc_library(name, srcs, hdrs, normal_hdrs = [], deps = None, copts = [], t name = name, srcs = srcs + _moc_srcs, hdrs = hdrs + normal_hdrs, + textual_hdrs = _moc_srcs, deps = deps, copts = copts + select({ "@platforms//os:windows": [], @@ -266,10 +267,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 +285,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,6 +324,32 @@ 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) + 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") native.cc_binary( name = name, srcs = srcs, @@ -326,7 +358,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, diff --git a/qt_libraries.bzl b/qt_libraries.bzl index 39305a1..d7bfa76 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,6 +95,10 @@ 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", [ @@ -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..fbaa861 100644 --- a/qt_linux_x86_64.BUILD +++ b/qt_linux_x86_64.BUILD @@ -7,7 +7,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 +22,9 @@ load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES") cc_library( name = "qt_hdrs", - hdrs = glob(["include/**"]), + hdrs = glob([ + "include/**", + ]), includes = [ "include", ], @@ -56,3 +60,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..2751343 100644 --- a/qt_mac_aarch64.BUILD +++ b/qt_mac_aarch64.BUILD @@ -3,14 +3,17 @@ 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 $(location :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 +31,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 +58,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..ca1d760 100644 --- a/qt_windows_x86_64.BUILD +++ b/qt_windows_x86_64.BUILD @@ -72,3 +72,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..3dae9b5 100644 --- a/tests/.bazelrc +++ b/tests/.bazelrc @@ -1,36 +1,26 @@ -# Setup compiler flags - required for Qt6 is at least C++17 -build:gcc9 --cxxopt=-std=c++2a -build:gcc9 --cxxopt=-Wall -build:gcc9 --cxxopt=-Werror +# GCC +build:gccd --cxxopt=-std=c++20 +build:gccd --cxxopt=-Wall +build:gccd --cxxopt=-Werror +build:gccd --compilation_mode=dbg -# GCC 11.2 -#build:gcc11 --cxxopt=-std=c++23 # blocked by emsdk -build:gcc11 --cxxopt=-std=c++20 -build:gcc11 --cxxopt=-Wall -#build:gcc11 --cxxopt=-Werror -#build:gcc11 --cxxopt=-Wno-error=volatile # blocked by emsdk -##build:gcc11 --cxxopt=-Wextra - -# Visual Studio 2019 -build:vs2019 --cxxopt=/std:c++20 -build:vs2019 --cxxopt=/Zc:__cplusplus # Untested -build:vs2019 --enable_runfiles # https://github.com/bazelbuild/bazel/issues/8843 -build:vs2019 --define compiler=vs2019 -build:vs2019 --copt=-DWIN32_LEAN_AND_MEAN -build:vs2019 --copt=-DNOGDI -build:vs2019 --host_copt=-DWIN32_LEAN_AND_MEAN -build:vs2019 --host_copt=-DNOGDI +# GCC +build:gcc --cxxopt=-std=c++20 +build:gcc --cxxopt=-Wall +build:gcc --cxxopt=-Werror +build:gcc --compilation_mode=opt # Visual Studio 2022 -build:vs2022 --cxxopt=/std:c++20 -build:vs2022 --cxxopt=/Zc:__cplusplus -build:vs2022 --enable_runfiles # https://github.com/bazelbuild/bazel/issues/8843 -build:vs2022 --define compiler=vs2022 -build:vs2022 --copt=-DWIN32_LEAN_AND_MEAN -build:vs2022 --copt=-DNOGDI -build:vs2022 --host_copt=-DWIN32_LEAN_AND_MEAN -build:vs2022 --host_copt=-DNOGDI +build:vs --cxxopt=/std:c++20 +build:vs --cxxopt=/Zc:__cplusplus +build:vs --enable_runfiles # https://github.com/bazelbuild/bazel/issues/8843 +build:vs --define compiler=vs2022 +build:vs --copt=-DWIN32_LEAN_AND_MEAN +build:vs --copt=-DNOGDI +build:vs --host_copt=-DWIN32_LEAN_AND_MEAN +build:vs --host_copt=-DNOGDI # macOS (e.g. Clang 12.0.0) -build:macos --cxxopt=-std=c++2a +build:macos --cxxopt=-std=c++20 build:macos --cxxopt=-Wall +build:macos --repo_env=CC=clang diff --git a/tests/.bazelversion b/tests/.bazelversion deleted file mode 100644 index 91e4a9f..0000000 --- a/tests/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -6.3.2 diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel new file mode 100644 index 0000000..05aa256 --- /dev/null +++ b/tests/MODULE.bazel @@ -0,0 +1,18 @@ +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_windows_x86_64", + "qt_mac_aarch64", +) +register_toolchains( + "@rules_qt//tools:all", + dev_dependency = True, +) diff --git a/tests/WORKSPACE.bazel b/tests/WORKSPACE.bazel index 63e9c6c..e69de29 100644 --- a/tests/WORKSPACE.bazel +++ b/tests/WORKSPACE.bazel @@ -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/BUILD.bazel b/tests/hello_world/BUILD.bazel index d18c054..f9a2b55 100644 --- a/tests/hello_world/BUILD.bazel +++ b/tests/hello_world/BUILD.bazel @@ -7,4 +7,7 @@ qt_cc_binary( "@rules_qt//:qt_core", "@rules_qt//:qt_widgets", ], + copts = [ + "-std=c++17", + ], )