diff --git a/meson.build b/meson.build index ee6cecb0a4..91af54d60a 100644 --- a/meson.build +++ b/meson.build @@ -688,6 +688,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, diff --git a/sys/meson_dist_script.py b/sys/meson_dist_script.py new file mode 100755 index 0000000000..942f2c2bf8 --- /dev/null +++ b/sys/meson_dist_script.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# +# SPDX-FileCopyrightText: 2021 ret2libc +# 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)