forked from bazelbuild/intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_defs.bzl
671 lines (615 loc) · 23.5 KB
/
build_defs.bzl
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
"""Convenience methods for plugin_api."""
# The current indirect ij_product mapping (eg. "intellij-latest")
INDIRECT_IJ_PRODUCTS = {
# Indirect ij_product mapping for internal Blaze Plugin
"intellij-latest": "intellij-2022.3",
"intellij-latest-mac": "intellij-2022.3-mac",
"intellij-beta": "intellij-2022.3",
"intellij-under-dev": "intellij-2022.3",
"intellij-ue-latest": "intellij-ue-2022.3",
"intellij-ue-latest-mac": "intellij-ue-2022.3-mac",
"intellij-ue-beta": "intellij-ue-2022.3",
"intellij-ue-under-dev": "intellij-ue-2022.3",
"android-studio-latest": "android-studio-2023.1",
"android-studio-latest-mac": "android-studio-2023.1-mac",
"android-studio-beta": "android-studio-2023.1",
"android-studio-beta-mac": "android-studio-2023.1-mac",
"android-studio-canary": "android-studio-2023.2",
"android-studio-canary-mac": "android-studio-2023.2-mac",
"clion-latest": "clion-2022.3",
"clion-latest-mac": "clion-2022.3-mac",
"clion-beta": "clion-2022.3",
"clion-under-dev": "clion-2022.3",
# Indirect ij_product mapping for Bazel Plugin OSS
# The old names for -oss-oldest-stable and -oss-latest-stable were
# -oss-stable and -oss-beta respectively.
"intellij-oss-oldest-stable": "intellij-2023.3",
"intellij-oss-latest-stable": "intellij-2024.1",
"intellij-oss-under-dev": "intellij-2024.1",
"intellij-ue-oss-oldest-stable": "intellij-ue-2023.3",
"intellij-ue-oss-latest-stable": "intellij-ue-2024.1",
"intellij-ue-oss-under-dev": "intellij-ue-2024.1",
"android-studio-oss-oldest-stable": "android-studio-2023.1",
"android-studio-oss-latest-stable": "android-studio-2023.2",
"android-studio-oss-under-dev": "android-studio-2023.2",
"clion-oss-oldest-stable": "clion-2023.3",
"clion-oss-latest-stable": "clion-2024.1",
"clion-oss-under-dev": "clion-2024.1",
# Indirect ij_product mapping for Cloud Code Plugin OSS
"intellij-cc-oldest-stable": "intellij-2022.3",
"intellij-cc-latest-stable": "intellij-2022.3",
"intellij-cc-under-dev": "intellij-2022.3",
"intellij-ue-cc-oldest-stable": "intellij-ue-2022.3",
"intellij-ue-cc-latest-stable": "intellij-ue-2022.3",
"intellij-ue-cc-under-dev": "intellij-ue-2022.3",
}
(CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_CANARY, CHANNEL_FREEFORM) = ("stable", "beta", "canary", "freeform")
INDIRECT_PRODUCT_CHANNELS = {
# Channel mapping for internal Blaze Plugin
"intellij-latest": CHANNEL_STABLE,
"intellij-latest-mac": CHANNEL_STABLE,
"intellij-beta": CHANNEL_BETA,
"intellij-under-dev": CHANNEL_CANARY,
"intellij-ue-latest": CHANNEL_STABLE,
"intellij-ue-latest-mac": CHANNEL_STABLE,
"intellij-ue-beta": CHANNEL_BETA,
"intellij-ue-under-dev": CHANNEL_CANARY,
"android-studio-latest": CHANNEL_STABLE,
"android-studio-latest-mac": CHANNEL_STABLE,
"android-studio-beta": CHANNEL_BETA,
"android-studio-beta-mac": CHANNEL_BETA,
"android-studio-canary": CHANNEL_CANARY,
"android-studio-canary-mac": CHANNEL_CANARY,
"clion-latest": CHANNEL_STABLE,
"clion-latest-mac": CHANNEL_STABLE,
"clion-beta": CHANNEL_BETA,
"clion-under-dev": CHANNEL_CANARY,
# Channel mapping for Bazel Plugin OSS
"intellij-oss-oldest-stable": CHANNEL_STABLE,
"intellij-oss-latest-stable": CHANNEL_STABLE,
"intellij-oss-under-dev": CHANNEL_CANARY,
"intellij-ue-oss-oldest-stable": CHANNEL_STABLE,
"intellij-ue-oss-latest-stable": CHANNEL_STABLE,
"intellij-ue-oss-under-dev": CHANNEL_CANARY,
"android-studio-oss-oldest-stable": CHANNEL_STABLE,
"android-studio-oss-latest-stable": CHANNEL_STABLE,
"android-studio-oss-under-dev": CHANNEL_CANARY,
"clion-oss-oldest-stable": CHANNEL_STABLE,
"clion-oss-latest-stable": CHANNEL_STABLE,
"clion-oss-under-dev": CHANNEL_CANARY,
# Channel mapping for Cloud Code Plugin OSS
"intellij-cc-oldest-stable": CHANNEL_STABLE,
"intellij-cc-latest-stable": CHANNEL_STABLE,
"intellij-cc-under-dev": CHANNEL_CANARY,
"intellij-ue-cc-oldest-stable": CHANNEL_STABLE,
"intellij-ue-cc-latest-stable": CHANNEL_STABLE,
"intellij-ue-cc-under-dev": CHANNEL_CANARY,
}
def _check_channel_map():
if INDIRECT_PRODUCT_CHANNELS.keys() != INDIRECT_IJ_PRODUCTS.keys():
fail("Key mismatch between INDIRECT_PRODUCT_CHANNELS and INDIRECT_IJ_PRODUCTS: missing: %s extra: %s" % (
[k for k in INDIRECT_IJ_PRODUCTS.keys() if k not in INDIRECT_PRODUCT_CHANNELS.keys()],
[k for k in INDIRECT_PRODUCT_CHANNELS.keys() if k not in INDIRECT_IJ_PRODUCTS.keys()],
))
unexpected = [
(k, v)
for k, v in INDIRECT_PRODUCT_CHANNELS.items()
if v not in [CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_CANARY]
]
if unexpected:
fail("Unexpected values in INDIRECT_PRODUCT_CHANNELS: %s" % unexpected)
DIRECT_IJ_PRODUCTS = {
"intellij-2021.3": struct(
ide = "intellij",
directory = "intellij_ce_2021_3",
),
"intellij-2021.3-mac": struct(
ide = "intellij",
directory = "intellij_ce_2021_3",
),
"intellij-2022.1": struct(
ide = "intellij",
directory = "intellij_ce_2022_1",
),
"intellij-2022.1-mac": struct(
ide = "intellij",
directory = "intellij_ce_2022_1",
),
"intellij-2022.2": struct(
ide = "intellij",
directory = "intellij_ce_2022_2",
),
"intellij-2022.2-mac": struct(
ide = "intellij",
directory = "intellij_ce_2022_2",
),
"intellij-2022.3": struct(
ide = "intellij",
directory = "intellij_ce_2022_3",
),
"intellij-2022.3-mac": struct(
ide = "intellij",
directory = "intellij_ce_2022_3",
),
"intellij-2023.1": struct(
ide = "intellij",
directory = "intellij_ce_2023_1",
),
"intellij-2023.1-mac": struct(
ide = "intellij",
directory = "intellij_ce_2023_1",
),
"intellij-2023.2": struct(
ide = "intellij",
directory = "intellij_ce_2023_2",
),
"intellij-2023.2-mac": struct(
ide = "intellij",
directory = "intellij_ce_2023_2",
),
"intellij-2023.3": struct(
ide = "intellij",
directory = "intellij_ce_2023_3",
),
"intellij-2023.3-mac": struct(
ide = "intellij",
directory = "intellij_ce_2023_3",
),
"intellij-2024.1": struct(
ide = "intellij",
directory = "intellij_ce_2024_1",
),
"intellij-2024.1-mac": struct(
ide = "intellij",
directory = "intellij_ce_2024_1",
),
"intellij-ue-2021.3": struct(
ide = "intellij-ue",
directory = "intellij_ue_2021_3",
),
"intellij-ue-2021.3-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2021_3",
),
"intellij-ue-2022.1": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_1",
),
"intellij-ue-2022.1-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_1",
),
"intellij-ue-2022.2": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_2",
),
"intellij-ue-2022.2-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_2",
),
"intellij-ue-2022.3": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_3",
),
"intellij-ue-2022.3-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2022_3",
),
"intellij-ue-2023.1": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_1",
),
"intellij-ue-2023.1-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_1",
),
"intellij-ue-2023.2": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_2",
),
"intellij-ue-2023.2-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_2",
),
"intellij-ue-2023.3": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_3",
),
"intellij-ue-2023.3-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2023_3",
),
"intellij-ue-2024.1": struct(
ide = "intellij-ue",
directory = "intellij_ue_2024_1",
),
"intellij-ue-2024.1-mac": struct(
ide = "intellij-ue",
directory = "intellij_ue_2024_1",
),
"android-studio-2022.3": struct(
ide = "android-studio",
archive = "android_studio_with_blaze_2022_3",
oss_workspace = "android_studio_2022_3",
),
"android-studio-2023.1": struct(
ide = "android-studio",
archive = "android_studio_with_blaze_2023_1",
oss_workspace = "android_studio_2023_1",
),
"android-studio-2023.2": struct(
ide = "android-studio",
archive = "android_studio_with_blaze_2023_2",
oss_workspace = "android_studio_2023_2",
),
"clion-2021.3": struct(
ide = "clion",
directory = "clion_2021_3",
),
"clion-2021.3-mac": struct(
ide = "clion",
directory = "clion_2021_3",
),
"clion-2022.1": struct(
ide = "clion",
directory = "clion_2022_1",
),
"clion-2022.1-mac": struct(
ide = "clion",
directory = "clion_2022_1",
),
"clion-2022.2": struct(
ide = "clion",
directory = "clion_2022_2",
),
"clion-2022.2-mac": struct(
ide = "clion",
directory = "clion_2022_2",
),
"clion-2022.3": struct(
ide = "clion",
directory = "clion_2022_3",
),
"clion-2022.3-mac": struct(
ide = "clion",
directory = "clion_2022_3",
),
"clion-2023.1": struct(
ide = "clion",
directory = "clion_2023_1",
),
"clion-2023.1-mac": struct(
ide = "clion",
directory = "clion_2023_1",
),
"clion-2023.2": struct(
ide = "clion",
directory = "clion_2023_2",
),
"clion-2023.2-mac": struct(
ide = "clion",
directory = "clion_2023_2",
),
"clion-2023.3": struct(
ide = "clion",
directory = "clion_2023_3",
),
"clion-2023.3-mac": struct(
ide = "clion",
directory = "clion_2023_3",
),
"clion-2024.1": struct(
ide = "clion",
directory = "clion_2024_1",
),
"clion-2024.1-mac": struct(
ide = "clion",
directory = "clion_2024_1",
),
}
def select_for_plugin_api(params):
"""Selects for a plugin_api.
Args:
params: A dict with ij_product -> value.
You may only include direct ij_products here,
not indirects (eg. intellij-latest).
Returns:
A select statement on all plugin_apis. Unless you include a "default",
a non-matched plugin_api will result in an error.
Example:
java_library(
name = "foo",
srcs = select_for_plugin_api({
"intellij-2016.3.1": [...my intellij 2016.3 sources ....],
"intellij-2012.2.4": [...my intellij 2016.2 sources ...],
}),
)
"""
for indirect_ij_product in INDIRECT_IJ_PRODUCTS:
if indirect_ij_product in params:
error_message = "".join([
"Do not select on indirect ij_product %s. " % indirect_ij_product,
"Instead, select on an exact ij_product.",
])
fail(error_message)
return _do_select_for_plugin_api(params)
def _do_select_for_plugin_api(params):
"""A version of select_for_plugin_api which accepts indirect products."""
if not params:
fail("Empty select_for_plugin_api")
expanded_params = dict(**params)
# Expand all indirect plugin_apis to point to their
# corresponding direct plugin_api.
#
# {"intellij-2016.3.1": "foo"} ->
# {"intellij-2016.3.1": "foo", "intellij-latest": "foo"}
fallback_value = None
for indirect_ij_product, resolved_plugin_api in INDIRECT_IJ_PRODUCTS.items():
if resolved_plugin_api in params:
expanded_params[indirect_ij_product] = params[resolved_plugin_api]
if not fallback_value:
fallback_value = params[resolved_plugin_api]
if indirect_ij_product in params:
expanded_params[resolved_plugin_api] = params[indirect_ij_product]
# Map the shorthand ij_products to full config_setting targets.
# This makes it more convenient so the user doesn't have to
# fully specify the path to the plugin_apis
select_params = dict()
for ij_product, value in expanded_params.items():
if ij_product == "default":
select_params["//conditions:default"] = value
else:
select_params["//intellij_platform_sdk:" + ij_product] = value
return select(
select_params,
no_match_error = "define an intellij product version, e.g. --define=ij_product=intellij-latest",
)
def select_for_ide(intellij = None, intellij_ue = None, android_studio = None, clion = None, default = []):
"""Selects for the supported IDEs.
Args:
intellij: Files to use for IntelliJ. If None, will use default.
intellij_ue: Files to use for IntelliJ UE. If None, will use value chosen for 'intellij'.
android_studio: Files to use for Android Studio. If None will use default.
clion: Files to use for CLion. If None will use default.
default: Files to use for any IDEs not passed.
Returns:
A select statement on all plugin_apis to lists of files, sorted into IDEs.
Example:
java_library(
name = "foo",
srcs = select_for_ide(
clion = [":cpp_only_sources"],
default = [":java_only_sources"],
),
)
"""
intellij = intellij if intellij != None else default
intellij_ue = intellij_ue if intellij_ue != None else intellij
android_studio = android_studio if android_studio != None else default
clion = clion if clion != None else default
ide_to_value = {
"intellij": intellij,
"intellij-ue": intellij_ue,
"android-studio": android_studio,
"clion": clion,
}
# Map (direct ij_product) -> corresponding ide value
params = dict()
for ij_product, value in DIRECT_IJ_PRODUCTS.items():
params[ij_product] = ide_to_value[value.ide]
params["default"] = default
return select_for_plugin_api(params)
def _plugin_api_directory(value):
if hasattr(value, "oss_workspace"):
directory = value.oss_workspace
else:
directory = value.directory
return "@" + directory + "//"
def select_from_plugin_api_directory(intellij, android_studio, clion, intellij_ue = None):
"""Internal convenience method to generate select statement from the IDE's plugin_api directories.
Args:
intellij: the items that IntelliJ product to use.
android_studio: the items that android studio product to use.
clion: the items that clion product to use.
intellij_ue: the items that intellij ue product to use.
Returns:
a select statement map from DIRECT_IJ_PRODUCTS to items that they should use.
"""
ide_to_value = {
"intellij": intellij,
"intellij-ue": intellij_ue if intellij_ue else intellij,
"android-studio": android_studio,
"clion": clion,
}
# Map (direct ij_product) -> corresponding product directory
params = dict()
for ij_product, value in DIRECT_IJ_PRODUCTS.items():
params[ij_product] = [_plugin_api_directory(value) + item for item in ide_to_value[value.ide]]
# No ij_product == intellij-latest
params["default"] = params[INDIRECT_IJ_PRODUCTS["intellij-latest"]]
return select_for_plugin_api(params)
def select_from_plugin_api_version_directory(params):
"""Selects for a plugin_api direct version based on its directory.
Args:
params: A dict with ij_product -> value.
You may only include direct ij_products here,
not indirects (eg. intellij-latest).
Returns:
A select statement on all plugin_apis. Unless you include a "default",
a non-matched plugin_api will result in an error.
"""
for indirect_ij_product in INDIRECT_IJ_PRODUCTS:
if indirect_ij_product in params:
error_message = "".join([
"Do not select on indirect ij_product %s. " % indirect_ij_product,
"Instead, select on an exact ij_product.",
])
fail(error_message)
# Map (direct ij_product) -> corresponding value relative to product directory
for ij_product, value in params.items():
if ij_product != "default":
params[ij_product] = [_plugin_api_directory(DIRECT_IJ_PRODUCTS[ij_product]) + item for item in value]
return _do_select_for_plugin_api(params)
def get_versions_to_build(product):
""""Returns a set of unique product version aliases to test and build during regular release process.
For each product, we care about four versions aliases to build and release to JetBrains
repository; -latest, -beta, -oss-oldest-stable and oss-latest-stable.
However, some of these aliases can point to the same IDE version and this can lead
to conflicts if we attempt to blindly build and upload the four versions.
This function is used to return only the aliases that point to different
IDE versions of the given product.
Args:
product: name of the product; android-studio, clion, intellij-ue
Returns:
A space separated list of product version aliases to build, the values can be
oss-oldest-stable, oss-latest-stable, internal-stable and internal-beta.
"""
aliases_to_build = []
plugin_api_versions = []
for alias in ["oss-oldest-stable", "latest", "oss-latest-stable", "beta"]:
indirect_ij_product = product + "-" + alias
if indirect_ij_product not in INDIRECT_IJ_PRODUCTS:
fail(
"Product-version alias %s not found." % indirect_ij_product,
"Invalid product: %s only android-studio, clion and intellij-ue are accepted." % product,
)
version = INDIRECT_IJ_PRODUCTS[indirect_ij_product]
if version not in plugin_api_versions:
plugin_api_versions.append(version)
if alias == "latest":
aliases_to_build.append("internal-stable")
elif alias == "beta":
aliases_to_build.append("internal-beta")
else:
aliases_to_build.append(alias)
return " ".join(aliases_to_build)
def get_unique_supported_oss_ide_versions(product):
""""Returns the unique supported IDE versions for the given product in the OSS Bazel plugin
Args:
product: name of the product; android-studio, clion, intellij-ue
Returns:
A space separated list of the aliases of the unique IDE versions for the
OSS Bazel plugin.
"""
supported_versions = []
unique_aliases = []
for alias in ["oss-oldest-stable", "oss-latest-stable"]:
indirect_ij_product = product + "-" + alias
if indirect_ij_product not in INDIRECT_IJ_PRODUCTS:
fail(
"Product-version alias %s not found." % indirect_ij_product,
"Invalid product: %s, only android-studio, clion and intellij-ue are accepted." % product,
)
ver = INDIRECT_IJ_PRODUCTS[indirect_ij_product]
if ver not in supported_versions:
supported_versions.append(ver)
unique_aliases.append(alias)
return " ".join(unique_aliases)
def combine_visibilities(*args):
"""
Concatenates the given lists of visibilities and returns the combined list.
If one of the given elements is //visibility:public then return //visibility:public
If one of the lists is None, skip it.
If the result list is empty, then return None.
Args:
*args: the list of visibilities lists to combine
Returns:
the concatenated visibility targets list
"""
res = []
for arg in args:
if arg:
for visibility in arg:
if visibility == "//visibility:public":
return ["//visibility:public"]
res.append(visibility)
if res == []:
return None
return res
def no_mockito_extensions(name, jars, **kwargs):
"""Removes mockito extensions from jars.
Args:
name: Name of the resulting java_import target.
jars: List of jars from which to remove mockito extensions.
**kwargs: Arbitrary attributes for the java_import target.
"""
output_jars = []
for input_jar in jars:
output_jar_name = name + "_" + input_jar.replace("/", "_")
output_jar = name + "/" + input_jar
native.genrule(
name = output_jar_name,
srcs = [input_jar],
outs = [output_jar],
cmd = """
cp "$<" "$@"
chmod u+w "$@"
zip -d "$@" mockito-extensions/*
""",
)
output_jars.append(output_jar_name)
native.java_import(
name = name,
jars = output_jars,
**kwargs
)
# Since 2022.3, JVM 17 is required to start IntelliJ
# https://blog.jetbrains.com/platform/2022/08/intellij-project-migrates-to-java-17/
def java_version_flags():
java11 = ["-source", "11", "-target", "11"]
java17 = ["-source", "17", "-target", "17"]
return select_for_plugin_api({
"intellij-2021.3": java11,
"intellij-2021.3-mac": java11,
"intellij-2022.1": java11,
"intellij-2022.1-mac": java11,
"intellij-2022.2": java11,
"intellij-2022.2-mac": java11,
"intellij-ue-2021.3": java11,
"intellij-ue-2021.3-mac": java11,
"intellij-ue-2022.1": java11,
"intellij-ue-2022.1-mac": java11,
"intellij-ue-2022.2": java11,
"intellij-ue-2022.2-mac": java11,
"android-studio-2022.2": java11,
"clion-2021.3": java11,
"clion-2021.3-mac": java11,
"clion-2022.1": java11,
"clion-2022.1-mac": java11,
"clion-2022.2": java11,
"clion-2022.2-mac": java11,
"default": java17,
})
def select_for_channel(channel_map):
"""Returns a select based on the IDE channel (stable, beta, canary).
Args:
channel_map: a dict with keys "stable", "beta" and "canary". The rest of targets will be considered "freeform"
Returns:
A select that will select values from channel_map based on the build config.
"""
_check_channel_map()
if channel_map.keys() != [CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_CANARY, CHANNEL_FREEFORM]:
fail("channel_map must contain exactly %s, %s and %s" % (CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_CANARY, CHANNEL_FREEFORM))
select_map = {
("//intellij_platform_sdk:%s" % indirect_product): channel_map[channel]
for indirect_product, channel in INDIRECT_PRODUCT_CHANNELS.items()
}
# We reverse INDIRECT_IJ_PRODUCTS.items() here to that the inverse map contains
# the first occurrence of any value that is duplicated, not the last:
inverse_ij_products = {v: k for k, v in reversed(INDIRECT_IJ_PRODUCTS.items())}
# Add directly specified IDE versions which some builds use:
select_map.update(
{
("//intellij_platform_sdk:%s" % direct_product): channel_map[INDIRECT_PRODUCT_CHANNELS[indirect_product]]
for direct_product, indirect_product in inverse_ij_products.items()
},
)
# Some IDE versions are not in a channel, but users would still like to build and test them:
select_map.update(
{
("//intellij_platform_sdk:%s" % direct_product): channel_map[CHANNEL_FREEFORM]
for direct_product in DIRECT_IJ_PRODUCTS.keys()
if direct_product not in inverse_ij_products
},
)
return select(select_map)