@@ -0,0 +1,114 | |||||
|
1 | #!/usr/bin/bash | |||
|
2 | ||||
|
3 | function usage { | |||
|
4 | echo " usage: $0 [ninja|make]" | |||
|
5 | echo " Launch clang-analyzer on the sources with ninja or make." | |||
|
6 | exit | |||
|
7 | } | |||
|
8 | ||||
|
9 | function execAndTest { | |||
|
10 | "$@" | |||
|
11 | local status=$? | |||
|
12 | if [ $status -ne 0 ]; then | |||
|
13 | echo "" >&2 | |||
|
14 | echo " ERROR with $1" >&2 | |||
|
15 | exit $status | |||
|
16 | fi | |||
|
17 | return $status | |||
|
18 | } | |||
|
19 | ||||
|
20 | # Défaut : Ninja | |||
|
21 | generator="Ninja" | |||
|
22 | builder="ninja" | |||
|
23 | ||||
|
24 | if [[ $# -gt 1 ]]; then | |||
|
25 | echo " ERROR: illegal number of arguments." >&2 | |||
|
26 | echo " provided: $#" >&2 | |||
|
27 | echo " expected: 0 or 1" >&2 | |||
|
28 | echo "" >&2 | |||
|
29 | usage | |||
|
30 | elif [[ $# -eq 1 ]]; then | |||
|
31 | if [[ "$1" == "ninja" ]]; then | |||
|
32 | echo "=> Using multiple jobs" | |||
|
33 | generator="Ninja" | |||
|
34 | builder="ninja" | |||
|
35 | elif [[ "$1" == "make" ]]; then | |||
|
36 | echo "=> Using single job" | |||
|
37 | generator="Ninja" | |||
|
38 | builder="ninja -j 1" | |||
|
39 | elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then | |||
|
40 | usage | |||
|
41 | else | |||
|
42 | echo " ERREUR:" >&2 | |||
|
43 | echo " L'option doit être 'ninja' ou 'make'" >&2 | |||
|
44 | echo "" >&2 | |||
|
45 | exit -1 | |||
|
46 | fi | |||
|
47 | fi | |||
|
48 | ||||
|
49 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |||
|
50 | ||||
|
51 | # On se place à la racine du projet SciQlop | |||
|
52 | execAndTest cd $DIR | |||
|
53 | if ! [ -e CMakeLists.txt -a -e README.md ]; then | |||
|
54 | echo " ERREUR:" >&2 | |||
|
55 | echo " CMakeLists.txt ou README.md n'existent pas." >&2 | |||
|
56 | echo " Verifier que le script est bien execute a partir" >&2 | |||
|
57 | echo " du sous-dossier 'scripts' de SciQlop" >&2 | |||
|
58 | echo "" | |||
|
59 | exit 1 | |||
|
60 | fi | |||
|
61 | ||||
|
62 | # Vérification de l'existence de scan-build, ccc-analyzer, ccc-analyzer.bat | |||
|
63 | # et c++-analyzer.bat | |||
|
64 | export SCAN_BUILD_DIR="C:/Dev/CNRS-DEV/cfe/tools/scan-build" | |||
|
65 | export CLANG_BUILD_DIR="C:/Appli/LLVM/bin" | |||
|
66 | if ! [ -e $SCAN_BUILD_DIR/bin/scan-build \ | |||
|
67 | -a -e $SCAN_BUILD_DIR/libexec/ccc-analyzer \ | |||
|
68 | -a -e $SCAN_BUILD_DIR/libexec/ccc-analyzer.bat \ | |||
|
69 | -a -e $SCAN_BUILD_DIR/libexec/c++-analyzer.bat ]; then | |||
|
70 | echo " ERREUR:" | |||
|
71 | echo " Les fichiers scan-build, ccc-analyzer, ccc-analyzer.bat" | |||
|
72 | echo " et c++-analyzer.bat ne sont pas présents dans le dossier :" | |||
|
73 | echo " $SCAN_BUILD_DIR." | |||
|
74 | echo " Assurez-vous d'avoir installé clang-analyzer en relançant le" | |||
|
75 | echo " script d'installation d'environnement de SciQlop." | |||
|
76 | echo "" | |||
|
77 | exit 2 | |||
|
78 | fi | |||
|
79 | ||||
|
80 | # Création d'un dossier build/debug_clanganalyzer et cd dedans | |||
|
81 | execAndTest mkdir -p build/debug_clanganalyzer | |||
|
82 | execAndTest cd build/debug_clanganalyzer | |||
|
83 | ||||
|
84 | # Création d'un dossier clang-analyzer-output pour recevoir les | |||
|
85 | # rapports | |||
|
86 | execAndTest mkdir -p clang-analyzer-output | |||
|
87 | ||||
|
88 | # Export des compilateurs pour clang-analyzer | |||
|
89 | export CCC_CC=gcc | |||
|
90 | export CCC_CXX=g++ | |||
|
91 | ||||
|
92 | # Exécution de cmake avec scan-build pour initialiser clang-analyzer | |||
|
93 | execAndTest $SCAN_BUILD_DIR/bin/scan-build \ | |||
|
94 | -o clang-analyzer-output \ | |||
|
95 | --use-analyzer $CLANG_BUILD_DIR/clang.exe \ | |||
|
96 | cmake -G "$generator" \ | |||
|
97 | -DCMAKE_BUILD_TYPE=Release \ | |||
|
98 | -DCMAKE_CXX_COMPILER=C:/Appli/LLVM/libexec/c++-analyzer.bat \ | |||
|
99 | -DCMAKE_C_COMPILER=C:/Appli/LLVM/libexec/ccc-analyzer.bat \ | |||
|
100 | -DCMAKE_CXX_COMPILER_ID=GNU \ | |||
|
101 | -DBUILD_TESTS=NONE \ | |||
|
102 | -DENABLE_CHECKSTYLE=OFF \ | |||
|
103 | -DENABLE_CODE_ANALYSIS=OFF \ | |||
|
104 | -DENABLE_FORMATTING=OFF \ | |||
|
105 | ../.. | |||
|
106 | ||||
|
107 | # Clean de la construction pour avoir tous les bugs tout le temps | |||
|
108 | execAndTest $builder clean | |||
|
109 | ||||
|
110 | # Exécution de ninja avec scan-build pour lancer clang-analyzer | |||
|
111 | execAndTest $SCAN_BUILD_DIR/scan-build \ | |||
|
112 | -o clang-analyzer-output \ | |||
|
113 | --use-analyzer $CLANG_BUILD_DIR/clang.exe \ | |||
|
114 | $builder |
@@ -2,9 +2,9 | |||||
2 | # compiler.cmake : configure the compilation flags |
|
2 | # compiler.cmake : configure the compilation flags | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") |
|
5 | IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | |
6 | INCLUDE("cmake/compiler/compiler_gnu.cmake") |
|
6 | INCLUDE("cmake/compiler/compiler_gnu.cmake") | |
7 | ELSEIF(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") |
|
7 | ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | |
8 | INCLUDE("cmake/compiler/compiler_msvc.cmake") |
|
8 | INCLUDE("cmake/compiler/compiler_msvc.cmake") | |
9 | ELSE() |
|
9 | ELSE() | |
10 | MESSAGE(FATAL_ERROR "Compiler not supported") |
|
10 | MESSAGE(FATAL_ERROR "Compiler not supported") |
General Comments 0
You need to be logged in to leave comments.
Login now