|
| 1 | +# Generated for direct meson-python packaging |
| 2 | +project( |
| 3 | + 'rest.connector', |
| 4 | + meson_version: '>=1.10.0', |
| 5 | +) |
| 6 | + |
| 7 | +fs = import('fs') |
| 8 | +pymod = import('python') |
| 9 | +package_folder = 'src' |
| 10 | +py = pymod.find_installation(pure: true) |
| 11 | +package_root = meson.project_source_root() / package_folder |
| 12 | +package_root_prefix = package_root + '/' |
| 13 | +git_prog = find_program('git') |
| 14 | + |
| 15 | +# File extensions to include from tracked files under src/. |
| 16 | +# Expected values are bare extensions without a leading dot, for example: 'py', 'yaml', 'json'. |
| 17 | +include_extensions = ['py', 'yaml', 'txt'] |
| 18 | +# Exact filenames to include when they do not rely on an extension match. |
| 19 | +# Expected values are basename matches, for example: 'ssh_host_key', 'runAll'. |
| 20 | +include_files = [] |
| 21 | +# Substring markers for tracked paths that should still be ignored if they ever appear. |
| 22 | +# Expected values are path fragments, for example: '/generated/', '/vendor/', '.egg-info/'. |
| 23 | +ignored_path_markers = [] |
| 24 | + |
| 25 | +all_tracked_files = run_command( |
| 26 | + git_prog, |
| 27 | + 'ls-files', |
| 28 | + package_folder, |
| 29 | + check: true, |
| 30 | +).stdout().strip().split('\n') |
| 31 | + |
| 32 | +foreach relpath : all_tracked_files |
| 33 | + if relpath == '' |
| 34 | + continue |
| 35 | + endif |
| 36 | + |
| 37 | + skip_path = false |
| 38 | + foreach marker : ignored_path_markers |
| 39 | + if relpath.contains(marker) |
| 40 | + skip_path = true |
| 41 | + break |
| 42 | + endif |
| 43 | + endforeach |
| 44 | + if skip_path |
| 45 | + continue |
| 46 | + endif |
| 47 | + |
| 48 | + path_has_included_ext = false |
| 49 | + foreach extension : include_extensions |
| 50 | + if relpath.endswith('.' + extension) |
| 51 | + path_has_included_ext = true |
| 52 | + break |
| 53 | + endif |
| 54 | + endforeach |
| 55 | + |
| 56 | + if not path_has_included_ext |
| 57 | + filename = fs.name(relpath) |
| 58 | + foreach include_name : include_files |
| 59 | + if filename == include_name |
| 60 | + path_has_included_ext = true |
| 61 | + break |
| 62 | + endif |
| 63 | + endforeach |
| 64 | + endif |
| 65 | + |
| 66 | + if not path_has_included_ext |
| 67 | + continue |
| 68 | + endif |
| 69 | + |
| 70 | + path = meson.project_source_root() / relpath |
| 71 | + relative_path = path.replace(package_root_prefix, '') |
| 72 | + install_target_dir = py.get_install_dir() |
| 73 | + relative_parent = fs.parent(relative_path) |
| 74 | + |
| 75 | + if relative_parent != '.' |
| 76 | + install_target_dir = install_target_dir / relative_parent |
| 77 | + endif |
| 78 | + |
| 79 | + install_data( |
| 80 | + path, |
| 81 | + install_dir: install_target_dir, |
| 82 | + ) |
| 83 | +endforeach |
0 commit comments