1 # Copyright (c) 2012 The Chromium OS Authors.
3 # SPDX-License-Identifier: GPL-2.0+
12 """Set up the buildman settings module by reading config files
15 config_fname: Config filename to read ('' for default)
20 settings = ConfigParser.SafeConfigParser()
23 if config_fname == '':
24 config_fname = '%s/.buildman' % os.getenv('HOME')
25 if not os.path.exists(config_fname):
26 print 'No config file found ~/.buildman\nCreating one...\n'
27 CreateBuildmanConfigFile(config_fname)
28 print 'To install tool chains, please use the --fetch-arch option'
30 settings.read(config_fname)
33 settings.readfp(StringIO.StringIO(data))
35 def GetItems(section):
36 """Get the items from a section of the config.
39 section: name of section to retrieve
42 List of (name, value) tuples for the section
45 return settings.items(section)
46 except ConfigParser.NoSectionError as e:
51 def SetItem(section, tag, value):
52 """Set an item and write it back to the settings file"""
56 settings.set(section, tag, value)
57 if config_fname is not None:
58 with open(config_fname, 'w') as fd:
61 def CreateBuildmanConfigFile(config_fname):
62 """Creates a new config file with no tool chain information.
65 config_fname: Config filename to create
71 f = open(config_fname, 'w')
73 print "Couldn't create buildman config file '%s'\n" % config_fname
76 print >>f, '''[toolchain]
78 # e.g. x86 = /opt/gcc-4.6.3-nolibc/x86_64-linux
81 # name = path to prefix
82 # e.g. x86 = /opt/gcc-4.6.3-nolibc/x86_64-linux/bin/x86_64-linux-
86 # Indicates which toolchain should be used to build for that arch
93 # Special flags to pass to 'make' for certain boards, e.g. to pass a test
94 # flag and build tag to snapper boards:
95 # snapper-boards=ENABLE_AT91_TEST=1
96 # snapper9260=${snapper-boards} BUILD_TAG=442
97 # snapper9g45=${snapper-boards} BUILD_TAG=443