aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/build_dll_and_java.py
blob: b9d8aff4df7da4f226c2a7cb9cdc9613b783f2ca (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import subprocess
import sys


def just_do_it(argv):
    delim = argv[0]
    args = []
    for item in argv:
        if item == delim:
            args.append([])
        else:
            args[-1].append(item)
    dll_cmd, java_cmd, inputs, dll_out, java_out, jsrs_out, roots = args
    dll_out, java_out, jsrs_out, build_root, source_root = dll_out[0], java_out[0], jsrs_out[0], roots[0], roots[1]
    for inp in inputs:
        origin_inp = inp
        if os.path.isabs(inp):
            if os.path.relpath(inp, build_root).startswith('..'):
                inp = os.path.relpath(inp, source_root)
            else:
                inp = os.path.relpath(inp, build_root)
        ext = os.path.splitext(inp)[1]
        if ext in ('.o', '.obj'):
            if os.path.join(build_root, inp) in java_cmd:
                inp = os.path.join(build_root, inp)
            if sys.platform == 'win32':
                inp = inp.replace('\\', '/')
                if inp not in java_cmd:
                    inp = build_root + '/' + inp
            java_cmd.remove(inp)
        if ext in ('.java', '.jsrc'):
            if origin_inp in dll_cmd:
                inp = origin_inp
            elif os.path.join(build_root, inp) in dll_cmd:
                inp = os.path.join(build_root, inp)
            if sys.platform == 'win32':
                inp = inp.replace('\\', '/')
            dll_cmd.remove(inp)
    java_cmd.insert(java_cmd.index(dll_out), java_out)
    java_cmd.remove(dll_out)
    subprocess.check_call(java_cmd)
    subprocess.check_call(dll_cmd)


if __name__ == '__main__':
    just_do_it(sys.argv[1:])