Skip to content
Permalink
Browse files
Refactorize project files
Every subproject "mysubproject" of type app or lib now contains three qmake
files:

  mysubproject.pro
  mysubproject.pri
  mysubproject_dependencies.pri

Dependency between two projects is satisfied by calling
include(../path/to/dependee/dependee.pri) inside dependent_dependencies.pri.
mysubproject.pri always includes mysubproject_dependencies.pri - this way
dependencies are gathered transitively.

Every mysubproject.pro starts with defining TARGET and including one of the
templates:

  ssuapplication.pri
  ssulibrary.pri

Settings common to both app and lib type of projects comes from

  ssu_common.pri

For tests, there are derived templates inside tests directory

  tests/testapplication.pri
  tests/testlibrary.pri

Common settings similarly comes from

  tests/tests_common.pri

Source code root is added to INCLUDEPATH and DEPENDPATH so it is possible to
include any header file specifying ints path relatively to source code root.
Since all the libs and apps are part of single source tree, I recommend to
express this fact by #including ssu own headers with "" instead of <>.

  #include "libssu/ssu.h"

Projects outside of ssu source tree will still use #include <ssu.h>

For tests, the "tests" dir is also added to INCLUDEPATH and DEPENDPATH so the
"tests/" path component can/should be omitted inside tests code:

  #include "testutils/process.h"

Building:

I have removed the hardcoded build paths (buildpath.pri). It is still possible
to keep source tree clean of build artefacts -- with shadow build:

mkdir build && cd build && qmake ../ssu.pro -r && make

Note that the output directories for app and lib binaries is still hardcoded
as build/{bin,lib}.

When gcov is to be used, simply build without the shadow build and object
files will be placed next to source files.

Other notes:

I found some CONFIG settings having no effect and removed these. Namely

CONFIG += dll - shared libs are build by default
CONFIG -= app_bundle - Mac OS X specific
CONFIG += console - Windows specific
CONFIG += qtestlib - QT+=testlib should be the prefered way

-maybe I am wrong?

The 'unix' conditional was not used consistently. Similar issue with
$${PREFIX}. As it is not much useful at the moment, I rather removed it.
  • Loading branch information
martyone committed Apr 4, 2013
1 parent 8cfafdf commit 16fe343d6ee3c028ec44ce42e24078b2131a108a
Showing with 187 additions and 253 deletions.
  1. +0 −24 buildpath.pri
  2. +2 −0 libssu/libssu.pri
  3. +15 −15 libssu/libssu.pro
  4. +1 −0 libssu/libssu_dependencies.pri
  5. +1 −0 libssu/ssu.cpp
  6. +5 −3 libssu/ssu.h
  7. +2 −2 libssu/ssucoreconfig.h
  8. +1 −1 libssu/ssudeviceinfo.h
  9. +1 −0 rndregisterui/rndregisterui.cpp
  10. +1 −1 rndregisterui/rndregisterui.h
  11. +6 −9 rndregisterui/rndregisterui.pro
  12. +1 −0 rndregisterui/rndregisterui_dependencies.pri
  13. +1 −0 rndssucli/main.cpp
  14. +3 −3 rndssucli/rndssucli.cpp
  15. +2 −1 rndssucli/rndssucli.h
  16. +4 −13 rndssucli/rndssucli.pro
  17. +1 −0 rndssucli/rndssucli_dependencies.pri
  18. +12 −0 ssu_common.pri
  19. +8 −0 ssuapplication.pri
  20. +2 −7 ssuconfperm/ssuconfperm.pro
  21. +2 −2 ssuks/ssukickstarter.h
  22. +4 −12 ssuks/ssuks.pro
  23. +1 −0 ssuks/ssuks_dependencies.pri
  24. +12 −0 ssulibrary.pri
  25. +1 −0 ssuurlresolver/main.cpp
  26. +5 −2 ssuurlresolver/ssuurlresolver.cpp
  27. +2 −1 ssuurlresolver/ssuurlresolver.h
  28. +10 −12 ssuurlresolver/ssuurlresolver.pro
  29. +1 −0 ssuurlresolver/ssuurlresolver_dependencies.pri
  30. +8 −0 tests/testapplication.pri
  31. +2 −0 tests/testlibrary.pri
  32. +2 −3 tests/tests.pro
  33. +6 −2 tests/{tests.pri → tests_common.pri}
  34. +3 −2 tests/testutils/sandboxfileenginehandler.cpp
  35. +3 −15 tests/testutils/sandboxhook.pro
  36. +1 −0 tests/testutils/sandboxhook_dependencies.pri
  37. +2 −0 tests/testutils/testutils.pri
  38. +5 −18 tests/testutils/testutils.pro
  39. +1 −0 tests/testutils/testutils_dependencies.pri
  40. +1 −1 tests/ut_rndssucli/rndssuclitest.cpp
  41. +8 −27 tests/ut_rndssucli/ut_rndssucli.pro
  42. +2 −0 tests/ut_rndssucli/ut_rndssucli_dependencies.pri
  43. +1 −2 tests/ut_settings/settingstest.cpp
  44. +1 −1 tests/ut_settings/upgradetesthelper.cpp
  45. +5 −15 tests/ut_settings/ut_settings.pro
  46. +2 −0 tests/ut_settings/ut_settings_dependencies.pri
  47. +11 −27 tests/ut_ssuurlresolver/ut_ssuurlresolver.pro
  48. +1 −0 tests/ut_ssuurlresolver/ut_ssuurlresolver_dependencies.pri
  49. +1 −1 tests/ut_urlresolver/main.cpp
  50. +1 −1 tests/ut_urlresolver/urlresolvertest.h
  51. +4 −14 tests/ut_urlresolver/ut_urlresolver.pro
  52. +2 −0 tests/ut_urlresolver/ut_urlresolver_dependencies.pri
  53. +4 −14 tests/ut_variables/ut_variables.pro
  54. +1 −0 tests/ut_variables/ut_variables_dependencies.pri
  55. +2 −2 tests/ut_variables/variablestest.h

This file was deleted.

@@ -0,0 +1,2 @@
include(libssu_dependencies.pri)
LIBS *= -lssu
@@ -1,35 +1,35 @@
BUILD = ../build/libssu
HEADERS = ssu.h \
TARGET = ssu
include(../ssulibrary.pri)

# TODO: which headers are public? i.e. to be installed
public_headers = \
ssu.h \

HEADERS = \
$${public_headers} \
ssucoreconfig.h \
ssudeviceinfo.h \
ssulog.h \
ssuvariables.h \
ssusettings.h \
ssurepomanager.h \
../constants.h
SOURCES = ssu.cpp \

SOURCES = \
ssu.cpp \
ssucoreconfig.cpp \
ssudeviceinfo.cpp \
ssulog.cpp \
ssuvariables.cpp \
ssurepomanager.cpp \
ssusettings.cpp
TEMPLATE = lib
TARGET = ssu
CONFIG += dll mobility link_pkgconfig
QT -= gui

CONFIG += mobility link_pkgconfig
QT += network xml
MOBILITY += systeminfo
PKGCONFIG += libsystemd-journal

headers.files = ssu.h
headers.path = /usr/include

unix:target.path = $${PREFIX}/usr/lib
INSTALLS += target headers
install_headers.files = $${public_headers}

ssuconfhack {
DEFINES += SSUCONFHACK
}

!include( ../buildpath.pri ) { error("Unable to find build path specification") }
@@ -0,0 +1 @@
# no dependencies so far
@@ -5,6 +5,7 @@
* @date 2012
*/

#include <QtNetwork>
#include <QtXml/QDomDocument>

#include "ssu.h"
@@ -8,15 +8,17 @@
#ifndef _Ssu_H
#define _Ssu_H

#include <QDateTime>
#include <QObject>
#include <QSettings>
#include <QDebug>

#include <QtNetwork>

#include <QtXml/QDomDocument>

#include <ssudeviceinfo.h>
#include "ssudeviceinfo.h"

class QNetworkAccessManager;
class QNetworkReply;

class Ssu: public QObject {
Q_OBJECT
@@ -11,8 +11,8 @@
#include <QObject>
#include <QSettings>

#include <ssusettings.h>
#include <ssu.h>
#include "ssusettings.h"
#include "ssu.h"

#ifndef SSU_CONFIGURATION
/// Path to the main SSU configuration file
@@ -11,7 +11,7 @@
#include <QObject>
#include <QSettings>

#include <ssusettings.h>
#include "ssusettings.h"

class SsuDeviceInfo: public QObject {
Q_OBJECT
@@ -6,6 +6,7 @@
*/

#include <QDeclarativeContext>
#include <QDir>
#include <QGraphicsObject>
#include <QApplication>

@@ -11,7 +11,7 @@
#include <QMainWindow>
#include <QtDeclarative/QDeclarativeView>

#include <ssu.h>
#include "libssu/ssu.h"

namespace Ui {
class RndRegisterUi;
@@ -1,23 +1,20 @@
TARGET = rndregisterui
include(../ssuapplication.pri)
include(rndregisterui_dependencies.pri)

HEADERS = rndregisterui.h
SOURCES = main.cpp \
rndregisterui.cpp
RESOURCES = resources.qrc
TEMPLATE = app
TARGET = rndregisterui
LIBS += -lssu

CONFIG += qdeclarative-boostable
CONFIG -= app_bundle
QT += core gui declarative network
QT += gui declarative

OTHER_FILES += \
resources/qml/rndregisterui.qml \
resources/qml/RndSsuPage.qml
unix:target.path = $${PREFIX}/usr/bin

desktop.files = rndregisterui.desktop
desktop.path = /usr/share/applications/

INSTALLS += target desktop

!include( ../buildpath.pri ) { error("Unable to find build path specification") }
INSTALLS += desktop
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
@@ -9,6 +9,7 @@
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include "rndssucli.h"

int main(int argc, char** argv){
@@ -9,9 +9,9 @@

#include <termios.h>

#include <ssudeviceinfo.h>
#include <ssurepomanager.h>
#include <ssucoreconfig.h>
#include "libssu/ssudeviceinfo.h"
#include "libssu/ssurepomanager.h"
#include "libssu/ssucoreconfig.h"

#include <QDebug>

@@ -10,9 +10,10 @@

#include <QObject>
#include <QSettings>
#include <QStringList>
#include <QDebug>

#include <ssu.h>
#include "libssu/ssu.h"

class RndSsuCli: public QObject {
Q_OBJECT
@@ -1,17 +1,8 @@
TARGET = ssu
include(../ssuapplication.pri)
include(rndssucli_dependencies.pri)

HEADERS = rndssucli.h
SOURCES = main.cpp \
rndssucli.cpp
#RESOURCES = rndregister.qrc
TEMPLATE = app
TARGET = ssu
TARGETDIR = ssucli
LIBS += -lssu
CONFIG -= app_bundle
CONFIG += console
QT -= gui
QT += network

unix:target.path = $${PREFIX}/usr/bin
INSTALLS += target

!include( ../buildpath.pri ) { error("Unable to find build path specification") }
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
@@ -0,0 +1,12 @@
CONFIG -= gui

INCLUDEPATH *= $$PWD
DEPENDPATH *= $$PWD

# TODO: determine build dir automatically
SSU_BUILD_DIR = $$PWD/build

DESTDIR_BIN = $$SSU_BUILD_DIR/bin
DESTDIR_LIB = $$SSU_BUILD_DIR/lib

LIBS += -L$$DESTDIR_LIB
@@ -0,0 +1,8 @@
isEmpty(TARGET):error("TARGET must be set before this file is included")
include(ssu_common.pri)

TEMPLATE = app
DESTDIR = $$DESTDIR_BIN

target.path = /usr/bin
INSTALLS += target
@@ -1,10 +1,5 @@
TEMPLATE = app
TARGET = ssuconfperm
include(../ssuapplication.pri)

SOURCES = ssuconfperm.c
HEADERS = ../constants.h
CONFIG -= qt

!include(../buildpath.pri){ error("Unable to find build path configuration")}

unix:target.path = $${PREFIX}/usr/bin
INSTALLS += target
@@ -12,8 +12,8 @@
#include <QSettings>
#include <QHash>

#include <ssudeviceinfo.h>
#include <ssu.h>
#include "libssu/ssudeviceinfo.h"
#include "libssu/ssu.h"

/*
class Q_CORE_EXPORT SsuKickstarter: public QObject {
@@ -1,16 +1,8 @@
TARGET = ssuks
include(../ssuapplication.pri)
include(ssuks_dependencies.pri)

HEADERS = ssuks.h \
ssukickstarter.h
SOURCES = ssuks.cpp \
ssukickstarter.cpp
TEMPLATE = app
TARGET = ssuks
LIBS += -lssu
CONFIG -= app_bundle
CONFIG += console
QT -= gui
QT += network

unix:target.path = $${PREFIX}/usr/bin
INSTALLS += target

!include( ../buildpath.pri ) { error("Unable to find build path specification") }
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
@@ -0,0 +1,12 @@
isEmpty(TARGET):error("TARGET must be set before this file is included")
include(ssu_common.pri)

TEMPLATE = lib

DESTDIR = $$DESTDIR_LIB

target.path = /usr/lib
INSTALLS += target

install_headers.path = /usr/include
INSTALLS += install_headers
@@ -9,6 +9,7 @@
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include "ssuurlresolver.h"

int main(int argc, char** argv){
@@ -5,11 +5,14 @@
* @date 2012
*/

#include "ssuurlresolver.h"

#include <QCoreApplication>
#include <QFileInfo>
#include <QStringList>
#include <systemd/sd-journal.h>

#include "ssuurlresolver.h"
#include "ssulog.h"
#include "libssu/ssulog.h"

SsuUrlResolver::SsuUrlResolver(): QObject(){
QObject::connect(this,SIGNAL(done()),
@@ -11,12 +11,13 @@
#include <QObject>
#include <QSettings>
#include <QDebug>
#include <QEventLoop>
#include <QFile>

#include <iostream>
#include <zypp/PluginFrame.h>

#include <ssu.h>
#include "libssu/ssu.h"

// quick hack for waiting for a signal
class SignalWait: public QObject {
@@ -1,16 +1,14 @@
TARGET = ssu
include(../ssuapplication.pri)
include(ssuurlresolver_dependencies.pri)

# We do not build a typical application - override defaults from ../ssuapplication.pri
DESTDIR = $$DESTDIR_LIB/zypp/plugins/urlresolver
target.path = /usr/lib/zypp/plugins/urlresolver

HEADERS = ssuurlresolver.h
SOURCES = main.cpp \
ssuurlresolver.cpp
TEMPLATE = app
TARGET = ssu
LIBS += -lssu
CONFIG -= app_bundle
CONFIG += console link_pkgconfig
QT -= gui
QT += network
PKGCONFIG += libzypp libsystemd-journal

unix:target.path = $${PREFIX}/usr/lib/zypp/plugins/urlresolver
INSTALLS += target

!include( ../buildpath.pri ) { error("Unable to find build path specification") }
CONFIG += link_pkgconfig
PKGCONFIG += libzypp libsystemd-journal
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
@@ -0,0 +1,8 @@
include(../ssuapplication.pri)
include(tests_common.pri)

QT += testlib

test_data_etc.path = $${TESTS_DATA_PATH}/configroot/etc/ssu
test_data_usr_share.path = $${TESTS_DATA_PATH}/configroot/usr/share/ssu
INSTALLS += test_data_etc test_data_usr_share
@@ -0,0 +1,2 @@
include(../ssulibrary.pri)
include(tests_common.pri)

0 comments on commit 16fe343

Please sign in to comment.