Re: [PATCH] toolchain/build: Support linaro android toolchain

2011-03-10 Thread Jim Huang
On 9 March 2011 15:35, Meng-Hsuan Cheng  wrote:
> Add linaro-build.sh to support linaro android toolchain.

Merged (along with slight syntax tweak) in GIT:
http://git.linaro.org/gitweb?p=android/platform/build.git;a=summary

Thanks for your contribution.

Sincerely,
-jserv

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH] toolchain/build: Support linaro android toolchain

2011-03-08 Thread Meng-Hsuan Cheng
Add linaro-build.sh to support linaro android toolchain.
--prefix=   Specify where to install (default:
/tmp/android-toolchain-eabi)
--toolchain-src=Specify Android toolchain source dir (default:
/../)
--with-gcc= Specify GCC source (support: directory, bzr, url)
--apply-gcc-patch=(yes|no)   Apply gcc-patches (default: no)
--help  Print help message

Change-Id: I15478ba3b3dd4f49be3767724028e4e4dcade1ca
---
 linaro-build.sh |  195
+++
 1 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100755 linaro-build.sh

diff --git a/linaro-build.sh b/linaro-build.sh
new file mode 100755
index 000..57266dd
--- /dev/null
+++ b/linaro-build.sh
@@ -0,0 +1,195 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Linaro
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+ARG_PREFIX_DIR=/tmp/android-toolchain-eabi
+ARG_TOOLCHAIN_SRC_DIR=${PWD%/build}
+
+ARG_LINARO_GCC_SRC_DIR=
+ARG_WGET_LINARO_GCC_SRC=
+ARG_BZR_LINARO_GCC_SRC=
+
+ARG_WITH_GCC=
+
+ARG_APPLY_PATCH=no
+
+abort() {
+  echo $@
+  exec false
+}
+
+error() {
+  abort "[ERROR] $@"
+}
+
+warn() {
+  echo "[WARNING] $@"
+}
+
+info() {
+  echo "[INFO] $@"
+}
+
+note() {
+  echo "[NOTE] $@"
+}
+
+usage() {
+  echo
""
+  echo "--prefix=   Specify where to install (default:
/tmp/android-toolchain-eabi)"
+  echo "--toolchain-src=Specify Android toolchain source dir (default:
/../)"
+  echo "--with-gcc= Specify GCC source (support: directory, bzr,
url)"
+  echo "--apply-gcc-patch=(yes|no)   Apply gcc-patches (default: no)"
+  echo "--help  Print help message"
+  echo
""
+}
+
+ARG_LINARO_GCC_SRC_DIR=
+
+
+downloadFormBZR() {
+  local MY_LP_LINARO_GCC=$1
+  ARG_LINARO_GCC_SRC_DIR=${MY_LP_LINARO_GCC#*:}
+
+  [ ! -d ${ARG_TOOLCHAIN_SRC_DIR}/gcc ] && mkdir -p
"${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+  if [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}" ];
then
+info "Use bzr to clone ${MY_LP_LINARO_GCC}"
+RUN=`bzr clone ${MY_LP_LINARO_GCC}
${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}`
+[ $? -ne 0 ] && error "bzr ${MY_LP_LINARO_GCC} error"
+  else
+info "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR} is already
exist, skip bzr clone"
+  fi
+}
+
+downloadFormHTTP() {
+  info "Use wget to get $1"
+  local MY_LINARO_GCC_FILE=`basename $1`
+  if [ -f "${MY_LINARO_GCC_FILE}" ]; then
+#TODO: Add md5 check
+info "${MY_LINARO_GCC_FILE} is already exist, skip download"
+  else
+RUN=`wget $1`
+[ $? -ne 0 ] && error "wget $1 error"
+#TODO: Add md5 check
+  fi
+
+  ARG_LINARO_GCC_SRC_DIR=`basename ${MY_LINARO_GCC_FILE} .tar.bz2`
+  [ ! -d ${ARG_TOOLCHAIN_SRC_DIR}/gcc ] && mkdir -p
"${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+  if [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}" ];
then
+info "untar ${MY_LINARO_GCC_FILE} to ${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+tar jxf ${MY_LINARO_GCC_FILE} -C ${ARG_TOOLCHAIN_SRC_DIR}/gcc
+  else
+info "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR} is already
exist, skip untar"
+  fi
+}
+
+getGCCFrom() {
+  # set empty to detect error
+  ARG_LINARO_GCC_SRC_DIR=
+  ARG_LINARO_GCC_VER=
+
+  case $1 in
+lp:*) # bzr clone lp:gcc-linaro
+  downloadFormBZR $1
+  ;;
+http://*) # snapshot url
http://launchpad.net/gcc-linaro/4.5/4.5-2011.02-0/+download/gcc-linaro-4.5-2011.02-0.tar.bz2
+  downloadFormHTTP $1
+  ;;
+*) # local directory
+  [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/$1" ] && error
"$ARG_TOOLCHAIN_SRC_DIR/gcc/$ARG_LINARO_GCC_SRC_DIR not exist"
+  ARG_LINARO_GCC_SRC_DIR=$1
+  esac
+
+  ARG_LINARO_GCC_VER=`echo ${ARG_LINARO_GCC_SRC_DIR} | grep -o "4\.[5-9]"`
+  if [ ${ARG_LINARO_GCC_VER} = "" ]; then
+warn "Cannot detect version for ${ARG_LINARO_GCC_VER}, 4.5 is used"
+ARG_LINARO_GCC_VER=4.5
+  fi
+}
+
+while [ $# -gt 0 ]; do
+  ARG=$1
+  ARG_PARMS="$ARG_PARMS '$ARG'"
+  shift
+  case "$ARG" in
+--prefix=*)
+  ARG_PREFIX_DIR="${ARG#*=}"
+  ;;
+--toolchain-src=*)
+  ARG_TOOLCHAIN_SRC_DIR="${ARG#*=}"
+  ;;
+--with-gcc=*)
+  ARG_WITH_GCC="${ARG#*=}"
+  ;;
+--apply-gcc-patch=yes | --apply-gcc-patch=no)
+  ARG_APPLY_PATCH="${ARG#*=}"
+  ;;
+--help)
+  usage && abort
+  ;;
+*)
+  error "Unrecognized parameter $ARG"
+  ;;
+  esac
+done
+
+BUILD_ARCH=`uname -m`
+BUILD_WITH_LOCAL=
+BUILD_H