All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v5] toolchain: allow side by side sysroot directories
@ 2016-01-12 17:49 Vicente Olivert Riera
  2016-01-19 22:14 ` Thomas Petazzoni
  0 siblings, 1 reply; 2+ messages in thread
From: Vicente Olivert Riera @ 2016-01-12 17:49 UTC (permalink / raw)
  To: buildroot

Currently our toolchain infrastructure assumes that every toolchain has
nested sysroot directories. However that's not true for all of them. The
Codescape toolchains from Imagination Technologies use a side by side
sysroot structure, for instance.

This patch allows our toolchain infrastructure to detect what kind of
sysroot structure we have (nested or side by side) and performs the
appropriate actions.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
---
Changes v4 -> v5:
 - Add an echo to display what is being symlinked. (Suggested by Romain)
Changes v1 -> v4:
 - This patch didn't exist before. It has been introduced in v4.

 toolchain/helpers.mk | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 1452ec6..d55474b 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -142,18 +142,25 @@ copy_toolchain_sysroot = \
 				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 		fi ; \
 	done ; \
-	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
-		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
-			cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
-		fi ; \
-		mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
+	SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
+	ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+	if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
 		relpath="./" ; \
-		nbslashs=`printf $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
-		for slash in `seq 1 $${nbslashs}` ; do \
-			relpath=$${relpath}"../" ; \
-		done ; \
-		ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
-		echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
+		if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} == $${SYSROOT_DIR_CANON} ] ; then \
+			if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
+				cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
+			fi ; \
+			mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
+			nbslashs=`printf $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
+			for slash in `seq 1 $${nbslashs}` ; do \
+				relpath=$${relpath}"../" ; \
+			done ; \
+			ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
+			echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
+		elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname $${SYSROOT_DIR_CANON}` ] ; then \
+			ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \
+			echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
+		fi ; \
 	fi ; \
 	if test -n "$${SUPPORT_LIB_DIR}" ; then \
 		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
-- 
2.4.10

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Buildroot] [PATCH v5] toolchain: allow side by side sysroot directories
  2016-01-12 17:49 [Buildroot] [PATCH v5] toolchain: allow side by side sysroot directories Vicente Olivert Riera
@ 2016-01-19 22:14 ` Thomas Petazzoni
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2016-01-19 22:14 UTC (permalink / raw)
  To: buildroot

Dear Vicente Olivert Riera,

On Tue, 12 Jan 2016 17:49:38 +0000, Vicente Olivert Riera wrote:
> Currently our toolchain infrastructure assumes that every toolchain has
> nested sysroot directories. However that's not true for all of them. The
> Codescape toolchains from Imagination Technologies use a side by side
> sysroot structure, for instance.
> 
> This patch allows our toolchain infrastructure to detect what kind of
> sysroot structure we have (nested or side by side) and performs the
> appropriate actions.
> 
> Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
> Reviewed-by: Romain Naour <romain.naour@gmail.com>
> ---
> Changes v4 -> v5:
>  - Add an echo to display what is being symlinked. (Suggested by Romain)
> Changes v1 -> v4:
>  - This patch didn't exist before. It has been introduced in v4.

I've applied after updating the comment above the function to explain
what's going on. It's a pity we can't have inline comments in those big
shell blocks. Part of my mid-term goal is to move some of this crap to
helper shell scripts, which would simplify the syntax and allow the
addition of comments everywhere.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-19 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-12 17:49 [Buildroot] [PATCH v5] toolchain: allow side by side sysroot directories Vicente Olivert Riera
2016-01-19 22:14 ` Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.