genrandconfig: get configs from in-tree toolchain-configs.csv

Now we have the toolchain config fragments in the buildroot directory
itself, it is no longer necessary to fetch it from the toolchain URL.

The --toolchains-url option is renamed to --toolchains-csv.

The paths in the toolchains_csv file should be either absolute, or
relative to buildrootdir.

After this change, the script should be called from autobuild-run as:

    subprocess.call([os.path.join(srcdir, "utils/genrandconfig"),
                     "-o", outputdir, "-b", srcdir,
                     "--toolchains-csv", kwargs['toolchains_csv']],
                    stdout=devnull, stderr=log)

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Arnout Vandecappelle 2017-07-21 03:05:26 +02:00 committed by Thomas Petazzoni
parent e7b9afa70a
commit 84929a53a4

View File

@ -118,15 +118,15 @@ class SystemInfo:
return not missing_requirements
def get_toolchain_configs(toolchains_url):
def get_toolchain_configs(toolchains_csv, buildrootdir):
"""Fetch and return the possible toolchain configurations
This function returns an array of toolchain configurations. Each
toolchain configuration is itself an array of lines of the defconfig.
"""
with urlopen_closing(toolchains_url) as r:
toolchains_csv = decode_byte_list(r.readlines())
with open(toolchains_csv) as r:
toolchains = decode_byte_list(r.readlines())
configs = []
(_, _, _, _, hostarch) = os.uname()
@ -134,9 +134,9 @@ def get_toolchain_configs(toolchains_url):
if hostarch == 'i686' or hostarch == 'i386' or hostarch == 'x86':
hostarch = 'x86'
for row in csv.reader(toolchains_csv):
for row in csv.reader(toolchains):
config = {}
url = row[0]
configfile = row[0]
config_hostarch = row[1]
keep = False
@ -158,8 +158,11 @@ def get_toolchain_configs(toolchains_url):
if not keep:
continue
with urlopen_closing(url) as r:
config = decode_byte_list(r.readlines())
if not os.path.isabs(configfile):
configfile = os.path.join(buildrootdir, configfile)
with open(configfile) as r:
config = r.readlines()
configs.append(config)
return configs
@ -329,7 +332,7 @@ def gen_config(args):
"""
# Select a random toolchain configuration
configs = get_toolchain_configs(args.toolchains_url)
configs = get_toolchain_configs(args.toolchains_csv, args.buildrootdir)
i = randint(0, len(configs) - 1)
toolchainconfig = configs[i]
@ -408,10 +411,10 @@ if __name__ == '__main__':
parser.add_argument("--buildrootdir", "-b",
help="Buildroot directory (relative to current directory)",
type=str, default='.')
parser.add_argument("--toolchains-url",
help="URL of toolchain configuration file",
parser.add_argument("--toolchains-csv",
help="Path of the toolchain configuration file",
type=str,
default="http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv")
default="support/config-fragments/autobuild/toolchain-configs.csv")
args = parser.parse_args()
# We need the absolute path to use with O=, because the relative