Skip to content

Commit

Permalink
Merge pull request #2 from pgerdt/qt5
Browse files Browse the repository at this point in the history
Qt5 build setup, remove qmlog dependency, simplify header includes
  • Loading branch information
Petri M. Gerdt committed Apr 23, 2013
2 parents fa18486 + 76b0e31 commit 9cd4e58
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 44 deletions.
1 change: 0 additions & 1 deletion H/iodata

This file was deleted.

15 changes: 15 additions & 0 deletions iodata-qt5.prf
@@ -0,0 +1,15 @@
LIBS += -liodata-qt5

QMAKE_EXTRA_COMPILERS += iodata_type_to_cxx iodata_type_to_h

iodata_type_to_cxx.input = IODATA_TYPES
iodata_type_to_cxx.output = iodata_${QMAKE_FILE_IN_BASE}.cpp
iodata_type_to_cxx.variable_out = SOURCES
iodata_type_to_cxx.commands = iodata-qt5-type-to-c++ ${QMAKE_FILE_IN} -o iodata_${QMAKE_FILE_IN_BASE}.cpp -d ${QMAKE_FILE_IN}.h

iodata_type_to_h.input = IODATA_TYPES
iodata_type_to_h.output = ${QMAKE_FILE_IN}.h
iodata_type_to_h.variable_out = HEADERS
iodata_type_to_h.commands = iodata-qt5-type-to-c++ ${QMAKE_FILE_IN} -o iodata_${QMAKE_FILE_IN_BASE}.cpp -d ${QMAKE_FILE_IN}.h

# iodata-qt5-type-to-c++ ${QMAKE_FILE_IN} -d ${QMAKE_FILE_OUT}
7 changes: 5 additions & 2 deletions root.pro
Expand Up @@ -2,7 +2,10 @@ TEMPLATE = subdirs

SUBDIRS = src tests type-to-cxx

prf.files = iodata.prf
prf.path = /usr/share/qt4/mkspecs/features
prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
equals(QT_MAJOR_VERSION, 4): prf.files = iodata.prf
equals(QT_MAJOR_VERSION, 5): prf.files = iodata-qt5.prf

INSTALLS = prf

OTHER_FILES += rpm/*.spec *.prf
69 changes: 69 additions & 0 deletions rpm/libiodata-qt5.spec
@@ -0,0 +1,69 @@
%define _name iodata-qt5
Name: libiodata-qt5
Version: 0.19
Release: 1
Summary: Library for input/ouput data
Group: System/System Control
License: LGPLv2
URL: http://meego.gitorious.org/meego-middleware/iodata
Source0: %{name}-%{version}.tar.bz2

BuildRequires: pkgconfig(Qt5Core)
BuildRequires: bison
BuildRequires: flex

%description
This package provides a library for writing and reading structured data.

%package devel
Summary: Development package for %{name}
Group: Development/Libraries
Requires: pkgconfig(Qt5Core)
Requires: %{name} = %{version}-%{release}

%description devel
Provides header files for iodata library.

%package tests
Summary: Testcases for iodata library
Group: Development/System
Requires: testrunner-lite

%description tests
%{summary}.

%prep
%setup -q -n %{name}-%{version}

%build
export IODATA_VERSION=%version
%qmake5
make

%install
%qmake_install
install -d %{buildroot}/%{_datadir}/%{name}-tests/
mv %{buildroot}/%{_datadir}/%{_name}-tests/tests.xml %{buildroot}/%{_datadir}/%{name}-tests/tests.xml

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc COPYING debian/changelog debian/copyright
%{_libdir}/%{name}.so.*

%files devel
%defattr(-,root,root,-)
%doc COPYING
%{_bindir}/iodata-qt5-type-to-c++
%{_includedir}/iodata-qt5/*
%{_libdir}/%{name}.so
%{_datadir}/qt5/mkspecs/features/iodata-qt5.prf

%files tests
%defattr(-,root,root,-)
%doc COPYING
%{_bindir}/%{_name}-test
%{_datadir}/%{name}-tests/tests.xml
13 changes: 13 additions & 0 deletions rpm/libiodata.changes
@@ -0,0 +1,13 @@
* Fri Mar 04 2011 Tapio Rantala <ext-tapio.rantala@nokia.com> - 0.17-1
- New upstream version (FEA#5513)

* Fri Jan 21 2011 Tapio Rantala <ext-tapio.rantala@nokia.com> - 0.0.16-1
- New upstream version (BMC#10590)

* Wed Nov 24 2010 Tapio Rantala <ext-tapio.rantala@nokia.com> - 0.0.15-1
- New upstream version (BMC#10590)
- Drop linklibs patch, not needed anymore
- Conforms to upstream version 0.0.15-a

* Mon Aug 23 2010 Tapio Rantala <ext-tapio.rantala@nokia.com> - 0.0.13-1
- Initial meego packaging
69 changes: 69 additions & 0 deletions rpm/libiodata.spec
@@ -0,0 +1,69 @@
%define _name iodata
Name: libiodata
Version: 0.19
Release: 1
Summary: Library for input/ouput data
Group: System/System Control
License: LGPLv2
URL: http://meego.gitorious.org/meego-middleware/iodata
Source0: %{name}-%{version}.tar.bz2

BuildRequires: pkgconfig(QtCore) >= 4.5
BuildRequires: bison
BuildRequires: flex

%description
This package provides a library for writing and reading structured data.

%package devel
Summary: Development package for %{name}
Group: Development/Libraries
Requires: pkgconfig(QtCore) >= 4.5
Requires: %{name} = %{version}-%{release}

%description devel
Provides header files for iodata library.

%package tests
Summary: Testcases for iodata library
Group: Development/System
Requires: testrunner-lite

%description tests
%{summary}.

%prep
%setup -q -n %{name}-%{version}

%build
export IODATA_VERSION=%version
%qmake
make

%install
%qmake_install
install -d %{buildroot}/%{_datadir}/%{name}-tests/
mv %{buildroot}/%{_datadir}/%{_name}-tests/tests.xml %{buildroot}/%{_datadir}/%{name}-tests/tests.xml

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc COPYING debian/changelog debian/copyright
%{_libdir}/%{name}.so.*

%files devel
%defattr(-,root,root,-)
%doc COPYING
%{_bindir}/iodata-type-to-c++
%{_includedir}/iodata/*
%{_libdir}/%{name}.so
%{_datadir}/qt4/mkspecs/features/iodata.prf

%files tests
%defattr(-,root,root,-)
%doc COPYING
%{_bindir}/%{_name}-test
%{_datadir}/%{name}-tests/tests.xml
5 changes: 5 additions & 0 deletions src/iodata
@@ -1 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/iodata.h>
#else
#include <iodata/iodata.h>
#endif
97 changes: 97 additions & 0 deletions src/log.h
@@ -0,0 +1,97 @@
/*-----------------------------------------------------------------------+
| |
| Copyright (C) 2013 Jolla Ltd. |
| Contact: Petri M. Gerdt <petri.gerdt@jollamobile.com> |
| |
| This file is part of Iodata |
| |
| Iodata is free software; you can redistribute it and/or modify |
| it under the terms of the GNU Lesser General Public License |
| version 2.1 as published by the Free Software Foundation. |
| |
| Iodata is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Lesser General Public License for more details. |
| |
| You should have received a copy of the GNU Lesser General Public |
| License along with Iodata. If not, see http://www.gnu.org/licenses/ |
| |
+-----------------------------------------------------------------------*/

#ifndef LOG_H
#define LOG_H

#include <QtGlobal>
#include <cassert>
#include <cstdio>

#define LOG_NONE 0
#define LOG_ASSERT 1
#define LOG_CRITICAL 2
#define LOG_ERROR 3
#define LOG_WARNING 4
#define LOG_NOTICE 5
#define LOG_INFO 6
#define LOG_DEBUG 7
#define LOG_FULL LOG_DEBUG

#define LOG_LEVEL LOG_WARNING

#if LOG_LEVEL >= LOG_DEBUG
# define log_debug(FMT,ARGS...) \
do { \
printf("DEBUG: %s:%d: %s", __FILE__, __LINE__, Q_FUNC_INFO); \
if (strlen(""FMT) > 0) \
printf(":\n- "FMT"\n", ## ARGS); \
else \
printf("\n"); \
} while(0)
#else
# define log_debug(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_INFO
# define log_info(FMT,ARGS...) do { fprintf(stderr, "INFO: "FMT"\n", ## ARGS); } while(0)
#else
# define log_info(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_INFO
# define log_notice(FMT,ARGS...) do { fprintf(stderr, "NOTICE: "FMT"\n", ## ARGS); } while(0)
#else
# define log_notice(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_WARNING
# define log_warning(FMT,ARGS...) do { fprintf(stderr, "WARNING: "FMT"\n", ## ARGS); } while(0)
#else
# define log_warning(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_ERROR
# define log_error(FMT,ARGS...) do { fprintf(stderr, "ERROR: "FMT"\n", ## ARGS); } while(0)
#else
# define log_error(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_CRITICAL
# define log_critical(FMT,ARGS...) do { fprintf(stderr, "CRITICAL: "FMT"\n", ## ARGS); } while(0)
#else
# define log_critical(FMT,ARGS...) do { } while(0)
#endif

#if LOG_LEVEL >= LOG_ASSERT
# define log_assert(COND, ARGS...) \
do { \
if (!(COND)) \
fprintf(stderr, "ASSERT: "ARGS); \
assert(COND); \
} while(0)
# define log_abort(FMT,ARGS...) do { fprintf(stderr, "ABORT: "FMT"\n", ## ARGS); assert(0); } while(0)
#else
# define log_assert(COND, ARGS...) do { assert(COND); } while(0)
# define log_abort(FMT,ARGS...) do { assert(0); } while(0)
#endif

#endif // LOG_H
3 changes: 1 addition & 2 deletions src/misc.cpp
Expand Up @@ -4,9 +4,8 @@

using namespace std ;

#include <qmlog>

#include "misc.h"
#include "log.h"

string str_vprintf(const char *format, va_list varg)
{
Expand Down
15 changes: 6 additions & 9 deletions src/src.pro
Expand Up @@ -2,21 +2,18 @@ VERSION = 0.$$(IODATA_VERSION)
TEMPLATE=lib
QT -= gui

CONFIG += qmlog

INCLUDEPATH += ../H
HEADERS = iodata.h validator.h storage.h misc.h log.h
SOURCES = iodata.cpp validator.cpp storage.cpp misc.cpp

TARGET = iodata
equals(QT_MAJOR_VERSION, 4): TARGET = iodata
equals(QT_MAJOR_VERSION, 5): TARGET = iodata-qt5
target.path = /usr/lib

devheaders.files = iodata.h validator.h storage.h iodata validator storage
devheaders.path = /usr/include/iodata

prf.files = iodata.prf
prf.path = /usr/share/qt4/mkspecs/features
equals(QT_MAJOR_VERSION, 4): devheaders.path = /usr/include/iodata
equals(QT_MAJOR_VERSION, 5): devheaders.path = /usr/include/iodata-qt5

INSTALLS = target devheaders prf
INSTALLS = target devheaders

FLEXSOURCES = datalang.l
BISONSOURCES = datalang.y
Expand Down
5 changes: 5 additions & 0 deletions src/storage
@@ -1 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/storage.h>
#else
#include <iodata/storage.h>
#endif
9 changes: 4 additions & 5 deletions src/storage.cpp
Expand Up @@ -30,11 +30,10 @@
#include <sstream>
using namespace std ;

#include <qmlog>

#include <iodata/iodata>
#include <iodata/validator>
#include <iodata/storage>
#include "log.h"
#include "iodata.h"
#include "validator.h"
#include "storage.h"

using namespace iodata ;

Expand Down
3 changes: 1 addition & 2 deletions src/storage.h
Expand Up @@ -32,8 +32,7 @@
#include <vector>
#include <string>

#include <iodata/iodata>
#include <iodata/validator>
#include "iodata.h"

namespace iodata { class storage ; }

Expand Down
5 changes: 5 additions & 0 deletions src/validator
@@ -1 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/validator.h>
#else
#include <iodata/validator.h>
#endif
2 changes: 1 addition & 1 deletion src/validator.cpp
Expand Up @@ -25,7 +25,7 @@
#include <iostream>
using namespace std ;

#include <qmlog>
#include "log.h"

#include "iodata.h"
#include "validator.h"
Expand Down
3 changes: 1 addition & 2 deletions src/validator.h
Expand Up @@ -34,8 +34,7 @@
#include <typeinfo>
using namespace std ;


#include <iodata/iodata>
#include "iodata.h"

namespace iodata
{
Expand Down

0 comments on commit 9cd4e58

Please sign in to comment.