Skip to content

Commit

Permalink
Refactorize project files
Browse files Browse the repository at this point in the history
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 16fe343
Show file tree
Hide file tree
Showing 55 changed files with 187 additions and 253 deletions.
24 changes: 0 additions & 24 deletions buildpath.pri

This file was deleted.

2 changes: 2 additions & 0 deletions libssu/libssu.pri
@@ -0,0 +1,2 @@
include(libssu_dependencies.pri)
LIBS *= -lssu
30 changes: 15 additions & 15 deletions libssu/libssu.pro
@@ -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") }
1 change: 1 addition & 0 deletions libssu/libssu_dependencies.pri
@@ -0,0 +1 @@
# no dependencies so far
1 change: 1 addition & 0 deletions libssu/ssu.cpp
Expand Up @@ -5,6 +5,7 @@
* @date 2012
*/

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

#include "ssu.h"
Expand Down
8 changes: 5 additions & 3 deletions libssu/ssu.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libssu/ssucoreconfig.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libssu/ssudeviceinfo.h
Expand Up @@ -11,7 +11,7 @@
#include <QObject>
#include <QSettings>

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

class SsuDeviceInfo: public QObject {
Q_OBJECT
Expand Down
1 change: 1 addition & 0 deletions rndregisterui/rndregisterui.cpp
Expand Up @@ -6,6 +6,7 @@
*/

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

Expand Down
2 changes: 1 addition & 1 deletion rndregisterui/rndregisterui.h
Expand Up @@ -11,7 +11,7 @@
#include <QMainWindow>
#include <QtDeclarative/QDeclarativeView>

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

namespace Ui {
class RndRegisterUi;
Expand Down
15 changes: 6 additions & 9 deletions rndregisterui/rndregisterui.pro
@@ -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
1 change: 1 addition & 0 deletions rndregisterui/rndregisterui_dependencies.pri
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
1 change: 1 addition & 0 deletions rndssucli/main.cpp
Expand Up @@ -9,6 +9,7 @@
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include "rndssucli.h"

int main(int argc, char** argv){
Expand Down
6 changes: 3 additions & 3 deletions rndssucli/rndssucli.cpp
Expand Up @@ -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>

Expand Down
3 changes: 2 additions & 1 deletion rndssucli/rndssucli.h
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions rndssucli/rndssucli.pro
@@ -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") }
1 change: 1 addition & 0 deletions rndssucli/rndssucli_dependencies.pri
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
12 changes: 12 additions & 0 deletions ssu_common.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
8 changes: 8 additions & 0 deletions ssuapplication.pri
@@ -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
9 changes: 2 additions & 7 deletions ssuconfperm/ssuconfperm.pro
@@ -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
4 changes: 2 additions & 2 deletions ssuks/ssukickstarter.h
Expand Up @@ -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 {
Expand Down
16 changes: 4 additions & 12 deletions ssuks/ssuks.pro
@@ -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") }
1 change: 1 addition & 0 deletions ssuks/ssuks_dependencies.pri
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
12 changes: 12 additions & 0 deletions ssulibrary.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
1 change: 1 addition & 0 deletions ssuurlresolver/main.cpp
Expand Up @@ -9,6 +9,7 @@
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
#include <QTimer>
#include "ssuurlresolver.h"

int main(int argc, char** argv){
Expand Down
7 changes: 5 additions & 2 deletions ssuurlresolver/ssuurlresolver.cpp
Expand Up @@ -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()),
Expand Down
3 changes: 2 additions & 1 deletion ssuurlresolver/ssuurlresolver.h
Expand Up @@ -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 {
Expand Down
22 changes: 10 additions & 12 deletions ssuurlresolver/ssuurlresolver.pro
@@ -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
1 change: 1 addition & 0 deletions ssuurlresolver/ssuurlresolver_dependencies.pri
@@ -0,0 +1 @@
include(../libssu/libssu.pri)
8 changes: 8 additions & 0 deletions tests/testapplication.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
2 changes: 2 additions & 0 deletions tests/testlibrary.pri
@@ -0,0 +1,2 @@
include(../ssulibrary.pri)
include(tests_common.pri)

0 comments on commit 16fe343

Please sign in to comment.