forked from iarsystems/bx-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases-set
executable file
·101 lines (85 loc) · 3.53 KB
/
aliases-set
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
#!/bin/bash
#
# Copyright (c) 2020-2022 IAR Systems AB
#
# aliases-set
#
# Set aliases for IAR Build Tools Docker images
#
# See LICENSE for detailed license information
#
function _bx_show_help()
{
echo "Usage: source ${BASH_SOURCE[0]} CONTAINER_ID"
echo " "
}
# Aliases for the arm/bin executables
function _bx-aliases-set()
{
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
echo "ERROR: the script is not being properly sourced." >&2
_bx_show_help
return 1
fi
if [ $# -ne 1 ]; then
_bx_show_help
return 1
fi
CONTAINER_ID=$1
# Find Build Tools
PACKAGE_DIR=$(docker exec ${CONTAINER_ID} find /opt/iarsystems -type l)
IMAGE_PACKAGE=${PACKAGE_DIR#/opt/iarsystems/bx}
# Base exec command
local DOCKER_EXEC_BASE=$(printf "alias bx-exec='docker exec --user `id -u`:`id -g` ${CONTAINER_ID}'")
eval ${DOCKER_EXEC_BASE}
local ICCARCH=$(printf "alias icc${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/icc${IMAGE_PACKAGE%fs}'")
eval $ICCARCH
case ${IMAGE_PACKAGE^^} in
# XLINK
BXAVR)
local AARCH=$(printf "alias a${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/a${IMAGE_PACKAGE%fs}'")
eval ${AARCH}
local XLINKARCH=$(printf "alias xlink${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/xlink${IMAGE_PACKAGE%fs}'")
eval $XLINKARCH
local XAR=$(printf "alias xar='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/xar'")
eval $XAR
;;
# ILINK, everything else
*)
local IASMARCH=$(printf "alias iasm${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/iasm${IMAGE_PACKAGE%fs}'")
eval ${IASMARCH}
local ILINKARCH=$(printf "alias ilink${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/ilink${IMAGE_PACKAGE%fs}'")
eval $ILINKARCH
local IARCHIVE=$(printf "alias iarchive='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/iarchive'")
eval $IARCHIVE
local IELFTOOL=$(printf "alias ielftool='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/ielftool'")
eval $IELFTOOL
local IELFDUMPARCH=$(printf "alias ielfdump${IMAGE_PACKAGE%fs}='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/ielfdump${IMAGE_PACKAGE%fs}'")
eval $IELFDUMPARCH
local IEXE2OBJ=$(printf "alias iexe2obj='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/iexe2obj'")
eval $IEXE2OBJ
local ISYMEXPORT=$(printf "alias isymexport='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/isymexport'")
eval $ISYMEXPORT
local IOBJMANIP=$(printf "alias iobjmanip='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/iobjmanip'")
eval $IOBJMANIP
;;
esac
# non-<arch> execs
local IARBUILD=$(printf "alias iarbuild='bx-exec ${PACKAGE_DIR}/common/bin/iarbuild'")
eval $IARBUILD
# C-STAT
local ICHECKS=$(printf "alias ichecks='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/ichecks'")
eval $ICHECKS
local ICSTAT=$(printf "alias icstat='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/icstat'")
eval $ICSTAT
local IREPORT=$(printf "alias ireport='bx-exec ${PACKAGE_DIR}/${IMAGE_PACKAGE%fs}/bin/ireport'")
eval $IREPORT
printf -- "-- The following aliases for IAR Build Tools were set:\n"
alias | grep bx-exec
printf -- "-- Now it is possible to execute the build tools seamlessly from the Linux machine.\n"
}
_bx-aliases-set $@
unset -f _bx-aliases-set
unset -f _bx_show_help
# Add Bash autocompletion for the IAR command line build utility
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/iarbuild-autocompletion.bash