diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2018-04-10 21:21:54 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-04-13 16:58:07 +0100 |
commit | 57ca83dac13c3dbac734fcd8c20fec222c5cb70f (patch) | |
tree | 5d4aa5e27929a74129e2dc98faa41905c59005e4 | |
parent | f91523b22ffe3e8662d24fcdcd9fdde62b9485c4 (diff) | |
download | poky-57ca83dac13c3dbac734fcd8c20fec222c5cb70f.tar.gz |
icecc-create-env: Allow logging to a file
Modifies the icecc-create-env script so that it can log output to a log
file. In addition, a --debug flag is added that allows verbose logging.
Finally, the silent flag was removed since it was never used in
icecc.bbclass
(From OE-Core rev: 3d0bd786fd79967cf8754d022044df311dd8ad3e)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env index 537e38a9ba..074c7675c0 100755 --- a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env +++ b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env | |||
@@ -7,6 +7,24 @@ | |||
7 | target_paths= | 7 | target_paths= |
8 | target_aliases= | 8 | target_aliases= |
9 | 9 | ||
10 | # Always prints, optionally to a log file | ||
11 | print_output () | ||
12 | { | ||
13 | if test -n "$log_path"; then | ||
14 | echo "$@" | tee -a "$log_path" | ||
15 | else | ||
16 | echo "$@" | ||
17 | fi | ||
18 | } | ||
19 | |||
20 | # Only prints if the debug flag is specified | ||
21 | print_debug () | ||
22 | { | ||
23 | if test -n "$debug"; then | ||
24 | print_output "$@" | ||
25 | fi | ||
26 | } | ||
27 | |||
10 | is_dynamic_elf () | 28 | is_dynamic_elf () |
11 | { | 29 | { |
12 | # Is the file an dynamically linked ELF executable? | 30 | # Is the file an dynamically linked ELF executable? |
@@ -54,6 +72,7 @@ add_alias () | |||
54 | *" $alias "*) | 72 | *" $alias "*) |
55 | ;; | 73 | ;; |
56 | *) | 74 | *) |
75 | print_debug "Adding alias '$2' -> '$1'" | ||
57 | target_aliases="$target_aliases $alias" | 76 | target_aliases="$target_aliases $alias" |
58 | ;; | 77 | ;; |
59 | esac | 78 | esac |
@@ -123,17 +142,23 @@ add_file () | |||
123 | fi | 142 | fi |
124 | } | 143 | } |
125 | 144 | ||
126 | # backward compat | 145 | while test -n "$1"; do |
127 | if test "$1" = "--respect-path"; then | 146 | case "$1" in |
128 | shift | 147 | --respect-path) |
129 | fi | 148 | # Ignore for backward compatability |
130 | 149 | ;; | |
131 | #add a --silent switch to avoid "broken pipe" errors when calling this scipt from within OE | 150 | --debug) |
132 | if test "$1" = "--silent"; then | 151 | debug=1 |
133 | silent=1 | 152 | ;; |
153 | --log) | ||
154 | do_log=1 | ||
155 | ;; | ||
156 | *) | ||
157 | break | ||
158 | ;; | ||
159 | esac | ||
134 | shift | 160 | shift |
135 | fi | 161 | done |
136 | |||
137 | 162 | ||
138 | added_gcc=$1 | 163 | added_gcc=$1 |
139 | shift | 164 | shift |
@@ -143,6 +168,11 @@ added_as=$1 | |||
143 | shift | 168 | shift |
144 | archive_name=$1 | 169 | archive_name=$1 |
145 | 170 | ||
171 | if test -n "$do_log"; then | ||
172 | log_path="$archive_name.log" | ||
173 | rm -f "$log_path" | ||
174 | fi | ||
175 | |||
146 | if test -z "$PATCHELF"; then | 176 | if test -z "$PATCHELF"; then |
147 | PATCHELF=`which patchelf 2> /dev/null` | 177 | PATCHELF=`which patchelf 2> /dev/null` |
148 | fi | 178 | fi |
@@ -150,22 +180,22 @@ if test -z "$PATCHELF"; then | |||
150 | PATCHELF=`which patchelf-uninative 2> /dev/null` | 180 | PATCHELF=`which patchelf-uninative 2> /dev/null` |
151 | fi | 181 | fi |
152 | if test -z "$PATCHELF"; then | 182 | if test -z "$PATCHELF"; then |
153 | echo "patchelf is required" | 183 | print_output "patchelf is required" |
154 | exit 1 | 184 | exit 1 |
155 | fi | 185 | fi |
156 | 186 | ||
157 | if test -z "$added_gcc" || test -z "$added_gxx" ; then | 187 | if test -z "$added_gcc" || test -z "$added_gxx" ; then |
158 | echo "usage: $0 <gcc_path> <g++_path>" | 188 | print_output "usage: $0 <gcc_path> <g++_path>" |
159 | exit 1 | 189 | exit 1 |
160 | fi | 190 | fi |
161 | 191 | ||
162 | if ! test -x "$added_gcc" ; then | 192 | if ! test -x "$added_gcc" ; then |
163 | echo "'$added_gcc' is no executable." | 193 | print_output "'$added_gcc' is not executable." |
164 | exit 1 | 194 | exit 1 |
165 | fi | 195 | fi |
166 | 196 | ||
167 | if ! test -x "$added_gxx" ; then | 197 | if ! test -x "$added_gxx" ; then |
168 | echo "'$added_gcc' is no executable." | 198 | print_output "'$added_gcc' is not executable." |
169 | exit 1 | 199 | exit 1 |
170 | fi | 200 | fi |
171 | 201 | ||
@@ -178,7 +208,7 @@ if test -z "$added_as" ; then | |||
178 | add_file /usr/bin/as /usr/bin/as | 208 | add_file /usr/bin/as /usr/bin/as |
179 | else | 209 | else |
180 | if ! test -x "$added_as" ; then | 210 | if ! test -x "$added_as" ; then |
181 | echo "'$added_as' is no executable." | 211 | print_output "'$added_as' is not executable." |
182 | exit 1 | 212 | exit 1 |
183 | fi | 213 | fi |
184 | 214 | ||
@@ -206,7 +236,7 @@ if test -x /bin/true; then | |||
206 | elif test -x /usr/bin/true; then | 236 | elif test -x /usr/bin/true; then |
207 | add_file /usr/bin/true /bin/true | 237 | add_file /usr/bin/true /bin/true |
208 | else | 238 | else |
209 | echo "'true' not found" | 239 | print_output "'true' not found" |
210 | exit 1 | 240 | exit 1 |
211 | fi | 241 | fi |
212 | 242 | ||
@@ -266,9 +296,7 @@ if test -z "$archive_name"; then | |||
266 | 296 | ||
267 | #calculate md5 and use it as the archive name | 297 | #calculate md5 and use it as the archive name |
268 | archive_name=`for i in $target_files; do test -f $tempdir/$i && $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || { | 298 | archive_name=`for i in $target_files; do test -f $tempdir/$i && $md5sum $tempdir/$i; done | sed -e 's/ .*$//' | $md5sum | sed -e 's/ .*$//'`.tar.gz || { |
269 | if test -z "$silent"; then | 299 | print_output "Couldn't compute MD5 sum." |
270 | echo "Couldn't compute MD5 sum." | ||
271 | fi | ||
272 | exit 2 | 300 | exit 2 |
273 | } | 301 | } |
274 | mydir=`pwd` | 302 | mydir=`pwd` |
@@ -283,9 +311,7 @@ else | |||
283 | fi | 311 | fi |
284 | fi | 312 | fi |
285 | 313 | ||
286 | if test -z "$silent"; then | 314 | print_output "creating $archive_name" |
287 | echo "creating $archive_name" | ||
288 | fi | ||
289 | 315 | ||
290 | cd $tempdir | 316 | cd $tempdir |
291 | # Add everything in the temp directory. Tar doesn't like to be given files with | 317 | # Add everything in the temp directory. Tar doesn't like to be given files with |
@@ -293,9 +319,7 @@ cd $tempdir | |||
293 | # the path prefix past the offending "..". This makes the archive generate | 319 | # the path prefix past the offending "..". This makes the archive generate |
294 | # incorrectly | 320 | # incorrectly |
295 | tar -czf "$mydir/$archive_name" . || { | 321 | tar -czf "$mydir/$archive_name" . || { |
296 | if test -z "$silent"; then | 322 | print_output "Couldn't create archive" |
297 | echo "Couldn't create archive" | ||
298 | fi | ||
299 | exit 3 | 323 | exit 3 |
300 | } | 324 | } |
301 | cd .. | 325 | cd .. |