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 ) 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 ; 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 ; Mon, 27 Jun 2011 05:15:52 +0000 (UTC) Received: by vws13 with SMTP id 13so3863791vws.40 for ; 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: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail 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 Date: Mon, 27 Jun 2011 01:15:31 -0400 Message-ID: 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