From aec3384010c453db9b7b64f8afa15c2723fd38f5 Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Thu, 5 Nov 2015 20:18:07 +0100 Subject: [PATCH 1/2] Build GUI. --- cppcheck-1.70-libsuffix.patch | 14 +++++++ cppcheck-1.70-tinyxml.patch | 66 ++++++++++++++++++++++++++++++++ cppcheck-1.70-translations.patch | 12 ++++++ cppcheck.spec | 52 +++++++++++++++++-------- 4 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 cppcheck-1.70-libsuffix.patch create mode 100644 cppcheck-1.70-tinyxml.patch create mode 100644 cppcheck-1.70-translations.patch diff --git a/cppcheck-1.70-libsuffix.patch b/cppcheck-1.70-libsuffix.patch new file mode 100644 index 0000000..f6f0b51 --- /dev/null +++ b/cppcheck-1.70-libsuffix.patch @@ -0,0 +1,14 @@ +diff -up cppcheck-1.70/lib/CMakeLists.txt.orig cppcheck-1.70/lib/CMakeLists.txt +--- cppcheck-1.70/lib/CMakeLists.txt.orig 2015-09-04 11:04:31.000000000 -0700 ++++ cppcheck-1.70/lib/CMakeLists.txt 2015-11-05 11:08:44.996474289 -0800 +@@ -42,8 +42,8 @@ endif() + + install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin COMPONENT libraries +- LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT libraries +- ARCHIVE DESTINATION lib COMPONENT libraries) ++ LIBRARY DESTINATION lib${LIB_SUFFIX} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT libraries ++ ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT libraries) + + install(FILES ${hdrs} + DESTINATION include/${PROJECT_NAME}/ diff --git a/cppcheck-1.70-tinyxml.patch b/cppcheck-1.70-tinyxml.patch new file mode 100644 index 0000000..25d6f00 --- /dev/null +++ b/cppcheck-1.70-tinyxml.patch @@ -0,0 +1,66 @@ +diff -up cppcheck-1.70/cli/CMakeLists.txt.tinyxml cppcheck-1.70/cli/CMakeLists.txt +--- cppcheck-1.70/cli/CMakeLists.txt.tinyxml 2015-09-04 20:04:31.000000000 +0200 ++++ cppcheck-1.70/cli/CMakeLists.txt 2015-11-05 18:53:51.310937488 +0100 +@@ -1,4 +1,3 @@ +-include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/) + include_directories(${PROJECT_SOURCE_DIR}/lib/) + + file(GLOB hdrs "*.h") +@@ -6,7 +5,7 @@ file(GLOB srcs "*.cpp") + file(GLOB mainfile "main.cpp") + list(REMOVE_ITEM srcs ${mainfile}) + +-link_libraries(${PROJECT_NAME} tinyxml) ++link_libraries(${PROJECT_NAME} -ltinyxml2) + + add_library(cli_lib OBJECT ${hdrs} ${srcs}) + +diff -up cppcheck-1.70/CMakeLists.txt.tinyxml cppcheck-1.70/CMakeLists.txt +--- cppcheck-1.70/CMakeLists.txt.tinyxml 2015-09-04 20:04:31.000000000 +0200 ++++ cppcheck-1.70/CMakeLists.txt 2015-11-05 18:54:41.847932573 +0100 +@@ -10,7 +10,6 @@ include(cmake/buildFiles.cmake REQUIRED) + + file(GLOB cfgs "cfg/*.cfg") + +-add_subdirectory(externals/tinyxml) + add_subdirectory(lib) # CppCheck Library + add_subdirectory(cli) # Client application + add_subdirectory(test) # Tests +diff -up cppcheck-1.70/gui/CMakeLists.txt.tinyxml cppcheck-1.70/gui/CMakeLists.txt +--- cppcheck-1.70/gui/CMakeLists.txt.tinyxml 2015-09-04 20:04:31.000000000 +0200 ++++ cppcheck-1.70/gui/CMakeLists.txt 2015-11-05 18:54:32.016937559 +0100 +@@ -11,7 +11,6 @@ if (BUILD_GUI) + endif() + + +- include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/) + include_directories(${PROJECT_SOURCE_DIR}/lib/) + + file(GLOB hdrs "*.h") +@@ -22,7 +21,7 @@ if (BUILD_GUI) + QT4_ADD_RESOURCES(resources "gui.qrc") + QT4_ADD_TRANSLATION(qms ${tss}) + +- link_libraries(${PROJECT_NAME} tinyxml ${QT_LIBRARIES}) ++ link_libraries(${PROJECT_NAME} -ltinyxml2 ${QT_LIBRARIES}) + + add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms}) + +diff -up cppcheck-1.70/test/CMakeLists.txt.tinyxml cppcheck-1.70/test/CMakeLists.txt +--- cppcheck-1.70/test/CMakeLists.txt.tinyxml 2015-09-04 20:04:31.000000000 +0200 ++++ cppcheck-1.70/test/CMakeLists.txt 2015-11-05 18:54:08.667937833 +0100 +@@ -3,13 +3,12 @@ if (BUILD_TESTS) + include_directories( + ${PROJECT_SOURCE_DIR}/lib/ + ${PROJECT_SOURCE_DIR}/cli/ +- ${PROJECT_SOURCE_DIR}/externals/tinyxml + ) + + file(GLOB hdrs "*.h") + file(GLOB srcs "*.cpp") + +- link_libraries(${PROJECT_NAME} tinyxml) ++ link_libraries(${PROJECT_NAME} -ltinyxml2) + + add_executable(testrunner ${hdrs} ${srcs} + $ diff --git a/cppcheck-1.70-translations.patch b/cppcheck-1.70-translations.patch new file mode 100644 index 0000000..3f6e0fb --- /dev/null +++ b/cppcheck-1.70-translations.patch @@ -0,0 +1,12 @@ +diff -up cppcheck-1.70/gui/CMakeLists.txt.orig cppcheck-1.70/gui/CMakeLists.txt +--- cppcheck-1.70/gui/CMakeLists.txt.orig 2015-11-05 10:38:42.248204919 -0800 ++++ cppcheck-1.70/gui/CMakeLists.txt 2015-11-05 10:45:01.897795689 -0800 +@@ -26,7 +26,7 @@ if (BUILD_GUI) + add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms}) + + install(TARGETS cppcheck-gui RUNTIME DESTINATION bin COMPONENT applications) +- install(FILES ${qms} DESTINATION bin COMPONENT applications) ++ install(FILES ${qms} DESTINATION share/${PROJECT_NAME}/ COMPONENT applications) + + set(CMAKE_AUTOMOC OFF) + diff --git a/cppcheck.spec b/cppcheck.spec index d6fc544..42cf4de 100644 --- a/cppcheck.spec +++ b/cppcheck.spec @@ -8,10 +8,19 @@ URL: http://cppcheck.wiki.sourceforge.net/ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.bz2 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +# Use system tinyxml2 +Patch0: cppcheck-1.70-tinyxml.patch +# Fix location of translations +Patch1: cppcheck-1.70-translations.patch +# Fix library install suffix +Patch2: cppcheck-1.70-libsuffix.patch + BuildRequires: pcre-devel BuildRequires: tinyxml2-devel >= 2.1.0 BuildRequires: docbook-style-xsl BuildRequires: libxslt +BuildRequires: qt4-devel +BuildRequires: cmake %description Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++ @@ -20,34 +29,44 @@ errors in the code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. The goal is to detect only real errors in the code (i.e. have zero false positives). +%package gui +Summary: Graphical user interface for cppcheck +Group: Applications/Engineering +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description gui +This package contains the graphical user interface for cppcheck. + %prep %setup -q +%patch0 -p1 -b .tinyxml +%patch1 -p1 -b .translations +%patch2 -p1 -b .libsuffix # Make sure bundled tinyxml is not used rm -r externals/tinyxml %build -# TINYXML= prevents use of bundled tinyxml -CXXFLAGS="%{optflags} -DNDEBUG $(pcre-config --cflags)" \ - LDFLAGS="$RPM_LD_FLAGS" LIBS=-ltinyxml2 make TINYXML= \ - CFGDIR=%{_datadir}/%{name} \ - HAVE_RULES=yes \ - DB2MAN=%{_datadir}/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl \ - %{?_smp_mflags} all man +# Manuals +make DB2MAN=%{_datadir}/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl man xsltproc --nonet -o man/manual.html \ %{_datadir}/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl \ man/manual.docbook +# Binaries +mkdir objdir-%{_target_platform} +cd objdir-%{_target_platform} +# Upstream doesn't support shared libraries (unversioned solib) +%cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=1 -DBUILD_SHARED_LIBS:BOOL=OFF + %install rm -rf %{buildroot} -install -D -p -m 755 cppcheck %{buildroot}%{_bindir}/cppcheck +make -C objdir-%{_target_platform} DESTDIR=%{buildroot} install install -D -p -m 644 cppcheck.1 %{buildroot}%{_mandir}/man1/cppcheck.1 -# Install cfg files -cd cfg -for f in *; do - install -D -p -m 644 $f %{buildroot}%{_datadir}/cppcheck/$f -done +# Don't ship devel stuff +rm -rf %{buildroot}%{_includedir}/CppCheck +rm %{buildroot}%{_libdir}/libCppCheck.* %check # Config is not available in the system-wide directory - delete executables and recompile @@ -63,12 +82,15 @@ CXXFLAGS="%{optflags} -DNDEBUG $(pcre-config --cflags)" \ rm -rf %{buildroot} %files -%defattr(-,root,root,-) %doc AUTHORS COPYING man/manual.html -%{_datadir}/cppcheck/ +%{_datadir}/CppCheck/ %{_bindir}/cppcheck %{_mandir}/man1/cppcheck.1* +%files gui +%{_bindir}/cppcheck-gui + + %changelog * Mon Sep 21 2015 Susi Lehtola - 1.70-1 - Update to 1.70. From 19d37668800c067d7dec47cbf5d674db7fed08af Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Thu, 5 Nov 2015 20:46:34 +0100 Subject: [PATCH 2/2] Include GUI. --- cppcheck-1.70-translations.patch | 28 ++++++++++++++++++++++++---- cppcheck.desktop | 11 +++++++++++ cppcheck.spec | 17 ++++++++++++++--- 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 cppcheck.desktop diff --git a/cppcheck-1.70-translations.patch b/cppcheck-1.70-translations.patch index 3f6e0fb..cfbbd49 100644 --- a/cppcheck-1.70-translations.patch +++ b/cppcheck-1.70-translations.patch @@ -1,12 +1,32 @@ -diff -up cppcheck-1.70/gui/CMakeLists.txt.orig cppcheck-1.70/gui/CMakeLists.txt ---- cppcheck-1.70/gui/CMakeLists.txt.orig 2015-11-05 10:38:42.248204919 -0800 -+++ cppcheck-1.70/gui/CMakeLists.txt 2015-11-05 10:45:01.897795689 -0800 +diff -up cppcheck-1.70/gui/CMakeLists.txt.translations cppcheck-1.70/gui/CMakeLists.txt +--- cppcheck-1.70/gui/CMakeLists.txt.translations 2015-11-05 11:37:19.343945331 -0800 ++++ cppcheck-1.70/gui/CMakeLists.txt 2015-11-05 11:37:19.344945349 -0800 @@ -26,7 +26,7 @@ if (BUILD_GUI) add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms}) install(TARGETS cppcheck-gui RUNTIME DESTINATION bin COMPONENT applications) - install(FILES ${qms} DESTINATION bin COMPONENT applications) -+ install(FILES ${qms} DESTINATION share/${PROJECT_NAME}/ COMPONENT applications) ++ install(FILES ${qms} DESTINATION share/${PROJECT_NAME}/lang/ COMPONENT applications) set(CMAKE_AUTOMOC OFF) +diff -up cppcheck-1.70/gui/translationhandler.cpp.translations cppcheck-1.70/gui/translationhandler.cpp +--- cppcheck-1.70/gui/translationhandler.cpp.translations 2015-09-04 11:04:31.000000000 -0700 ++++ cppcheck-1.70/gui/translationhandler.cpp 2015-11-05 11:38:34.991299374 -0800 +@@ -106,15 +106,7 @@ bool TranslationHandler::SetLanguage(con + if (datadir.isEmpty()) + datadir = appPath; + +- QString translationFile; +- if (QFile::exists(datadir + "/lang/" + mTranslations[index].mFilename + ".qm")) +- translationFile = datadir + "/lang/" + mTranslations[index].mFilename + ".qm"; +- +- else if (QFile::exists(datadir + "/" + mTranslations[index].mFilename + ".qm")) +- translationFile = datadir + "/" + mTranslations[index].mFilename + ".qm"; +- +- else +- translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm"; ++ QString translationFile("/usr/share/CppCheck/lang/" + mTranslations[index].mFilename + ".qm"); + + if (!mTranslator->load(translationFile) && !failure) { + translationFile += ".qm"; diff --git a/cppcheck.desktop b/cppcheck.desktop new file mode 100644 index 0000000..06c7311 --- /dev/null +++ b/cppcheck.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=CppCheck +GenericName=C++ Source code analyzer +Comment=Perform static code analysis on your C++ programs +Exec=cppcheck-gui +Icon=cppcheck +Terminal=false +Type=Application +StartupNotify=true +Categories=Development;Utility;Qt; + diff --git a/cppcheck.spec b/cppcheck.spec index 42cf4de..2b43037 100644 --- a/cppcheck.spec +++ b/cppcheck.spec @@ -1,11 +1,12 @@ Name: cppcheck Version: 1.70 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Tool for static C/C++ code analysis Group: Development/Languages License: GPLv3+ URL: http://cppcheck.wiki.sourceforge.net/ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.bz2 +Source1: cppcheck.desktop BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) # Use system tinyxml2 @@ -21,6 +22,7 @@ BuildRequires: docbook-style-xsl BuildRequires: libxslt BuildRequires: qt4-devel BuildRequires: cmake +BuildRequires: desktop-file-utils %description Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++ @@ -68,9 +70,13 @@ install -D -p -m 644 cppcheck.1 %{buildroot}%{_mandir}/man1/cppcheck.1 rm -rf %{buildroot}%{_includedir}/CppCheck rm %{buildroot}%{_libdir}/libCppCheck.* +# Install desktop file +desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1} +# Install logo +install -D -p -m 644 gui/icon.png %{buildroot}%{_datadir}/pixmaps/cppcheck.png + %check -# Config is not available in the system-wide directory - delete executables and recompile -find . -name \*.o -delete +# CMake build doesn't have check... CXXFLAGS="%{optflags} -DNDEBUG $(pcre-config --cflags)" \ LDFLAGS="$RPM_LD_FLAGS" LIBS=-ltinyxml2 make TINYXML= \ CFGDIR=$(pwd)/cfg \ @@ -89,9 +95,14 @@ rm -rf %{buildroot} %files gui %{_bindir}/cppcheck-gui +%{_datadir}/applications/cppcheck.desktop +%{_datadir}/pixmaps/cppcheck.png %changelog +* Thu Nov 5 2015 Susi Lehtola - 1.70-2 +- Include GUI (BZ #1278318). + * Mon Sep 21 2015 Susi Lehtola - 1.70-1 - Update to 1.70.