-
Notifications
You must be signed in to change notification settings - Fork 35
/
symlink-all.sh
executable file
·144 lines (114 loc) · 3.75 KB
/
symlink-all.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
#
# Copyright (C) 2012-2014 Embecosm Limited
#
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# A wrapper for the GCC symlink-tree script, to build a symlink tree of all
# the component directories.
# Usage:
# symlink-all.sh <basedir> <logfile> <ignore> <unisrc> <component1> \
# <component2> ...
# The <unisrc> directory is assumed to exist. symlink-tree is run in that
# directory for each top level directory in each <component> directory,
# excluding any top level files/directories given by the <ignore> argument.
# For some components (binutils, gdb) we add some specific known directories
# to ignore. This is a consequence of their shared upstream repository.
# We assume the component directories are direct subdirs of the base
# directory. We therefore also assume that the symlink-tree script can be
# found in ${basedir}/gcc
################################################################################
# #
# Shell functions #
# #
################################################################################
# Function to check for relative directory and makes it absolute
# @param[in] $1 The directory to make absolute if necessary.
absdir() {
case ${1} in
/*)
echo "${1}"
;;
*)
echo "${PWD}/${1}"
;;
esac
}
# Convenience function to copy a message to the log and terminal
# @param[in] $1 The message to log
logterm () {
echo $1 | tee -a ${logfile}
}
# Convenience function to copy a message to the log only
# @param[in] $1 The message to log
logonly () {
echo $1 >> ${logfile}
}
# Set the base directory and logfile
basedir="$1"
shift
logfile="$1"
shift
always_ignore="$1"
shift
# Change to the unisrc directory, which can be relative to the base directory.
unisrc_dir=$1
shift
if ! cd ${basedir}
then
logterm "ERROR: sylink-all: Could not change to base dir ${basedir}"
exit 1
fi
if ! cd ${unisrc_dir}
then
logterm "ERROR: symlink-all: Could not change to unified dir ${unisrc_dir}"
exit 1
fi
# Symlink each tree
for component in $*
do
logterm "Adding component ${component} to unified source"
# Special case of some directories to ignore for some components
case $component in
binutils)
ignore="${always_ignore} gdb sim"
;;
gdb)
ignore="${always_ignore} binutils ld opcodes bfd"
;;
gcc)
ignore="${always_ignore}"
;;
cgen)
ignore="${always_ignore} etc config"
;;
*)
ignore="${always_ignore} sim"
;;
esac
if ! ${basedir}/gcc/symlink-tree "${basedir}/${component}" "${ignore}" \
>> ${logfile} 2>&1
then
exit 1
fi
done
exit 0