From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-catalyst+bounces-2395-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1Qb4BC-0004yL-5I
	for garchives@archives.gentoo.org; Mon, 27 Jun 2011 05:16:14 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 00FAC1C013;
	Mon, 27 Jun 2011 05:15:53 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id C88871C013
	for <gentoo-catalyst@lists.gentoo.org>; Mon, 27 Jun 2011 05:15:53 +0000 (UTC)
Received: from mail-vw0-f53.google.com (mail-vw0-f53.google.com [209.85.212.53])
	(using TLSv1 with cipher RC4-SHA (128/128 bits))
	(No client certificate requested)
	(Authenticated sender: mattst88)
	by smtp.gentoo.org (Postfix) with ESMTPSA id 087C52AC00A
	for <gentoo-catalyst@lists.gentoo.org>; Mon, 27 Jun 2011 05:15:52 +0000 (UTC)
Received: by vws13 with SMTP id 13so3863791vws.40
        for <gentoo-catalyst@lists.gentoo.org>; Sun, 26 Jun 2011 22:15:51 -0700 (PDT)
Received: by 10.52.160.68 with SMTP id xi4mr7761489vdb.106.1309151751090; Sun,
 26 Jun 2011 22:15:51 -0700 (PDT)
Precedence: bulk
List-Post: <mailto:gentoo-catalyst@lists.gentoo.org>
List-Help: <mailto:gentoo-catalyst+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-catalyst+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-catalyst+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-catalyst.gentoo.org>
X-BeenThere: gentoo-catalyst@lists.gentoo.org
Reply-to: gentoo-catalyst@lists.gentoo.org
MIME-Version: 1.0
Received: by 10.52.158.168 with HTTP; Sun, 26 Jun 2011 22:15:31 -0700 (PDT)
From: Matt Turner <mattst88@gentoo.org>
Date: Mon, 27 Jun 2011 01:15:31 -0400
Message-ID: <BANLkTikRAXECejd_6mmw_w3=7HCgGE-3NA@mail.gmail.com>
Subject: [gentoo-catalyst] [rfc] simplifying arch classes
To: gentoo-catalyst@lists.gentoo.org
Content-Type: text/plain; charset=ISO-8859-1
X-Archives-Salt: 
X-Archives-Hash: 4290554baaa1e625357df4c86d1460cb

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