[bazel] Support Windows builds in Bazel
Extend bazel build to support windows in addition to linux and mac. Bug: v8:11234 Change-Id: I264f8dd8a33e221890a408d504a94ce2bc9cc19f No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3265064 Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#77896}
This commit is contained in:
parent
b295d0b0af
commit
8927f28f41
58
BUILD.bazel
58
BUILD.bazel
@ -322,6 +322,14 @@ v8_config(
|
||||
"V8_HAVE_TARGET_OS",
|
||||
"V8_TARGET_OS_MACOSX",
|
||||
],
|
||||
"@config//:is_windows": [
|
||||
"V8_HAVE_TARGET_OS",
|
||||
"V8_TARGET_OS_WIN",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"_CRT_RAND_S",
|
||||
"_WIN32_WINNT=0x0602",
|
||||
],
|
||||
}) + select({
|
||||
":is_v8_enable_pointer_compression": [
|
||||
"V8_COMPRESS_POINTERS",
|
||||
@ -615,6 +623,11 @@ filegroup(
|
||||
"src/base/debug/stack_trace_posix.cc",
|
||||
"src/base/platform/platform-macos.cc",
|
||||
],
|
||||
"@config//:is_windows": [
|
||||
"src/base/win32-headers.h",
|
||||
"src/base/debug/stack_trace_win.cc",
|
||||
"src/base/platform/platform-win32.cc",
|
||||
],
|
||||
}),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@ -1196,6 +1209,7 @@ filegroup(
|
||||
"src/execution/isolate-utils-inl.h",
|
||||
"src/snapshot/embedded/platform-embedded-file-writer-base.h",
|
||||
"src/snapshot/embedded/embedded-file-writer.h",
|
||||
"src/execution/encoded-c-signature.h",
|
||||
"src/execution/isolate.cc",
|
||||
"src/execution/isolate.h",
|
||||
"src/execution/local-isolate-inl.h",
|
||||
@ -2163,7 +2177,7 @@ filegroup(
|
||||
],
|
||||
}) + select({
|
||||
# Only for x64 builds and for arm64 with x64 host simulator.
|
||||
"@config//:is_x64": [
|
||||
"@config//:is_posix_64bit": [
|
||||
"src/trap-handler/handler-inside-posix.cc",
|
||||
"src/trap-handler/handler-outside-posix.cc",
|
||||
],
|
||||
@ -2174,6 +2188,22 @@ filegroup(
|
||||
"src/trap-handler/handler-outside-simulator.cc",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"@config//:is_windows": [
|
||||
"src/trap-handler/handler-inside-win.cc",
|
||||
"src/trap-handler/handler-outside-win.cc",
|
||||
"src/trap-handler/handler-inside-win.h",
|
||||
# Needed on windows to work around https://github.com/bazelbuild/bazel/issues/6337
|
||||
"third_party/zlib/zlib.h",
|
||||
"third_party/zlib/zconf.h",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"@config//:is_windows_64bit": [
|
||||
"src/diagnostics/unwinding-info-win64.cc",
|
||||
"src/diagnostics/unwinding-info-win64.h",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
":is_v8_enable_webassembly": [
|
||||
"src/asmjs/asm-js.cc",
|
||||
@ -2770,10 +2800,13 @@ filegroup(
|
||||
# Note these cannot be v8_target_is_* selects because these contain
|
||||
# inline assembly that runs inside the executable. Since these are
|
||||
# linked directly into mksnapshot, they must use the actual target cpu.
|
||||
"@config//:is_ia32": ["src/heap/base/asm/ia32/push_registers_asm.cc"],
|
||||
"@config//:is_x64": ["src/heap/base/asm/x64/push_registers_asm.cc"],
|
||||
"@config//:is_arm": ["src/heap/base/asm/arm/push_registers_asm.cc"],
|
||||
"@config//:is_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"],
|
||||
"@config//:is_inline_asm_ia32": ["src/heap/base/asm/ia32/push_registers_asm.cc"],
|
||||
"@config//:is_inline_asm_x64": ["src/heap/base/asm/x64/push_registers_asm.cc"],
|
||||
"@config//:is_inline_asm_arm": ["src/heap/base/asm/arm/push_registers_asm.cc"],
|
||||
"@config//:is_inline_asm_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"],
|
||||
"@config//:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.S"],
|
||||
"@config//:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.S"],
|
||||
"@config//:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"],
|
||||
}),
|
||||
)
|
||||
|
||||
@ -3038,6 +3071,7 @@ genrule(
|
||||
"src/inspector/protocol/Schema.h",
|
||||
],
|
||||
cmd = "bazel/generate-inspector-files.sh $(@D)",
|
||||
cmd_bat = "bazel\\generate-inspector-files.cmd $(@D)",
|
||||
local = 1,
|
||||
message = "Generating inspector files",
|
||||
)
|
||||
@ -3076,6 +3110,7 @@ genrule(
|
||||
srcs = [],
|
||||
outs = ["builtins-generated/bytecodes-builtins-list.h"],
|
||||
cmd = "$(location :bytecode_builtins_list_generator) $@",
|
||||
cmd_bat = "$(location :bytecode_builtins_list_generator) $@",
|
||||
tools = [":bytecode_builtins_list_generator"],
|
||||
)
|
||||
|
||||
@ -3084,6 +3119,7 @@ genrule(
|
||||
srcs = [],
|
||||
outs = ["src/regexp/special-case.cc"],
|
||||
cmd = "$(location :regexp_special_case_generator) $@",
|
||||
cmd_bat = "$(location :regexp_special_case_generator) $@",
|
||||
tools = [":regexp_special_case_generator"],
|
||||
)
|
||||
|
||||
@ -3149,7 +3185,10 @@ cc_library(
|
||||
srcs = [
|
||||
":torque_base_files",
|
||||
],
|
||||
copts = ["-fexceptions"],
|
||||
copts = select({
|
||||
"@config//:is_posix": [ "-fexceptions" ],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
features = ["-use_header_modules"],
|
||||
deps = [
|
||||
":torque_base_headers",
|
||||
@ -3253,7 +3292,10 @@ v8_binary(
|
||||
"src/torque/torque.cc",
|
||||
":torque_base_files",
|
||||
],
|
||||
copts = ["-fexceptions"],
|
||||
copts = select({
|
||||
"@config//:is_posix": [ "-fexceptions" ],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
features = ["-use_header_modules"],
|
||||
linkopts = select({
|
||||
"@config//:is_android": ["-llog"],
|
||||
@ -3270,7 +3312,7 @@ v8_binary(
|
||||
"@config//:is_android": ["-llog"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
noicu_deps = [":noicu/v8_libshared"],
|
||||
noicu_deps = [":v8_libshared_noicu"],
|
||||
)
|
||||
|
||||
v8_binary(
|
||||
|
@ -26,14 +26,29 @@ cc_library(
|
||||
"U_ENABLE_RESOURCE_TRACING=0",
|
||||
"UNISTR_FROM_STRING_EXPLICIT=",
|
||||
"UNISTR_FROM_CHAR_EXPLICIT=",
|
||||
],
|
||||
copts = [
|
||||
"-Wno-unused-function",
|
||||
"-Wno-parentheses",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-deprecated-declarations",
|
||||
],
|
||||
] + select({
|
||||
"@platforms//os:windows": [
|
||||
"U_STATIC_IMPLEMENTATION",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
copts = select({
|
||||
"@platforms//os:windows": [
|
||||
"/wd4005", # Macro redefinition.
|
||||
"/wd4068", # Unknown pragmas.
|
||||
"/wd4267", # Conversion from size_t on 64-bits.
|
||||
"/utf-8", # ICU source files are in UTF-8.
|
||||
],
|
||||
"//conditions:default": [
|
||||
"-Wno-unused-function",
|
||||
"-Wno-parentheses",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-deprecated-declarations",
|
||||
],
|
||||
}),
|
||||
includes = [
|
||||
"source/common",
|
||||
"source/i18n",
|
||||
@ -49,9 +64,25 @@ cc_library(
|
||||
"source/i18n/**/*.h",
|
||||
"source/i18n/**/*.cpp"
|
||||
]),
|
||||
copts = select({
|
||||
"@platforms//os:windows": [
|
||||
"/wd4005", # Macro redefinition.
|
||||
"/wd4068", # Unknown pragmas.
|
||||
"/wd4267", # Conversion from size_t on 64-bits.
|
||||
"/utf-8", # ICU source files are in UTF-8.
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
defines = [
|
||||
"U_I18N_IMPLEMENTATION",
|
||||
],
|
||||
] + select({
|
||||
"@platforms//os:windows": [
|
||||
"U_STATIC_IMPLEMENTATION",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
deps = [ ":icuuc" ],
|
||||
alwayslink = 1,
|
||||
)
|
||||
@ -65,6 +96,25 @@ cc_library(
|
||||
srcs = [
|
||||
"source/stubdata/stubdata.cpp",
|
||||
],
|
||||
copts = select({
|
||||
"@platforms//os:windows": [
|
||||
"/wd4005", # Macro redefinition.
|
||||
"/wd4068", # Unknown pragmas.
|
||||
"/wd4267", # Conversion from size_t on 64-bits.
|
||||
"/utf-8", # ICU source files are in UTF-8.
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
defines = [
|
||||
"U_I18N_IMPLEMENTATION",
|
||||
] + select({
|
||||
"@platforms//os:windows": [
|
||||
"U_STATIC_IMPLEMENTATION",
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
include_prefix = "third_party/icu",
|
||||
deps = [
|
||||
":icuuc",
|
||||
|
@ -45,8 +45,12 @@ cc_library(
|
||||
include_prefix = "third_party/zlib",
|
||||
defines = [
|
||||
"CHROMIUM_ZLIB_NO_CHROMECONF",
|
||||
"HAVE_HIDDEN",
|
||||
"CPU_NO_SIMD",
|
||||
],
|
||||
] + select({
|
||||
"@platforms//os:windows": [],
|
||||
"//conditions:default": [
|
||||
"HAVE_HIDDEN",
|
||||
],
|
||||
}),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
@ -99,6 +99,28 @@ config_setting(
|
||||
constraint_values = ["@platforms//os:macos"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "is_windows",
|
||||
constraint_values = ["@platforms//os:windows"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_64bit",
|
||||
match_any = [
|
||||
":v8_target_arm64",
|
||||
":is_x64",
|
||||
":is_arm64",
|
||||
],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_windows_64bit",
|
||||
match_all = [
|
||||
":is_64bit",
|
||||
":is_windows",
|
||||
],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_posix",
|
||||
match_any = [
|
||||
@ -107,3 +129,46 @@ selects.config_setting_group(
|
||||
":is_macos",
|
||||
],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_posix_64bit",
|
||||
match_all = [
|
||||
":is_posix",
|
||||
":is_x64",
|
||||
]
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_inline_asm_x64",
|
||||
match_all = [":is_posix", ":is_x64"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_inline_asm_ia32",
|
||||
match_all = [":is_posix", ":is_ia32"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_inline_asm_arm64",
|
||||
match_all = [":is_posix", ":is_arm64"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_inline_asm_arm",
|
||||
match_all = [":is_posix", ":is_arm"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_msvc_asm_x64",
|
||||
match_all = [":is_windows", ":is_x64"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_msvc_asm_ia32",
|
||||
match_all = [":is_windows", ":is_ia32"],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "is_msvc_asm_arm64",
|
||||
match_all = [":is_windows", ":is_arm64"],
|
||||
)
|
||||
|
@ -88,25 +88,40 @@ v8_config = rule(
|
||||
def _default_args():
|
||||
return struct(
|
||||
deps = [":define_flags"],
|
||||
copts = [
|
||||
"-fPIC",
|
||||
"-Werror",
|
||||
"-Wextra",
|
||||
"-Wno-bitwise-instead-of-logical",
|
||||
"-Wno-builtin-assume-aligned-alignment",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-implicit-int-float-conversion",
|
||||
"-Wno-deprecated-copy",
|
||||
"-Wno-non-virtual-dtor",
|
||||
"-std=c++17",
|
||||
"-isystem .",
|
||||
],
|
||||
defines = select({
|
||||
"@v8//bazel/config:is_windows": [
|
||||
"UNICODE",
|
||||
"_UNICODE",
|
||||
"_CRT_RAND_S",
|
||||
"_WIN32_WINNT=0x0602", # Override bazel default to Windows 8
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
copts = select({
|
||||
"@v8//bazel/config:is_posix": [
|
||||
"-fPIC",
|
||||
"-Werror",
|
||||
"-Wextra",
|
||||
"-Wno-bitwise-instead-of-logical",
|
||||
"-Wno-builtin-assume-aligned-alignment",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-implicit-int-float-conversion",
|
||||
"-Wno-deprecated-copy",
|
||||
"-Wno-non-virtual-dtor",
|
||||
"-std=c++17",
|
||||
"-isystem .",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
includes = ["include"],
|
||||
linkopts = [
|
||||
"-pthread",
|
||||
] + select({
|
||||
"@config//:is_macos": [],
|
||||
"//conditions:default": ["-Wl,--no-as-needed -ldl"],
|
||||
linkopts = select({
|
||||
"@v8//bazel/config:is_windows": [
|
||||
"Winmm.lib",
|
||||
"DbgHelp.lib",
|
||||
"Advapi32.lib",
|
||||
],
|
||||
"@v8//bazel/config:is_macos": ["-pthread"],
|
||||
"//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
|
||||
}) + select({
|
||||
":should_add_rdynamic": ["-rdynamic"],
|
||||
"//conditions:default": [],
|
||||
@ -184,7 +199,7 @@ def v8_library(
|
||||
default = _default_args()
|
||||
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
||||
native.cc_library(
|
||||
name = "noicu/" + name,
|
||||
name = name + "_noicu",
|
||||
srcs = srcs + noicu_srcs,
|
||||
deps = deps + noicu_deps + default.deps,
|
||||
includes = includes + default.includes,
|
||||
@ -193,8 +208,15 @@ def v8_library(
|
||||
alwayslink = 1,
|
||||
**kwargs
|
||||
)
|
||||
# Alias target used because of cc_library bug in bazel on windows
|
||||
# https://github.com/bazelbuild/bazel/issues/14237
|
||||
# TODO(victorgomes): Remove alias once bug is fixed
|
||||
native.alias(
|
||||
name = "noicu/" + name,
|
||||
actual = name + "_noicu",
|
||||
)
|
||||
native.cc_library(
|
||||
name = "icu/" + name,
|
||||
name = name + "_icu",
|
||||
srcs = srcs + icu_srcs,
|
||||
deps = deps + icu_deps + default.deps,
|
||||
includes = includes + default.includes,
|
||||
@ -203,6 +225,13 @@ def v8_library(
|
||||
alwayslink = 1,
|
||||
**kwargs
|
||||
)
|
||||
# Alias target used because of cc_library bug in bazel on windows
|
||||
# https://github.com/bazelbuild/bazel/issues/14237
|
||||
# TODO(victorgomes): Remove alias once bug is fixed
|
||||
native.alias(
|
||||
name = "icu/" + name,
|
||||
actual = name + "_icu",
|
||||
)
|
||||
else:
|
||||
native.cc_library(
|
||||
name = name,
|
||||
|
24
bazel/generate-inspector-files.cmd
Normal file
24
bazel/generate-inspector-files.cmd
Normal file
@ -0,0 +1,24 @@
|
||||
REM Copyright 2021 the V8 project authors. All rights reserved.
|
||||
REM Use of this source code is governed by a BSD-style license that can be
|
||||
REM found in the LICENSE file.
|
||||
|
||||
set BAZEL_OUT=%1
|
||||
|
||||
REM Bazel nukes all env vars, and we need the following for gn to work
|
||||
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
set ProgramFiles(x86)=C:\Program Files (x86)
|
||||
set windir=C:\Windows
|
||||
|
||||
REM Create a default GN output folder
|
||||
cmd.exe /S /E:ON /V:ON /D /c gn gen out/inspector
|
||||
|
||||
REM Generate inspector files
|
||||
cmd.exe /S /E:ON /V:ON /D /c autoninja -C out/inspector gen/src/inspector/protocol/Forward.h
|
||||
|
||||
REM Create directories in bazel output folder
|
||||
MKDIR -p %BAZEL_OUT%\include\inspector
|
||||
MKDIR -p %BAZEL_OUT%\src\inspector\protocol
|
||||
|
||||
REM Copy generated files to bazel output folder
|
||||
COPY out\inspector\gen\include\inspector\* %BAZEL_OUT%\include\inspector\
|
||||
COPY out\inspector\gen\src\inspector\protocol\* %BAZEL_OUT%\src\inspector\protocol\
|
Loading…
Reference in New Issue
Block a user