以前写过“自动将Visual Studio编译生成的dll和lib文件放置到不同的路径中”这篇文章(其实就是使用了Visual Studio的post build),今天我想简单介绍一下如何在Linux下在Eclipse中使用post build的方法。
首先如下图所示,设置post build。
在post build 中我们使用script,以下是我使用的Bash script 例子:
#!/bin/bash
# copy the exe file, if exists
# find $1 -name '*.exe'YOUR_BIN_PATH=$YOUR_BIN_PATH
YOUR_LIB_PATH=$YOUR_LIB_PATH# Get the file extension to decide the target folder to copy.
file_ext=${filename##*.}filename=$1
# Based on the file extension, we copy the file to different the target folder.
if [ $file_ext = "so" ]
then
echo "Copying dynamic library file $contain_so"
cp -v $filename $YOUR_LIB_PATH
elif [ $file_ext = "a" ]
then
echo "Copying static library file $contain_sa"
cp -v $filename $YOUR_LIB_PATH
else
echo "Copying executable file $1"
cp -v $filename $YOUR_BIN_PATH
fi
延伸阅读:
1. 如何编写bash script:http://linuxconfig.org/Bash_scripting_Tutorial
2. 也许你还有兴趣知道,如何设置Eclipse的Debug configurations中的Environment,如下图所示:
没有评论:
发表评论