From 66ff85a04873f307baeed7c0d2c92e195bda4b96 Mon Sep 17 00:00:00 2001
From: Marcin Juszkiewicz <hrw@openedhand.com>
Date: Thu, 3 Jan 2008 14:07:44 +0000
Subject: base and sanity bbclasses + qemu: move gcc3 availability checking
 into base.bbclass

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3402 311d38ba-8fff-0310-9ca6-ca027cbcb966
---
 meta/classes/base.bbclass              | 17 +++++++++++++++++
 meta/classes/sanity.bbclass            | 10 +---------
 meta/packages/qemu/qemu-gcc3-check.inc | 17 +++--------------
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index d4cae4931..816f872f0 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -897,6 +897,23 @@ python () {
     base_after_parse(d)
 }
 
+def check_app_exists(app, d):
+	from bb import which, data
+
+	app = data.expand(app, d)
+	path = data.getVar('PATH', d)
+	return len(which(path, app)) != 0
+
+def check_gcc3(data):
+
+	gcc3_versions = 'gcc-3.4 gcc34 gcc-3.4.4 gcc-3.4.6 gcc-3.4.7 gcc-3.3 gcc33 gcc-3.3.6 gcc-3.2 gcc32'
+
+	for gcc3 in gcc3_versions.split():
+		if check_app_exists(gcc3, data):
+			return gcc3
+	
+	return False
+
 # Patch handling
 inherit patch
 
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 8b5526075..957e24e1e 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -24,14 +24,6 @@ def check_conf_exists(fn, data):
 			return True
 	return False
 
-def check_app_exists(app, d):
-	from bb import which, data
-
-	app = data.expand(app, d)
-	path = data.getVar('PATH', d)
-	return len(which(path, app)) != 0
-
-
 def check_sanity(e):
 	from bb import note, error, data, __version__
 	from bb.event import Handled, NotHandled, getName
@@ -96,7 +88,7 @@ def check_sanity(e):
 	if "qemu-native" not in assume_provided:
 		gcc_version = commands.getoutput("${BUILD_PREFIX}gcc --version | head -n 1 | cut -f 3 -d ' '")
 
-		if not check_app_exists('gcc-3.4', e.data) and not check_app_exists('gcc-3.3', e.data) and gcc_version[0] != '3':
+		if not check_gcc3(e.data) and gcc_version[0] != '3':
 			missing = missing + "gcc-3.x (needed for qemu-native),"
 	else:
 		required_utilities = required_utilities + " qemu-arm"
diff --git a/meta/packages/qemu/qemu-gcc3-check.inc b/meta/packages/qemu/qemu-gcc3-check.inc
index 658e72ffc..81c3555b4 100644
--- a/meta/packages/qemu/qemu-gcc3-check.inc
+++ b/meta/packages/qemu/qemu-gcc3-check.inc
@@ -4,19 +4,8 @@ python __anonymous() {
     path = data.getVar('PATH', d, 1)
     oldOeConf = data.getVar('EXTRA_OECONF', d, 1)
     if not oldOeConf: oldOeConf = ""
-    if len(which(path, 'gcc-3.4.4')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc-3.4.4", d)
-    elif len(which(path, 'gcc-3.4')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc-3.4", d)
-    elif len(which(path, 'gcc34')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc34", d)
-    elif len(which(path, 'gcc33')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc33", d)
-    elif len(which(path, 'gcc-3.3')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc-3.3", d)
-    elif len(which(path, 'gcc-3.3.6')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc-3.3.6", d)
-    elif len(which(path, 'gcc-3.4.6')) != 0:
-        data.setVar('EXTRA_OECONF', oldOeConf + " --cc=gcc-3.4.6", d)
+    gcc3 = check_gcc3(d)
+    if gcc3:
+	data.setVar('EXTRA_OECONF', oldOeConf + " --cc=" + gcc3, d)
 }
 
-- 
cgit v1.2.3