Add dist script to remove .git folders from subprojects (#1998)
This commit is contained in:
parent
fe3e1f47e8
commit
24af48b6e4
2 changed files with 35 additions and 0 deletions
|
|
@ -810,6 +810,9 @@ if cli_enabled
|
|||
)
|
||||
endif
|
||||
|
||||
meson_dist_script = files('sys/meson_dist_script.py')
|
||||
meson.add_dist_script(meson_dist_script)
|
||||
|
||||
summary({
|
||||
'prefix': rizin_prefix,
|
||||
'bindir': rizin_bindir,
|
||||
|
|
|
|||
32
sys/meson_dist_script.py
Executable file
32
sys/meson_dist_script.py
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2021 ret2libc <sirmy15@gmail.com>
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
#
|
||||
# Script used by meson during the `meson dist` step to create a src tarball
|
||||
# without .git directories for subprojects
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def traverse_dir(d):
|
||||
for i in os.listdir(d):
|
||||
# ignore . and ..
|
||||
if i in (".", ".."):
|
||||
continue
|
||||
|
||||
fulli = os.path.abspath(os.path.join(d, i))
|
||||
# avoid possible loops
|
||||
if fulli == d:
|
||||
continue
|
||||
|
||||
if i == ".git":
|
||||
shutil.rmtree(fulli)
|
||||
elif os.path.isdir(fulli):
|
||||
traverse_dir(fulli)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dist_dir = os.path.abspath(os.environ["MESON_DIST_ROOT"])
|
||||
traverse_dir(dist_dir)
|
||||
Loading…
Reference in a new issue