summaryrefslogtreecommitdiffstats
path: root/build/export_generators/ide-gradle/codegen_run_program.jinja
blob: 0c20799f5bef6bc4d60ad9bd3dc44da43c45424e (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
48
49
50
51
52
53
54
55
{%- if current_target.custom_runs|length -%}
{%-     set current_target_object_indexes = current_target_object_indexes + current_target.custom_runs|map(attribute='_object_index') -%}
{%-     for custom_run in current_target.custom_runs %}

val {{ varprefix }}{{ custom_run['_object_index'] }} = task<Exec>("{{ varprefix }}{{ custom_run['_object_index'] }}") {
    group = "build"
    description = "Code generation by run custom program"

{#- Ignore default CWD to export_root -#}
{%-        if custom_run.cwd and custom_run.cwd != export_root %}
    workingDir = file({{ PatchRoots(custom_run.cwd) }})
{%-        else %}
    workingDir = file("$buildDir")
{%-        endif %}

    commandLine("bash", "-c", listOf(
{%-        for arg in custom_run.command -%}
{%-            if custom_run.depends|select("eq", arg)|length or custom_run.depends|select("in", arg)|length %}
        {{ PatchRoots(arg, true) }}
{%-            elif custom_run.outputs|select("eq", arg)|length or custom_run.outputs|select("in", arg)|length %}
{%-                if proto_template -%}
        {#- generated proto put to prepared proto dir #}
        {{ PatchGeneratedProto(arg) }}
{%-                else %}
        {{ PatchRoots(arg, false, true) }}
{%-                endif -%}
{%-            else %}
        {{ PatchRoots(arg) }}
{%-            endif -%}
{%-            if not loop.last %}, {% endif -%}
{%-        endfor %}
    ).joinToString(" "))

{%-        if custom_run.depends|length -%}
{%-            for depend in custom_run.depends|unique %}
    inputs.files({{ PatchRoots(depend, true) }})
{%             endfor -%}
{%-        endif -%}

{%-        if custom_run.outputs|length -%}
{%-            for out in custom_run.outputs|unique %}
{%-                if proto_template %}
    outputs.files({{ PatchGeneratedProto(out) }})
{%-                else %}
    outputs.files({{ PatchRoots(out, false, true) }})
{%-                endif -%}
{%-            endfor -%}
{%-        endif -%}
{#-
    Не использованы атрибуты
    custom_run-env="list"
#}
}
{%-     endfor -%}
{%- endif -%}