[2/3] scripts/cc: get the right ecj for the gcc version.

Submitted by Bryan Hundven on Sept. 25, 2014, 11:19 a.m.

Details

Message ID 1411643977-3339-3-git-send-email-bryanhundven@gmail.com
State New
Headers show

Commit Message

Bryan Hundven Sept. 25, 2014, 11:19 a.m.
If we look at:
ftp://gcc.gnu.org/pub/java/

Not all ecj-{MAJOR.MINOR}.jar versions are the same.
Grabbing latest is also naive, as it is NOT the latest ;)

Since we also have to deal with linaro version numbers, add a helper
function to extract the version number in a common way.

Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
---
 scripts/build/cc/gcc.sh | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh
index 9dbc41e..3f6d94e 100644
--- a/scripts/build/cc/gcc.sh
+++ b/scripts/build/cc/gcc.sh
@@ -2,6 +2,15 @@ 
 # Copyright 2007 Yann E. MORIN
 # Licensed under the GPL v2. See COPYING in the root of this package
 
+# Discover the ecj version to get
+do_get_ecj_version() {
+    if [ "$(echo ${CT_CC_VERSION} | grep -o 'linaro')" = "linaro" ]; then
+        echo ${CT_CC_VERSION} | sed -r -e 's/linaro-([0-9]\.[0-9])-.*/\1/'
+    else
+        echo "${CT_CC_VERSION%.*}"
+    fi
+}
+
 # Download gcc
 do_cc_get() {
     local linaro_version
@@ -36,8 +45,9 @@  do_cc_get() {
     # GCC source tree, which will not be there unless we get it and
     # put it there ourselves
     if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
-        CT_GetFile ecj-latest .jar ftp://gcc.gnu.org/pub/java   \
-                                   ftp://sourceware.org/pub/java
+        CT_GetFile "ecj-$(do_get_ecj_version)" .jar \
+            ftp://gcc.gnu.org/pub/java              \
+            ftp://sourceware.org/pub/java
     fi
 }
 
@@ -56,7 +66,8 @@  do_cc_extract() {
     if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y"                     \
          -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"   \
        ]; then
-        CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"
+        CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-$(do_get_ecj_version).jar" \
+            "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"
     fi
 }