aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/uservices.py
blob: 35b7f6fdea2506762f7207fef6b53d0690069030 (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
import json
import ymake


def on_process_usrv_files(unit, *args):
    mode = None
    if args[0] == 'NO_DEPS':
        for f in args[1:]:
            if f == 'OUT_NOAUTO':
                mode = f
                continue
            if mode is not None:
                unit.on_move([f + '.usrv', mode, f])
            elif f.endswith('.cpp'):
                unit.on_move([f + '.usrv', 'OUT', f])
            else:
                unit.on_move([f + '.usrv', 'OUT_NOAUTO', f])
        return

    deps_file = unit.resolve(unit.resolve_arc_path(args[0]))
    try:
        all_deps = json.load(open(deps_file, 'r'))
    except Exception as e:
        ymake.report_configure_error('Malformed dependencies JSON `{}`: {}'.format(args[0], e.__repr__()))
        return
    mode = 'OUT'
    for f in args[1:]:
        if f == 'OUT_NOAUTO':
            mode = f
            continue
        try:
            deps = all_deps[f]
        except KeyError:
            ymake.report_configure_error('Dependencies for {} not found in {}'.format(f, args[0]))
            unit.on_usrv_mv_with_deps([f])
            return
        deps_type = 'OUTPUT_INCLUDES' if f.endswith('.proto') else 'CPP_DEPS'
        unit.on_move([f + '.usrv', mode, f, deps_type] + deps)