osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-dev/+/40837?usp=email )
Change subject: gen_makefile: turn projects_deps into a dict
......................................................................
gen_makefile: turn projects_deps into a dict
Let read_projects_deps() return a dictionary instead of a list of
tuples. This allows looking up entries in the dictionary by project
name, which I'm making use of in a future patch.
While using a dictionary here makes more sense, I assume this was
implemented as list of tuples because with earlier (long EOL) python3
versions, the order of entries in the dictionary were not stable. From
https://docs.python.org/3/library/stdtypes.html#dict:
Changed in version 3.7: Dictionary order is guaranteed
to be insertion
order. This behavior was an implementation detail of CPython from 3.6.
Change-Id: I74c53f4d6dda791c5d9e14f2274260f0e8cbbad2
---
M gen_makefile.py
1 file changed, 9 insertions(+), 9 deletions(-)
Approvals:
Jenkins Builder: Verified
jolly: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
diff --git a/gen_makefile.py b/gen_makefile.py
index e06dbd2..c49a27a 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -144,15 +144,15 @@
self.extend(k, v)
def read_projects_deps(path):
- 'Read deps config and return tuples of (project_name,
which-other-to-build-first).'
- l = []
+ 'Read deps config and return a dict of {project_name: which-other-to-build-first,
…}.'
+ ret = {}
for line in open(path):
line = line.strip()
if not line or line.startswith('#'):
continue
tokens = line.split()
- l.append((tokens[0], tokens[1:]))
- return l
+ ret[tokens[0]] = tokens[1:]
+ return ret
def read_projects_dict(path):
'Read urls/buildsystems config and return dict {project_name: url, …}.'
@@ -170,7 +170,7 @@
'Read config opts file and return tuples of (project_name, config-opts).'
if not path:
return {}
- return dict(read_projects_deps(path))
+ return read_projects_deps(path)
def gen_makefile_clone(proj, src, src_proj, update_src_copy_cmd):
if proj == "osmocom-bb_layer23":
@@ -646,17 +646,17 @@
"""
# convenience target: clone all repositories first
-content += 'clone: \\\n\t' + ' \\\n\t'.join([ '.make.%s.clone' %
p for p, d in projects_deps ]) + '\n\n'
+content += 'clone: \\\n\t' + ' \\\n\t'.join([ '.make.%s.clone' %
p for p, d in projects_deps.items() ]) + '\n\n'
# convenience target: clean all
-content += 'clean: \\\n\t' + ' \\\n\t'.join([ '%s-clean' % p for
p, d in projects_deps ]) + '\n\n'
+content += 'clean: \\\n\t' + ' \\\n\t'.join([ '%s-clean' % p for
p, d in projects_deps.items() ]) + '\n\n'
# now the actual useful build rules
content += 'all: clone all-install\n\n'
-content += 'all-install: \\\n\t' + ' \\\n\t'.join([
'.make.%s.install' % p for p, d in projects_deps ]) + '\n\n'
+content += 'all-install: \\\n\t' + ' \\\n\t'.join([
'.make.%s.install' % p for p, d in projects_deps.items() ]) + '\n\n'
-for proj, deps in projects_deps:
+for proj, deps in projects_deps.items():
all_config_opts = []
all_config_opts.extend(configure_opts.get('ALL') or [])
all_config_opts.extend(configure_opts.get(proj) or [])
--
To view, visit
https://gerrit.osmocom.org/c/osmo-dev/+/40837?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I74c53f4d6dda791c5d9e14f2274260f0e8cbbad2
Gerrit-Change-Number: 40837
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>