bitcoin-core / gui-qml

Bitcoin GUI (experimental QML-based fork)
MIT License
110 stars 40 forks source link

Enable Ahead-of-Time Compilation #105

Open promag opened 2 years ago

promag commented 2 years ago

Currently build works with invalid syntax, like

--- a/src/qml/controls/OptionButton.qml
+++ b/src/qml/controls/OptionButton.qml
@@ -65,7 +65,7 @@ Button {
                 rightPadding: 7
                 bottomPadding: 4
                 leftPadding: 7
-                color: "black"
+                co lor: "black"
                 text: qsTr("Recommended")
             }
         }

which gives a runtime error:

QQmlApplicationEngine failed to load component
qrc:/qml/pages/stub.qml:43:9: Type ConnectionOptions unavailable
qrc:/qml/components/ConnectionOptions.qml:15:5: Type OptionButton unavailable
qrc:/qml/controls/OptionButton.qml:68:20: Unexpected token `identifier'

Fix this by turning to build-time errors. It's unclear how to use it with Autotools though.

Reference: https://doc.qt.io/qt-5.15/qtquick-deployment.html#ahead-of-time-compilation https://doc.qt.io/archives/QtQuickCompiler/index.html

hebasto commented 2 years ago

https://doc.qt.io/qt-5.15/qtquick-deployment.html#ahead-of-time-compilation

hebasto commented 2 years ago

The following patch

--- a/depends/packages/qt.mk
+++ b/depends/packages/qt.mk
@@ -309,7 +309,7 @@ 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 qtdeclarative INSTALL_ROOT=$($(package)_staging_dir) install_subtargets && \
   $(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

makes QML-specific tools available in our depends, in particular qmlcachegen and qmllint.

hebasto commented 2 years ago
--- a/src/qml/controls/OptionButton.qml
+++ b/src/qml/controls/OptionButton.qml
@@ -65,7 +65,7 @@ Button {
                 rightPadding: 7
                 bottomPadding: 4
                 leftPadding: 7
-                color: "black"
+                co lor: "black"
                 text: qsTr("Recommended")
             }
         }

A compile-time error:

$ /home/hebasto/GitHub/gui-qml/depends/x86_64-pc-linux-gnu/native/bin/qmlcachegen /home/hebasto/GitHub/gui-qml/src/qml/controls/OptionButton.qml
Error compiling qml file: /home/hebasto/GitHub/gui-qml/src/qml/controls/OptionButton.qml:68:20: error: Unexpected token `identifier'
jarolrod commented 2 years ago

This will be free with a CMAKE build system