public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [rfc] simplifying arch classes
@ 2011-06-27  5:15 Matt Turner
  2011-06-27 17:41 ` Sebastian Pipping
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Turner @ 2011-06-27  5:15 UTC (permalink / raw
  To: gentoo-catalyst

The arch class structure ({alpha,amd64,mips,hppa,etc}.py files) are a
lot of typing for the small number of attributes they synthesize. This
makes them prone to typing errors.

Consider mips.py. It supports big and little endian; mips 1, 3, 4,
loongson, cobalt; o32, n32, n64, multilib ABIs. Almost every
combination of these attributes exists as a hard-coded class, leaving
us with 24 builder and 5 abstract base classes.

Wouldn't it be simpler to pass in some information into an arch_mips
class and let it generate the requested attributes. Something like
this:

class arch_mips(generic):
    "MIPS class"
    def __init__(self, Olevel, arch, additional_cflags, include_workarounds):
        generic.__init__(self)

        self.settings["CFLAGS"] = "-O" + Olevel
        self.settings["CFLAGS"] += " -march=" + arch
        if additional_cflags != "":
            self.settings["CFLAGS"] += " " + additional_cflags
        if include_workarounds:
            if arch == "mips3":
                self.settings["CFLAGS"] += " -mfix-r4000 -mfix-r4400"
            elif arch == "r4000" or arch == "r4k":
                self.settings["CFLAGS"] += " -mfix-r4000"
            elif arch == "r4300":
                self.settings["CFLAGS"] += " -mfix-r4300"
            elif arch == "r10000" or arch == "r10k":
                self.settings["CFLAGS"] += " -mfix-r10000"
        self.settings["CFLAGS"] += " -pipe"

Clearly a simplistic and incomplete example, but it should be enough
to understand the idea.

Thanks,
Matt



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-27 18:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-27  5:15 [gentoo-catalyst] [rfc] simplifying arch classes Matt Turner
2011-06-27 17:41 ` Sebastian Pipping
2011-06-27 17:58   ` Matt Turner
2011-06-27 18:18     ` Sebastian Pipping
2011-06-27 18:24       ` Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox