Git Product home page Git Product logo

bazel_rules_qt's Introduction

Circle CI (Linux) AppVeyor (Windows) Bazel CI
ci status ci status ci status

Bazel rules for Qt

These bazel rules and BUILD targets make it easy to use Qt from C++ projects built with bazel.

Note that unlike many libraries used through bazel, it requires Qt to be installed when building the application. Also keep in mind that this rules only allow to link Qt dynamically. In addition in the case of Linux it also requires Qt to be installed on the system when running it. For Windows, it is not needed to have Qt installed in the system to run your program. The needed dll files are copied to the output folder to make it self contained. However qt is still dynamically linked.

Platform support

This project currently only works on Linux and Windows, eventually Mac OS X might be supported as well.

Usage

You can either copy the qt.BUILD and qt.bzl files into your project, add this project as a submodule if you're using git or use a git_repository rule to fetch the rules.

Configure your WORKSPACE to include the qt libraries:

# WORKSPACE

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "com_justbuchanan_rules_qt",
    remote = "https://github.com/justbuchanan/bazel_rules_qt.git",
    branch = "master",
)

load("@com_justbuchanan_rules_qt//:qt_configure.bzl", "qt_configure")

qt_configure()

load("@local_config_qt//:local_qt.bzl", "local_qt_path")

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

load("@com_justbuchanan_rules_qt//tools:qt_toolchain.bzl", "register_qt_toolchains")
register_qt_toolchains()

Use the build rules provided by qt.bzl to build your project. See qt.bzl for which rules are available.

# BUILD

load("@com_justbuchanan_rules_qt//:qt.bzl", "qt_cc_library", "qt_ui_library")

qt_cc_library(
    name = "MyWidget",
    srcs = ["MyWidget.cc"],
    hdrs = ["MyWidget.h"],
    deps = ["@qt//:qt_widgets"],
)

qt_ui_library(
    name = "mainwindow",
    ui = "mainwindow.ui",
    deps = ["@qt//:qt_widgets"],
)

cc_binary(
    name = "main",
    srcs = ["main.cpp"],
    copts = ["-fpic"],
    deps = [
        "@qt//:qt_widgets",
        ":MyWidget",
        ":mainwindow",
    ],
)

Credits

This is a fork of https://github.com/bbreslauer/qt-bazel-example with many modifications.

bazel_rules_qt's People

Contributors

dnewmarch avatar justbuchanan avatar limdor avatar vertexwahn avatar

bazel_rules_qt's Issues

Install Qt in the Bazel CI

rules_qt relies on Qt being preinstalled in the system. In order to be able to test rules_qt in the Bazel CI we need to adapt the .presubmit to install Qt.

As far as I know we have 3 options:

  • Install Qt using apt-get (sudo rights are needed)
  • Install Qt using the offline installer (Quite complicated to get a non interactive installer, scripting is needed)
  • Install Qt using aqt (https://github.com/miurahr/aqtinstall)

Seems that the best option would be the last one, in case that this does not work there would be still the option to preinstall Qt in the docker container but this would affect all bazel jobs: bazelbuild/continuous-integration#1078

Provide Qt as a toolchain

Provide the autodetected Qt as a toolchain is the way to go and would allow to specify multiple qt versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.