Skip to content

build: Add required packages for static builds #19

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

Merged
merged 4 commits into from
Aug 27, 2021
Merged
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
26 changes: 26 additions & 0 deletions build-aux/m4/bitcoin_qt.m4
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
if test -d "$qt_plugin_path/platforms/android"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms/android -lqtfreetype -lEGL"
fi
if test -d "$qt_plugin_path/../qml/QtQuick/Controls"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick/Controls"
fi
if test -d "$qt_plugin_path/../qml/QtQuick/Controls.2"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick/Controls.2"
fi
if test -d "$qt_plugin_path/../qml/QtQuick/Dialogs"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick/Dialogs"
fi
if test -d "$qt_plugin_path/../qml/QtQuick/Templates.2"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick/Templates.2"
fi
if test -d "$qt_plugin_path/../qml/QtQuick/Window.2"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick/Window.2"
fi
if test -d "$qt_plugin_path/../qml/QtQuick.2"; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtQuick.2"
fi
fi

AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
Expand Down Expand Up @@ -171,6 +189,14 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lqtforandroid -ljnigraphics -landroid -lqtfreetype $QT_LIBS"
AC_DEFINE(QT_QPA_PLATFORM_ANDROID, 1, [Define this symbol if the qt platform is android])
fi
if test "x$use_qml" != xno; then
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuick2DialogsPlugin], [-ldialogplugin])
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuick2Plugin], [-lqtquick2plugin])
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuick2WindowPlugin], [-lwindowplugin])
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuickControls1Plugin], [-lqtquickcontrolsplugin])
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuickControls2Plugin], [-lqtquickcontrols2plugin])
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QtQuickTemplates2Plugin], [-lqtquicktemplates2plugin])
fi
fi
CPPFLAGS=$TEMP_CPPFLAGS
CXXFLAGS=$TEMP_CXXFLAGS
Expand Down
40 changes: 39 additions & 1 deletion depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,31 @@ $(package)_patches += support_new_android_ndks.patch fix_android_jni_static.patc
$(package)_patches+= no_sdk_version_check.patch
$(package)_patches+= fix_lib_paths.patch fix_android_pch.patch
$(package)_patches+= qtbase-moc-ignore-gcc-macro.patch fix_limits_header.patch
$(package)_patches += fix_qml_python.patch

$(package)_qtdeclarative_file_name = qtdeclarative-$($(package)_suffix)
$(package)_qtdeclarative_sha256_hash = 1267e029abc8424424c419bc1681db069ec76e51270cc220994e0f442c9f78d3

$(package)_qtgraphicaleffects_file_name = qtgraphicaleffects-$($(package)_suffix)
$(package)_qtgraphicaleffects_sha256_hash = d84490104965fb5e831b3d1b9ce72786071e9bdd8080deb07ee1ed189f3eda0a

$(package)_qtquickcontrols_file_name = qtquickcontrols-$($(package)_suffix)
$(package)_qtquickcontrols_sha256_hash = cd6b81fda691ab15d25ac60b6a3437667a892e401438e07a64c88cadd3481389

$(package)_qtquickcontrols2_file_name = qtquickcontrols2-$($(package)_suffix)
$(package)_qtquickcontrols2_sha256_hash = c05585f42db7c17fb7f344f8a9cabd38a4e9dff17b3d04ec35e8edab7ead355c

$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
$(package)_qttranslations_sha256_hash=577b0668a777eb2b451c61e8d026d79285371597ce9df06b6dee6c814164b7c3

$(package)_qttools_file_name=qttools-$($(package)_suffix)
$(package)_qttools_sha256_hash=98b2aaca230458f65996f3534fd471d2ffd038dd58ac997c0589c06dc2385b4f

$(package)_extra_sources = $($(package)_qttranslations_file_name)
$(package)_extra_sources += $($(package)_qtdeclarative_file_name)
$(package)_extra_sources += $($(package)_qtgraphicaleffects_file_name)
$(package)_extra_sources += $($(package)_qtquickcontrols_file_name)
$(package)_extra_sources += $($(package)_qtquickcontrols2_file_name)
$(package)_extra_sources += $($(package)_qttranslations_file_name)
$(package)_extra_sources += $($(package)_qttools_file_name)

define $(package)_set_vars
Expand Down Expand Up @@ -181,18 +198,34 @@ endef

define $(package)_fetch_cmds
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtdeclarative_file_name),$($(package)_qtdeclarative_file_name),$($(package)_qtdeclarative_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtgraphicaleffects_file_name),$($(package)_qtgraphicaleffects_file_name),$($(package)_qtgraphicaleffects_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtquickcontrols_file_name),$($(package)_qtquickcontrols_file_name),$($(package)_qtquickcontrols_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtquickcontrols2_file_name),$($(package)_qtquickcontrols2_file_name),$($(package)_qtquickcontrols2_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttranslations_file_name),$($(package)_qttranslations_file_name),$($(package)_qttranslations_sha256_hash)) && \
$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttools_file_name),$($(package)_qttools_file_name),$($(package)_qttools_sha256_hash))
endef

define $(package)_extract_cmds
mkdir -p $($(package)_extract_dir) && \
echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qtdeclarative_sha256_hash) $($(package)_source_dir)/$($(package)_qtdeclarative_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qtgraphicaleffects_sha256_hash) $($(package)_source_dir)/$($(package)_qtgraphicaleffects_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qtquickcontrols_sha256_hash) $($(package)_source_dir)/$($(package)_qtquickcontrols_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qtquickcontrols2_sha256_hash) $($(package)_source_dir)/$($(package)_qtquickcontrols2_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qttranslations_sha256_hash) $($(package)_source_dir)/$($(package)_qttranslations_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \
mkdir qtbase && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \
mkdir qtdeclarative && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtdeclarative_file_name) -C qtdeclarative && \
mkdir qtgraphicaleffects && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtgraphicaleffects_file_name) -C qtgraphicaleffects && \
mkdir qtquickcontrols && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtquickcontrols_file_name) -C qtquickcontrols && \
mkdir qtquickcontrols2 && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtquickcontrols2_file_name) -C qtquickcontrols2 && \
mkdir qttranslations && \
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \
mkdir qttools && \
Expand Down Expand Up @@ -232,6 +265,7 @@ define $(package)_preprocess_cmds
patch -p1 -i $($(package)_patch_dir)/fix_lib_paths.patch && \
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_limits_header.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_qml_python.patch && \
mkdir -p qtbase/mkspecs/macx-clang-linux &&\
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
Expand All @@ -258,7 +292,11 @@ define $(package)_build_cmds
endef

define $(package)_stage_cmds
export PATH && \
$(MAKE) -C qtbase/src INSTALL_ROOT=$($(package)_staging_dir) $(addsuffix -install_subtargets,$(addprefix sub-,$($(package)_qt_libs))) && \
$(MAKE) -C qtdeclarative INSTALL_ROOT=$($(package)_staging_dir) sub-src-install_subtargets && \
$(MAKE) -C qtquickcontrols INSTALL_ROOT=$($(package)_staging_dir) install && \
$(MAKE) -C qtquickcontrols2 INSTALL_ROOT=$($(package)_staging_dir) sub-src-install_subtargets && \
$(MAKE) -C qttools/src/linguist INSTALL_ROOT=$($(package)_staging_dir) $(addsuffix -install_subtargets,$(addprefix sub-,$($(package)_linguist_tools))) && \
$(MAKE) -C qttranslations INSTALL_ROOT=$($(package)_staging_dir) install_subtargets
endef
Expand Down
135 changes: 135 additions & 0 deletions depends/patches/qt/fix_qml_python.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
Fix python check

Upsream bugreports:
- https://bugreports.qt.io/browse/QTBUG-72926
- https://bugreports.qt.io/browse/QTBUG-84038

Upstream commits:
- Qt 5.15: 1c6a70e1880a8fe0f3d8da4932c4f3533693219c
- Qt 6.0: 2b41025fc967b37c8bff77c4b75bab333ae13f46

--- old/qtdeclarative/qtdeclarative.pro
+++ new/qtdeclarative/qtdeclarative.pro
@@ -1,10 +1,2 @@
CONFIG += tests_need_tools examples_need_tools
load(qt_parts)
-
-!python_available {
- py_out = $$system('python -c "print(1)"')
- !equals(py_out, 1): error("Building QtQml requires Python.")
- tmp = python_available
- CONFIG += $$tmp
- cache(CONFIG, add, tmp)
-}

--- old/qtdeclarative/src/3rdparty/masm/masm.pri
+++ new/qtdeclarative/src/3rdparty/masm/masm.pri
@@ -58,7 +58,7 @@
udis86.output = udis86_itab.h
udis86.input = ITAB
udis86.CONFIG += no_link
- udis86.commands = python $$PWD/disassembler/udis86/itab.py ${QMAKE_FILE_IN}
+ udis86.commands = $QMAKE_PYTHON $$PWD/disassembler/udis86/itab.py ${QMAKE_FILE_IN}
QMAKE_EXTRA_COMPILERS += udis86

udis86_tab_cfile.target = $$OUT_PWD/udis86_itab.c
@@ -113,7 +113,7 @@
retgen.script = $$PWD/yarr/create_regex_tables
retgen.input = retgen.script
retgen.CONFIG += no_link
-retgen.commands = python $$retgen.script > ${QMAKE_FILE_OUT}
+retgen.commands = $$QMAKE_PYTHON $$retgen.script > ${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += retgen

# Taken from WebKit/Tools/qmake/mkspecs/features/unix/default_post.prf

--- old/qtdeclarative/src/qml/configure.json
+++ new/qtdeclarative/src/qml/configure.json
@@ -23,6 +23,11 @@
],
"qmake": "CONFIG += c++11"
}
+ },
+ "qml-python": {
+ "label": "python",
+ "type": "detectPython",
+ "log": "location"
}
},

@@ -123,9 +128,25 @@
"section": "QML",
"condition": "features.thread",
"output": [ "privateFeature" ]
+ },
+ "qml-python": {
+ "label": "python",
+ "condition": "tests.qml-python",
+ "output": [
+ "privateFeature",
+ { "type": "varAssign", "name": "QMAKE_PYTHON", "value": "tests.qml-python.location" }
+ ]
}
},

+ "report": [
+ {
+ "type": "error",
+ "condition": "!features.qml-python",
+ "message": "Python is required to build QtQml."
+ }
+ ],
+
"summary": [
{
"section": "Qt QML",

--- old/qtdeclarative/src/qml/configure.pri
+++ new/qtdeclarative/src/qml/configure.pri
@@ -0,0 +1,22 @@
+equals(QMAKE_HOST.os, Windows): EXE_SUFFIX = .exe
+
+defineTest(qtConfTest_detectPython) {
+ PYTHON_NAMES = python$$EXE_SUFFIX python2$${EXE_SUFFIX} python3$${EXE_SUFFIX} py$${EXE_SUFFIX}
+ for (name, PYTHON_NAMES) {
+ python_path = $$qtConfFindInPath("$$name")
+ !isEmpty(python_path): \
+ break()
+ }
+ isEmpty(python_path) {
+ qtLog("No $$PYTHON_NAMES are found in PATH. Giving up.")
+ return(false)
+ }
+
+ # Make tests.python.location available in configure.json.
+ $${1}.location = $$clean_path($$python_path)
+ export($${1}.location)
+ $${1}.cache += location
+ export($${1}.cache)
+
+ return(true)
+}

--- old/qtdeclarative/src/qml/qml.pro
+++ new/qtdeclarative/src/qml/qml.pro
@@ -7,6 +7,9 @@
TRACEPOINT_PROVIDER = $$PWD/qtqml.tracepoints
CONFIG += qt_tracepoints

+!qtConfig(qml-python): \
+ error(Python is required to build QtQml.)
+
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES

msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x66000000
@@ -81,8 +84,9 @@
}
include(types/types.pri)
include(../3rdparty/masm/masm-defs.pri)
-include(../3rdparty/masm/masm.pri)

MODULE_PLUGIN_TYPES = \
qmltooling
load(qt_module)
+
+include(../3rdparty/masm/masm.pri)
6 changes: 5 additions & 1 deletion depends/patches/qt/qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ CONFIG += $$prl
cache(CONFIG, add stash, prl)

TEMPLATE = subdirs
SUBDIRS = qtbase qttools qttranslations
SUBDIRS = qtbase qtdeclarative qtgraphicaleffects qtquickcontrols qtquickcontrols2 qttools qttranslations

qtdeclarative.depends = qtbase
qtgraphicaleffects.depends = qtdeclarative
qtquickcontrols.depends = qtdeclarative
qtquickcontrols2.depends = qtgraphicaleffects
qttools.depends = qtbase
qttranslations.depends = qttools

Expand Down
10 changes: 10 additions & 0 deletions src/qml/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
#include <QStringLiteral>
#include <QUrl>

#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
Q_IMPORT_PLUGIN(QtQuick2DialogsPlugin);
Q_IMPORT_PLUGIN(QtQuick2Plugin);
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin);
Q_IMPORT_PLUGIN(QtQuickControls1Plugin);
Q_IMPORT_PLUGIN(QtQuickControls2Plugin);
Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin);
#endif

namespace {
void SetupUIArgs(ArgsManager& argsman)
{
Expand Down
6 changes: 1 addition & 5 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@

#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
#if defined(QT_QPA_PLATFORM_XCB)
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_WINDOWS)
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#if defined(QT_QPA_PLATFORM_WINDOWS)
Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin);
#elif defined(QT_QPA_PLATFORM_COCOA)
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
Q_IMPORT_PLUGIN(QMacStylePlugin);
#endif
#endif
Expand Down
11 changes: 11 additions & 0 deletions src/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
#include <string>
#include <tuple>

#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
#if defined(QT_QPA_PLATFORM_XCB)
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_WINDOWS)
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_COCOA)
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
#endif
#endif

/** Translate string to current locale using Qt. */
extern const std::function<std::string(const char*)> G_TRANSLATION_FUN = [](const char* psz) {
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
Expand Down