Integration with Buildroot Toolchain Eclipse plugin
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 13 Jan 2013 04:52:13 +0000 (04:52 +0000)
committerPeter Korsgaard <jacmet@sunsite.dk>
Mon, 14 Jan 2013 15:33:30 +0000 (16:33 +0100)
The Eclipse plugin at
https://github.com/mbats/eclipse-buildroot-toolchain-plugin allows
users of Eclipse to easily use the toolchain available in
Buildroot. To do so, this plugin reads
~/.buildroot-eclipse.toolchains, which contains the list of Buildroot
toolchains available on the system, and then offer those toolchains to
compile Eclipse projects.

In order to interface with this plugin, this commit adds an option
that allows the user to tell whether (s)he wants the Buildroot project
toolchain to be visible under this Eclipse plugin. It simply adds a
line in this ~/.buildroot-eclipse.toolchains file.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Makefile
support/scripts/eclipse-register-toolchain [new file with mode: 0755]
toolchain/toolchain-common.in

index f40863247d9c7b06dbc9d3e22ff3b41e9250780d..1fc51e9cbd38f2bc19a8a850f2427ebb3cff7d88 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -347,6 +347,10 @@ TARGETS+=target-generatelocales
 endif
 endif
 
+ifeq ($(BR2_ECLIPSE_REGISTER),y)
+TARGETS+=toolchain-eclipse-register
+endif
+
 include fs/common.mk
 
 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
@@ -542,6 +546,9 @@ target-generatelocales: host-localedef
        done
 endif
 
+toolchain-eclipse-register:
+       ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
+
 source: dirs $(TARGETS_SOURCE) $(HOST_SOURCE)
 
 external-deps:
diff --git a/support/scripts/eclipse-register-toolchain b/support/scripts/eclipse-register-toolchain
new file mode 100755 (executable)
index 0000000..dd9f158
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+project_directory=$1
+toolchain_prefix=$2
+architecture=$3
+
+TOOLCHAIN_ECLIPSE_FILE=${HOME}/.buildroot-eclipse.toolchains
+
+if test -f ${TOOLCHAIN_ECLIPSE_FILE} ; then
+    mv ${TOOLCHAIN_ECLIPSE_FILE} ${TOOLCHAIN_ECLIPSE_FILE}.tmp
+    cat ${TOOLCHAIN_ECLIPSE_FILE}.tmp | while read toolchain ; do
+       path=$(echo ${toolchain} | cut -f1 -d ':')
+        # Filter lines corresponding to still existing projects
+       echo "Testing ${path} ..."
+       if ! test -d ${path} ; then
+           continue
+       fi
+       # .. and the current project
+       if test ${path} = ${project_directory} ; then
+           continue
+       fi
+       echo ${toolchain} >> ${TOOLCHAIN_ECLIPSE_FILE}
+    done
+    rm ${TOOLCHAIN_ECLIPSE_FILE}.tmp
+fi
+
+# Add the toolchain
+echo "${project_directory}:${toolchain_prefix}:${architecture}" >> ${TOOLCHAIN_ECLIPSE_FILE}
index 9f11a3984ced7e98a6c899c6fab6e459af5ec545..f6905ae2318b8b242597b9caaff7e9f314d52fdf 100644 (file)
@@ -131,3 +131,10 @@ config BR2_TARGET_LDFLAGS
        string "Target linker options"
        help
          Extra options to pass to the linker when building for the target.
+
+config BR2_ECLIPSE_REGISTER
+       bool "Register toolchain within Eclipse Buildroot plug-in"
+       help
+         This options tells Buildroot to generate the necessary
+         configuration files to make your toolchain appear within
+         Eclipse, through the Eclipse Buildroot plugin.