On Thu, Aug 17, 2006 at 08:53:25PM +1000, Jamie Lenehan wrote:
> Attached is a patch I'd like to propose to allow for multiple site
> files to be used so that common stuff can be moved into common site
[...]

Here's a slightly modified version that adds support for alias site
files. The patch as written adds an alias for i386-linux, i486-linux,
i586-linux and i686-linux of "ix86-linux", The alias site file is
then tried as the second site file - so it'd be "i686-linux" then
"ix86-linux" then the common site files. This should allow nearly all
the duplication with the x86 entries to be removed.

We have a similar siutation with arm-linux and arm-linux-gnueabi -
they are identical. So this patch adds an alias for arm-linux-gnueabi
of "arm-linux" so then the arm-linux-gnueabi site file isn't needed.

# 
# old_revision [ea4038ae0ee61090a3e49c8da9f589836593f82a]
# 
# add_file "classes/info.bbclass"
#  content [611f248f4923faecb82793c11e8f3f443d144408]
# 
# patch "classes/autotools.bbclass"
#  from [9467624c157cb8970b3658f48e7952ac0fa11fcc]
#    to [3e170fbb78f12caeb89ed4ef1b23e73dfef84684]
# 
============================================================
--- classes/info.bbclass        611f248f4923faecb82793c11e8f3f443d144408
+++ classes/info.bbclass        611f248f4923faecb82793c11e8f3f443d144408
@@ -0,0 +1,65 @@
+# info.bbclass
+#
+# This class exists to provide information about the targets that
+# may be needed by other classes and/or recipes. If you add a new
+# target this will probably need to be updated.
+#
+
+#
+# Returns information about 'what' for the named target 'target'
+# where 'target' == "<arch>-<os>"
+#
+# 'what' can be one of
+# * target: Returns the target name ("<arch>-<os>")
+# * endianess: Return "be" for big endian targets, "le" for little endian
+# * bits: Returns the bit size of the target, either "32" or "64"
+# * libc: Returns the name of the c library used by the target
+#
+# It is an error for the target not to exist.
+# If 'what' doesn't exist then an empty value is returned
+#
+def get_info_for_named_target(target, what, d):
+       import bb
+       targetinfo = {\
+               "armeb-linux":          dict(endianess="be", bits="32", 
libc="glibc" ),\
+               "armeb-linux-uclibc":   dict(endianess="be", bits="32", 
libc="uclibc"),\
+               "arm-linux":            dict(endianess="le", bits="32", 
libc="glibc" ),\
+               "arm-linux-gnueabi":    dict(endianess="le", bits="32", 
libc="gnueabi", alias="arm-linux"),\
+               "arm-linux-uclibc":     dict(endianess="le", bits="32", 
libc="uclibc" ),\
+               "i386-linux":           dict(endianess="le", bits="32", 
libc="glibc",  alias="ix86-linux"),\
+               "i486-linux":           dict(endianess="le", bits="32", 
libc="glibc",  alias="ix86-linux"),\
+               "i586-linux":           dict(endianess="le", bits="32", 
libc="glibc",  alias="ix86-linux"),\
+               "i686-linux":           dict(endianess="le", bits="32", 
libc="glibc",  alias="ix86-linux"),\
+               "i386-linux-uclibc":    dict(endianess="le", bits="32", 
libc="uclibc", alias="ix86-linux-uclibc"),\
+               "i486-linux-uclibc":    dict(endianess="le", bits="32", 
libc="uclibc", alias="ix86-linux-uclibc"),\
+               "i586-linux-uclibc":    dict(endianess="le", bits="32", 
libc="uclibc", alias="ix86-linux-uclibc"),\
+               "i686-linux-uclibc":    dict(endianess="le", bits="32", 
libc="uclibc", alias="ix86-linux-uclibc"),\
+               "mipsel-linux":         dict(endianess="le", bits="32", 
libc="glibc" ),\
+               "mipsel-linux-uclibc":  dict(endianess="le", bits="32", 
libc="uclibc"),\
+               "powerpc-darwin":       dict(endianess="be", bits="32", 
libc="darwin"),\
+               "powerpc-linux":        dict(endianess="be", bits="32", 
libc="glibc" ),\
+               "powerpc-linux-uclibc": dict(endianess="be", bits="32", 
libc="uclibc"),\
+               "sh3-linux":            dict(endianess="le", bits="32", 
libc="glibc" ),\
+               "sh4-linux":            dict(endianess="le", bits="32", 
libc="glibc" ),\
+               "sh4-linux-uclibc":     dict(endianess="le", bits="32", 
libc="uclibc"),\
+               "sparc-linux":          dict(endianess="be", bits="32", 
libc="glibc" ),\
+               "x86_64-linux":         dict(endianess="le", bits="64", 
libc="glibc" ),\
+               "x86_64-linux-uclibc":  dict(endianess="le", bits="64", 
libc="uclibc")}
+       if targetinfo.has_key(target):
+               info = targetinfo[target]
+               # allow them to ask for the target name
+               if what == "target":
+                       return target;
+               # otherwise get the information from the table
+               return info.get(what, "")
+       else:
+               bb.error("Information not available for target '%s'" % target)
+
+#
+# Returns information about 'what' for the current target
+#
+def get_info_for_target(what, d):
+       import bb
+       target = bb.data.getVar('HOST_ARCH', d, 1) + "-" + 
bb.data.getVar('HOST_OS', d, 1)
+       return get_info_for_named_target(target, what, d)
+
============================================================
--- classes/autotools.bbclass   9467624c157cb8970b3658f48e7952ac0fa11fcc
+++ classes/autotools.bbclass   3e170fbb78f12caeb89ed4ef1b23e73dfef84684
@@ -1,5 +1,44 @@
-inherit base
+inherit base info
 
+#
+# Define which site files to use. We check for several site files and use
+# each one that is found in the following order:
+#
+# 1) <arch>-<os>       - target specific settings
+# 2) <alias>           - target alias, if it has one
+# 3) common-(le|be)    - endianess specific settings
+# 4) common-(32|64)bits        - bit-size specific settings
+# 5) common-<libc>     - libc specified settings
+# 6) common            - common settings
+#
+def get_config_site_files(d):
+       import bb
+       sites = []
+       sites.append(get_info_for_target("target", d));
+       alias = get_info_for_target("alias", d)
+       if alias:
+               sites.append(alias);
+       sites.append("common-" + get_info_for_target("endianess", d));
+       sites.append("common-" + get_info_for_target("bits", d) + "bit");
+       sites.append("common-libc-" + get_info_for_target("libc", d));
+       sites.append("common");
+       path = bb.data.getVar('BBPATH', d, 1);
+       sitefiles = ""
+       for i in sites:
+               file = bb.which(path, 'site/%s' % i);
+               if file:
+                       sitefiles += file + " ";
+       bb.debug(1, "Sitefiles " + sitefiles);
+       return sitefiles
+
+#
+# Export CONFIG_SITE to the enviroment. The autotools will
+# make use of this to determine where to load in variables
+# from.
+#
+export CONFIG_SITE = "[EMAIL PROTECTED](d)}"
+
+
 def autotools_dep_prepend(d):
        import bb;
 

-- 
 Jamie Lenehan <[EMAIL PROTECTED]>
_______________________________________________
Oe mailing list
[email protected]
https://www.handhelds.org/mailman/listinfo/oe

Reply via email to