File: v8-target-cpu.bzl

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (61 lines) | stat: -rw-r--r-- 1,846 bytes parent folder | download | duplicates (16)
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
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Build rules to choose the v8 target architecture."""

load("@bazel_skylib//lib:selects.bzl", "selects")

V8CpuTypeInfo = provider(
    doc = "A singleton provider that specifies the V8 target CPU type",
    fields = {
        "value": "The V8 Target CPU selected.",
    },
)

def _host_target_cpu_impl(ctx):
    allowed_values = ["arm", "arm64", "ia32", "ppc64le", "riscv64", "s390x", "x64", "none"]
    cpu_type = ctx.build_setting_value
    if cpu_type in allowed_values:
        return V8CpuTypeInfo(value = cpu_type)
    else:
        fail("Error setting " + str(ctx.label) + ": invalid v8 target cpu '" +
             cpu_type + "'. Allowed values are " + str(allowed_values))

v8_target_cpu = rule(
    implementation = _host_target_cpu_impl,
    build_setting = config.string(flag = True),
    doc = "CPU that V8 will generate code for.",
)

def v8_configure_target_cpu(name, matching_configs):
    selects.config_setting_group(
        name = "is_" + name,
        match_any = matching_configs,
    )

    # If v8_target_cpu flag is set to 'name'
    native.config_setting(
        name = "v8_host_target_is_" + name,
        flag_values = {
            ":v8_target_cpu": name,
        },
    )

    # Default target if no v8_host_target flag is set.
    selects.config_setting_group(
        name = "v8_target_is_" + name,
        match_all = [
            ":v8_host_target_is_none",
            ":is_" + name,
        ],
    )

    # Select either the default target or the flag.
    selects.config_setting_group(
        name = "v8_target_" + name,
        match_any = [
            ":v8_host_target_is_" + name,
            ":v8_target_is_" + name,
        ],
    )