mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
bazel: Add initial config for binary distribution (see #3757)
Add support for building the CEF binary distribution using Bazel and the default platform toolchain. Tested to work for Windows x64, MacOS ARM64 and x64 (cross-compile from ARM64), and Linux x64. Windows x86 (cross-compile from x64) is known to be broken, see https://github.com/bazelbuild/bazel/issues/22164. Includes minor changes to tests directory structure to meet Bazel build requirements.
This commit is contained in:
76
bazel/win/exe_helpers.bzl
Normal file
76
bazel/win/exe_helpers.bzl
Normal file
@@ -0,0 +1,76 @@
|
||||
# Copyright (c) 2024 The Chromium Embedded Framework 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:copy_filegroups.bzl", "copy_filegroups")
|
||||
load("//bazel/win:mt.bzl", "add_manifest")
|
||||
load("//bazel/win:rc.bzl", "compile_rc")
|
||||
load("//bazel/win:variables.bzl",
|
||||
"COMMON_LINKOPTS",
|
||||
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
|
||||
def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_deps=[],
|
||||
deps=[], linkopts=[], copts=[], defines=[], data=[]):
|
||||
# Resource file.
|
||||
res_target = "{}_res".format(name)
|
||||
compile_rc(
|
||||
name = res_target,
|
||||
rc_file = rc_file,
|
||||
srcs = resources_srcs,
|
||||
deps = resources_deps,
|
||||
out = "{}.res".format(name),
|
||||
target_compatible_with = ["@platforms//os:windows"],
|
||||
)
|
||||
|
||||
# Copy DLLs and resources into the current project.
|
||||
copy_target = "{}_dlls_and_resources".format(name)
|
||||
copy_filegroups(
|
||||
name = copy_target,
|
||||
filegroups = [
|
||||
"//:dlls",
|
||||
"//:resources",
|
||||
],
|
||||
remove_prefixes = [
|
||||
"Debug",
|
||||
"Release",
|
||||
"Resources",
|
||||
],
|
||||
)
|
||||
|
||||
# Executable target.
|
||||
binary_target = "{}_no_manifest".format(name)
|
||||
cc_binary(
|
||||
name = binary_target,
|
||||
srcs = srcs,
|
||||
deps = [
|
||||
"//:cef_wrapper",
|
||||
"//:cef",
|
||||
"//:cef_sandbox",
|
||||
] + deps,
|
||||
linkopts = [
|
||||
"$(location :{})".format(res_target),
|
||||
] + COMMON_LINKOPTS + linkopts,
|
||||
copts = select({
|
||||
"//:windows_dbg": COMMON_COPTS_DEBUG,
|
||||
"//conditions:default": COMMON_COPTS_RELEASE,
|
||||
}) + COMMON_COPTS + copts,
|
||||
defines = defines,
|
||||
additional_linker_inputs = [
|
||||
":{}".format(res_target),
|
||||
],
|
||||
data = [
|
||||
":{}".format(copy_target),
|
||||
] + data,
|
||||
features = ["generate_pdb_file"],
|
||||
target_compatible_with = ["@platforms//os:windows"],
|
||||
)
|
||||
|
||||
# Add manifest and rename to final executable.
|
||||
add_manifest(
|
||||
name = name,
|
||||
mt_files = manifest_srcs,
|
||||
in_binary = ":{}".format(binary_target),
|
||||
out_binary = "{}.exe".format(name),
|
||||
target_compatible_with = ["@platforms//os:windows"],
|
||||
)
|
Reference in New Issue
Block a user