编译指令-Linux


这一部分的最新代码已经在我的 github 上。

注意 ~/.run 文件夹可能需要手动新建。
mkdir ~/.run

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
#!/bin/sh
name=""
for i in "$@"
do
name="$name$i"
done
name=${name////_}
name=${name// /_}
if [ ! -e ~/.run/md5_$name ]
then
touch ~/.run/md5_$name
fi
md5sum $@ > ~/.run/new_md5_$name
diff ~/.run/new_md5_$name ~/.run/md5_$name > ~/.run/diff_tmp
if [ $? == 0 ]
then
echo "Run your code here:"
rm ~/.run/new_md5_$name
~/.run/run_$name
else
cp ~/.run/new_md5_$name ~/.run/md5_$name
rm ~/.run/new_md5_$name
g++ -O2 -lm -Wall -std=c++17 -fsanitize=address,undefined -o ~/.run/run_$name $@
if [ $? == 0 ]
then
echo "Compiled successfully!"
echo "Run your code here:"
~/.run/run_$name
else
echo "Compiled error!"
fi
fi