-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_version.sh
executable file
·67 lines (47 loc) · 2.26 KB
/
generate_version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
curdir=$(pwd)
. /etc/profile
# if you use client/server visit and have "cd /lustre/tmp/..." in your ~/.bashrc this workaround is needed
cd $curdir
cat > version.cpp <<EOF
#include <iostream>
#include "mpi.h"
using namespace std;
bool printVersion() {
int rank;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
if(rank==0){
EOF
echo " cout << endl << \"----------- Compilation --------- \"<<endl;" >>version.cpp
echo " cout << \"date: $(date)\" <<endl;" >>version.cpp
echo " cout << \"folder: $PWD \"<<endl;" >>version.cpp
echo " cout << \"CMP: $1 \"<<endl;" >>version.cpp
echo " cout << \"CXXFLAGS: $2 \"<<endl;" >>version.cpp
echo " cout << \"FLAGS: $3 \"<<endl;" >>version.cpp
echo " cout << \"INC_MPI: $4 \"<<endl;" >>version.cpp
echo " cout << \"INC_DCCRG: $5 \"<<endl;" >>version.cpp
echo " cout << \"INC_ZOLTAN: $6 \"<<endl;" >>version.cpp
echo " cout << \"INC_BOOST: $7 \"<<endl;" >>version.cpp
echo " cout << endl << \"----------- git branch --------- \"<<endl;" >>version.cpp
git branch | sed 's/\"/\\"/g' | sed 's/\\\"/\\"/g' | gawk '{printf("%s\"%s\"%s\n"," cout << ",$0," << endl;")}' >> version.cpp
echo " cout << endl << \"----------- git log (last 10 commits) --------- \"<<endl;" >>version.cpp
git log --pretty=oneline | head | sed 's/\"/\\"/g' | sed 's/\\\"/\\"/g' | gawk '{printf("%s\"%s\"%s\n"," cout << ",$0," << endl;")}' >> version.cpp
echo " cout << endl << \"----------- module list --------- \"<<endl;" >>version.cpp
module list 2>&1 | gawk '{printf("%s\"%s\"%s\n"," cout << ",$0," << endl;")}' >> version.cpp
echo " cout << endl << \"----------- git status --------- \"<<endl;" >>version.cpp
git status | sed 's/\"/\\"/g' | sed 's/\\\"/\\"/g' |gawk '{printf("%s\"%s\"%s\n"," cout << ",$0," << endl;")}' >> version.cpp
echo " cout << endl << \"----------- git diff ---------- \"<<endl;" >>version.cpp
echo " const char diff_data[] = {" >> version.cpp
DIFF=$(git diff `git diff --name-only |grep -v generate_version.sh` | xxd -i)
if [[ -n $DIFF ]]; then
echo -n $DIFF >> version.cpp
echo " ,0 };" >> version.cpp
else
echo " 0 };" >> version.cpp
fi
echo " cout << diff_data << endl;" >> version.cpp
cat >> version.cpp <<EOF
}
return true;
}
EOF