1#!/bin/bash 2 3# Copyright JS Foundation and other contributors, http://js.foundation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17if [[ "$OSTYPE" == "linux"* ]]; then 18 CPPCHECK_JOBS=${CPPCHECK_JOBS:=$(nproc)} 19elif [[ "$OSTYPE" == "darwin"* ]]; then 20 CPPCHECK_JOBS=${CPPCHECK_JOBS:=$(sysctl -n hw.ncpu)} 21else 22 CPPCHECK_JOBS=${CPPCHECK_JOBS:=1} 23fi 24 25JERRY_CORE_DIRS=`find jerry-core -type d` 26JERRY_EXT_DIRS=`find jerry-ext -type d` 27JERRY_PORT_DIRS=`find jerry-port -type d` 28JERRY_LIBM_DIRS=`find jerry-libm -type d` 29 30 31INCLUDE_DIRS=() 32for DIR in $JERRY_CORE_DIRS $JERRY_EXT_DIRS $JERRY_PORT_DIRS $JERRY_LIBM_DIRS 33do 34 INCLUDE_DIRS=("${INCLUDE_DIRS[@]}" "-I$DIR") 35done 36 37cppcheck -j$CPPCHECK_JOBS --force \ 38 --language=c --std=c99 \ 39 --quiet \ 40 --enable=warning,style,performance,portability,information \ 41 --template="{file}:{line}: {severity}({id}): {message}" \ 42 --error-exitcode=1 \ 43 --inline-suppr \ 44 --exitcode-suppressions=tools/cppcheck/suppressions-list \ 45 --suppressions-list=tools/cppcheck/suppressions-list \ 46 "${INCLUDE_DIRS[@]}" \ 47 jerry-core jerry-ext jerry-port jerry-libm jerry-main tests/unit-* 48