diff mbox

[PATCH/autobuild,v2,6/7] autobuild-run: simplify, don't make a dict of config

Message ID 20170410220003.30421-6-arnout@mind.be
State Accepted
Headers show

Commit Message

Arnout Vandecappelle April 10, 2017, 10 p.m. UTC
A toolchain config was defined as a dict with keys url, hostarch,
libc and contents. Of these, only contents and libc were actually
used outside of get_toolchain_configs(). And the use of libc has
been removed in the previous patch.

So there is no reason anymore to make config a dict. Just replace
it with its contents.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 scripts/autobuild-run | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Comments

Thomas Petazzoni April 12, 2017, 8:42 p.m. UTC | #1
Hello,

On Tue, 11 Apr 2017 00:00:02 +0200, Arnout Vandecappelle
(Essensium/Mind) wrote:

> -    configlines = config["contents"]
> +    configlines = config

So, using directly the variable named "config" in the remainder of this
function would be more logical, no?

(Note: as I said, I have already applied the patch, so further
improvements need to be done as follow-up patches)

Thanks!

Thomas
Arnout Vandecappelle April 13, 2017, 8:41 p.m. UTC | #2
On 12-04-17 22:42, Thomas Petazzoni wrote:
> Hello,
> 
> On Tue, 11 Apr 2017 00:00:02 +0200, Arnout Vandecappelle
> (Essensium/Mind) wrote:
> 
>> -    configlines = config["contents"]
>> +    configlines = config
> 
> So, using directly the variable named "config" in the remainder of this
> function would be more logical, no?

 Indeed, it looks kind of ridiculous now...

 Regards,
 Arnout
diff mbox

Patch

diff --git a/scripts/autobuild-run b/scripts/autobuild-run
index cb81186..20e0033 100755
--- a/scripts/autobuild-run
+++ b/scripts/autobuild-run
@@ -252,11 +252,8 @@  class SystemInfo:
 def get_toolchain_configs(**kwargs):
     """Fetch and return the possible toolchain configurations
 
-    This function returns an array of dictionaries, with for each toolchain:
-        - url: the URL of the toolchain defconfig
-        - libc: the C library used by the toolchain
-        - hostarch: the host architecture for which the toolchain is built
-        - contents: an array of lines of the defconfig
+    This function returns an array of toolchain configurations. Each
+    toolchain configuration is itself an array of lines of the defconfig.
     """
     toolchains_url = kwargs['toolchains_url']
 
@@ -271,31 +268,30 @@  def get_toolchain_configs(**kwargs):
 
     for row in csv.reader(l):
         config = {}
-        config["url"] = row[0]
-        config["hostarch"] = row[1]
+        url = row[0]
+        config_hostarch = row[1]
         keep = False
 
         # Keep all toolchain configs that work regardless of the host
         # architecture
-        if config['hostarch'] == "any":
+        if config_hostarch == "any":
             keep = True
 
         # Keep all toolchain configs that can work on the current host
         # architecture
-        if hostarch == config["hostarch"]:
+        if hostarch == config_hostarch:
             keep = True
 
         # Assume that x86 32 bits toolchains work on x86_64 build
         # machines
-        if hostarch == 'x86_64' and config["hostarch"] == "x86":
+        if hostarch == 'x86_64' and config_hostarch == "x86":
             keep = True
 
         if not keep:
             continue
 
-        config["libc"] = row[2]
-        with urlopen_closing(config["url"]) as r:
-            config["contents"] = decode_byte_list(r.readlines())
+        with urlopen_closing(url) as r:
+            config = decode_byte_list(r.readlines())
         configs.append(config)
     return configs
 
@@ -542,7 +538,7 @@  def gen_config(**kwargs):
     i = randint(0, len(configs) - 1)
     config = configs[i]
 
-    configlines = config["contents"]
+    configlines = config
 
     # Amend the configuration with a few things.
     configlines.append("BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y\n")
@@ -569,7 +565,7 @@  def gen_config(**kwargs):
         log_write(log, "ERROR: cannot oldconfig")
         return -1
 
-    if not is_toolchain_usable(config=config["contents"], **kwargs):
+    if not is_toolchain_usable(config=config, **kwargs):
         return -1
 
     # Now, generate the random selection of packages, and fixup