2024-07-28 20:19:47 +02:00
|
|
|
# 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",
|
2024-08-06 17:57:15 +02:00
|
|
|
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
|
|
|
|
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
|
2024-07-28 20:19:47 +02:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
|
|
|
|
|
|
|
def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_deps=[],
|
2024-08-06 17:57:15 +02:00
|
|
|
deps=[], linkopts=[], copts=[], local_defines=[], data=[],
|
|
|
|
additional_linker_inputs=[], features=[], **kwargs):
|
2024-07-28 20:19:47 +02:00
|
|
|
# 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 = [
|
2024-07-31 23:53:27 +02:00
|
|
|
"@cef//:dlls",
|
|
|
|
"@cef//:resources",
|
2024-07-28 20:19:47 +02:00
|
|
|
],
|
|
|
|
remove_prefixes = [
|
|
|
|
"Debug",
|
|
|
|
"Release",
|
|
|
|
"Resources",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Executable target.
|
|
|
|
binary_target = "{}_no_manifest".format(name)
|
|
|
|
cc_binary(
|
|
|
|
name = binary_target,
|
|
|
|
srcs = srcs,
|
|
|
|
deps = [
|
2024-07-31 23:53:27 +02:00
|
|
|
"@cef//:cef_wrapper",
|
|
|
|
"@cef//:cef",
|
|
|
|
"@cef//:cef_sandbox",
|
2024-07-28 20:19:47 +02:00
|
|
|
] + deps,
|
|
|
|
linkopts = [
|
|
|
|
"$(location :{})".format(res_target),
|
|
|
|
] + COMMON_LINKOPTS + linkopts,
|
2024-08-06 17:57:15 +02:00
|
|
|
copts = COMMON_COPTS + select({
|
2024-07-31 23:53:27 +02:00
|
|
|
"@cef//:windows_dbg": COMMON_COPTS_DEBUG,
|
2024-07-28 20:19:47 +02:00
|
|
|
"//conditions:default": COMMON_COPTS_RELEASE,
|
2024-08-06 17:57:15 +02:00
|
|
|
}) + copts,
|
|
|
|
local_defines = COMMON_DEFINES + select({
|
|
|
|
"@cef//:windows_dbg": COMMON_DEFINES_DEBUG,
|
|
|
|
"//conditions:default": COMMON_DEFINES_RELEASE,
|
|
|
|
}) + local_defines,
|
2024-07-28 20:19:47 +02:00
|
|
|
additional_linker_inputs = [
|
|
|
|
":{}".format(res_target),
|
2024-08-06 17:57:15 +02:00
|
|
|
] + additional_linker_inputs,
|
2024-07-28 20:19:47 +02:00
|
|
|
data = [
|
|
|
|
":{}".format(copy_target),
|
|
|
|
] + data,
|
2024-08-06 17:57:15 +02:00
|
|
|
features = ["generate_pdb_file"] + features,
|
2024-07-28 20:19:47 +02:00
|
|
|
target_compatible_with = ["@platforms//os:windows"],
|
2024-08-06 17:57:15 +02:00
|
|
|
**kwargs
|
2024-07-28 20:19:47 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# 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"],
|
|
|
|
)
|