python-treq: bump to version 16.12.0
[buildroot-gz.git] / support / scripts / eclipse-register-toolchain
blob6f919985c09a14dca416860c04a7b544ad11aa73
1 #!/bin/sh
3 # This script registers the toolchain of a Buildroot project into the
4 # Eclipse plugin. To do so, it adds a new line for the Buildroot
5 # toolchain into the $HOME/.buildroot-eclipse.toolchains file, which
6 # the Eclipse Buildroot plugin reads to discover automatically the
7 # available Buildroot toolchains on the system.
9 # This script should typically not be called manually. Instead, one
10 # should enable the BR2_ECLIPSE_REGISTER configuration option, which
11 # will lead Buildroot to automatically call this script with the
12 # appropriate arguments.
14 # Usage:
15 # eclipse-register-toolchain project-directory toolchain-prefix architecture
17 # project-directory is the absolute path to the Buildroot project
18 # output directory (which contains the host/, target/, build/,
19 # images/, etc. subdirectories). It should be an absolute and
20 # canonical path.
22 # toolchain-prefix is the prefix of the cross-compilation tools, i.e
23 # 'arm-linux-' if the cross-compiler executable is 'arm-linux-gcc'.
25 # architecture is the lower-cased name of the architecture targetted
26 # by the Buildroot project.
28 if test $# -ne 3; then
29 echo "Invalid number of arguments."
30 echo "Usage: $0 project-directory toolchain-prefix architecture"
31 exit 1
34 project_directory=$1
35 toolchain_prefix=$2
36 architecture=$3
38 if test ! -d ${project_directory} ; then
39 echo "Non-existing project directory ${project_directory}"
40 exit 1
43 if test ! -d ${project_directory}/host ; then
44 echo "Your project directory does not look like a Buildroot output"
45 exit 1
48 if test ! -e ${project_directory}/host/usr/bin/${toolchain_prefix}gcc ; then
49 echo "Cannot find the cross-compiler in the project directory"
50 exit 1
53 TOOLCHAIN_ECLIPSE_FILE=${HOME}/.buildroot-eclipse.toolchains
55 # First, we remove all lines from the ${TOOLCHAIN_ECLISPE_FILE} that
56 # correspond to toolchains that no longer exist.
57 if test -f ${TOOLCHAIN_ECLIPSE_FILE} ; then
58 mv ${TOOLCHAIN_ECLIPSE_FILE} ${TOOLCHAIN_ECLIPSE_FILE}.tmp
59 cat ${TOOLCHAIN_ECLIPSE_FILE}.tmp | while read toolchain ; do
60 path=$(echo ${toolchain} | cut -f1 -d ':')
61 # Filter lines corresponding to still existing projects
62 echo "Testing ${path} ..."
63 if ! test -d ${path} ; then
64 continue
66 # .. and the current project
67 if test ${path} = ${project_directory} ; then
68 continue
70 echo ${toolchain} >> ${TOOLCHAIN_ECLIPSE_FILE}
71 done
72 rm ${TOOLCHAIN_ECLIPSE_FILE}.tmp
75 # Add the toolchain
76 echo "${project_directory}:${toolchain_prefix}:${architecture}" >> ${TOOLCHAIN_ECLIPSE_FILE}