1 |
commit: 9322294404f2c5011564047a1534c4c049a7ccfa |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 18 23:00:00 2018 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 18 23:04:07 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=93222944 |
7 |
|
8 |
dev-util/cppcheck: Add upstream patch to fix test |
9 |
|
10 |
On some platforms 'char' is unsigned by default, causing the test to |
11 |
fail. |
12 |
|
13 |
See https://trofi.github.io/posts/203-signed-char-or-unsigned-char.html |
14 |
|
15 |
dev-util/cppcheck/cppcheck-1.84-r1.ebuild | 110 +++++++++++++++++++++ |
16 |
.../files/cppcheck-1.84-char-signedness.patch | 88 +++++++++++++++++ |
17 |
2 files changed, 198 insertions(+) |
18 |
|
19 |
diff --git a/dev-util/cppcheck/cppcheck-1.84-r1.ebuild b/dev-util/cppcheck/cppcheck-1.84-r1.ebuild |
20 |
new file mode 100644 |
21 |
index 00000000000..4d0e7a668ec |
22 |
--- /dev/null |
23 |
+++ b/dev-util/cppcheck/cppcheck-1.84-r1.ebuild |
24 |
@@ -0,0 +1,110 @@ |
25 |
+# Copyright 1999-2018 Gentoo Foundation |
26 |
+# Distributed under the terms of the GNU General Public License v2 |
27 |
+ |
28 |
+EAPI=6 |
29 |
+ |
30 |
+PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} ) |
31 |
+ |
32 |
+inherit distutils-r1 flag-o-matic qmake-utils toolchain-funcs |
33 |
+ |
34 |
+DESCRIPTION="Static analyzer of C/C++ code" |
35 |
+HOMEPAGE="http://cppcheck.sourceforge.net" |
36 |
+SRC_URI="https://github.com/danmar/cppcheck/archive/${PV}.tar.gz -> ${P}.tar.gz" |
37 |
+ |
38 |
+LICENSE="GPL-3+" |
39 |
+SLOT="0" |
40 |
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~sparc ~x86" |
41 |
+IUSE="htmlreport pcre qt5" |
42 |
+ |
43 |
+RDEPEND=" |
44 |
+ dev-libs/tinyxml2:= |
45 |
+ htmlreport? ( dev-python/pygments[${PYTHON_USEDEP}] ) |
46 |
+ pcre? ( dev-libs/libpcre ) |
47 |
+ qt5? ( |
48 |
+ dev-qt/qtcore:5 |
49 |
+ dev-qt/qtgui:5 |
50 |
+ dev-qt/qtprintsupport:5 |
51 |
+ ) |
52 |
+" |
53 |
+DEPEND="${RDEPEND} |
54 |
+ app-text/docbook-xsl-stylesheets |
55 |
+ dev-libs/libxslt |
56 |
+ virtual/pkgconfig |
57 |
+" |
58 |
+ |
59 |
+PATCHES=( |
60 |
+ "${FILESDIR}"/${PN}-1.75-tinyxml2.patch |
61 |
+ "${FILESDIR}"/${PN}-1.84-char-signedness.patch |
62 |
+) |
63 |
+ |
64 |
+src_prepare() { |
65 |
+ default |
66 |
+ append-cxxflags -std=c++0x |
67 |
+ |
68 |
+ # Drop bundled libs, patch Makefile generator and re-run it |
69 |
+ rm -r externals/tinyxml || die |
70 |
+ tc-export CXX |
71 |
+ emake dmake |
72 |
+ ./dmake || die |
73 |
+} |
74 |
+ |
75 |
+src_configure() { |
76 |
+ if use pcre ; then |
77 |
+ sed -e '/HAVE_RULES=/s:=no:=yes:' \ |
78 |
+ -i Makefile || die |
79 |
+ fi |
80 |
+} |
81 |
+ |
82 |
+src_compile() { |
83 |
+ export LIBS="$(pkg-config --libs tinyxml2)" |
84 |
+ emake ${PN} man \ |
85 |
+ CFGDIR="${EROOT}usr/share/${PN}/cfg" \ |
86 |
+ DB2MAN="${EROOT}usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl" |
87 |
+ |
88 |
+ if use qt5 ; then |
89 |
+ pushd gui || die |
90 |
+ eqmake5 |
91 |
+ emake |
92 |
+ popd || die |
93 |
+ fi |
94 |
+ if use htmlreport ; then |
95 |
+ pushd htmlreport || die |
96 |
+ distutils-r1_src_compile |
97 |
+ popd || die |
98 |
+ fi |
99 |
+} |
100 |
+ |
101 |
+src_test() { |
102 |
+ # safe final version |
103 |
+ mv -v ${PN}{,.final} || die |
104 |
+ mv -v lib/library.o{,.final} || die |
105 |
+ mv -v cli/cppcheckexecutor.o{,.final} || die |
106 |
+ #trigger recompile with CFGDIR inside ${S} |
107 |
+ emake check CFGDIR="${S}/cfg" |
108 |
+ # restore |
109 |
+ mv -v ${PN}{.final,} || die |
110 |
+ mv -v lib/library.o{.final,} || die |
111 |
+ mv -v cli/cppcheckexecutor.o{.final,} || die |
112 |
+} |
113 |
+ |
114 |
+src_install() { |
115 |
+ # it's not autotools-based, so "${ED}" here, not "${D}", bug 531760 |
116 |
+ emake install DESTDIR="${ED}" |
117 |
+ |
118 |
+ insinto "/usr/share/${PN}/cfg" |
119 |
+ doins cfg/*.cfg |
120 |
+ if use qt5 ; then |
121 |
+ dobin gui/${PN}-gui |
122 |
+ dodoc gui/{projectfile.txt,gui.${PN}} |
123 |
+ fi |
124 |
+ if use htmlreport ; then |
125 |
+ pushd htmlreport || die |
126 |
+ distutils-r1_src_install |
127 |
+ popd || die |
128 |
+ find "${D}" -name "*.egg-info" -delete |
129 |
+ else |
130 |
+ rm "${ED}/usr/bin/cppcheck-htmlreport" || die |
131 |
+ fi |
132 |
+ doman ${PN}.1 |
133 |
+ dodoc -r triage |
134 |
+} |
135 |
|
136 |
diff --git a/dev-util/cppcheck/files/cppcheck-1.84-char-signedness.patch b/dev-util/cppcheck/files/cppcheck-1.84-char-signedness.patch |
137 |
new file mode 100644 |
138 |
index 00000000000..ee1b136c9a9 |
139 |
--- /dev/null |
140 |
+++ b/dev-util/cppcheck/files/cppcheck-1.84-char-signedness.patch |
141 |
@@ -0,0 +1,88 @@ |
142 |
+From 320a957bbc912325363cf86b61108db860195ec3 Mon Sep 17 00:00:00 2001 |
143 |
+From: Alexander Mai <amai@××××××××.net> |
144 |
+Date: Thu, 28 Jun 2018 22:16:18 +0200 |
145 |
+Subject: [PATCH] Extend TestSymbolDatabase::findFunction19 to outline |
146 |
+ different results depending whether char is signed or unsigned on compile |
147 |
+ time |
148 |
+ |
149 |
+--- |
150 |
+ test/testsymboldatabase.cpp | 28 ++++++++++++++++++++-------- |
151 |
+ 1 file changed, 20 insertions(+), 8 deletions(-) |
152 |
+ |
153 |
+diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp |
154 |
+index 0dafd2730..28473e8e9 100644 |
155 |
+--- a/test/testsymboldatabase.cpp |
156 |
++++ b/test/testsymboldatabase.cpp |
157 |
+@@ -26,6 +26,7 @@ |
158 |
+ #include "tokenlist.h" |
159 |
+ #include "utils.h" |
160 |
+ |
161 |
++#include <climits> |
162 |
+ #include <cstddef> |
163 |
+ #include <list> |
164 |
+ #include <map> |
165 |
+@@ -5065,6 +5066,7 @@ private: |
166 |
+ " long get(long x) { return x; }\n" |
167 |
+ " long long get(long long x) { return x; }\n" |
168 |
+ " unsigned char get(unsigned char x) { return x; }\n" |
169 |
++ " signed char get(signed char x) { return x; }\n" |
170 |
+ " unsigned short get(unsigned short x) { return x; }\n" |
171 |
+ " unsigned int get(unsigned int x) { return x; }\n" |
172 |
+ " unsigned long get(unsigned long x) { return x; }\n" |
173 |
+@@ -5079,12 +5081,13 @@ private: |
174 |
+ " long v5 = 1; v5 = get(get(v5));\n" |
175 |
+ " long long v6 = 1; v6 = get(get(v6));\n" |
176 |
+ " unsigned char v7 = '1'; v7 = get(get(v7));\n" |
177 |
+- " unsigned short v8 = 1; v8 = get(get(v8));\n" |
178 |
+- " unsigned int v9 = 1; v9 = get(get(v9));\n" |
179 |
+- " unsigned long v10 = 1; v10 = get(get(v10));\n" |
180 |
+- " unsigned long long v11 = 1; v11 = get(get(v11));\n" |
181 |
+- " E1 v12 = e1; v12 = get(get(v12));\n" |
182 |
+- " E2 v13 = E2::e2; v13 = get(get(v13));\n" |
183 |
++ " signed char v8 = '1'; v8 = get(get(v8));\n" |
184 |
++ " unsigned short v9 = 1; v9 = get(get(v9));\n" |
185 |
++ " unsigned int v10 = 1; v10 = get(get(v10));\n" |
186 |
++ " unsigned long v11 = 1; v11 = get(get(v11));\n" |
187 |
++ " unsigned long long v12 = 1; v12 = get(get(v12));\n" |
188 |
++ " E1 v13 = e1; v13 = get(get(v13));\n" |
189 |
++ " E2 v14 = E2::e2; v14 = get(get(v14));\n" |
190 |
+ " }\n" |
191 |
+ "};"); |
192 |
+ |
193 |
+@@ -5094,7 +5097,10 @@ private: |
194 |
+ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 4); |
195 |
+ |
196 |
+ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v2 ) ) ;"); |
197 |
+- ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 5); |
198 |
++ if (std::numeric_limits<char>::is_signed) |
199 |
++ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 5); |
200 |
++ else |
201 |
++ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 10); |
202 |
+ |
203 |
+ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v3 ) ) ;"); |
204 |
+ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 6); |
205 |
+@@ -5112,7 +5118,10 @@ private: |
206 |
+ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 10); |
207 |
+ |
208 |
+ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v8 ) ) ;"); |
209 |
+- ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 11); |
210 |
++ if (std::numeric_limits<char>::is_signed) |
211 |
++ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 5); |
212 |
++ else |
213 |
++ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 10); |
214 |
+ |
215 |
+ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v9 ) ) ;"); |
216 |
+ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 12); |
217 |
+@@ -5128,6 +5137,9 @@ private: |
218 |
+ |
219 |
+ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v13 ) ) ;"); |
220 |
+ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 16); |
221 |
++ |
222 |
++ f = Token::findsimplematch(tokenizer.tokens(), "get ( get ( v14 ) ) ;"); |
223 |
++ ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 17); |
224 |
+ } |
225 |
+ |
226 |
+ void findFunction20() { // # 8280 |
227 |
+-- |
228 |
+2.16.4 |
229 |
+ |