aboutsummaryrefslogtreecommitdiff
path: root/tools/copy_files.py
blob: 8ea67a9ee98a0f587d330d6f7e35387a8207894a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# copy_files.py STAMP DEST SRC [SRC ...]
#
# Copy each SRC next to the built executable (DEST) and touch STAMP so Meson can
# track the custom_target. Used to stage the LLDB/Python runtime DLLs beside
# hsdbg.exe on Windows, mirroring the old premake postbuild copies.

import os
import shutil
import sys


def main(argv):
    if len(argv) < 3:
        sys.stderr.write("usage: copy_files.py STAMP DEST SRC [SRC ...]\n")
        return 1

    stamp, dest = argv[1], argv[2]
    os.makedirs(dest, exist_ok=True)

    for src in argv[3:]:
        if os.path.isfile(src):
            shutil.copy2(src, dest)
        else:
            sys.stderr.write(f"warning: {src} not found, skipping\n")

    with open(stamp, "w") as handle:
        handle.write("")

    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv))