X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=tools%2Fbuildman%2Fbsettings.py;h=892cfa09e241ef16023c57e32ec3eec72fd62c2a;hb=3c476d841daa491f87c8f07851038afbdf4d90a8;hp=7e66c63b4b770e901ef41bea12a585bbfde076cb;hpb=f140b5863b258120f5412ea86733f70c87837ee9;p=oweals%2Fu-boot.git diff --git a/tools/buildman/bsettings.py b/tools/buildman/bsettings.py index 7e66c63b4b..892cfa09e2 100644 --- a/tools/buildman/bsettings.py +++ b/tools/buildman/bsettings.py @@ -1,26 +1,11 @@ # Copyright (c) 2012 The Chromium OS Authors. # -# See file CREDITS for list of people who contributed to this -# project. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, -# MA 02111-1307 USA +# SPDX-License-Identifier: GPL-2.0+ # import ConfigParser import os +import StringIO def Setup(fname=''): @@ -33,11 +18,19 @@ def Setup(fname=''): global config_fname settings = ConfigParser.SafeConfigParser() - config_fname = fname - if config_fname == '': - config_fname = '%s/.buildman' % os.getenv('HOME') - if config_fname: - settings.read(config_fname) + if fname is not None: + config_fname = fname + if config_fname == '': + config_fname = '%s/.buildman' % os.getenv('HOME') + if not os.path.exists(config_fname): + print 'No config file found ~/.buildman\nCreating one...\n' + CreateBuildmanConfigFile(config_fname) + print 'To install tool chains, please use the --fetch-arch option' + if config_fname: + settings.read(config_fname) + +def AddFile(data): + settings.readfp(StringIO.StringIO(data)) def GetItems(section): """Get the items from a section of the config. @@ -51,10 +44,56 @@ def GetItems(section): try: return settings.items(section) except ConfigParser.NoSectionError as e: - print e - print ("Warning: No tool chains - please add a [toolchain] section " - "to your buildman config file %s. See README for details" % - config_fname) return [] except: raise + +def SetItem(section, tag, value): + """Set an item and write it back to the settings file""" + global settings + global config_fname + + settings.set(section, tag, value) + if config_fname is not None: + with open(config_fname, 'w') as fd: + settings.write(fd) + +def CreateBuildmanConfigFile(config_fname): + """Creates a new config file with no tool chain information. + + Args: + config_fname: Config filename to create + + Returns: + None + """ + try: + f = open(config_fname, 'w') + except IOError: + print "Couldn't create buildman config file '%s'\n" % config_fname + raise + + print >>f, '''[toolchain] +# name = path +# e.g. x86 = /opt/gcc-4.6.3-nolibc/x86_64-linux + +[toolchain-prefix] +# name = path to prefix +# e.g. x86 = /opt/gcc-4.6.3-nolibc/x86_64-linux/bin/x86_64-linux- + +[toolchain-alias] +# arch = alias +# Indicates which toolchain should be used to build for that arch +x86 = i386 +blackfin = bfin +nds32 = nds32le +openrisc = or1k + +[make-flags] +# Special flags to pass to 'make' for certain boards, e.g. to pass a test +# flag and build tag to snapper boards: +# snapper-boards=ENABLE_AT91_TEST=1 +# snapper9260=${snapper-boards} BUILD_TAG=442 +# snapper9g45=${snapper-boards} BUILD_TAG=443 +''' + f.close();