TP Histogramme.
[GPU.git] / WCudaMSE / BUILDER / makefile / private / script / workspace_classification.sh
1 #!/bin/bash
2 #
3 # Version: 0.0.3
4 # Date: 04.03.2014
5 #
6 # link:
7 # http://www.cyberciti.biz/faq/unix-linux-extract-filename-and-extension-in-bash/
8 # http://stackoverflow.com/questions/2625976/sorting-space-delimited-numbers-with-linux-bash
9 # http://stackoverflow.com/questions/3236871/how-to-return-a-string-value-from-a-bash-function
10
11 #-----------------------------------------------
12 # init
13 #-----------------------------------------------
14
15 source ./workspace_os_management.sh
16
17 #-----------------------------------------------
18 # CLassification Project
19 #-----------------------------------------------
20
21 #buildable
22 setCUDA=""
23 setCPP=""
24 setIntel=""
25
26 #buildable: os specific only
27 setLinux=""
28 setWin=""
29
30 #not buildable
31 setETUDE=""
32
33 setDataProject=$(find ${workspaceRoot} -name 'dataProject.mk')
34
35 for filePath in ${setDataProject}
36 do
37
38 folderPath=${filePath%/*}
39 folder=${folderPath##*/}
40
41 #echo ${filePath}
42 #echo "folderPath = " ${folderPath}
43 #echo "folder = " ${folder}
44
45 if [ -d ./${folder} ] # test si folder est bien sun sous folder de workspaceRoot
46 then
47
48 #Etude
49 if [[ ${folder} == *Etude* ]]
50 then
51 setETUDE="${setETUDE} ${folder}"
52 fi
53
54 #Os specific
55 if [[ ${folder} == *Linux* ]]
56 then
57 setLinux="${setLinux} ${folder}"
58
59 elif [[ ${folder} == *Win* ]]
60 then
61 setWin="${setWin} ${folder}"
62 fi
63
64 #GCC, INTEL ou Cuda
65 if [[ ${folder} == *Cuda* ]]
66 then
67 setCUDA="${setCUDA} ${folder}"
68
69 elif [[ ${folder} == *Intel* ]]
70 then
71 setIntel="${setIntel} ${folder}"
72
73 else
74 setCPP="${setCPP} ${folder}"
75 fi
76 fi
77
78 done
79
80 #-----------------------------------------------
81 # ensemble operation
82 #-----------------------------------------------
83
84 # result=$1 - $2
85 # ie, ce qui est dans $1 mais pas dans $2
86 #
87 # Example:
88 # un='a b c d e'
89 # deux='e c'
90 # result=$(sub "$un" "$deux")
91 # echo "result=" $result # donne a b d
92 function sub()
93 {
94 input1=$1
95 input2=$2
96
97 for e1 in $1
98 do
99 isFound=false
100 for e2 in $2
101 do
102 if [[ $e1 == $e2 ]]
103 then
104 isFound=true
105 break
106 fi
107 done
108 #echo "[ $isFound $e2 ]"
109 if [[ $isFound != true ]]
110 then
111 echo ${e1}
112 fi
113 done
114 }
115
116 #soustarction de Etude
117 setCPP=$(sub "$setCPP" "$setETUDE")
118 setIntel=$(sub "$setIntel" "$setETUDE")
119 setCUDA=$(sub "$setCUDA" "$setETUDE")
120
121 #soustarction de os specific
122 if [[ $OS == "Linux" ]]
123 then
124 setCPP=$(sub "$setCPP" "$setWin")
125 setIntel=$(sub "$setIntel" "$setWin")
126 setCUDA=$(sub "$setCUDA" "$setWin")
127
128 elif [[ $OS == "Win" ]]
129 then
130 setCPP=$(sub "$setCPP" "$setLinux")
131 setIntel=$(sub "$setIntel" "$setLinux")
132 setCUDA=$(sub "$setCUDA" "$setLinux")
133 fi
134
135 #-----------------------------------------------
136 # sort
137 #-----------------------------------------------
138
139 #setCPP=$(printf "%s\n" $setCPP | sort -n)
140 function sorting()
141 {
142 input=$@
143 result=$(printf "%s\n" $input | sort -n)
144 echo $result
145 }
146
147 setCPP=$(sorting "$setCPP")
148 setCUDA=$(sorting "$setCUDA")
149 setETUDE=$(sorting "$setETUDE")
150 setIntel=$(sorting "$setIntel")
151 setLinux=$(sorting "$setLinux")
152 setWin=$(sorting "$setWin")
153
154 #-----------------------------------------------
155 # show classification
156 #-----------------------------------------------
157
158 function printing()
159 {
160 echo ""
161
162 input=$@
163 for element in ${input}
164 do
165 echo " " ${element}
166 done
167
168 echo ""
169 }
170
171 echo ""
172 echo "--------------------------------------------------------------------------------------------------------"
173 echo "[Classification of project]"
174 echo ""
175 echo " Workspace = "${workspaceRoot}
176 echo " State = Please wait ..."
177 echo -n " Time = "
178 date +"%T"
179 echo "--------------------------------------------------------------------------------------------------------"
180 echo ""
181
182 echo "[CUDA] Projects :"
183 printing $setCUDA
184
185 echo "[CPP] Projects :"
186 printing $setCPP
187
188 echo "[CPP_Intel] Projects :"
189 printing $setIntel
190
191 echo "[Linux] Projects : "
192 printing $setLinux
193
194 echo "[WIN] Projects : "
195 printing $setWin
196
197 echo "[ETUDE] Projects: (not build here)"
198 printing $setETUDE
199
200 #Liasser de temps au user de voir classification
201 echo ""
202 echo "Pause ..."
203 sleep 2
204
205 #-----------------------------------------------
206 # end
207 #-----------------------------------------------
208
209