-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlinuxPostBuild.sh
executable file
·67 lines (63 loc) · 2.61 KB
/
linuxPostBuild.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
67
################################################################################
# Targoman: A robust Statistical Machine Translation framework
#
# Copyright 2014-2015 by ITRC <http://itrc.ac.ir>
#
# This file is part of Targoman.
#
# Targoman is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Targoman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Targoman. If not, see <http://www.gnu.org/licenses/>.
################################################################################
#!/bin/sh
BasePath=$1
IncludeTarget=$2
ConfigTarget=$3
# No need to create folders as they will be created
# when needed
#mkdir -pv $IncludeTarget
#for Dir in `find $BasePath -type d -not -name Private`
#do
# mkdir -pv $Dir
#done
# Creating a symbolic link reduces the pain of ambigious changes in headers!
#cp -vrf --parents `find $BasePath -name *.h -o -name *.hpp -o -name *.hh` $IncludeTarget || :
for File in $(find "$BasePath" -name "*.h" -o -name "*.hpp" -o -name "*.hh"); do
SrcPath=$(dirname $File);
SrcName=$(basename $File);
# Check if the header is private
if echo "$SrcPath" | egrep "\bPrivate\b" 2>&1 > /dev/null; then
echo "Ignoring private header $File ...";
else
TgtPath="$IncludeTarget/$BasePath/$(python -c "import os.path; print os.path.relpath('$SrcPath', '$BasePath')")";
SrcPath="$(python -c "import os.path; print os.path.relpath('$SrcPath', '$TgtPath')")";
if [ -r "$TgtPath/$SrcName" ]; then
echo "Already exists $File ...";
else
mkdir -pv "$TgtPath" || : ;
echo "Creating symbolic link for $File ...";
# DO NOT USE $File BECAUSE THE SYMBOLIC LINK
# MUST POINT TO A RELATIVE PATH
ln -s "$SrcPath/$SrcName" "$TgtPath/$SrcName" || : ;
fi
fi
done
# No need to remove anything anymore!
#rm -rvf $IncludeTarget/$BasePath/Private || :
# Config files will be copied only when the exist!
if find "conf/"* 2>&1 > /dev/null; then
mkdir -p $ConfigTarget || : ;
echo "Copying config files ...";
cp -rvf "conf/"* $ConfigTarget || : ;
else
echo "No config files to copy ...";
fi