Skip to content

Commit 931dcd8

Browse files
committed
Support FROM_SANDBOX in ya ide gradle
Support FROM_SANDBOX in ya ide gradle commit_hash:3bcebefec4489fc51219cab48a93516ea20f3e2e
1 parent ed9b6e6 commit 931dcd8

File tree

9 files changed

+69
-29
lines changed

9 files changed

+69
-29
lines changed

build/export_generators/ide-gradle/codegen_copy_file.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{%- set copy_files = current_target.target_commands|selectattr("macro", "eq", "copy_file") -%}
12
{%- if copy_files|length -%}
3+
{%- set current_target_object_indexes = current_target_object_indexes + copy_files|map(attribute='_object_index') -%}
24
{%- for copy in copy_files -%}
35
{%- set src = copy.args[0] -%}
46
{%- set dst = copy.args[1] -%}
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
{%- set current_target_object_indexes = [] -%}
22

3-
{%- set copy_files = current_target.target_commands|selectattr("macro", "eq", "copy_file") -%}
4-
{%- if copy_files|length -%}
5-
{%- set current_target_object_indexes = current_target_object_indexes + copy_files|map(attribute='_object_index') -%}
6-
{%- endif -%}
7-
8-
9-
{%- set move_files = current_target.target_commands|selectattr("macro", "eq", "move_file") -%}
10-
{%- if move_files|length -%}
11-
{%- set current_target_object_indexes = current_target_object_indexes + move_files|map(attribute='_object_index') -%}
12-
{%- endif -%}
13-
143
{%- include "[generator]/codegen_run_program.jinja" -%}
154
{%- include "[generator]/codegen_run_java_program.jinja" -%}
165
{%- include "[generator]/codegen_copy_file.jinja" -%}
176
{%- include "[generator]/codegen_move_file.jinja" -%}
7+
{%- include "[generator]/codegen_from_sandbox.jinja" -%}
188
{%- include "[generator]/codegen_depends.jinja" -%}

build/export_generators/ide-gradle/codegen_depends.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@
2121
{{ ObjDepends(move) }}
2222
{%- endfor -%}
2323
{%- endif -%}
24+
25+
{%- if current_target.from_sandboxes|length -%}
26+
{%- for from_sandbox in current_target.from_sandboxes -%}
27+
{{ ObjDepends(from_sandbox) }}
28+
{%- endfor -%}
29+
{%- endif -%}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{%- if current_target.from_sandboxes|length -%}
2+
{%- set current_target_object_indexes = current_target_object_indexes + current_target.from_sandboxes|map(attribute='_object_index') -%}
3+
{%- for from_sandbox in current_target.from_sandboxes %}
4+
5+
val {{ varprefix }}{{ from_sandbox['_object_index'] }} = tasks.register<Exec>("{{ varprefix }}{{ from_sandbox['_object_index'] }}") {
6+
workingDir = file("$buildDir{%- if from_sandbox.reldir != "." -%}/{{ from_sandbox.reldir }}{%- endif -%}")
7+
commandLine("bash", "-c", listOf(
8+
"{{ arcadia_root }}/ya",
9+
"download",
10+
{%- if from_sandbox.mode == "--copy-to-dir" %}
11+
"--original-name",
12+
{%- elif from_sandbox.mode == "--untar-to" %}
13+
"--untar",
14+
{%- endif %}
15+
"sbr:{{ from_sandbox.resource_id }}"
16+
).joinToString(" "))
17+
18+
{%- if from_sandbox.renames|length and from_sandbox.renames|length == from_sandbox.outs|length -%}
19+
{%- for rename in from_sandbox.renames %}
20+
doLast {
21+
file("$workingDir/{{ rename }}").renameTo(file("$workingDir/{{ from_sandbox.outs[loop.index0] }}"))
22+
}
23+
{%- endfor -%}
24+
{%- endif -%}
25+
{%- for out in from_sandbox.outs %}
26+
outputs.files(file("$workingDir/{{ out }}"))
27+
{%- endfor %}
28+
}
29+
{% endfor -%}
30+
{%- endif -%}

build/export_generators/ide-gradle/codegen_move_file.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{%- set move_files = current_target.target_commands|selectattr("macro", "eq", "move_file") -%}
12
{%- if move_files|length -%}
3+
{%- set current_target_object_indexes = current_target_object_indexes + move_files|map(attribute='_object_index') -%}
24
{%- for move in move_files -%}
35
{%- set src = move.args[0] -%}
46
{%- set dst = move.args[1] %}
57

6-
val {{ varprefix }}{{ move['_object_index'] }} = tasks.register("{{ varprefix }}{{ move['_object_index'] }}") {
8+
val {{ varprefix }}{{ move['_object_index'] }} = tasks.register<Copy>("{{ varprefix }}{{ move['_object_index'] }}") {
79
doLast {
810
file({{ PatchRoots(src, move['flags']|select("eq", "src_is_depend")|length) }}).renameTo(file({{ PatchRoots(dst) }}))
911
}

build/export_generators/ide-gradle/codegen_run_java_program.jinja

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- set current_target_object_indexes = current_target_object_indexes + current_target.runs|map(attribute='_object_index') -%}
33
{%- for run in current_target.runs %}
44

5-
val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{{ run['_object_index'] }}") {
5+
val {{ varprefix }}{{ run['_object_index'] }} = tasks.register<JavaExec>("{{ varprefix }}{{ run['_object_index'] }}") {
66
group = "build"
77
description = "Code generation by run java program"
88

@@ -34,7 +34,7 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{
3434
{{ PatchGeneratedProto(arg) }},
3535
{%- else %}
3636
{{ PatchRoots(arg, false, true) }},
37-
{%- endif %}
37+
{%- endif -%}
3838
{%- elif run.tool|select("in", arg)|length %}
3939
{{ PatchRoots(arg, true) }},
4040
{%- else %}
@@ -48,20 +48,20 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{
4848
{%- if run.in_dir|length -%}
4949
{%- for in_dir in run.in_dir|unique %}
5050
inputs.files(fileTree({{ PatchRoots(in_dir) }}))
51-
{% endfor -%}
52-
{%- endif -%}
51+
{%- endfor %}
52+
{% endif -%}
5353

5454
{%- if run.in|length -%}
5555
{%- for in_file in run.in|unique %}
5656
inputs.files({{ PatchRoots(in_file) }})
57-
{% endfor -%}
58-
{%- endif -%}
57+
{%- endfor %}
58+
{% endif -%}
5959

6060
{%- if run.in_noparse|length -%}
6161
{%- for in_file in run.in_noparse|unique %}
6262
inputs.files({{ PatchRoots(in_file) }})
63-
{% endfor -%}
64-
{%- endif -%}
63+
{%- endfor %}
64+
{% endif -%}
6565

6666
{%- if run.out_dir|length -%}
6767
{%- for out_dir in run.out_dir|unique %}
@@ -70,8 +70,8 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{
7070
{%- else %}
7171
outputs.dir({{ PatchRoots(out_dir, false, true) }})
7272
{%- endif -%}
73-
{%- endfor -%}
74-
{%- endif -%}
73+
{%- endfor %}
74+
{% endif -%}
7575

7676
{%- if run.out|length -%}
7777
{%- for out in run.out|unique %}
@@ -80,8 +80,8 @@ val {{ varprefix }}{{ run['_object_index'] }} = task<JavaExec>("{{ varprefix }}{
8080
{%- else %}
8181
outputs.files({{ PatchRoots(out, false, true) }})
8282
{%- endif -%}
83-
{%- endfor -%}
84-
{%- endif -%}
83+
{%- endfor %}
84+
{% endif -%}
8585

8686
{#-
8787
Не использованы атрибуты

build/export_generators/ide-gradle/codegen_run_program.jinja

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- set current_target_object_indexes = current_target_object_indexes + current_target.custom_runs|map(attribute='_object_index') -%}
33
{%- for custom_run in current_target.custom_runs %}
44

5-
val {{ varprefix }}{{ custom_run['_object_index'] }} = task<Exec>("{{ varprefix }}{{ custom_run['_object_index'] }}") {
5+
val {{ varprefix }}{{ custom_run['_object_index'] }} = tasks.register<Exec>("{{ varprefix }}{{ custom_run['_object_index'] }}") {
66
group = "build"
77
description = "Code generation by run custom program"
88

@@ -34,17 +34,17 @@ val {{ varprefix }}{{ custom_run['_object_index'] }} = task<Exec>("{{ varprefix
3434
{%- if custom_run.depends|length -%}
3535
{%- for depend in custom_run.depends|unique %}
3636
inputs.files({{ PatchRoots(depend, true) }})
37-
{% endfor -%}
38-
{%- endif -%}
37+
{%- endfor %}
38+
{% endif -%}
3939

4040
{%- if custom_run.outputs|length -%}
4141
{%- for out in custom_run.outputs|unique %}
4242
{%- if proto_template %}
4343
outputs.files({{ PatchGeneratedProto(out) }})
4444
{%- else %}
4545
outputs.files({{ PatchRoots(out, false, true) }})
46-
{%- endif -%}
47-
{%- endfor -%}
46+
{%- endif %}
47+
{% endfor -%}
4848
{%- endif -%}
4949
{#-
5050
Не использованы атрибуты

build/export_generators/ide-gradle/generator.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ kapt-processors="list"
122122
kapt-classpaths="list"
123123
kapt-ap_opts="list"
124124

125+
from_sandboxes="list"
126+
from_sandboxes-mode="str"
127+
from_sandboxes-resource_id="str"
128+
from_sandboxes-renames="list"
129+
from_sandboxes-outs="list"
130+
from_sandboxes-reldir="str"
131+
from_sandboxes-executable="bool"
132+
125133
[attrs.root]
126134

127135
[attrs.dir]

build/ymake.core.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,6 +4881,8 @@ macro _RUN_ANTLR_BASE(IN{input}[], IN_NOPARSE{input}[], OUT{output}[], OUT_NOAUT
48814881
macro FROM_SANDBOX(Id, OUT{output}[], OUT_NOAUTO{output}[], OUTPUT_INCLUDES[], INDUCED_DEPS[], FILE?"--copy-to-dir":"--untar-to", AUTOUPDATED="", PREFIX=".", RENAME[], EXECUTABLE?"--executable":"", SBR="sbr:") {
48824882
.CMD=${hide:SANDBOX_FAKEID} ${cwd:BINDIR} ${resource;pre=$SBR:Id} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_sandbox.py"} --resource-file $(RESOURCE_ROOT)/sbr/$Id/resource --resource-id $Id $FILE $PREFIX ${pre=--rename :RENAME} $EXECUTABLE -- $OUT $OUT_NOAUTO ${hide;input:"build/scripts/fetch_from.py"} ${hide;output_include:OUTPUT_INCLUDES} $INDUCED_DEPS ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${hide;requirements:"network:full"} ${hide;kv:"p SB"} ${hide;kv:"pc yellow"} ${hide;kv:"show_out"}
48834883
.STRUCT_CMD=yes
4884+
.SEM=from_sandboxes-ITEM && from_sandboxes-mode $FILE && from_sandboxes-resource_id $Id && from_sandboxes-renames $RENAME && from_sandboxes-outs $OUT $OUT_NOAUTO && from_sandboxes-reldir $PREFIX && from_sandboxes-executable $IF(${not;empty:EXECUTABLE} THEN true ELSE false) ${hide;output:OUT} ${hide;noauto;output:OUT_NOAUTO} ${resource;pre=$SBR:Id}
4885+
.STRUCT_SEM=yes
48844886
ADD_CHECK(check.resource $Id)
48854887
}
48864888

0 commit comments

Comments
 (0)