Skip to content

Commit

Permalink
csmatch: experimental compiler wrapper for smatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudka committed Jul 20, 2018
1 parent 8331330 commit b66ff09
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ add_executable(cscppc cscppc.c cswrap-core.c cswrap/cswrap-util.c)
add_executable(csclng csclng.c cswrap-core.c cswrap/cswrap-util.c)
add_executable(csclng++ ${CMAKE_CURRENT_BINARY_DIR}/csclng++.c
cswrap-core.c cswrap/cswrap-util.c)
install(TARGETS cscppc csclng csclng++ DESTINATION bin)
add_executable(csmatch csmatch.c cswrap-core.c cswrap/cswrap-util.c)
install(TARGETS cscppc csclng csclng++ csmatch DESTINATION bin)

# install default.supp (suppression file for cppcheck)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/default.supp DESTINATION share/cscppc)
Expand Down
53 changes: 53 additions & 0 deletions csmatch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2018 Red Hat, Inc.
*
* This file is part of cscppc.
*
* cscppc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* cscppc 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cscppc. If not, see <http://www.gnu.org/licenses/>.
*/

#include "cswrap-core.h"

#include <stddef.h>

const char *wrapper_name = "csmatch";

#ifdef PATH_TO_CSMATCH
const char *wrapper_path = PATH_TO_CSMATCH;
#else
const char *wrapper_path = "";
#endif

const char *wrapper_proc_prefix = "[csmatch] ";

const char *wrapper_addopts_envvar_name = "CSMATCH_ADD_OPTS";

const char *wrapper_debug_envvar_name = "DEBUG_CSMATCH";

const char *analyzer_name = "smatch";

const bool analyzer_is_cxx_ready = false;

const bool analyzer_is_gcc_compatible = true;

static const char *analyzer_def_arg_list[] = {
"-D_Float128=long double",
NULL
};

const char **analyzer_def_argv = analyzer_def_arg_list;

const int analyzer_def_argc =
sizeof(analyzer_def_arg_list)/
sizeof(analyzer_def_arg_list[0]);
23 changes: 20 additions & 3 deletions make-srpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,24 @@ Conflicts: csmock-plugin-clang < 1.5.0
This package contains the csclng compiler wrapper that runs the Clang analyzer
in background fully transparently.
%package -n csmatch
Summary: A compiler wrapper that runs smatch in background
Requires: clang
%description -n csmatch
This package contains the csmatch compiler wrapper that runs the smatch analyzer
in background fully transparently.
%prep
%setup -q
%build
mkdir cscppc_build
cd cscppc_build
export CFLAGS="\$RPM_OPT_FLAGS"' -DPATH_TO_CSCPPC=\\"%{_libdir}/cscppc\\" -DPATH_TO_CSCLNG=\\"%{_libdir}/csclng\\"'
export CFLAGS="\$RPM_OPT_FLAGS"
CFLAGS="\$CFLAGS"' -DPATH_TO_CSCPPC=\\"%{_libdir}/cscppc\\"'
CFLAGS="\$CFLAGS"' -DPATH_TO_CSCLNG=\\"%{_libdir}/csclng\\"'
CFLAGS="\$CFLAGS"' -DPATH_TO_CSMATCH=\\"%{_libdir}/csmatch\\"'
export LDFLAGS="\$RPM_OPT_FLAGS -static -pthread"
%cmake ..
make %{?_smp_mflags} VERBOSE=yes
Expand All @@ -145,12 +156,13 @@ ctest %{?_smp_mflags} --output-on-failure
cd cscppc_build
make install DESTDIR="\$RPM_BUILD_ROOT"
install -m0755 -d "\$RPM_BUILD_ROOT%{_libdir}"{,/cscppc,/csclng}
install -m0755 -d "\$RPM_BUILD_ROOT%{_libdir}"{,/cs{cppc,clng,match}}
for i in cc gcc %{_arch}-redhat-linux-gcc
do
ln -s ../../bin/cscppc "\$RPM_BUILD_ROOT%{_libdir}/cscppc/\$i"
ln -s ../../bin/csclng "\$RPM_BUILD_ROOT%{_libdir}/csclng/\$i"
ln -s ../../bin/csmatch "\$RPM_BUILD_ROOT%{_libdir}/csmatch/\$i"
done
for i in c++ g++ %{_arch}-redhat-linux-c++ %{_arch}-redhat-linux-g++
Expand All @@ -172,7 +184,12 @@ done
%{_bindir}/csclng++
%{_libdir}/csclng
%{_mandir}/man1/csclng.1*
%doc COPYING README
%doc COPYING
%files -n csmatch
%{_bindir}/csmatch
%{_libdir}/csmatch
%doc COPYING
EOF

rpmbuild -bs "$SPEC" \
Expand Down

0 comments on commit b66ff09

Please sign in to comment.