Skip to content

Use aqt for genbindings #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions cmd/genbindings/config-libraries.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"strings"
)

const Qt5Root = "/opt/Qt/5.15.2/gcc_64/include/"
const Qt6Root = "/opt/Qt/6.2.4/gcc_64/include/"

func ProcessLibraries(clangBin, outDir, extraLibsDir string) {

AllowAllHeaders := func(string) bool { return true }
Expand All @@ -15,9 +18,10 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
"/usr/include/x86_64-linux-gnu/qt5/QtGui",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
Qt5Root + "QtCore",
Qt5Root + "QtCore",
Qt5Root + "QtGui",
Qt5Root + "QtWidgets",
},
func(fullpath string) bool {
// Block cbor and generate it separately
Expand All @@ -37,7 +41,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/cbor",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtCore",
Qt5Root + "QtCore",
},
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
Expand All @@ -53,7 +57,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/printsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport",
Qt5Root + "QtPrintSupport",
},
AllowAllHeaders,
clangBin,
Expand All @@ -65,7 +69,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/svg",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtSvg",
Qt5Root + "QtSvg",
},
AllowAllHeaders,
clangBin,
Expand All @@ -77,7 +81,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/network",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtNetwork",
Qt5Root + "QtNetwork",
},
AllowAllHeaders,
clangBin,
Expand All @@ -92,8 +96,8 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
// Theoretically, QtMultimediaWidgets and QtMultimedia are different
// packages, but QtMultimedia qcamera.h has a dependency on qvideowidget.
// Bind them together since our base /qt/ package is Widgets anyway.
"/usr/include/x86_64-linux-gnu/qt5/QtMultimedia",
"/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets",
Qt5Root + "QtMultimedia",
Qt5Root + "QtMultimediaWidgets",
},
AllowAllHeaders,
clangBin,
Expand All @@ -105,7 +109,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/script",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtScript",
Qt5Root + "QtScript",
},
AllowAllHeaders,
clangBin,
Expand All @@ -119,8 +123,8 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/webkit",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtWebKit",
"/usr/include/x86_64-linux-gnu/qt5/QtWebKitWidgets",
Qt5Root + "QtWebKit",
Qt5Root + "QtWebKitWidgets",
},
AllowAllHeaders,
clangBin,
Expand All @@ -133,7 +137,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/webchannel",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtWebChannel",
Qt5Root + "QtWebChannel",
},
AllowAllHeaders,
clangBin,
Expand All @@ -146,9 +150,9 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt/webengine",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/QtWebEngine",
"/usr/include/x86_64-linux-gnu/qt5/QtWebEngineCore",
"/usr/include/x86_64-linux-gnu/qt5/QtWebEngineWidgets",
Qt5Root + "QtWebEngine",
Qt5Root + "QtWebEngineCore",
Qt5Root + "QtWebEngineWidgets",
},

func(fullpath string) bool {
Expand All @@ -168,7 +172,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt-restricted-extras/qscintilla",
[]string{
"/usr/include/x86_64-linux-gnu/qt5/Qsci",
Qt5Root + "Qsci",
},
AllowAllHeaders,
clangBin,
Expand Down Expand Up @@ -199,9 +203,9 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtCore",
"/usr/include/x86_64-linux-gnu/qt6/QtGui",
"/usr/include/x86_64-linux-gnu/qt6/QtWidgets",
Qt6Root + "QtCore",
Qt6Root + "QtGui",
Qt6Root + "QtWidgets",
},
func(fullpath string) bool {
// Block cbor and generate it separately
Expand All @@ -221,7 +225,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/cbor",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtCore",
Qt6Root + "QtCore",
},
func(fullpath string) bool {
// Only include the same json, xml, cbor files excluded above
Expand All @@ -238,7 +242,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/printsupport",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtPrintSupport",
Qt6Root + "QtPrintSupport",
},
AllowAllHeaders,
clangBin,
Expand All @@ -251,8 +255,8 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/svg",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtSvg",
"/usr/include/x86_64-linux-gnu/qt6/QtSvgWidgets",
Qt6Root + "QtSvg",
Qt6Root + "QtSvgWidgets",
},
AllowAllHeaders,
clangBin,
Expand All @@ -265,7 +269,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/network",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtNetwork",
Qt6Root + "QtNetwork",
},
func(fullpath string) bool {
fname := filepath.Base(fullpath)
Expand All @@ -281,8 +285,8 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/multimedia",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtMultimedia",
"/usr/include/x86_64-linux-gnu/qt6/QtMultimediaWidgets",
Qt6Root + "QtMultimedia",
Qt6Root + "QtMultimediaWidgets",
},
AllowAllHeaders,
clangBin,
Expand All @@ -295,7 +299,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/spatialaudio",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtSpatialAudio",
Qt6Root + "QtSpatialAudio",
},
AllowAllHeaders,
clangBin,
Expand All @@ -308,7 +312,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/webchannel",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtWebChannel",
Qt6Root + "QtWebChannel",
},
AllowAllHeaders,
clangBin,
Expand All @@ -321,8 +325,8 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt6/webengine",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/QtWebEngineCore",
"/usr/include/x86_64-linux-gnu/qt6/QtWebEngineWidgets",
Qt6Root + "QtWebEngineCore",
Qt6Root + "QtWebEngineWidgets",
},
func(fullpath string) bool {
baseName := filepath.Base(fullpath)
Expand All @@ -342,7 +346,7 @@ func ProcessLibraries(clangBin, outDir, extraLibsDir string) {
generate(
"qt-restricted-extras/qscintilla6",
[]string{
"/usr/include/x86_64-linux-gnu/qt6/Qsci",
Qt6Root + "Qsci",
},
AllowAllHeaders,
clangBin,
Expand Down
47 changes: 32 additions & 15 deletions docker/genbindings.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
FROM debian:bookworm

ENV QT6_VERSION=6.2.4
ENV QT5_VERSION=5.15.2

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
apt-get install --no-install-recommends -qyy \
python3 \
python3-pip \
python3.11-venv \
golang-go \
qtbase5-dev \
qtmultimedia5-dev \
qtscript5-dev \
libqt5svg5-dev \
libqt5webkit5-dev \
qtwebengine5-dev \
qt6-base-dev \
qt6-multimedia-dev \
qt6-svg-dev \
qt6-webengine-dev \
libqscintilla2-qt5-dev \
libqscintilla2-qt6-dev \
clang \
git \
ca-certificates \
pkg-config \
build-essential && \
apt-get clean


RUN python3 -m venv /opt/virtualenvironment
ENV PATH="/opt/virtualenvironment/bin:$PATH"
RUN python3 -m pip install aqtinstall

RUN aqt install-qt linux desktop $QT5_VERSION gcc_64 --outputdir /opt/Qt
ENV PATH=/opt/Qt/$QT5_VERSION/gcc_64/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/Qt/$QT5_VERSION/gcc_64/lib
ENV QT_PLUGIN_PATH=/opt/Qt/$QT5_VERSION/gcc_64/plugins
ENV QTDIR=/opt/Qt/$QT5_VERSION/gcc_64
ENV PKG_CONFIG_PATH=/opt/Qt/$QT5_VERSION/gcc_64/lib/pkgconfig:$PKG_CONFIG_PATH

RUN aqt install-qt linux desktop $QT6_VERSION gcc_64 --outputdir /opt/Qt
ENV PATH=/opt/Qt/$QT6_VERSION/gcc_64/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/Qt/$QT6_VERSION/gcc_64/lib
ENV QT_PLUGIN_PATH=/opt/Qt/$QT6_VERSION/gcc_64/plugins
ENV QTDIR=/opt/Qt/$QT6_VERSION/gcc_64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these declarations overwrite the Qt5 ones? I think they're maybe not needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point.
They will be overriding the Qt5 ones.
We will likely need to generate the bindings for each major version in a separate step?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LD_LIBRARY_PATH and QT_PLUGIN_PATH are used by Qt apps at runtime to find their needed .so files. The PATH and QTDIR are only needed so that a developer can more easily run qmake.

I think Genbindings doesn't need any of those four, it should only need the Qt5Root change in config-libraries.go plus the new PKG_CONFIG_PATH entries.

ENV PKG_CONFIG_PATH=/opt/Qt/$QT6_VERSION/gcc_64/lib/pkgconfig:$PKG_CONFIG_PATH

RUN mkdir -p /usr/local/src/scintilla && \
git clone 'https://github.com/mirror/scintilla.git' /usr/local/src/scintilla && \
git -C /usr/local/src/scintilla checkout rel-5-5-2

RUN \
cd /usr/local/src/scintilla/qt/ScintillaEditBase && \
qmake && \
Expand All @@ -37,7 +50,11 @@ RUN \

RUN mkdir -p /usr/local/lib/pkgconfig

COPY pkg-config/QScintilla.pc.example /usr/local/lib/pkgconfig/QScintilla.pc
COPY pkg-config/ScintillaEdit.pc.example /usr/local/lib/pkgconfig/ScintillaEdit.pc
COPY pkg-config/QScintilla.pc.example /opt/Qt/$QT5_VERSION/gcc_64/lib/pkgconfig/QScintilla.pc
COPY pkg-config/ScintillaEdit.pc.example /opt/Qt/$QT5_VERSION/gcc_64/lib/pkgconfig/ScintillaEdit.pc

COPY pkg-config/QScintilla.pc.example /opt/Qt/$QT6_VERSION/gcc_64/lib/pkgconfig/QScintilla.pc
COPY pkg-config/ScintillaEdit.pc.example /opt/Qt/$QT6_VERSION/gcc_64/lib/pkgconfig/ScintillaEdit.pc


ENV GOFLAGS=-buildvcs=false