1# Copyright (C) 2022 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@bazel_skylib//lib:new_sets.bzl", "sets")
16load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
17load(":stl.bzl", "stl_info_from_attr")
18
19_ANDROID_STATIC_DEPS = ["//external/libcxxabi:libc++demangle"]
20_STATIC_DEP = ["//external/libcxx:libc++_static"]
21_ANDROID_BINARY_STATIC_DEP = ["//prebuilts/clang/host/linux-x86:libunwind"]
22_SHARED_DEP = ["//external/libcxx:libc++"]
23_SDK_SYSTEM_DYNAMIC_DEPS = ["//bionic/libc:libstdc++"]
24_SDK_SYSTEM_DEPS = ["//prebuilts/ndk:ndk_system"]
25_SDK_LIBUNWIND = "//prebuilts/ndk:ndk_libunwind"
26_SDK_LIBCXX = "//prebuilts/ndk:ndk_libc++_shared"
27_SDK_LIBCXX_STATIC = "//prebuilts/ndk:ndk_libc++_static"
28_SDK_LIBCXX_ABI = "//prebuilts/ndk:ndk_libc++abi"
29
30_ANDROID_CPPFLAGS = []
31_ANDROID_LINKOPTS = []
32_LINUX_CPPFLAGS = ["-nostdinc++"]
33_LINUX_LINKOPTS = ["-nostdlib++"]
34_LINUX_BIONIC_CPPFLAGS = []
35_LINUX_BIONIC_LINKOPTS = []
36_DARWIN_CPPFLAGS = [
37    "-nostdinc++",
38    "-D_LIBCPP_DISABLE_AVAILABILITY",
39]
40_DARWIN_CPPFLAGS_STL_NONE = ["-nostdinc++"]
41_DARWIN_LINKOPTS = ["-nostdlib++"]
42_WINDOWS_CPPFLAGS = [
43    "-nostdinc++",
44    "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
45    "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
46    "-D_LIBCPP_HAS_THREAD_API_WIN32",
47]
48_WINDOWS_CPPFLAGS_STL_NONE = ["-nostdinc++"]
49_WINDOWS_LINKOPTS = ["-nostdlib++"]
50
51_StlInfo = provider(fields = ["static", "shared", "deps"])
52
53def _stl_impl(ctx):
54    return [
55        _StlInfo(
56            static = ctx.attr.static,
57            shared = ctx.attr.shared,
58            deps = ctx.attr.deps,
59        ),
60    ]
61
62_stl = rule(
63    implementation = _stl_impl,
64    attrs = {
65        "shared": attr.string_list(),
66        "static": attr.string_list(),
67        "deps": attr.string_list(default = []),
68    },
69)
70
71_StlFlagsInfo = provider(fields = ["cppflags", "linkopts"])
72
73def _stl_flags_impl(ctx):
74    return [
75        _StlFlagsInfo(
76            cppflags = ctx.attr.cppflags,
77            linkopts = ctx.attr.linkopts,
78        ),
79    ]
80
81_stl_flags = rule(
82    implementation = _stl_flags_impl,
83    attrs = {
84        "cppflags": attr.string_list(),
85        "linkopts": attr.string_list(),
86    },
87)
88
89def _test_stl(
90        stl,
91        is_shared,
92        is_binary,
93        android_deps,
94        non_android_deps,
95        android_flags,
96        linux_flags,
97        linux_bionic_flags,
98        darwin_flags,
99        windows_flags,
100        sdk_deps):
101    target_name = _stl_deps_target(stl, is_shared, is_binary)
102    flags_target_name = _stl_flags_target(stl, is_shared, is_binary)
103    android_test_name = target_name + "_android_test"
104    non_android_test_name = target_name + "_non_android_test"
105    android_flags_test_name = target_name + "_android_flags_test"
106    linux_flags_test_name = target_name + "_linux_flags_test"
107    linux_bionic_flags_test_name = target_name + "_linux_bionic_flags_test"
108    darwin_flags_test_name = target_name + "_darwin_flags_test"
109    windows_flags_test_name = target_name + "_windows_flags_test"
110    sdk_test_name = target_name + "_sdk_test"
111
112    _stl_deps_android_test(
113        name = android_test_name,
114        static = android_deps.static,
115        shared = android_deps.shared,
116        deps = android_deps.deps,
117        target_under_test = target_name,
118    )
119
120    _stl_deps_non_android_test(
121        name = non_android_test_name,
122        static = non_android_deps.static,
123        shared = non_android_deps.shared,
124        deps = non_android_deps.deps,
125        target_under_test = target_name,
126    )
127
128    _stl_flags_android_test(
129        name = android_flags_test_name,
130        cppflags = android_flags.cppflags,
131        linkopts = android_flags.linkopts,
132        target_under_test = flags_target_name,
133    )
134
135    _stl_flags_linux_test(
136        name = linux_flags_test_name,
137        cppflags = linux_flags.cppflags,
138        linkopts = linux_flags.linkopts,
139        target_under_test = flags_target_name,
140    )
141
142    _stl_flags_linux_bionic_test(
143        name = linux_bionic_flags_test_name,
144        cppflags = linux_bionic_flags.cppflags,
145        linkopts = linux_bionic_flags.linkopts,
146        target_under_test = flags_target_name,
147    )
148
149    _stl_flags_darwin_test(
150        name = darwin_flags_test_name,
151        cppflags = darwin_flags.cppflags,
152        linkopts = darwin_flags.linkopts,
153        target_under_test = flags_target_name,
154    )
155
156    _stl_flags_windows_test(
157        name = windows_flags_test_name,
158        cppflags = windows_flags.cppflags,
159        linkopts = windows_flags.linkopts,
160        target_under_test = flags_target_name,
161    )
162
163    _stl_deps_sdk_test(
164        name = sdk_test_name,
165        static = sdk_deps.static,
166        shared = sdk_deps.shared,
167        deps = sdk_deps.deps,
168        target_under_test = target_name,
169    )
170
171    return [
172        android_test_name,
173        non_android_test_name,
174        android_flags_test_name,
175        linux_flags_test_name,
176        linux_bionic_flags_test_name,
177        darwin_flags_test_name,
178        windows_flags_test_name,
179        sdk_test_name,
180    ]
181
182def _stl_deps_target(name, is_shared, is_binary):
183    target_name = name if name else "empty"
184    target_name += "_shared" if is_shared else "_static"
185    target_name += "_bin" if is_binary else "_lib"
186    info = stl_info_from_attr(name, is_shared, is_binary)
187
188    _stl(
189        name = target_name,
190        shared = info.shared_deps,
191        static = info.static_deps,
192        deps = info.deps,
193        tags = ["manual"],
194    )
195
196    return target_name
197
198def _stl_deps_test_impl(ctx):
199    env = analysistest.begin(ctx)
200
201    stl_info = analysistest.target_under_test(env)[_StlInfo]
202
203    expected_static = sets.make(ctx.attr.static)
204    actual_static = sets.make(stl_info.static)
205    asserts.set_equals(
206        env,
207        expected = expected_static,
208        actual = actual_static,
209    )
210
211    expected_shared = sets.make(ctx.attr.shared)
212    actual_shared = sets.make(stl_info.shared)
213    asserts.set_equals(
214        env,
215        expected = expected_shared,
216        actual = actual_shared,
217    )
218
219    expected_deps = sets.make(ctx.attr.deps)
220    actual_deps = sets.make(stl_info.deps)
221    asserts.set_equals(
222        env,
223        expected = expected_deps,
224        actual = actual_deps,
225    )
226
227    return analysistest.end(env)
228
229def _stl_flags_target(name, is_shared, is_binary):
230    target_name = name if name else "empty"
231    target_name += "_shared" if is_shared else "_static"
232    target_name += "_bin" if is_binary else "_lib"
233    target_name += "_flags"
234    info = stl_info_from_attr(name, is_shared)
235
236    _stl_flags(
237        name = target_name,
238        cppflags = info.cppflags,
239        linkopts = info.linkopts,
240        tags = ["manual"],
241    )
242
243    return target_name
244
245def _stl_flags_test_impl(ctx):
246    env = analysistest.begin(ctx)
247
248    stl_info = analysistest.target_under_test(env)[_StlFlagsInfo]
249
250    expected_cppflags = sets.make(ctx.attr.cppflags)
251    actual_cppflags = sets.make(stl_info.cppflags)
252    asserts.set_equals(
253        env,
254        expected = expected_cppflags,
255        actual = actual_cppflags,
256    )
257
258    expected_linkopts = sets.make(ctx.attr.linkopts)
259    actual_linkopts = sets.make(stl_info.linkopts)
260    asserts.set_equals(
261        env,
262        expected = expected_linkopts,
263        actual = actual_linkopts,
264    )
265
266    return analysistest.end(env)
267
268__stl_flags_android_test = analysistest.make(
269    impl = _stl_flags_test_impl,
270    attrs = {
271        "cppflags": attr.string_list(),
272        "linkopts": attr.string_list(),
273    },
274)
275
276def _stl_flags_android_test(**kwargs):
277    __stl_flags_android_test(
278        target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"],
279        **kwargs
280    )
281
282__stl_flags_linux_test = analysistest.make(
283    impl = _stl_flags_test_impl,
284    attrs = {
285        "cppflags": attr.string_list(),
286        "linkopts": attr.string_list(),
287    },
288)
289
290def _stl_flags_linux_test(**kwargs):
291    __stl_flags_linux_test(
292        target_compatible_with = ["//build/bazel_common_rules/platforms/os:linux"],
293        **kwargs
294    )
295
296__stl_flags_linux_bionic_test = analysistest.make(
297    impl = _stl_flags_test_impl,
298    attrs = {
299        "cppflags": attr.string_list(),
300        "linkopts": attr.string_list(),
301    },
302)
303
304def _stl_flags_linux_bionic_test(**kwargs):
305    __stl_flags_linux_bionic_test(
306        target_compatible_with = ["//build/bazel_common_rules/platforms/os:linux_bionic"],
307        **kwargs
308    )
309
310_stl_flags_windows_test = analysistest.make(
311    impl = _stl_flags_test_impl,
312    attrs = {
313        "cppflags": attr.string_list(),
314        "linkopts": attr.string_list(),
315    },
316    config_settings = {
317        "//command_line_option:platforms": "@//build/bazel/rules/cc:windows_for_testing",
318    },
319)
320
321_stl_flags_darwin_test = analysistest.make(
322    impl = _stl_flags_test_impl,
323    attrs = {
324        "cppflags": attr.string_list(),
325        "linkopts": attr.string_list(),
326    },
327    config_settings = {
328        "//command_line_option:platforms": "@//build/bazel/rules/cc:darwin_for_testing",
329    },
330)
331
332__stl_deps_android_test = analysistest.make(
333    impl = _stl_deps_test_impl,
334    attrs = {
335        "static": attr.string_list(),
336        "shared": attr.string_list(),
337        "deps": attr.string_list(default = []),
338    },
339)
340
341def _stl_deps_android_test(**kwargs):
342    __stl_deps_android_test(
343        target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"],
344        **kwargs
345    )
346
347__stl_deps_non_android_test = analysistest.make(
348    impl = _stl_deps_test_impl,
349    attrs = {
350        "static": attr.string_list(),
351        "shared": attr.string_list(),
352        "deps": attr.string_list(default = []),
353    },
354)
355
356def _stl_deps_non_android_test(**kwargs):
357    __stl_deps_non_android_test(
358        target_compatible_with = ["//build/bazel_common_rules/platforms/os:linux"],
359        **kwargs
360    )
361
362__stl_deps_sdk_test = analysistest.make(
363    impl = _stl_deps_test_impl,
364    attrs = {
365        "static": attr.string_list(),
366        "shared": attr.string_list(),
367        "deps": attr.string_list(default = []),
368    },
369    config_settings = {
370        "@//build/bazel/rules/apex:api_domain": "unbundled_app",
371    },
372)
373
374def _stl_deps_sdk_test(**kwargs):
375    __stl_deps_sdk_test(
376        target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"],
377        **kwargs
378    )
379
380def stl_test_suite(name):
381    native.test_suite(
382        name = name,
383        tests =
384            _test_stl(
385                stl = "",
386                is_shared = True,
387                is_binary = False,
388                android_deps = struct(
389                    static = _ANDROID_STATIC_DEPS,
390                    shared = _SHARED_DEP,
391                    deps = None,
392                ),
393                non_android_deps = struct(
394                    static = None,
395                    shared = _SHARED_DEP,
396                    deps = None,
397                ),
398                android_flags = struct(
399                    cppflags = _ANDROID_CPPFLAGS,
400                    linkopts = _ANDROID_LINKOPTS,
401                ),
402                linux_flags = struct(
403                    cppflags = _LINUX_CPPFLAGS,
404                    linkopts = _LINUX_LINKOPTS,
405                ),
406                linux_bionic_flags = struct(
407                    cppflags = _LINUX_BIONIC_CPPFLAGS,
408                    linkopts = _LINUX_BIONIC_LINKOPTS,
409                ),
410                darwin_flags = struct(
411                    cppflags = _DARWIN_CPPFLAGS,
412                    linkopts = _DARWIN_LINKOPTS,
413                ),
414                windows_flags = struct(
415                    cppflags = _WINDOWS_CPPFLAGS,
416                    linkopts = _WINDOWS_LINKOPTS,
417                ),
418                sdk_deps = struct(
419                    static = None,
420                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
421                    deps = _SDK_SYSTEM_DEPS,
422                ),
423            ) +
424            _test_stl(
425                stl = "system",
426                is_shared = True,
427                is_binary = False,
428                android_deps = struct(
429                    static = _ANDROID_STATIC_DEPS,
430                    shared = _SHARED_DEP,
431                    deps = None,
432                ),
433                non_android_deps = struct(
434                    static = None,
435                    shared = _SHARED_DEP,
436                    deps = None,
437                ),
438                android_flags = struct(
439                    cppflags = _ANDROID_CPPFLAGS,
440                    linkopts = _ANDROID_LINKOPTS,
441                ),
442                linux_flags = struct(
443                    cppflags = _LINUX_CPPFLAGS,
444                    linkopts = _LINUX_LINKOPTS,
445                ),
446                linux_bionic_flags = struct(
447                    cppflags = _LINUX_BIONIC_CPPFLAGS,
448                    linkopts = _LINUX_BIONIC_LINKOPTS,
449                ),
450                darwin_flags = struct(
451                    cppflags = _DARWIN_CPPFLAGS,
452                    linkopts = _DARWIN_LINKOPTS,
453                ),
454                windows_flags = struct(
455                    cppflags = _WINDOWS_CPPFLAGS,
456                    linkopts = _WINDOWS_LINKOPTS,
457                ),
458                sdk_deps = struct(
459                    static = None,
460                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
461                    deps = _SDK_SYSTEM_DEPS,
462                ),
463            ) +
464            _test_stl(
465                stl = "libc++",
466                is_shared = True,
467                is_binary = False,
468                android_deps = struct(
469                    static = _ANDROID_STATIC_DEPS,
470                    shared = _SHARED_DEP,
471                    deps = None,
472                ),
473                non_android_deps = struct(
474                    static = None,
475                    shared = _SHARED_DEP,
476                    deps = None,
477                ),
478                android_flags = struct(
479                    cppflags = _ANDROID_CPPFLAGS,
480                    linkopts = _ANDROID_LINKOPTS,
481                ),
482                linux_flags = struct(
483                    cppflags = _LINUX_CPPFLAGS,
484                    linkopts = _LINUX_LINKOPTS,
485                ),
486                linux_bionic_flags = struct(
487                    cppflags = _LINUX_BIONIC_CPPFLAGS,
488                    linkopts = _LINUX_BIONIC_LINKOPTS,
489                ),
490                darwin_flags = struct(
491                    cppflags = _DARWIN_CPPFLAGS,
492                    linkopts = _DARWIN_LINKOPTS,
493                ),
494                windows_flags = struct(
495                    cppflags = _WINDOWS_CPPFLAGS,
496                    linkopts = _WINDOWS_LINKOPTS,
497                ),
498                sdk_deps = struct(
499                    static = [_SDK_LIBUNWIND],
500                    shared = [_SDK_LIBCXX],
501                    deps = None,
502                ),
503            ) +
504            _test_stl(
505                stl = "libc++_static",
506                is_shared = True,
507                is_binary = False,
508                android_deps = struct(
509                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP,
510                    shared = None,
511                    deps = None,
512                ),
513                non_android_deps = struct(
514                    static = _STATIC_DEP,
515                    shared = None,
516                    deps = None,
517                ),
518                android_flags = struct(
519                    cppflags = _ANDROID_CPPFLAGS,
520                    linkopts = _ANDROID_LINKOPTS,
521                ),
522                linux_flags = struct(
523                    cppflags = _LINUX_CPPFLAGS,
524                    linkopts = _LINUX_LINKOPTS,
525                ),
526                linux_bionic_flags = struct(
527                    cppflags = _LINUX_BIONIC_CPPFLAGS,
528                    linkopts = _LINUX_BIONIC_LINKOPTS,
529                ),
530                darwin_flags = struct(
531                    cppflags = _DARWIN_CPPFLAGS,
532                    linkopts = _DARWIN_LINKOPTS,
533                ),
534                windows_flags = struct(
535                    cppflags = _WINDOWS_CPPFLAGS,
536                    linkopts = _WINDOWS_LINKOPTS,
537                ),
538                sdk_deps = struct(
539                    static = [_SDK_LIBUNWIND, _SDK_LIBCXX_STATIC, _SDK_LIBCXX_ABI],
540                    shared = None,
541                    deps = None,
542                ),
543            ) +
544            _test_stl(
545                stl = "none",
546                is_shared = True,
547                is_binary = False,
548                android_deps = struct(
549                    static = None,
550                    shared = None,
551                    deps = None,
552                ),
553                non_android_deps = struct(
554                    static = None,
555                    shared = None,
556                    deps = None,
557                ),
558                android_flags = struct(
559                    cppflags = _ANDROID_CPPFLAGS,
560                    linkopts = _ANDROID_LINKOPTS,
561                ),
562                linux_flags = struct(
563                    cppflags = _LINUX_CPPFLAGS,
564                    linkopts = _LINUX_LINKOPTS,
565                ),
566                linux_bionic_flags = struct(
567                    cppflags = _LINUX_BIONIC_CPPFLAGS,
568                    linkopts = _LINUX_BIONIC_LINKOPTS,
569                ),
570                darwin_flags = struct(
571                    cppflags = _DARWIN_CPPFLAGS_STL_NONE,
572                    linkopts = _DARWIN_LINKOPTS,
573                ),
574                windows_flags = struct(
575                    cppflags = _WINDOWS_CPPFLAGS_STL_NONE,
576                    linkopts = _WINDOWS_LINKOPTS,
577                ),
578                sdk_deps = struct(
579                    static = None,
580                    shared = None,
581                    deps = None,
582                ),
583            ) +
584            _test_stl(
585                stl = "",
586                is_shared = False,
587                is_binary = False,
588                android_deps = struct(
589                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP,
590                    shared = None,
591                    deps = None,
592                ),
593                non_android_deps = struct(
594                    static = _STATIC_DEP,
595                    shared = None,
596                    deps = None,
597                ),
598                android_flags = struct(
599                    cppflags = _ANDROID_CPPFLAGS,
600                    linkopts = _ANDROID_LINKOPTS,
601                ),
602                linux_flags = struct(
603                    cppflags = _LINUX_CPPFLAGS,
604                    linkopts = _LINUX_LINKOPTS,
605                ),
606                linux_bionic_flags = struct(
607                    cppflags = _LINUX_BIONIC_CPPFLAGS,
608                    linkopts = _LINUX_BIONIC_LINKOPTS,
609                ),
610                darwin_flags = struct(
611                    cppflags = _DARWIN_CPPFLAGS,
612                    linkopts = _DARWIN_LINKOPTS,
613                ),
614                windows_flags = struct(
615                    cppflags = _WINDOWS_CPPFLAGS,
616                    linkopts = _WINDOWS_LINKOPTS,
617                ),
618                sdk_deps = struct(
619                    static = None,
620                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
621                    deps = _SDK_SYSTEM_DEPS,
622                ),
623            ) +
624            _test_stl(
625                stl = "system",
626                is_shared = False,
627                is_binary = False,
628                android_deps = struct(
629                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP,
630                    shared = None,
631                    deps = None,
632                ),
633                non_android_deps = struct(
634                    static = _STATIC_DEP,
635                    shared = None,
636                    deps = None,
637                ),
638                android_flags = struct(
639                    cppflags = _ANDROID_CPPFLAGS,
640                    linkopts = _ANDROID_LINKOPTS,
641                ),
642                linux_flags = struct(
643                    cppflags = _LINUX_CPPFLAGS,
644                    linkopts = _LINUX_LINKOPTS,
645                ),
646                linux_bionic_flags = struct(
647                    cppflags = _LINUX_BIONIC_CPPFLAGS,
648                    linkopts = _LINUX_BIONIC_LINKOPTS,
649                ),
650                darwin_flags = struct(
651                    cppflags = _DARWIN_CPPFLAGS,
652                    linkopts = _DARWIN_LINKOPTS,
653                ),
654                windows_flags = struct(
655                    cppflags = _WINDOWS_CPPFLAGS,
656                    linkopts = _WINDOWS_LINKOPTS,
657                ),
658                sdk_deps = struct(
659                    static = None,
660                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
661                    deps = _SDK_SYSTEM_DEPS,
662                ),
663            ) +
664            _test_stl(
665                stl = "libc++",
666                is_shared = False,
667                is_binary = False,
668                android_deps = struct(
669                    static = _ANDROID_STATIC_DEPS,
670                    shared = _SHARED_DEP,
671                    deps = None,
672                ),
673                non_android_deps = struct(
674                    static = None,
675                    shared = _SHARED_DEP,
676                    deps = None,
677                ),
678                android_flags = struct(
679                    cppflags = _ANDROID_CPPFLAGS,
680                    linkopts = _ANDROID_LINKOPTS,
681                ),
682                linux_flags = struct(
683                    cppflags = _LINUX_CPPFLAGS,
684                    linkopts = _LINUX_LINKOPTS,
685                ),
686                linux_bionic_flags = struct(
687                    cppflags = _LINUX_BIONIC_CPPFLAGS,
688                    linkopts = _LINUX_BIONIC_LINKOPTS,
689                ),
690                darwin_flags = struct(
691                    cppflags = _DARWIN_CPPFLAGS,
692                    linkopts = _DARWIN_LINKOPTS,
693                ),
694                windows_flags = struct(
695                    cppflags = _WINDOWS_CPPFLAGS,
696                    linkopts = _WINDOWS_LINKOPTS,
697                ),
698                sdk_deps = struct(
699                    static = [_SDK_LIBUNWIND],
700                    shared = [_SDK_LIBCXX],
701                    deps = None,
702                ),
703            ) +
704            _test_stl(
705                stl = "libc++_static",
706                is_shared = False,
707                is_binary = False,
708                android_deps = struct(
709                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP,
710                    shared = None,
711                    deps = None,
712                ),
713                non_android_deps = struct(
714                    static = _STATIC_DEP,
715                    shared = None,
716                    deps = None,
717                ),
718                android_flags = struct(
719                    cppflags = _ANDROID_CPPFLAGS,
720                    linkopts = _ANDROID_LINKOPTS,
721                ),
722                linux_flags = struct(
723                    cppflags = _LINUX_CPPFLAGS,
724                    linkopts = _LINUX_LINKOPTS,
725                ),
726                linux_bionic_flags = struct(
727                    cppflags = _LINUX_BIONIC_CPPFLAGS,
728                    linkopts = _LINUX_BIONIC_LINKOPTS,
729                ),
730                darwin_flags = struct(
731                    cppflags = _DARWIN_CPPFLAGS,
732                    linkopts = _DARWIN_LINKOPTS,
733                ),
734                windows_flags = struct(
735                    cppflags = _WINDOWS_CPPFLAGS,
736                    linkopts = _WINDOWS_LINKOPTS,
737                ),
738                sdk_deps = struct(
739                    static = [_SDK_LIBUNWIND, _SDK_LIBCXX_STATIC, _SDK_LIBCXX_ABI],
740                    shared = None,
741                    deps = None,
742                ),
743            ) +
744            _test_stl(
745                stl = "none",
746                is_shared = False,
747                is_binary = False,
748                android_deps = struct(
749                    static = None,
750                    shared = None,
751                    deps = None,
752                ),
753                non_android_deps = struct(
754                    static = None,
755                    shared = None,
756                    deps = None,
757                ),
758                android_flags = struct(
759                    cppflags = _ANDROID_CPPFLAGS,
760                    linkopts = _ANDROID_LINKOPTS,
761                ),
762                linux_flags = struct(
763                    cppflags = _LINUX_CPPFLAGS,
764                    linkopts = _LINUX_LINKOPTS,
765                ),
766                linux_bionic_flags = struct(
767                    cppflags = _LINUX_BIONIC_CPPFLAGS,
768                    linkopts = _LINUX_BIONIC_LINKOPTS,
769                ),
770                darwin_flags = struct(
771                    cppflags = _DARWIN_CPPFLAGS_STL_NONE,
772                    linkopts = _DARWIN_LINKOPTS,
773                ),
774                windows_flags = struct(
775                    cppflags = _WINDOWS_CPPFLAGS_STL_NONE,
776                    linkopts = _WINDOWS_LINKOPTS,
777                ),
778                sdk_deps = struct(
779                    static = None,
780                    shared = None,
781                    deps = None,
782                ),
783            ) +
784            _test_stl(
785                stl = "",
786                is_shared = True,
787                is_binary = True,
788                android_deps = struct(
789                    static = _ANDROID_STATIC_DEPS + _ANDROID_BINARY_STATIC_DEP,
790                    shared = _SHARED_DEP,
791                    deps = None,
792                ),
793                non_android_deps = struct(
794                    static = None,
795                    shared = _SHARED_DEP,
796                    deps = None,
797                ),
798                android_flags = struct(
799                    cppflags = _ANDROID_CPPFLAGS,
800                    linkopts = _ANDROID_LINKOPTS,
801                ),
802                linux_flags = struct(
803                    cppflags = _LINUX_CPPFLAGS,
804                    linkopts = _LINUX_LINKOPTS,
805                ),
806                linux_bionic_flags = struct(
807                    cppflags = _LINUX_BIONIC_CPPFLAGS,
808                    linkopts = _LINUX_BIONIC_LINKOPTS,
809                ),
810                darwin_flags = struct(
811                    cppflags = _DARWIN_CPPFLAGS,
812                    linkopts = _DARWIN_LINKOPTS,
813                ),
814                windows_flags = struct(
815                    cppflags = _WINDOWS_CPPFLAGS,
816                    linkopts = _WINDOWS_LINKOPTS,
817                ),
818                sdk_deps = struct(
819                    static = None,
820                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
821                    deps = _SDK_SYSTEM_DEPS,
822                ),
823            ) +
824            _test_stl(
825                stl = "system",
826                is_shared = True,
827                is_binary = True,
828                android_deps = struct(
829                    static = _ANDROID_STATIC_DEPS + _ANDROID_BINARY_STATIC_DEP,
830                    shared = _SHARED_DEP,
831                    deps = None,
832                ),
833                non_android_deps = struct(
834                    static = None,
835                    shared = _SHARED_DEP,
836                    deps = None,
837                ),
838                android_flags = struct(
839                    cppflags = _ANDROID_CPPFLAGS,
840                    linkopts = _ANDROID_LINKOPTS,
841                ),
842                linux_flags = struct(
843                    cppflags = _LINUX_CPPFLAGS,
844                    linkopts = _LINUX_LINKOPTS,
845                ),
846                linux_bionic_flags = struct(
847                    cppflags = _LINUX_BIONIC_CPPFLAGS,
848                    linkopts = _LINUX_BIONIC_LINKOPTS,
849                ),
850                darwin_flags = struct(
851                    cppflags = _DARWIN_CPPFLAGS,
852                    linkopts = _DARWIN_LINKOPTS,
853                ),
854                windows_flags = struct(
855                    cppflags = _WINDOWS_CPPFLAGS,
856                    linkopts = _WINDOWS_LINKOPTS,
857                ),
858                sdk_deps = struct(
859                    static = None,
860                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
861                    deps = _SDK_SYSTEM_DEPS,
862                ),
863            ) +
864            _test_stl(
865                stl = "libc++",
866                is_shared = True,
867                is_binary = True,
868                android_deps = struct(
869                    static = _ANDROID_STATIC_DEPS + _ANDROID_BINARY_STATIC_DEP,
870                    shared = _SHARED_DEP,
871                    deps = None,
872                ),
873                non_android_deps = struct(
874                    static = None,
875                    shared = _SHARED_DEP,
876                    deps = None,
877                ),
878                android_flags = struct(
879                    cppflags = _ANDROID_CPPFLAGS,
880                    linkopts = _ANDROID_LINKOPTS,
881                ),
882                linux_flags = struct(
883                    cppflags = _LINUX_CPPFLAGS,
884                    linkopts = _LINUX_LINKOPTS,
885                ),
886                linux_bionic_flags = struct(
887                    cppflags = _LINUX_BIONIC_CPPFLAGS,
888                    linkopts = _LINUX_BIONIC_LINKOPTS,
889                ),
890                darwin_flags = struct(
891                    cppflags = _DARWIN_CPPFLAGS,
892                    linkopts = _DARWIN_LINKOPTS,
893                ),
894                windows_flags = struct(
895                    cppflags = _WINDOWS_CPPFLAGS,
896                    linkopts = _WINDOWS_LINKOPTS,
897                ),
898                sdk_deps = struct(
899                    static = [_SDK_LIBUNWIND],
900                    shared = [_SDK_LIBCXX],
901                    deps = None,
902                ),
903            ) +
904            _test_stl(
905                stl = "libc++_static",
906                is_shared = True,
907                is_binary = True,
908                android_deps = struct(
909                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP + _ANDROID_BINARY_STATIC_DEP,
910                    shared = None,
911                    deps = None,
912                ),
913                non_android_deps = struct(
914                    static = _STATIC_DEP,
915                    shared = None,
916                    deps = None,
917                ),
918                android_flags = struct(
919                    cppflags = _ANDROID_CPPFLAGS,
920                    linkopts = _ANDROID_LINKOPTS,
921                ),
922                linux_flags = struct(
923                    cppflags = _LINUX_CPPFLAGS,
924                    linkopts = _LINUX_LINKOPTS,
925                ),
926                linux_bionic_flags = struct(
927                    cppflags = _LINUX_BIONIC_CPPFLAGS,
928                    linkopts = _LINUX_BIONIC_LINKOPTS,
929                ),
930                darwin_flags = struct(
931                    cppflags = _DARWIN_CPPFLAGS,
932                    linkopts = _DARWIN_LINKOPTS,
933                ),
934                windows_flags = struct(
935                    cppflags = _WINDOWS_CPPFLAGS,
936                    linkopts = _WINDOWS_LINKOPTS,
937                ),
938                sdk_deps = struct(
939                    static = [_SDK_LIBUNWIND, _SDK_LIBCXX_STATIC, _SDK_LIBCXX_ABI],
940                    shared = None,
941                    deps = None,
942                ),
943            ) +
944            _test_stl(
945                stl = "none",
946                is_shared = True,
947                is_binary = True,
948                android_deps = struct(
949                    static = None,
950                    shared = None,
951                    deps = None,
952                ),
953                non_android_deps = struct(
954                    static = None,
955                    shared = None,
956                    deps = None,
957                ),
958                android_flags = struct(
959                    cppflags = _ANDROID_CPPFLAGS,
960                    linkopts = _ANDROID_LINKOPTS,
961                ),
962                linux_flags = struct(
963                    cppflags = _LINUX_CPPFLAGS,
964                    linkopts = _LINUX_LINKOPTS,
965                ),
966                linux_bionic_flags = struct(
967                    cppflags = _LINUX_BIONIC_CPPFLAGS,
968                    linkopts = _LINUX_BIONIC_LINKOPTS,
969                ),
970                darwin_flags = struct(
971                    cppflags = _DARWIN_CPPFLAGS_STL_NONE,
972                    linkopts = _DARWIN_LINKOPTS,
973                ),
974                windows_flags = struct(
975                    cppflags = _WINDOWS_CPPFLAGS_STL_NONE,
976                    linkopts = _WINDOWS_LINKOPTS,
977                ),
978                sdk_deps = struct(
979                    static = None,
980                    shared = None,
981                    deps = None,
982                ),
983            ) +
984            _test_stl(
985                stl = "",
986                is_shared = False,
987                is_binary = True,
988                android_deps = struct(
989                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP + _ANDROID_BINARY_STATIC_DEP,
990                    shared = None,
991                    deps = None,
992                ),
993                non_android_deps = struct(
994                    static = _STATIC_DEP,
995                    shared = None,
996                    deps = None,
997                ),
998                android_flags = struct(
999                    cppflags = _ANDROID_CPPFLAGS,
1000                    linkopts = _ANDROID_LINKOPTS,
1001                ),
1002                linux_flags = struct(
1003                    cppflags = _LINUX_CPPFLAGS,
1004                    linkopts = _LINUX_LINKOPTS,
1005                ),
1006                linux_bionic_flags = struct(
1007                    cppflags = _LINUX_BIONIC_CPPFLAGS,
1008                    linkopts = _LINUX_BIONIC_LINKOPTS,
1009                ),
1010                darwin_flags = struct(
1011                    cppflags = _DARWIN_CPPFLAGS,
1012                    linkopts = _DARWIN_LINKOPTS,
1013                ),
1014                windows_flags = struct(
1015                    cppflags = _WINDOWS_CPPFLAGS,
1016                    linkopts = _WINDOWS_LINKOPTS,
1017                ),
1018                sdk_deps = struct(
1019                    static = None,
1020                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
1021                    deps = _SDK_SYSTEM_DEPS,
1022                ),
1023            ) +
1024            _test_stl(
1025                stl = "system",
1026                is_shared = False,
1027                is_binary = True,
1028                android_deps = struct(
1029                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP + _ANDROID_BINARY_STATIC_DEP,
1030                    shared = None,
1031                    deps = None,
1032                ),
1033                non_android_deps = struct(
1034                    static = _STATIC_DEP,
1035                    shared = None,
1036                    deps = None,
1037                ),
1038                android_flags = struct(
1039                    cppflags = _ANDROID_CPPFLAGS,
1040                    linkopts = _ANDROID_LINKOPTS,
1041                ),
1042                linux_flags = struct(
1043                    cppflags = _LINUX_CPPFLAGS,
1044                    linkopts = _LINUX_LINKOPTS,
1045                ),
1046                linux_bionic_flags = struct(
1047                    cppflags = _LINUX_BIONIC_CPPFLAGS,
1048                    linkopts = _LINUX_BIONIC_LINKOPTS,
1049                ),
1050                darwin_flags = struct(
1051                    cppflags = _DARWIN_CPPFLAGS,
1052                    linkopts = _DARWIN_LINKOPTS,
1053                ),
1054                windows_flags = struct(
1055                    cppflags = _WINDOWS_CPPFLAGS,
1056                    linkopts = _WINDOWS_LINKOPTS,
1057                ),
1058                sdk_deps = struct(
1059                    static = None,
1060                    shared = _SDK_SYSTEM_DYNAMIC_DEPS,
1061                    deps = _SDK_SYSTEM_DEPS,
1062                ),
1063            ) +
1064            _test_stl(
1065                stl = "libc++",
1066                is_shared = False,
1067                is_binary = True,
1068                android_deps = struct(
1069                    static = _ANDROID_STATIC_DEPS + _ANDROID_BINARY_STATIC_DEP,
1070                    shared = _SHARED_DEP,
1071                    deps = None,
1072                ),
1073                non_android_deps = struct(
1074                    static = None,
1075                    shared = _SHARED_DEP,
1076                    deps = None,
1077                ),
1078                android_flags = struct(
1079                    cppflags = _ANDROID_CPPFLAGS,
1080                    linkopts = _ANDROID_LINKOPTS,
1081                ),
1082                linux_flags = struct(
1083                    cppflags = _LINUX_CPPFLAGS,
1084                    linkopts = _LINUX_LINKOPTS,
1085                ),
1086                linux_bionic_flags = struct(
1087                    cppflags = _LINUX_BIONIC_CPPFLAGS,
1088                    linkopts = _LINUX_BIONIC_LINKOPTS,
1089                ),
1090                darwin_flags = struct(
1091                    cppflags = _DARWIN_CPPFLAGS,
1092                    linkopts = _DARWIN_LINKOPTS,
1093                ),
1094                windows_flags = struct(
1095                    cppflags = _WINDOWS_CPPFLAGS,
1096                    linkopts = _WINDOWS_LINKOPTS,
1097                ),
1098                sdk_deps = struct(
1099                    static = [_SDK_LIBUNWIND],
1100                    shared = [_SDK_LIBCXX],
1101                    deps = None,
1102                ),
1103            ) +
1104            _test_stl(
1105                stl = "libc++_static",
1106                is_shared = False,
1107                is_binary = True,
1108                android_deps = struct(
1109                    static = _ANDROID_STATIC_DEPS + _STATIC_DEP + _ANDROID_BINARY_STATIC_DEP,
1110                    shared = None,
1111                    deps = None,
1112                ),
1113                non_android_deps = struct(
1114                    static = _STATIC_DEP,
1115                    shared = None,
1116                    deps = None,
1117                ),
1118                android_flags = struct(
1119                    cppflags = _ANDROID_CPPFLAGS,
1120                    linkopts = _ANDROID_LINKOPTS,
1121                ),
1122                linux_flags = struct(
1123                    cppflags = _LINUX_CPPFLAGS,
1124                    linkopts = _LINUX_LINKOPTS,
1125                ),
1126                linux_bionic_flags = struct(
1127                    cppflags = _LINUX_BIONIC_CPPFLAGS,
1128                    linkopts = _LINUX_BIONIC_LINKOPTS,
1129                ),
1130                darwin_flags = struct(
1131                    cppflags = _DARWIN_CPPFLAGS,
1132                    linkopts = _DARWIN_LINKOPTS,
1133                ),
1134                windows_flags = struct(
1135                    cppflags = _WINDOWS_CPPFLAGS,
1136                    linkopts = _WINDOWS_LINKOPTS,
1137                ),
1138                sdk_deps = struct(
1139                    static = [_SDK_LIBUNWIND, _SDK_LIBCXX_STATIC, _SDK_LIBCXX_ABI],
1140                    shared = None,
1141                    deps = None,
1142                ),
1143            ) +
1144            _test_stl(
1145                stl = "none",
1146                is_shared = False,
1147                is_binary = True,
1148                android_deps = struct(
1149                    static = None,
1150                    shared = None,
1151                    deps = None,
1152                ),
1153                non_android_deps = struct(
1154                    static = None,
1155                    shared = None,
1156                    deps = None,
1157                ),
1158                android_flags = struct(
1159                    cppflags = _ANDROID_CPPFLAGS,
1160                    linkopts = _ANDROID_LINKOPTS,
1161                ),
1162                linux_flags = struct(
1163                    cppflags = _LINUX_CPPFLAGS,
1164                    linkopts = _LINUX_LINKOPTS,
1165                ),
1166                linux_bionic_flags = struct(
1167                    cppflags = _LINUX_BIONIC_CPPFLAGS,
1168                    linkopts = _LINUX_BIONIC_LINKOPTS,
1169                ),
1170                darwin_flags = struct(
1171                    cppflags = _DARWIN_CPPFLAGS_STL_NONE,
1172                    linkopts = _DARWIN_LINKOPTS,
1173                ),
1174                windows_flags = struct(
1175                    cppflags = _WINDOWS_CPPFLAGS_STL_NONE,
1176                    linkopts = _WINDOWS_LINKOPTS,
1177                ),
1178                sdk_deps = struct(
1179                    static = None,
1180                    shared = None,
1181                    deps = None,
1182                ),
1183            ),
1184    )
1185