summaryrefslogtreecommitdiff
path: root/packaging/ttrace.spec
blob: 9ebeaebe19a57acaee5303cc4842a0f6bec4317c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Name:		ttrace
Summary:    T-trace for tizen
Version:	1.1.0
Release:    1
Group:      System/Libraries
License:    Apache-2.0 and BSD-3-Clause
Source0:    %{name}-%{version}.tar.gz
SOURCE100:	packaging/ttrace.conf
SOURCE101:	packaging/sys-kernel-debug-tracing.mount
SOURCE102:	packaging/ttrace-marker.service
SOURCE103:	packaging/atrace-bootup.sh

BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(gmock)
BuildRequires: cmake

%if 0%{?gcov:1}
BuildRequires: lcov
%endif

%define keepstatic 1

# tizen_profile_name is for optional features that are not built in Tizen Public OBS.
%define TTRACE_PROFILE none
%if "%{?tizen_profile_name}" == "mobile"
%define TTRACE_PROFILE mobile
%else
%if "%{?tizen_profile_name}" == "tv"
%define TTRACE_PROFILE tv
%else
%if "%{?tizen_profile_name}" == "wearable"
%define TTRACE_PROFILE wearable
%endif
%endif
%endif

%define TTRACE_TIZEN_VERSION_MAJOR 2
%if 0%{?tizen_version_major} >= 3
%define TTRACE_TIZEN_VERSION_MAJOR 3
%endif

%define ATRACE_VERSION 1.1
%define ATRACE_HELPER_VERSION 1.0

%description
T-trace library

%package devel
Summary:    T-trace for tizen
Group:      Development/Libraries
Requires:   %{name} = %{version}-%{release}

%description devel
T-trace library devel

%if 0%{?gcov:1}
%package gcov
Summary:  ttrace(gcov)
Group:    Development/Libraries
%description gcov
New T-trace library cov objects
%endif

%package unittests
Summary:	T-trace unittests binary

%description unittests
T-trace unittests binary

%prep
%setup -q

%build
%if 0%{?gcov:1}
export CFLAGS+=" -fprofile-arcs -ftest-coverage"
export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
export FFLAGS+=" -fprofile-arcs -ftest-coverage"
export LDFLAGS+=" -lgcov"
%endif

export CFLAGS="$CFLAGS -g -Wall -std=gnu99"
export CXXFLAGS="$CXXFLAGS -std=c++11 -fPIE -pie"

MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
      -DTTRACE_PROFILE=%{TTRACE_PROFILE} -DTTRACE_TIZEN_VERSION_MAJOR=%{TTRACE_TIZEN_VERSION_MAJOR} \
      -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
      -DATRACE_VERSION=%{ATRACE_VERSION} -DATRACE_HELPER_VERSION=%{ATRACE_HELPER_VERSION}
make %{?jobs:-j%jobs}

%check
(cd test && LD_LIBRARY_PATH=../src ctest -V)
%if 0%{?gcov:1}
lcov -c --ignore-errors graph --no-external -q -d . -o ttrace.info
genhtml ttrace.info -o ttrace.out
%endif

%install
rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}/usr/lib/tmpfiles.d
install -m 0644 %{SOURCE100} %{buildroot}/usr/lib/tmpfiles.d/ttrace.conf
install -m 0644 %{SOURCE101} %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE102} %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_bindir}
cp %{SOURCE103} %{buildroot}%{_bindir}
%install_service sysinit.target.wants ttrace-marker.service
%install_service sysinit.target.wants sys-kernel-debug-tracing.mount

%if 0%{?gcov:1}
builddir=$(basename $PWD)
gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
mkdir -p "$gcno_obj_dir"
find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';'
%endif

cat << EOF > run-unittest.sh
#!/bin/bash
setup() {
	echo "setup start"
}

test_main() {
	echo "test_main start"
	/usr/bin/ttrace-unit-test
}

teardown() {
	echo "teardown start"
}

main() {
	setup
	test_main
	teardown
}

main "\$*"
EOF

mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%manifest ttrace.manifest
%defattr(-,root,root,-)
%{_libdir}/libttrace.so.*
%{_unitdir}/ttrace-marker.service
%{_unitdir}/sys-kernel-debug-tracing.mount
%attr(755,root,users) %{_bindir}/atrace
%attr(755,root,users) %{_bindir}/atrace-%{ATRACE_VERSION}
%attr(755,root,users) %{_bindir}/atrace-helper
%attr(755,root,users) %{_bindir}/atrace-helper-%{ATRACE_HELPER_VERSION}
%{_unitdir}/sysinit.target.wants/ttrace-marker.service
%{_unitdir}/sysinit.target.wants/sys-kernel-debug-tracing.mount
%attr(755,root,root) %{_bindir}/atrace-bootup.sh
/usr/lib/tmpfiles.d/ttrace.conf
%license LICENSE

%files devel
%defattr(-,root,root,-)
%{_includedir}/*.h
%{_libdir}/libttrace.so
%{_libdir}/pkgconfig/*.pc

%if 0%{?gcov:1}
%files gcov
%{_datadir}/gcov/obj/*
%endif

%files unittests
%{_bindir}/ttrace-unit-test
%{_bindir}/tizen-unittests/%{name}/run-unittest.sh