justbuchanan / bazel_rules_qt

Bazel rules for Qt5
Apache License 2.0
46 stars 23 forks source link

Fetch Qt instead of require it to be preinstalled #25

Open Vertexwahn opened 3 years ago

Vertexwahn commented 3 years ago

If you want to use those rules you have to install Qt on every developer machine and configure your CI to pre-install Qt. For instance, when using Azure you have to do something similar as described here

The requirement of a pre-installed Qt version is really anyoing.

Get rid of this!

Fetch a pre-build version of Qt via Bazel.

justbuchanan commented 3 years ago

This is a good suggestion, thanks for filing it. There are some pros/cons to each approach, so I think it would be good to aim for supporting both.

A few thoughts:

Ideally, I think it would be nice to provide two options with rules_qt:

  1. bazel downloads qt source, builds it, and statically links it into your app
  2. bazel uses system-installed dynamic libraries
Vertexwahn commented 3 years ago

I created an experiment here using Qt6. The idea here is to use a prebuild version of Qt and use dynamic linking.

jheaff1 commented 1 year ago

FYI I’ve started working on a rule set like bazel_rules_qt that builds qt from source.

https://github.com/jheaff1/rules_qt/tree/build_qt_on_linux

It’s still very much a work in progress

gedalia commented 1 year ago

maybe there's a middle ground? Our system has a prebuilt qt that we grab for CI. It looks like BAZEL_RULES_QT_DIR env allow me to override the default include path. But not the moc path or the libs directory, is there any reason why that couldn't be pushed through the rest of the system? That would at least provide a workable way to build the package portablely.

Vertexwahn commented 1 year ago

Vertexwahn/rules_qt6 fetches on Windows and Linux a prebuild version of Qt6 - no need to preinstall anything - on macOS it is still required to preinstall Qt6 (brew install qt6) whit these rules.

It would be really cool if someone would mange it to build Qt from scratch with Bazel. That would eliminate all the prebuild/prefetch things and only build the necessary things. I see this as a long term solution.

A better short time solution would be to use aqt in a Bazel rule to install a prebuild version of Qt (and maybe brew on macOS if not doable with aqt). This seems for me most promising and doable in shorttime.

Preinstalling something should be avoided in my opinion. There might be users that have no idea of Qt or work on different systems (as I do) and do not want to repeat install instructions every time.

Also Bzlmod should be talken in consideration.

jheaff1 commented 1 year ago

I’ve built Qt from source using Bazel and was in the process of making a rule set for it but sadly I don’t have time to work on it anymore

here is a branch that can build Qt for Linux using Bazel. I also have a messy private repo that can build Qt for windows and android. If people are interested I could make that public

https://github.com/jheaff1/rules_qt/commits/build_qt_on_linux

jheaff1 commented 1 year ago

Aside from aqt, one could use this script to install qt without user interaction:

https://github.com/qbs/qbs/blob/master/scripts/install-qt.sh

Vertexwahn commented 1 year ago

@jheaff1 Did not realize that your rules work already on linux - would be nice if you share also the qt and android variant - maybe in own branches - not sure if I will ever have time to apply this to rules_qt6, but if someone wants to improve Qt Bazel support that direction does not sound to bad...