source: wrappers/wrapper

Last change on this file was 914241e, checked in by Paweł Foremski <pjf@…>, 9 years ago

trivial support for ccache

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/bin/bash
2#
3# Wrapper around toolchain
4# The place where the fakebox magic takes place
5#
6
7# original tool name
8ME="`basename $0`"
9
10[[ $FB_DEBUG -ge 1 ]] && echo " [FB]  called: $ME $@" >&2
11
12# hacks
13[[ "$FB_OFF" = "1" ]] && exec "/usr/bin/$ME" "$@"
14[[ "$ME" = "strip" ]] && exec "$FB_WRAP-$ME" "$@"
15[[ "$ME" = "cc" ]] && ME=gcc
16
17{ [[ "$ME" = "gcc" ]] || [[ "$ME" = "g++" ]]; } && CCACHE="$FB_CCACHE_PATH"
18
19# prefix absolute /usr paths with $FB_TOP
20for i in "$@"; do
21        i="${i//I\/usr/I$FB_TOP/usr}"
22        i="${i//L\/usr/L$FB_TOP/usr}"
23        args[${#args[@]}]="${i// \/usr/$FB_TOP/usr}"
24done
25
26# handle special cases
27[[ "$1" = "-V" ]] || case "$ME" in
28        gcc|g++|ld|cpp|cc)
29                if [[ "$FB_USE_SYSROOT_OPT" = "1" ]]; then
30                        args[${#args[@]}]="--sysroot=$FB_ROOTFS"
31                else
32                        args[${#args[@]}]="-I$FB_ROOTFS/usr/include"
33                        args[${#args[@]}]="-L$FB_ROOTFS/lib"
34                        args[${#args[@]}]="-L$FB_ROOTFS/usr/lib"
35                        FB_WRAP_ADD="$FB_WRAP_ADD_GCC_LD"
36                fi
37                ;;
38esac
39
40# exec proper tool
41[[ $FB_DEBUG -ge 2 ]] && echo " [FB]  result: $CCACHE $FB_WRAP-$ME" "${args[@]}" $FB_WRAP_ADD >&2
42exec $CCACHE "$FB_WRAP-$ME" "${args[@]}" $FB_WRAP_ADD
Note: See TracBrowser for help on using the repository browser.