forked from TinkerTools/tinker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export
75 lines (61 loc) · 1.87 KB
/
export
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
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Attempt to update to the most recent version from GitHub then generate the interface code.
# Usage:
# bash export update
# bash export c cpp
src_dir=$PWD/../source
export LC_COLLATE=C
check_from_github() {
echo "Checking updates on GitHub..."
url_base="https://raw.githubusercontent.com/TinkerTools/tinker9/master/ext/interface"
vnum=$(curl -s "$url_base/version.txt")
if [[ $vnum =~ ^-?[0-9]+$ ]]; then
# If vnum is a valid integer, compare it to the local version number.
lnum=0
if [ -f version.txt ]; then
lnum=$(cat version.txt)
fi
if [ $lnum -lt $vnum ]; then
echo Updating from GitHub...
curl -O "$url_base/export"
curl -O "$url_base/parse.py"
curl -O "$url_base/version.txt"
mkdir -p include/tinker/{gfortran,ifort}
curl -o include/tinker/gfortran/macro.hh "$url_base/include/tinker/gfortran/macro.hh"
curl -o include/tinker/ifort/macro.hh "$url_base/include/tinker/ifort/macro.hh"
echo "Update completed. Please run this command again."
exit 0
else
echo "Already the newest."
fi
else
echo Cannot check the version on GitHub. Skipping the update...
fi
}
export_c() {
mkdir -p c
rm -rf c/*
mkdir -p c/tinker/detail
cd c/tinker
python3 ../../parse.py --lang=c $src_dir/*.f | bash
cd ../..
}
export_cpp() {
mkdir -p cpp
rm -rf cpp/*
mkdir -p cpp/tinker/detail
cd cpp/tinker
python3 ../../parse.py --lang=cpp $src_dir/*.f | bash
cd ../..
}
for a in "$@"; do
if [ "$a" = update ]; then
check_from_github
elif [ "$a" = c ]; then
echo "Exporting the C interface..."
export_c
elif [ "$a" = cpp ]; then
echo "Exporting the C++ interface..."
export_cpp
fi
done