meson: Use workspace Cargo.toml to find crates path

We were globing recursively during meson run and it was spending 20secs
here in total only to run the dependencies.py script
This commit is contained in:
Thibault Saunier 2022-09-17 11:33:34 -03:00 committed by Sebastian Dröge
parent ced6bcc246
commit f19af9f760

View file

@ -6,6 +6,8 @@
from argparse import ArgumentParser from argparse import ArgumentParser
from pathlib import Path from pathlib import Path
import sys
try: try:
# Python11 stdlib # Python11 stdlib
@ -40,14 +42,19 @@ RENAMES = {
if __name__ == "__main__": if __name__ == "__main__":
opts = PARSER.parse_args() opts = PARSER.parse_args()
with (opts.src_dir / 'Cargo.toml').open('rb') as f:
crates = tomllib.load(f)['workspace']['members']
deps = set() deps = set()
for p in opts.plugins: for p in opts.plugins:
assert p.startswith('gst') assert p.startswith('gst')
name = p[3:] name = p[3:]
name = RENAMES.get(name, name) name = RENAMES.get(name, name)
files = list(opts.src_dir.glob(f'**/{name}/Cargo.toml')) crate_path = None
assert len(files) == 1 for crate in crates:
with files[0].open('rb') as f: if Path(crate).name == name:
crate_path = opts.src_dir / crate / 'Cargo.toml'
assert crate_path
with crate_path.open('rb') as f:
data = tomllib.load(f) data = tomllib.load(f)
try: try:
requires = data['package']['metadata']['capi']['pkg_config']['requires_private'] requires = data['package']['metadata']['capi']['pkg_config']['requires_private']