aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/perl_wrapper.py
blob: cb4027f1d36c425e006d016c839bf0b415646d64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import sys
import shutil

if __name__ == '__main__':
    path = sys.argv[1]
    to = sys.argv[-1]
    fr = sys.argv[-2]
    to_dir = os.path.dirname(to)

    os.chdir(to_dir)

    f1 = os.path.basename(fr)
    fr_ = os.path.dirname(fr)
    f2 = os.path.basename(fr_)
    fr_ = os.path.dirname(fr_)

    os.makedirs(f2)
    shutil.copyfile(fr, os.path.join(f2, f1))

    if path[0] != '/':
        path = os.path.join(os.path.dirname(__file__), path)

    os.execv(path, [path] + sys.argv[2:])