osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-dev/+/40839?usp=email )
Change subject: gen_makefile: add --targets
......................................................................
gen_makefile: add --targets
Add an option to specify the targets to include in the Makefile, instead
of always including all of them. This option will be used by testenv to
check early if there are any unknown targets, and to make running the
generated Makefile faster.
Running the Makefile is currently slowed down when having a lot of
projects cloned in osmo-dev's src dir, because regardless of the target
to be built, make is looking for all source files for all projects while
parsing the Makefile. For each project we have:
libosmocore_configure_files := $(shell find -L …/src/libosmocore …)
libosmocore_files := $(shell find -L …/src/libosmocore …)
Changing ":=" to "=" doesn't make it faster either, make still
executes
the find commands while parsing target lines such as:
.make.libosmocore.build: .make.libosmocore.configure $(libosmocore_files)
Related: osmo-ttcn3-hacks Ib2d8802b305f145d27aab3c1cc3129709b93d93d
Change-Id: I89bb60e94dd03606dbba5a3609d5e1a95993af5b
---
M gen_makefile.py
M tests/test_gen_makefile.py
2 files changed, 51 insertions(+), 0 deletions(-)
Approvals:
jolly: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
osmith: Looks good to me, approved
diff --git a/gen_makefile.py b/gen_makefile.py
index 5eb28ef..4730c59 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -153,6 +153,9 @@
parser.add_argument('-A', '--autoreconf-in-src-copy',
action='store_true',
help="run autoreconf in a copy of the source dir, avoids
'run make distclean' errors")
+parser.add_argument('--targets',
+ help="comma separated list of high-level targets to build
instead of all targets")
+
args = parser.parse_args()
class listdict(dict):
@@ -215,6 +218,40 @@
ret += f"{short}: {' '.join(full)}\n"
return ret
+def filter_projects_deps_targets():
+ if not args.targets:
+ return projects_deps
+
+ ret = {}
+ for target in args.targets.split(","):
+ # .make.osmocom-bb.clone -> osmocom-bb
+ if target.startswith(".make."):
+ target = target.split(".")[2]
+
+ current_targets = [target]
+ if target in convenience_targets:
+ current_targets = convenience_targets[target]
+
+ for target in current_targets:
+ # Add target + all dependencies to ret
+ queue = [target]
+ while queue:
+ project = queue.pop()
+ if project not in projects_deps:
+ print()
+ print(f"ERROR: filter_projects_deps_targets: can't find project
{project} in projects_deps!")
+ print()
+ sys.exit(1)
+
+ deps = projects_deps[project]
+ ret[project] = deps
+
+ for dep in deps:
+ if dep not in ret:
+ queue += [dep]
+
+ return ret
+
def gen_makefile_clone(proj, src, src_proj, update_src_copy_cmd):
if proj == "osmocom-bb_layer23":
return f'''
@@ -555,6 +592,7 @@
'''
projects_deps = read_projects_deps(all_deps_file)
+projects_deps = filter_projects_deps_targets()
projects_urls = read_projects_dict(all_urls_file)
projects_buildsystems = read_projects_dict(all_buildsystems_file)
configure_opts = listdict()
@@ -631,6 +669,8 @@
content += " --build-debug \\\n"
if args.autoreconf_in_src_copy:
content += " --autoreconf-in-src-copy \\\n"
+if args.targets:
+ content += f" --targets={shlex.quote(args.targets)} \\\n"
content += " $(NULL)\n"
if args.autoreconf_in_src_copy:
diff --git a/tests/test_gen_makefile.py b/tests/test_gen_makefile.py
index 2ae0667..6232003 100644
--- a/tests/test_gen_makefile.py
+++ b/tests/test_gen_makefile.py
@@ -64,3 +64,14 @@
run_cmd(["./gen_makefile.py", "-m", tmp_path,
"--autoreconf-in-src-copy"], cwd=osmo_dev_path)
run_cmd(["make", ".make.open5gs.configure"], cwd=tmp_path)
run_make_regen_2x(tmp_path)
+
+
+def test_gen_makefile_with_targets_arg(tmp_path):
+ run_cmd(["./gen_makefile.py", "-m", tmp_path,
"--targets", "trxcon,osmo-mgw"], cwd=osmo_dev_path)
+ run_cmd("grep -q '^osmocom-bb_trxcon_files :=' Makefile",
cwd=tmp_path, shell=True)
+ run_cmd("grep -q '^osmo-mgw_files :=' Makefile", cwd=tmp_path,
shell=True)
+ run_cmd("grep -q '^libosmocore_files :=' Makefile", cwd=tmp_path,
shell=True)
+ run_cmd("! grep -q '^osmo-bts_files :=' Makefile", cwd=tmp_path,
shell=True)
+ run_cmd("! grep -q '^osmo-s1gw_files :=' Makefile", cwd=tmp_path,
shell=True)
+ run_cmd("! grep -q '^open5gs_files :=' Makefile", cwd=tmp_path,
shell=True)
+ run_make_regen_2x(tmp_path)
--
To view, visit
https://gerrit.osmocom.org/c/osmo-dev/+/40839?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: I89bb60e94dd03606dbba5a3609d5e1a95993af5b
Gerrit-Change-Number: 40839
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>