11cb0ef41Sopenharmony_ci# Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciload("@bazel_skylib//lib:selects.bzl", "selects")
61cb0ef41Sopenharmony_ciload(
71cb0ef41Sopenharmony_ci    ":v8-target-cpu.bzl",
81cb0ef41Sopenharmony_ci    "v8_configure_target_cpu",
91cb0ef41Sopenharmony_ci    "v8_target_cpu",
101cb0ef41Sopenharmony_ci)
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cipackage(
131cb0ef41Sopenharmony_ci    default_visibility = [
141cb0ef41Sopenharmony_ci        "//visibility:public",
151cb0ef41Sopenharmony_ci    ],
161cb0ef41Sopenharmony_ci)
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconfig_setting(
191cb0ef41Sopenharmony_ci    name = "is_fastbuild",
201cb0ef41Sopenharmony_ci    values = {
211cb0ef41Sopenharmony_ci        "compilation_mode": "fastbuild",
221cb0ef41Sopenharmony_ci    },
231cb0ef41Sopenharmony_ci)
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconfig_setting(
261cb0ef41Sopenharmony_ci    name = "is_debug",
271cb0ef41Sopenharmony_ci    values = {
281cb0ef41Sopenharmony_ci        "compilation_mode": "dbg",
291cb0ef41Sopenharmony_ci    },
301cb0ef41Sopenharmony_ci)
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciconfig_setting(
331cb0ef41Sopenharmony_ci    name = "platform_cpu_x64",
341cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:x86_64"],
351cb0ef41Sopenharmony_ci)
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciconfig_setting(
381cb0ef41Sopenharmony_ci    name = "platform_cpu_ia32",
391cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:x86_32"],
401cb0ef41Sopenharmony_ci)
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciconfig_setting(
431cb0ef41Sopenharmony_ci    name = "platform_cpu_arm64",
441cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:aarch64"],
451cb0ef41Sopenharmony_ci)
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ciconfig_setting(
481cb0ef41Sopenharmony_ci    name = "platform_cpu_arm",
491cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:arm"],
501cb0ef41Sopenharmony_ci)
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ciconfig_setting(
531cb0ef41Sopenharmony_ci    name = "platform_cpu_s390x",
541cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:s390x"],
551cb0ef41Sopenharmony_ci)
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ciconfig_setting(
581cb0ef41Sopenharmony_ci    name = "platform_cpu_riscv64",
591cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:riscv64"],
601cb0ef41Sopenharmony_ci)
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ciconfig_setting(
631cb0ef41Sopenharmony_ci    name = "platform_cpu_ppc64le",
641cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//cpu:ppc"],
651cb0ef41Sopenharmony_ci)
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_civ8_target_cpu(
681cb0ef41Sopenharmony_ci    name = "v8_target_cpu",
691cb0ef41Sopenharmony_ci    build_setting_default = "none",
701cb0ef41Sopenharmony_ci)
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_ciconfig_setting(
731cb0ef41Sopenharmony_ci    name = "v8_host_target_is_none",
741cb0ef41Sopenharmony_ci    flag_values = {
751cb0ef41Sopenharmony_ci        ":v8_target_cpu": "none",
761cb0ef41Sopenharmony_ci    },
771cb0ef41Sopenharmony_ci)
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_civ8_configure_target_cpu(
801cb0ef41Sopenharmony_ci    name = "x64",
811cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_x64"],
821cb0ef41Sopenharmony_ci)
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_civ8_configure_target_cpu(
851cb0ef41Sopenharmony_ci    name = "ia32",
861cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_ia32"],
871cb0ef41Sopenharmony_ci)
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_civ8_configure_target_cpu(
901cb0ef41Sopenharmony_ci    name = "arm64",
911cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_arm64"],
921cb0ef41Sopenharmony_ci)
931cb0ef41Sopenharmony_ci
941cb0ef41Sopenharmony_civ8_configure_target_cpu(
951cb0ef41Sopenharmony_ci    name = "arm",
961cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_arm"],
971cb0ef41Sopenharmony_ci)
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_civ8_configure_target_cpu(
1001cb0ef41Sopenharmony_ci    name = "s390x",
1011cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_s390x"],
1021cb0ef41Sopenharmony_ci)
1031cb0ef41Sopenharmony_ci
1041cb0ef41Sopenharmony_civ8_configure_target_cpu(
1051cb0ef41Sopenharmony_ci    name = "riscv64",
1061cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_riscv64"],
1071cb0ef41Sopenharmony_ci)
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_civ8_configure_target_cpu(
1101cb0ef41Sopenharmony_ci    name = "ppc64le",
1111cb0ef41Sopenharmony_ci    matching_configs = [":platform_cpu_ppc64le"],
1121cb0ef41Sopenharmony_ci)
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ciselects.config_setting_group(
1151cb0ef41Sopenharmony_ci    name = "v8_target_is_32_bits",
1161cb0ef41Sopenharmony_ci    match_any = [
1171cb0ef41Sopenharmony_ci        ":v8_target_ia32",
1181cb0ef41Sopenharmony_ci        ":v8_target_arm",
1191cb0ef41Sopenharmony_ci    ],
1201cb0ef41Sopenharmony_ci)
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci# Running arm64 simulator on x64 host.
1231cb0ef41Sopenharmony_ciselects.config_setting_group(
1241cb0ef41Sopenharmony_ci    name = "v8_arm64_simulator",
1251cb0ef41Sopenharmony_ci    match_all = [
1261cb0ef41Sopenharmony_ci        ":v8_target_arm64",
1271cb0ef41Sopenharmony_ci        ":is_x64",
1281cb0ef41Sopenharmony_ci    ],
1291cb0ef41Sopenharmony_ci)
1301cb0ef41Sopenharmony_ci
1311cb0ef41Sopenharmony_ciconfig_setting(
1321cb0ef41Sopenharmony_ci    name = "is_linux",
1331cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//os:linux"],
1341cb0ef41Sopenharmony_ci)
1351cb0ef41Sopenharmony_ci
1361cb0ef41Sopenharmony_ciconfig_setting(
1371cb0ef41Sopenharmony_ci    name = "is_android",
1381cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//os:android"],
1391cb0ef41Sopenharmony_ci)
1401cb0ef41Sopenharmony_ci
1411cb0ef41Sopenharmony_ciconfig_setting(
1421cb0ef41Sopenharmony_ci    name = "is_macos",
1431cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//os:macos"],
1441cb0ef41Sopenharmony_ci)
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ciconfig_setting(
1471cb0ef41Sopenharmony_ci    name = "is_windows",
1481cb0ef41Sopenharmony_ci    constraint_values = ["@platforms//os:windows"],
1491cb0ef41Sopenharmony_ci)
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ciselects.config_setting_group(
1521cb0ef41Sopenharmony_ci    name = "is_64bit",
1531cb0ef41Sopenharmony_ci    match_any = [
1541cb0ef41Sopenharmony_ci        ":v8_target_arm64",
1551cb0ef41Sopenharmony_ci        ":is_x64",
1561cb0ef41Sopenharmony_ci        ":is_arm64",
1571cb0ef41Sopenharmony_ci        ":is_s390x",
1581cb0ef41Sopenharmony_ci        ":is_riscv64",
1591cb0ef41Sopenharmony_ci        ":is_ppc64le",
1601cb0ef41Sopenharmony_ci    ],
1611cb0ef41Sopenharmony_ci)
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_ciselects.config_setting_group(
1641cb0ef41Sopenharmony_ci    name = "is_windows_64bit",
1651cb0ef41Sopenharmony_ci    match_all = [
1661cb0ef41Sopenharmony_ci        ":is_64bit",
1671cb0ef41Sopenharmony_ci        ":is_windows",
1681cb0ef41Sopenharmony_ci    ],
1691cb0ef41Sopenharmony_ci)
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ciselects.config_setting_group(
1721cb0ef41Sopenharmony_ci    name = "is_posix",
1731cb0ef41Sopenharmony_ci    match_any = [
1741cb0ef41Sopenharmony_ci        ":is_linux",
1751cb0ef41Sopenharmony_ci        ":is_android",
1761cb0ef41Sopenharmony_ci        ":is_macos",
1771cb0ef41Sopenharmony_ci    ],
1781cb0ef41Sopenharmony_ci)
1791cb0ef41Sopenharmony_ci
1801cb0ef41Sopenharmony_ciselects.config_setting_group(
1811cb0ef41Sopenharmony_ci    name = "is_not_android",
1821cb0ef41Sopenharmony_ci    match_any = [
1831cb0ef41Sopenharmony_ci        ":is_windows",
1841cb0ef41Sopenharmony_ci        ":is_linux",
1851cb0ef41Sopenharmony_ci        ":is_macos",
1861cb0ef41Sopenharmony_ci    ]
1871cb0ef41Sopenharmony_ci)
1881cb0ef41Sopenharmony_ci
1891cb0ef41Sopenharmony_ciselects.config_setting_group(
1901cb0ef41Sopenharmony_ci    name = "is_non_android_posix",
1911cb0ef41Sopenharmony_ci    match_any = [
1921cb0ef41Sopenharmony_ci        ":is_linux",
1931cb0ef41Sopenharmony_ci        ":is_macos",
1941cb0ef41Sopenharmony_ci    ],
1951cb0ef41Sopenharmony_ci)
1961cb0ef41Sopenharmony_ci
1971cb0ef41Sopenharmony_ciselects.config_setting_group(
1981cb0ef41Sopenharmony_ci    name = "is_posix_x64",
1991cb0ef41Sopenharmony_ci    match_all = [
2001cb0ef41Sopenharmony_ci        ":is_posix",
2011cb0ef41Sopenharmony_ci        ":is_x64",
2021cb0ef41Sopenharmony_ci    ],
2031cb0ef41Sopenharmony_ci)
2041cb0ef41Sopenharmony_ci
2051cb0ef41Sopenharmony_ciselects.config_setting_group(
2061cb0ef41Sopenharmony_ci    name = "is_non_android_posix_x64",
2071cb0ef41Sopenharmony_ci    match_all = [
2081cb0ef41Sopenharmony_ci        ":is_non_android_posix",
2091cb0ef41Sopenharmony_ci        ":is_x64",
2101cb0ef41Sopenharmony_ci    ],
2111cb0ef41Sopenharmony_ci)
2121cb0ef41Sopenharmony_ci
2131cb0ef41Sopenharmony_ciselects.config_setting_group(
2141cb0ef41Sopenharmony_ci    name = "is_inline_asm_x64",
2151cb0ef41Sopenharmony_ci    match_all = [
2161cb0ef41Sopenharmony_ci        ":is_posix",
2171cb0ef41Sopenharmony_ci        ":is_x64",
2181cb0ef41Sopenharmony_ci    ],
2191cb0ef41Sopenharmony_ci)
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_ciselects.config_setting_group(
2221cb0ef41Sopenharmony_ci    name = "is_inline_asm_ia32",
2231cb0ef41Sopenharmony_ci    match_all = [
2241cb0ef41Sopenharmony_ci        ":is_posix",
2251cb0ef41Sopenharmony_ci        ":is_ia32",
2261cb0ef41Sopenharmony_ci    ],
2271cb0ef41Sopenharmony_ci)
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_ciselects.config_setting_group(
2301cb0ef41Sopenharmony_ci    name = "is_inline_asm_arm64",
2311cb0ef41Sopenharmony_ci    match_all = [
2321cb0ef41Sopenharmony_ci        ":is_posix",
2331cb0ef41Sopenharmony_ci        ":is_arm64",
2341cb0ef41Sopenharmony_ci    ],
2351cb0ef41Sopenharmony_ci)
2361cb0ef41Sopenharmony_ci
2371cb0ef41Sopenharmony_ciselects.config_setting_group(
2381cb0ef41Sopenharmony_ci    name = "is_inline_asm_arm",
2391cb0ef41Sopenharmony_ci    match_all = [
2401cb0ef41Sopenharmony_ci        ":is_posix",
2411cb0ef41Sopenharmony_ci        ":is_arm",
2421cb0ef41Sopenharmony_ci    ],
2431cb0ef41Sopenharmony_ci)
2441cb0ef41Sopenharmony_ci
2451cb0ef41Sopenharmony_ciselects.config_setting_group(
2461cb0ef41Sopenharmony_ci    name = "is_inline_asm_s390x",
2471cb0ef41Sopenharmony_ci    match_all = [
2481cb0ef41Sopenharmony_ci        ":is_posix",
2491cb0ef41Sopenharmony_ci        ":is_s390x",
2501cb0ef41Sopenharmony_ci    ],
2511cb0ef41Sopenharmony_ci)
2521cb0ef41Sopenharmony_ci
2531cb0ef41Sopenharmony_ciselects.config_setting_group(
2541cb0ef41Sopenharmony_ci    name = "is_inline_asm_riscv64",
2551cb0ef41Sopenharmony_ci    match_all = [
2561cb0ef41Sopenharmony_ci        ":is_posix",
2571cb0ef41Sopenharmony_ci        ":is_riscv64",
2581cb0ef41Sopenharmony_ci    ],
2591cb0ef41Sopenharmony_ci)
2601cb0ef41Sopenharmony_ci
2611cb0ef41Sopenharmony_ciselects.config_setting_group(
2621cb0ef41Sopenharmony_ci    name = "is_inline_asm_ppc64le",
2631cb0ef41Sopenharmony_ci    match_all = [
2641cb0ef41Sopenharmony_ci        ":is_posix",
2651cb0ef41Sopenharmony_ci        ":is_ppc64le",
2661cb0ef41Sopenharmony_ci    ],
2671cb0ef41Sopenharmony_ci)
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ciselects.config_setting_group(
2701cb0ef41Sopenharmony_ci    name = "is_msvc_asm_x64",
2711cb0ef41Sopenharmony_ci    match_all = [
2721cb0ef41Sopenharmony_ci        ":is_windows",
2731cb0ef41Sopenharmony_ci        ":is_x64",
2741cb0ef41Sopenharmony_ci    ],
2751cb0ef41Sopenharmony_ci)
2761cb0ef41Sopenharmony_ci
2771cb0ef41Sopenharmony_ciselects.config_setting_group(
2781cb0ef41Sopenharmony_ci    name = "is_msvc_asm_ia32",
2791cb0ef41Sopenharmony_ci    match_all = [
2801cb0ef41Sopenharmony_ci        ":is_windows",
2811cb0ef41Sopenharmony_ci        ":is_ia32",
2821cb0ef41Sopenharmony_ci    ],
2831cb0ef41Sopenharmony_ci)
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ciselects.config_setting_group(
2861cb0ef41Sopenharmony_ci    name = "is_msvc_asm_arm64",
2871cb0ef41Sopenharmony_ci    match_all = [
2881cb0ef41Sopenharmony_ci        ":is_windows",
2891cb0ef41Sopenharmony_ci        ":is_arm64",
2901cb0ef41Sopenharmony_ci    ],
2911cb0ef41Sopenharmony_ci)
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ciconfig_setting(
2941cb0ef41Sopenharmony_ci    name = "is_compiler_default",
2951cb0ef41Sopenharmony_ci    flag_values = {
2961cb0ef41Sopenharmony_ci        "@bazel_tools//tools/cpp:compiler": "compiler",
2971cb0ef41Sopenharmony_ci    },
2981cb0ef41Sopenharmony_ci)
2991cb0ef41Sopenharmony_ci
3001cb0ef41Sopenharmony_ciselects.config_setting_group(
3011cb0ef41Sopenharmony_ci    name = "is_compiler_default_on_linux",
3021cb0ef41Sopenharmony_ci    match_all = [
3031cb0ef41Sopenharmony_ci        ":is_compiler_default",
3041cb0ef41Sopenharmony_ci        ":is_linux",
3051cb0ef41Sopenharmony_ci    ],
3061cb0ef41Sopenharmony_ci)
3071cb0ef41Sopenharmony_ci
3081cb0ef41Sopenharmony_ciselects.config_setting_group(
3091cb0ef41Sopenharmony_ci    name = "is_compiler_default_on_macos",
3101cb0ef41Sopenharmony_ci    match_all = [
3111cb0ef41Sopenharmony_ci        ":is_compiler_default",
3121cb0ef41Sopenharmony_ci        ":is_macos",
3131cb0ef41Sopenharmony_ci    ],
3141cb0ef41Sopenharmony_ci)
3151cb0ef41Sopenharmony_ci
3161cb0ef41Sopenharmony_ciconfig_setting(
3171cb0ef41Sopenharmony_ci    name = "is_compiler_clang",
3181cb0ef41Sopenharmony_ci    flag_values = {
3191cb0ef41Sopenharmony_ci        "@bazel_tools//tools/cpp:compiler": "clang",
3201cb0ef41Sopenharmony_ci    },
3211cb0ef41Sopenharmony_ci)
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ciselects.config_setting_group(
3241cb0ef41Sopenharmony_ci    name = "is_clang",
3251cb0ef41Sopenharmony_ci    match_any = [
3261cb0ef41Sopenharmony_ci        ":is_compiler_default_on_macos",
3271cb0ef41Sopenharmony_ci        ":is_compiler_clang",
3281cb0ef41Sopenharmony_ci    ],
3291cb0ef41Sopenharmony_ci)
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_ciselects.config_setting_group(
3321cb0ef41Sopenharmony_ci    name = "is_clang_s390x",
3331cb0ef41Sopenharmony_ci    match_all = [
3341cb0ef41Sopenharmony_ci        ":is_clang",
3351cb0ef41Sopenharmony_ci        ":is_s390x",
3361cb0ef41Sopenharmony_ci    ],
3371cb0ef41Sopenharmony_ci)
3381cb0ef41Sopenharmony_ci
3391cb0ef41Sopenharmony_ciconfig_setting(
3401cb0ef41Sopenharmony_ci    name = "is_compiler_gcc",
3411cb0ef41Sopenharmony_ci    flag_values = {
3421cb0ef41Sopenharmony_ci        "@bazel_tools//tools/cpp:compiler": "gcc",
3431cb0ef41Sopenharmony_ci    },
3441cb0ef41Sopenharmony_ci)
3451cb0ef41Sopenharmony_ci
3461cb0ef41Sopenharmony_ciselects.config_setting_group(
3471cb0ef41Sopenharmony_ci    name = "is_gcc",
3481cb0ef41Sopenharmony_ci    match_any = [
3491cb0ef41Sopenharmony_ci        ":is_compiler_default_on_linux",
3501cb0ef41Sopenharmony_ci        ":is_compiler_gcc",
3511cb0ef41Sopenharmony_ci    ],
3521cb0ef41Sopenharmony_ci)
3531cb0ef41Sopenharmony_ci
3541cb0ef41Sopenharmony_ciselects.config_setting_group(
3551cb0ef41Sopenharmony_ci    name = "is_gcc_fastbuild",
3561cb0ef41Sopenharmony_ci    match_all = [
3571cb0ef41Sopenharmony_ci        ":is_gcc",
3581cb0ef41Sopenharmony_ci        ":is_fastbuild",
3591cb0ef41Sopenharmony_ci    ],
3601cb0ef41Sopenharmony_ci)
361