Move subarch and maching maps to bottom of arch files, since the classes aren't defin...
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 00:59:23 +0000 (18:59 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 00:59:23 +0000 (18:59 -0600)
14 files changed:
ChangeLog
modules/catalyst/arch/__init__.py
modules/catalyst/arch/alpha.py
modules/catalyst/arch/amd64.py
modules/catalyst/arch/arm.py
modules/catalyst/arch/hppa.py
modules/catalyst/arch/ia64.py
modules/catalyst/arch/mips.py
modules/catalyst/arch/powerpc.py
modules/catalyst/arch/s390.py
modules/catalyst/arch/sh.py
modules/catalyst/arch/sparc.py
modules/catalyst/arch/x86.py
modules/generic_stage_target.py

index 957bfdf23e931a2186f04dafb4b3ebe23fafa32b..814316b719db5d59d36b7918c5cc2fe72113b9cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,17 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+  modules/catalyst/arch/__init__.py, modules/catalyst/arch/alpha.py,
+  modules/catalyst/arch/amd64.py, modules/catalyst/arch/arm.py,
+  modules/catalyst/arch/hppa.py, modules/catalyst/arch/ia64.py,
+  modules/catalyst/arch/mips.py, modules/catalyst/arch/powerpc.py,
+  modules/catalyst/arch/s390.py, modules/catalyst/arch/sh.py,
+  modules/catalyst/arch/sparc.py, modules/catalyst/arch/x86.py,
+  modules/generic_stage_target.py:
+  Move subarch and maching maps to bottom of arch files, since the classes
+  aren't defined yet at the top
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/arch/sh.py:
   Forgot the sh arch module
index e4de205d6fa5395b2f3f0270d94b937d7b84c907..d907e25b952073301dd180dc12619066cc30eff7 100644 (file)
@@ -32,13 +32,10 @@ class arches:
        def find_arch_modules(self):
                search_dir = os.path.abspath(os.path.dirname(__file__))
                arch_module_list = [x[:-3] for x in os.listdir(search_dir) \
-                       if x.endswith('.py')]
+                       if x.endswith('.py') and not x.startswith('__')]
                return arch_module_list
 
        def get_arches(self):
-               self.archmap = {}
-               self.subarchmap = {}
-               machinemap = {}
                # We don't know if this works yet
 #              for x in self.find_arch_modules():
                for x in __arch_module_list:
@@ -47,4 +44,4 @@ class arches:
                                msg("Cannot import catalyst.arch." + x + ". This usually only " + \
                                        "happens due to a syntax error, which should be reported as " \
                                        "a bug.")
-
+               return self.__arch_modules
index b700392856dc4396c3919ed0f5f39c3e00a4b955..f5e19ee628743946ee3abf35288798df6d40c58c 100644 (file)
@@ -2,19 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "alpha": arch_alpha,
-       "ev4": arch_ev4,
-       "ev45": arch_ev45,
-       "ev5": arch_ev5,
-       "ev56": arch_ev56,
-       "pca56": arch_pca56,
-       "ev6": arch_ev6,
-       "ev67": arch_ev67
-}
-
-__machine_map = ("alpha", )
-
 class generic_alpha(builder.generic):
        "abstract base class for all alpha builders"
        def __init__(self,myspec):
@@ -79,3 +66,16 @@ class arch_ev67(generic_alpha):
                self.settings["CFLAGS"]+=" -O2 -mcpu=ev67"
                self.settings["CHOST"]="alphaev67-unknown-linux-gnu"
                self.settings["HOSTUSE"]=["ev6"]
+
+__subarch_map = {
+       "alpha": arch_alpha,
+       "ev4": arch_ev4,
+       "ev45": arch_ev45,
+       "ev5": arch_ev5,
+       "ev56": arch_ev56,
+       "pca56": arch_pca56,
+       "ev6": arch_ev6,
+       "ev67": arch_ev67
+}
+
+__machine_map = ("alpha", )
index 1501a12e9a8185d68cf00add7ad47c4c54c4c108..450e56a69c2c0cddfd6d378df68ff13697d72dfc 100644 (file)
@@ -1,24 +1,6 @@
 
 import builder
 
-__subarch_map = {
-       "amd64"         : arch_amd64,
-       "k8"            : arch_k8,
-       "opteron"       : arch_k8,
-       "athlon64"      : arch_k8,
-       "athlonfx"      : arch_k8,
-       "nocona"        : arch_nocona,
-# uncomment when gcc 4.3 is stable and delete this line
-#      "core2"         : arch_core2,
-#      "k8-sse3"       : arch_k8_sse3,
-#      "opteron-sse3"  : arch_k8_sse3,
-#      "athlon64-sse3" : arch_k8_sse3,
-#      "amdfam10"      : arch_amdfam10,
-#      "barcelona"     : arch_amdfam10
-}
-
-__machine_map = ("x86_64","amd64","nocona")
-
 class generic_amd64(builder.generic):
        "abstract base class for all amd64 builders"
        def __init__(self,myspec):
@@ -71,3 +53,22 @@ class arch_amdfam10(generic_amd64):
                self.settings["CFLAGS"]="-O2 -march=amdfam10 -pipe"
                self.settings["CHOST"]="x86_64-pc-linux-gnu"
                self.settings["HOSTUSE"]=["mmx","sse","sse2","3dnow"]
+
+__subarch_map = {
+       "amd64"         : arch_amd64,
+       "k8"            : arch_k8,
+       "opteron"       : arch_k8,
+       "athlon64"      : arch_k8,
+       "athlonfx"      : arch_k8,
+       "nocona"        : arch_nocona,
+# uncomment when gcc 4.3 is stable and delete this line
+#      "core2"         : arch_core2,
+#      "k8-sse3"       : arch_k8_sse3,
+#      "opteron-sse3"  : arch_k8_sse3,
+#      "athlon64-sse3" : arch_k8_sse3,
+#      "amdfam10"      : arch_amdfam10,
+#      "barcelona"     : arch_amdfam10
+}
+
+__machine_map = ("x86_64","amd64","nocona")
+
index 3d875a74946d7d7ce238312b90c213826e537c20..0b47b51755ee218d612b5fa876eac2e1da0417ac 100644 (file)
@@ -2,15 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "arm"    : arch_arm,
-       "armv4l" : arch_armv4l,
-       "armeb"  : arch_armeb,
-       "armv5b" : arch_armv5b
-}
-
-__machine_map = ("arm", "armv4l", "armeb", "armv5b", "armv5tel")
-
 class generic_arm(builder.generic):
        "Abstract base class for all arm (little endian) builders"
        def __init__(self,myspec):
@@ -52,3 +43,13 @@ class arch_armv5b(generic_arm):
                generic_arm.__init__(self,myspec)
                self.settings["CFLAGS"]+=" -mcpu=xscale"
                self.settings["CHOST"]="armv5b-unknown-linux-gnu"
+
+       "arm"    : arch_arm,
+       "armv4l" : arch_armv4l,
+       "armeb"  : arch_armeb,
+       "armv5b" : arch_armv5b
+}
+
+__machine_map = ("arm", "armv4l", "armeb", "armv5b", "armv5tel")
+
+
index ce30035c5a7aa9b47261952e502d53b2f9255a8a..548a048f5035c8f39c9aaa77f3b75ca29a77efcc 100644 (file)
@@ -2,14 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "hppa":         arch_hppa,
-       "hppa1.1":      arch_hppa1_1,
-       "hppa2.0":      arch_hppa2_0
-}
-
-__machine_map = ("parisc","parisc64","hppa","hppa64")
-
 class generic_hppa(builder.generic):
        "Abstract base class for all hppa builders"
        def __init__(self,myspec):
@@ -38,3 +30,12 @@ class arch_hppa2_0(generic_hppa):
                generic_hppa.__init__(self,myspec)
                self.settings["CFLAGS"]+=" -march=2.0"
                self.settings["CHOST"]="hppa2.0-unknown-linux-gnu"
+
+__subarch_map = {
+       "hppa":         arch_hppa,
+       "hppa1.1":      arch_hppa1_1,
+       "hppa2.0":      arch_hppa2_0
+}
+
+__machine_map = ("parisc","parisc64","hppa","hppa64")
+
index 5e17cca8765f9732ca9084d6fda78217b709c606..674d9faaa78bb073f242706560a9b4c6c3f381dd 100644 (file)
@@ -2,12 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "ia64": arch_ia64
-}
-
-__machine_map = ("ia64", )
-
 class arch_ia64(builder.generic):
        "builder class for ia64"
        def __init__(self,myspec):
@@ -16,3 +10,10 @@ class arch_ia64(builder.generic):
                self.settings["CFLAGS"]="-O2 -pipe"
                self.settings["CFLAGS"]="-O2 -pipe"
                self.settings["CHOST"]="ia64-unknown-linux-gnu"
+
+__subarch_map = {
+       "ia64": arch_ia64
+}
+
+__machine_map = ("ia64", )
+
index ee4c06492ec3e764fd86e9cbf8a0f4735797645e..55638449c426757f3d898c2e754dfab0f1645c67 100644 (file)
@@ -2,35 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = { 
-       "cobalt"                : arch_cobalt,
-       "cobalt_n32"    : arch_cobalt_n32,
-       "ip27"                  : arch_ip27,
-       "ip27_n32"              : arch_ip27_n32,
-       "ip28"                  : arch_ip28,
-       "ip28_n32"              : arch_ip28_n32,
-       "ip30"                  : arch_ip30,
-       "ip30_n32"              : arch_ip30_n32,
-       "mips"                  : arch_mips1,
-       "mips1"                 : arch_mips1,
-       "mips2"                 : arch_mips2,
-       "mips3"                 : arch_mips3,
-       "mips3_n32"             : arch_mips3_n32,
-       "mips3_n64"             : arch_mips3_n64,
-       "mips4"                 : arch_mips4,
-       "mips4_n32"             : arch_mips4_n32,
-       "mipsel"                : arch_mipsel1,
-       "mipsel1"               : arch_mipsel1,
-       "mipsel2"               : arch_mipsel2,
-       "mipsel3"               : arch_mipsel3,
-       "mipsel3_n32"   : arch_mipsel3_n32,
-       "mipsel4"               : arch_mipsel4,
-       "mipsel4_n32"   : arch_mipsel4_n32,
-       "loongson"              : arch_mipsel3,
-}
-
-__machine_map = ("mips","mips64")
-
 class generic_mips(builder.generic):
        "Abstract base class for all mips builders [Big-endian]"
        def __init__(self,myspec):
@@ -191,3 +162,33 @@ class arch_ip30_n32(generic_mipsel):
        def __init__(self,myspec):
                arch_mips4_n32.__init__(self,myspec)
                self.settings["HOSTUSE"]=["ip30","n32"]
+
+__subarch_map = { 
+       "cobalt"                : arch_cobalt,
+       "cobalt_n32"    : arch_cobalt_n32,
+       "ip27"                  : arch_ip27,
+       "ip27_n32"              : arch_ip27_n32,
+       "ip28"                  : arch_ip28,
+       "ip28_n32"              : arch_ip28_n32,
+       "ip30"                  : arch_ip30,
+       "ip30_n32"              : arch_ip30_n32,
+       "mips"                  : arch_mips1,
+       "mips1"                 : arch_mips1,
+       "mips2"                 : arch_mips2,
+       "mips3"                 : arch_mips3,
+       "mips3_n32"             : arch_mips3_n32,
+       "mips3_n64"             : arch_mips3_n64,
+       "mips4"                 : arch_mips4,
+       "mips4_n32"             : arch_mips4_n32,
+       "mipsel"                : arch_mipsel1,
+       "mipsel1"               : arch_mipsel1,
+       "mipsel2"               : arch_mipsel2,
+       "mipsel3"               : arch_mipsel3,
+       "mipsel3_n32"   : arch_mipsel3_n32,
+       "mipsel4"               : arch_mipsel4,
+       "mipsel4_n32"   : arch_mipsel4_n32,
+       "loongson"              : arch_mipsel3,
+}
+
+__machine_map = ("mips","mips64")
+
index 1e898329c62579526e05a0c9ba2ff52b4c760cac..ed0d9f88f499ca84edf4eaf3b56c3b68f6019e21 100644 (file)
@@ -2,24 +2,6 @@
 import os,builder
 from catalyst_support import *
 
-__subarch_map = {
-       "970"           : arch_970,
-       "cell"          : arch_cell,
-       "g3"            : arch_g3,
-       "g4"            : arch_g4,
-       "g5"            : arch_g5,
-       "power"         : arch_power,
-       "power-ppc"     : arch_power_ppc,
-       "power3"        : arch_power3,
-       "power4"        : arch_power4,
-       "power5"        : arch_power5,
-       "power6"        : arch_power6,
-       "ppc"           : arch_ppc,
-       "ppc64"         : arch_ppc64
-}
-
-__machine_map = ("ppc","ppc64","powerpc","powerpc64")
-
 class generic_ppc(builder.generic):
        "abstract base class for all 32-bit powerpc builders"
        def __init__(self,myspec):
@@ -122,3 +104,22 @@ class arch_power6(arch_ppc64):
                arch_ppc64.__init__(self,myspec)
                self.settings["CFLAGS"]="-O2 -pipe -mcpu=power6 -mtune=power6"
                self.settings["HOSTUSE"]=["altivec","ibm"]
+
+__subarch_map = {
+       "970"           : arch_970,
+       "cell"          : arch_cell,
+       "g3"            : arch_g3,
+       "g4"            : arch_g4,
+       "g5"            : arch_g5,
+       "power"         : arch_power,
+       "power-ppc"     : arch_power_ppc,
+       "power3"        : arch_power3,
+       "power4"        : arch_power4,
+       "power5"        : arch_power5,
+       "power6"        : arch_power6,
+       "ppc"           : arch_ppc,
+       "ppc64"         : arch_ppc64
+}
+
+__machine_map = ("ppc","ppc64","powerpc","powerpc64")
+
index 1c6e425aec7d24407b14c42826ee2079eb77817f..f12ee55fd74c9580ea9c66b3e790d743039b2dfc 100644 (file)
@@ -2,13 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "s390": arch_s390,
-       "s390x": arch_s390x
-}
-
-__machine_map = ("s390", "s390x")
-
 class generic_s390(builder.generic):
        "abstract base class for all s390 builders"
        def __init__(self,myspec):
@@ -34,3 +27,11 @@ class arch_s390x(generic_s390x):
                generic_s390x.__init__(self,myspec)
                self.settings["CFLAGS"]="-O2 -pipe"
                self.settings["CHOST"]="s390x-ibm-linux-gnu"
+
+__subarch_map = {
+       "s390": arch_s390,
+       "s390x": arch_s390x
+}
+
+__machine_map = ("s390", "s390x")
+
index fca9f89ad4b8e5518fe533b198405f35dce7a986..d3a682bb030c7f1b5f9bc346da07cda591e6b978 100644 (file)
@@ -2,19 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "sh"    :arch_sh,
-       "sh2"   :arch_sh2,
-       "sh3"   :arch_sh3,
-       "sh4"   :arch_sh4,
-       "sheb"  :arch_sheb,
-       "sh2eb" :arch_sh2eb,
-       "sh3eb" :arch_sh3eb,
-       "sh4eb" :arch_sh4eb
-}
-
-__machine_map = ("sh2","sh3","sh4","sh2eb","sh3eb","sh4eb")
-
 class generic_sh(builder.generic):
        "Abstract base class for all sh builders [Little-endian]"
        def __init__(self,myspec):
@@ -82,3 +69,17 @@ class arch_sh4eb(generic_sheb):
                generic_sheb.__init__(self,myspec)
                self.settings["CFLAGS"]="-O2 -m4 -pipe"
                self.settings["CHOST"]="sh4eb-unknown-linux-gnu"
+
+__subarch_map = {
+       "sh"    :arch_sh,
+       "sh2"   :arch_sh2,
+       "sh3"   :arch_sh3,
+       "sh4"   :arch_sh4,
+       "sheb"  :arch_sheb,
+       "sh2eb" :arch_sh2eb,
+       "sh3eb" :arch_sh3eb,
+       "sh4eb" :arch_sh4eb
+}
+
+__machine_map = ("sh2","sh3","sh4","sh2eb","sh3eb","sh4eb")
+
index 558d1015c11842efe109c2a4faabfb18fa941478..2c801efd326ed1efea98dbcda07bc25dab97699e 100644 (file)
@@ -2,13 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "sparc"         : arch_sparc,
-       "sparc64"       : arch_sparc64
-}
-
-__machine_map = ("sparc","sparc64")
-
 class generic_sparc(builder.generic):
        "abstract base class for all sparc builders"
        def __init__(self,myspec):
@@ -40,3 +33,11 @@ class arch_sparc64(generic_sparc64):
                generic_sparc64.__init__(self,myspec)
                self.settings["CFLAGS"]="-O2 -mcpu=ultrasparc -pipe"
                self.settings["CHOST"]="sparc-unknown-linux-gnu"
+
+__subarch_map = {
+       "sparc"         : arch_sparc,
+       "sparc64"       : arch_sparc64
+}
+
+__machine_map = ("sparc","sparc64")
+
index 1db259d54ef0d6ecd820bf7ec4f874622c009605..41b873ea8eb383c9787b67b196f2dcaf6a001919 100644 (file)
@@ -2,34 +2,6 @@
 import builder,os
 from catalyst_support import *
 
-__subarch_map = {
-       "x86"                   : arch_x86,
-       "i386"                  : arch_i386,
-       "i486"                  : arch_i486,
-       "i586"                  : arch_i586,
-       "i686"                  : arch_i686,
-       "pentium"               : arch_i586,
-       "pentium2"              : arch_pentium2,
-       "pentium3"              : arch_pentium3,
-       "pentium3m"             : arch_pentium3,
-       "pentium-m"             : arch_pentium_m,
-       "pentium4"              : arch_pentium4,
-       "pentium4m"             : arch_pentium4,
-       "pentiumpro"            : arch_i686,
-       "pentium-mmx"           : arch_pentium_mmx,
-       "prescott"              : arch_prescott,
-       "k6"                    : arch_k6,
-       "k6-2"                  : arch_k6_2,
-       "k6-3"                  : arch_k6_2,
-       "athlon"                : arch_athlon,
-       "athlon-tbird"          : arch_athlon,
-       "athlon-4"              : arch_athlon_xp,
-       "athlon-xp"             : arch_athlon_xp,
-       "athlon-mp"             : arch_athlon_xp
-}
-
-__machine_map = ('i386', 'i486', 'i586', 'i686')
-
 class generic_x86(builder.generic):
        "abstract base class for all x86 builders"
        def __init__(self,myspec):
@@ -150,3 +122,32 @@ class arch_athlon_xp(generic_x86):
                self.settings["CFLAGS"]="-O2 -march=athlon-xp -pipe"
                self.settings["CHOST"]="i686-pc-linux-gnu"
                self.settings["HOSTUSE"]=["mmx","3dnow","sse"]
+
+__subarch_map = {
+       "x86"                   : arch_x86,
+       "i386"                  : arch_i386,
+       "i486"                  : arch_i486,
+       "i586"                  : arch_i586,
+       "i686"                  : arch_i686,
+       "pentium"               : arch_i586,
+       "pentium2"              : arch_pentium2,
+       "pentium3"              : arch_pentium3,
+       "pentium3m"             : arch_pentium3,
+       "pentium-m"             : arch_pentium_m,
+       "pentium4"              : arch_pentium4,
+       "pentium4m"             : arch_pentium4,
+       "pentiumpro"            : arch_i686,
+       "pentium-mmx"           : arch_pentium_mmx,
+       "prescott"              : arch_prescott,
+       "k6"                    : arch_k6,
+       "k6-2"                  : arch_k6_2,
+       "k6-3"                  : arch_k6_2,
+       "athlon"                : arch_athlon,
+       "athlon-tbird"          : arch_athlon,
+       "athlon-4"              : arch_athlon_xp,
+       "athlon-xp"             : arch_athlon_xp,
+       "athlon-mp"             : arch_athlon_xp
+}
+
+__machine_map = ('i386', 'i486', 'i586', 'i686')
+
index f6c55d5e3b96300bef9e86965f3f92e79574bc0c..8cbed1ba38edf8cfab04e60b7e1e31f0e0430a06 100644 (file)
@@ -9,6 +9,7 @@ from catalyst_support import *
 from generic_target import *
 from stat import *
 import catalyst_lock
+import catalyst.arch
 
 class generic_stage_target(generic_target):
 
@@ -51,35 +52,14 @@ class generic_stage_target(generic_target):
                self.archmap = {}
                self.subarchmap = {}
                machinemap = {}
-               for x in [x[:-3] for x in os.listdir(self.settings["sharedir"]+\
-                       "/arch/") if x.endswith(".py")]:
-                       try:
-                               fh=open(self.settings["sharedir"]+"/arch/"+x+".py")
-                               """
-                               This next line loads the plugin as a module and assigns it to
-                               archmap[x]
-                               """
-                               self.archmap[x]=imp.load_module(x,fh,"arch/"+x+\
-                                       ".py",(".py","r",imp.PY_SOURCE))
-                               """
-                               This next line registers all the subarches supported in the
-                               plugin
-                               """
-                               tmpsubarchmap, tmpmachinemap = self.archmap[x].register()
-                               self.subarchmap.update(tmpsubarchmap)
-                               for machine in tmpmachinemap:
-                                       machinemap[machine] = x
-                               for subarch in tmpsubarchmap:
-                                       machinemap[subarch] = x
-                               fh.close()
-                       except IOError:
-                               """
-                               This message should probably change a bit, since everything in
-                               the dir should load just fine. If it doesn't, it's probably a
-                               syntax error in the module
-                               """
-                               msg("Can't find/load "+x+".py plugin in "+\
-                                       self.settings["sharedir"]+"/arch/")
+               arches = catalyst.arch.arches()
+               for x in arches.get_arches():
+                       tmpsubarchmap, tmpmachinemap = self.archmap[x].register()
+                       self.subarchmap.update(x.__subarch_map)
+                       for machine in x.__machine_map:
+                               machinemap[machine] = x
+                       for subarch in x.__subarch_map:
+                               machinemap[subarch] = x
 
                if self.settings.has_key("chost"):
                        hostmachine = self.settings["chost"].split("-")[0]