Rizin
unix-like reverse engineering framework and cli tools
meson_dist_script.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 #
3 # SPDX-FileCopyrightText: 2021 ret2libc <sirmy15@gmail.com>
4 # SPDX-License-Identifier: LGPL-3.0-only
5 #
6 # Script used by meson during the `meson dist` step to create a src tarball
7 # without .git directories for subprojects
8 
9 import os
10 import shutil
11 
12 
13 def traverse_dir(d):
14  for i in os.listdir(d):
15  # ignore . and ..
16  if i in (".", ".."):
17  continue
18 
19  fulli = os.path.abspath(os.path.join(d, i))
20  # avoid possible loops
21  if fulli == d:
22  continue
23 
24  if i == ".git":
25  shutil.rmtree(fulli)
26  elif os.path.isdir(fulli):
27  traverse_dir(fulli)
28 
29 
30 if __name__ == "__main__":
31  dist_dir = os.path.abspath(os.environ["MESON_DIST_ROOT"])
32  traverse_dir(dist_dir)