| 1 | #!/bin/bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | # You may not use this file except in compliance with the License. |
| 6 | # A copy of the License is located at |
| 7 | # |
| 8 | # http://aws.amazon.com/apache2.0 |
| 9 | # |
| 10 | # or in the "license" file accompanying this file. This file is distributed |
| 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | # express or implied. See the License for the specific language governing |
| 13 | # permissions and limitations under the License. |
| 14 | # |
| 15 | |
| 16 | set -e |
| 17 | |
| 18 | usage() { |
| 19 | echo "install_cppcheck.sh install_dir" |
| 20 | exit 1 |
| 21 | } |
| 22 | |
| 23 | if [ "$#" -ne "1" ]; then |
| 24 | usage |
| 25 | fi |
| 26 | |
| 27 | INSTALL_DIR=$1 |
| 28 | source codebuild/bin/jobs.sh |
| 29 | |
| 30 | mkdir -p $INSTALL_DIR||true |
| 31 | cd "$INSTALL_DIR" |
| 32 | git clone --branch 2.3 --depth 1 https://github.com/danmar/cppcheck.git cppcheck-src |
| 33 | cd cppcheck-src |
| 34 | |
| 35 | # The cppcheck 2.3 build fails without this import. This should be removed after cppcheck is |
| 36 | # updated: https://github.com/aws/s2n-tls/issues/5239 |
| 37 | sed -i '1s/^/#include <limits>\n/' ./lib/programmemory.cpp |
| 38 | |
| 39 | # -DNO_UNIX_SIGNAL_HANDLING is added to support the cppcheck 2.3 build, and should also be removed |
| 40 | # after cppcheck is updated: https://github.com/aws/s2n-tls/issues/5239 |
| 41 | # These build instructions are based on https://github.com/danmar/cppcheck#gnu-make. |
| 42 | make -j $JOBS MATCHCOMPILER=yes CXXFLAGS="-O2 -DNDEBUG -DNO_UNIX_SIGNAL_HANDLING" |
| 43 | |
| 44 | mv cppcheck .. |
| 45 | mv cfg .. |
| 46 | cd .. |
| 47 | rm -rf cppcheck-src |