changeset 876:0051cb07da28

Reduce libraries, document i386 build and statically link fonts.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 07 Aug 2014 19:12:37 +0200
parents a43ebf716abd
children ccbc74ad855f
files INSTALL ui/CMakeLists.txt ui/administrator.cpp ui/fonts.qrc ui/fonts/DejaVuSans.ttf ui/main.cpp
diffstat 6 files changed, 109 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/INSTALL	Thu Aug 07 13:05:26 2014 +0200
+++ b/INSTALL	Thu Aug 07 19:12:37 2014 +0200
@@ -3,9 +3,11 @@
 
 For Debian based GNU / Linux
 ============================
-Tested development platform: Ubuntu 14.4.
+Tested development platform: Ubuntu 14.4 amd64.
 
 The following commands build qt5 and polarssl which are dependencies of the Software.
+To only build for the amd64 platform omit the i386 instructions.
+
 For build dependencies please refer to the Qt documentation 
 ( qtbase/src/plugins/platforms/xcb/README ).
 Polarssl needs cmake and build-essentials.
@@ -31,9 +33,10 @@
     ./configure --prefix=$YOURPREFIX \
     -opensource \
     -release  -nomake tests  -nomake examples  -confirm-license \
-    -static -no-cups -no-nis -no-icu -fontconfig \
+    -static -no-cups -no-nis -no-icu -no-fontconfig -qt-freetype \
     -no-directfb -no-opengl -no-kms -no-eglfs -no-egl -no-openssl -no-glib \
-    -system-libpng -qpa xcb -qt-xcb -no-nis -no-libjpeg -no-gif && \
+    -system-libpng -qpa xcb -qt-xkbcommon -qt-xcb -no-nis -no-libjpeg -qt-libpng \
+    -qt-zlib -no-gif && \
     nice make -j8 && \
     make install
 
@@ -69,6 +72,63 @@
     cmake .. -DCMAKE_PREFIX_PATH=$YOURPREFIX
 
 
+I386
+====
+Install dependencies (list might be incomplete)
+    apt-get install libx32stdc++-4.8-dev libc6:i386 g++-4.8-multilib \
+   libxcb1:i386 libxcb1-dev:i386 libx11-xcb1:i386 libx11-xcb-dev:i386 libxcb-keysyms1:i386 \
+   libxcb-keysyms1-dev:i386 libxcb-image0:i386 libxcb-image0-dev:i386 \
+   libxcb-shm0:i386 libxcb-shm0-dev:i386 libxcb-icccm4:i386 \
+   libxcb-icccm4-dev:i386 libxcb-sync-dev:i386 \
+   libxcb-render-util0:i386 libxcb-render-util0-dev:i386 \
+   libxcb-xfixes0-dev:i386 libxrender-dev:i386 libxcb-shape0-dev:i386 \
+   libxcb-randr0-dev:i386 libxcb-glx0-dev:i386 libdbus-1-dev:i386 \
+   libsm-dev:i386
+
+Some packages are problematic as they do not support multiarch installation so
+we just download and extract them.
+    mkdir $YOURPREFIX/i386/packages
+    apt-get download -o=Debug::NoLocking=1 -o=dir::cache=$YOURPREFIX/i386/packages libxi-dev:i386 \
+    libfontconfig1-dev:i386 libfreetype6-dev:i386
+    cd $YOURPREFIX/i386/packages
+    for file in *.deb; do; dpkg -x $file .; done;
+
+Create a new directory for qt. As qt has to build in source you need a different
+directory.
+    mkdir i386
+    cd i386
+    tar -xf ../qt-everywhere-opensource-src-5.3.1.tar.xz
+    cd qt-everywhere-opensource-src-5.3.1/qtbase/
+    ./configure --prefix=$YOURPREFIX/i386 \
+    -opensource -platform linux-g++-32 \
+    -release  -nomake tests  -nomake examples  -confirm-license \
+    -static -no-cups -no-nis -no-icu \
+    -no-directfb -no-opengl -no-kms -no-eglfs -no-egl -no-openssl -no-glib \
+    -system-libpng -qpa xcb -qt-xcb -no-nis -no-libjpeg -no-gif -qt-zlib \
+    -no-fontconfig -qt-freetype -qt-libpng -qt-xkbcommon \
+    && \
+    nice make -j8 && \
+    make install
+
+Switch back to the polarssl directory
+    cd ../../../polarssl-1.3.8/
+    mkdir build-i386
+    cd build-i386
+    cmake .. -DCMAKE_C_FLAGS="-fpic -m32" -DCMAKE_INSTALL_PREFIX=$YOURPREFIX/i386 \
+         -DCMAKE_VERBOSE_MAKEFILE=True \
+         -DENABLE_TESTING=FALSE -DENABLE_PROGRAMS=FALSE && \
+    nice make -j8 && \
+    make install
+
+Now for Trustbridge itself
+    cd ../../trustbridge
+    mkdir build-i386
+    cd build-i386
+    cmake .. -DCMAKE_PREFIX_PATH="$YOURPREFIX/i386" \
+    -DCMAKE_VERBOSE_MAKEFILE=True \
+    -DCMAKE_C_FLAGS=-m32 \
+    -DCMAKE_CXX_FLAGS="-m32"
+
 Hiawatha (for Downloader unit test)
 ===================================
 Hiawatha is used in the downloader unit tests to provide a testbench
--- a/ui/CMakeLists.txt	Thu Aug 07 13:05:26 2014 +0200
+++ b/ui/CMakeLists.txt	Thu Aug 07 19:12:37 2014 +0200
@@ -61,10 +61,12 @@
 set(TRUSTBRIDGE_RESOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc
    ${CMAKE_CURRENT_SOURCE_DIR}/certs.qrc
+   ${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc
 )
 
 set(ADMINISTRATOR_RESOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc
+   ${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc
 )
 
 if(UNIX)
@@ -74,20 +76,14 @@
    get_target_property(_loc Qt5::Widgets LOCATION)
    get_filename_component(_qtpath ${_loc} PATH)
 
-   if(NOT XKBCOMMON_LIB)
-      # Hack on a hack to overwrite the xkbcommon libname.
-      set(XKBCOMMON_LIB -lxkbcommon)
-   endif()
-
    set(XCB_EXTRA_LIBS
       -L${_qtpath}
+      -lQt5DBus -lQt5Gui -lQt5Core -lQt5PlatformSupport
+      -lX11 -lX11-xcb -lxcb -lxcb-static
+      -lXrender -lSM -lICE -ldbus-1
+      -lm -ldl -lrt -lpthread )
 
-      -lX11 -lX11-xcb -lxcb -lxcb-static -lXi -lXrender -lSM -lICE -ldbus-1
-      ${XKBCOMMON_LIB} -lQt5PlatformSupport
-      -lfreetype -lQt5DBus -lQt5Gui -ljpeg -lpng -lQt5Core
-      -lz -lm -ldl -lrt -lpthread -lfontconfig)
-
-   set(EXTRA_STATIC_LIBS -lz -lpthread -ldl -lpng -ljpeg
+   set(EXTRA_STATIC_LIBS -lpthread -ldl
       Qt5::QXcbIntegrationPlugin ${XCB_EXTRA_LIBS})
 
 elseif(WIN32)
@@ -96,7 +92,8 @@
    set(WINDOWS_EXTRA_LIBS
         -L${_qtpath}
         -lwinspool -lshlwapi -lfreetype -lbz2 -lpng16
-        -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm
+        -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32
+        -lharfbuzz -lglib-2.0 -lintl -liconv -lwinmm
         -lglu32 -lopengl32 -lgdi32 -ljpeg -lpng -lQt5Core -lole32 -lmstask -luuid -lws2_32
         -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16)
 
--- a/ui/administrator.cpp	Thu Aug 07 13:05:26 2014 +0200
+++ b/ui/administrator.cpp	Thu Aug 07 19:12:37 2014 +0200
@@ -6,6 +6,7 @@
  * See LICENSE.txt for details.
  */
 #include "administratorwindow.h"
+#include "util.h"
 
 #include <QApplication>
 #include <QtPlugin>
@@ -14,6 +15,7 @@
 #include <QTranslator>
 #include <QDebug>
 #include <QTextCodec>
+#include <QFontDatabase>
 
 #ifndef VERSION
 #define VERSION "0.0.1"
@@ -71,6 +73,19 @@
      * look decent on western europe's windows */
     QTextCodec::setCodecForLocale(QTextCodec::codecForName ("ISO-8859-1"));
 
+    /* Install static fonts */
+
+    /* The putenv here works around a bug in qt. Qt thinks it is a fatal
+     * error if the font directory does not exist. */
+    qputenv("QT_QPA_FONTDIR", get_install_dir());
+    int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
+    if (fontId != -1)
+    {
+        QFont font("DejaVuSans");
+        font.setPointSize(9);
+        app.setFont(font);
+    }
+
     AdministratorWindow adminWin;
     adminWin.show();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/fonts.qrc	Thu Aug 07 19:12:37 2014 +0200
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/fonts">
+    <file alias="DejaVuSans.ttf">fonts/DejaVuSans.ttf</file>
+</qresource>
+</RCC>
Binary file ui/fonts/DejaVuSans.ttf has changed
--- a/ui/main.cpp	Thu Aug 07 13:05:26 2014 +0200
+++ b/ui/main.cpp	Thu Aug 07 19:12:37 2014 +0200
@@ -9,6 +9,7 @@
 #include "processhelp.h"
 #include "logging.h"
 #include "selftest.h"
+#include "util.h"
 #ifdef WIN32
 #include "taskscheduler.h"
 #endif
@@ -22,6 +23,7 @@
 #include <QTranslator>
 
 #include <QStyleFactory>
+#include <QFontDatabase>
 
 #ifndef VERSION
 #define VERSION "0.0.1"
@@ -70,6 +72,7 @@
 
     qDebug() << "Application style is: " << app.style()->metaObject()->className();
     qDebug() << "Available styles: " << QStyleFactory::keys().join(", ");
+    qDebug() << "Font is: " << app.font();
 
     QStringList arguments = QApplication::arguments();
     bool trayMode = arguments.contains("--tray");
@@ -129,6 +132,20 @@
     startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8());
     startup_file.close();
 #endif
+
+    /* Install static fonts */
+
+    /* The putenv here works around a bug in qt. Qt thinks it is a fatal
+     * error if the font directory does not exist. */
+    qputenv("QT_QPA_FONTDIR", get_install_dir());
+    int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
+    if (fontId != -1)
+    {
+        QFont font("DejaVuSans");
+        font.setPointSize(9);
+        app.setFont(font);
+    }
+
     MainWindow mainWin(trayMode);
 
     return app.exec();

http://wald.intevation.org/projects/trustbridge/