Commit 715d5a3a authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[bazel] Upstream BUILD and create config pkg

- Upstream changes made by BUILD and defs.bzl
- Creates a new config package, since configurations targets
  are different between bazel and blaze
- Runs buildifier in all files

No-Try: true
Change-Id: I65a1bc94a76b79eb26a348baf11eef4249be9552
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3250637Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77597}
parent 392078fb
This diff is collapsed.
......@@ -16,6 +16,12 @@ http_archive(
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
new_local_repository(
name = "config",
path = "bazel/config",
build_file = "bazel/config/BUILD.bazel",
)
new_local_repository(
name = "zlib",
path = "third_party/zlib",
......
......@@ -26,7 +26,6 @@ cc_library(
"U_ENABLE_RESOURCE_TRACING=0",
"UNISTR_FROM_STRING_EXPLICIT=",
"UNISTR_FROM_CHAR_EXPLICIT=",
"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
],
copts = [
"-Wno-unused-function",
......
# 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.
load("@bazel_skylib//lib:selects.bzl", "selects")
load(
":v8-target-cpu.bzl",
"v8_configure_target_cpu",
"v8_target_cpu",
)
package(
default_visibility = [
"//visibility:public",
],
)
config_setting(
name = "platform_cpu_x64",
constraint_values = ["@platforms//cpu:x86_64"],
)
config_setting(
name = "platform_cpu_ia32",
constraint_values = ["@platforms//cpu:x86_32"],
)
config_setting(
name = "platform_cpu_arm64",
constraint_values = ["@platforms//cpu:arm"],
)
config_setting(
name = "platform_cpu_arm",
constraint_values = ["@platforms//cpu:arm"],
)
v8_target_cpu(
name = "v8_target_cpu",
build_setting_default = "none",
)
config_setting(
name = "v8_host_target_is_none",
flag_values = {
":v8_target_cpu": "none",
},
)
v8_configure_target_cpu(
name = "x64",
matching_configs = [":platform_cpu_x64"],
)
v8_configure_target_cpu(
name = "ia32",
matching_configs = [":platform_cpu_ia32"],
)
v8_configure_target_cpu(
name = "arm",
matching_configs = [":platform_cpu_arm64"],
)
v8_configure_target_cpu(
name = "arm64",
matching_configs = [":platform_cpu_arm"],
)
selects.config_setting_group(
name = "v8_target_is_32_bits",
match_any = [
":v8_target_ia32",
":v8_target_arm",
],
)
# Running arm64 simulator on x64 host.
selects.config_setting_group(
name = "v8_arm64_simulator",
match_all = [
":v8_target_arm64",
":is_x64",
],
)
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
)
config_setting(
name = "is_android",
constraint_values = ["@platforms//os:android"],
)
config_setting(
name = "is_macos",
constraint_values = ["@platforms//os:macos"],
)
selects.config_setting_group(
name = "is_posix",
match_any = [
":is_linux",
":is_android",
":is_macos",
],
)
# 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", "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,
],
)
This diff is collapsed.
def _v8_disable_pointer_compression(settings, attr):
return {
"//third_party/v8/HEAD:v8_enable_pointer_compression": "False",
}
v8_disable_pointer_compression = transition(
implementation = _v8_disable_pointer_compression,
inputs = [],
outputs = ["//third_party/v8/HEAD:v8_enable_pointer_compression"],
)
# The implementation of transition_rule: all this does is copy the
# cc_binary's output to its own output and propagate its runfiles
# and executable to use for "$ bazel run".
#
# This makes transition_rule as close to a pure wrapper of cc_binary
# as possible.
def _v8_binary_non_pointer_compression(ctx):
binary = ctx.attr.binary[0]
outfile = ctx.actions.declare_file(ctx.label.name)
cc_binary_outfile = binary[DefaultInfo].files.to_list()[0]
ctx.actions.run_shell(
inputs = [cc_binary_outfile],
outputs = [outfile],
command = "cp %s %s" % (cc_binary_outfile.path, outfile.path),
)
return [
DefaultInfo(
executable = outfile,
data_runfiles = binary[DefaultInfo].data_runfiles,
),
]
# The purpose of this rule is to transition to a config where v8_target_cpu is
# set to the appropriate architecture, which will remain in place through exec
# transitions, so mksnapshot can for instance build on x64 but for arm64.
v8_binary_non_pointer_compression = rule(
implementation = _v8_binary_non_pointer_compression,
attrs = {
# This is the cc_binary whose deps will select() on that feature.
# Note specificaly how it's configured with v8_target_cpu_transition, which
# ensures that setting propagates down the graph.
"binary": attr.label(cfg = v8_disable_pointer_compression),
# This is a stock Bazel requirement for any rule that uses Starlark
# transitions. It's okay to copy the below verbatim for all such rules.
#
# The purpose of this requirement is to give the ability to restrict
# which packages can invoke these rules, since Starlark transitions
# make much larger graphs possible that can have memory and performance
# consequences for your build. The whitelist defaults to "everything".
# But you can redefine it more strictly if you feel that's prudent.
"_allowlist_function_transition": attr.label(
default = "//tools/allowlists/function_transition_allowlist",
),
},
# Making this executable means it works with "$ bazel run".
executable = True,
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment