Revert "set up GL sample app to build through Bazel Mac toolchain"

This reverts commit 9be648ad64.

Reason for revert: breaking G3 roll

Original change's description:
> set up GL sample app to build through Bazel Mac toolchain
>
> Suggested review order.
> 1) tools/sk_app/* and src/gpu/ganesh/*
> sets up the actual target to be built by the toolchain
> 2) toolchain/* and .bazelrc
> changes to the mac hermetic toolchain, including support for framework dependencies, objc compilation, and dynamic lib dependency resolution
>
> Change-Id: Ic8209b97a0d8448f984d43a579e600ba4e9118e1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/549897
> Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>

Change-Id: I5414b94f2c6175ea8c7dbc6cd72c7dd8d1b47892
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/551236
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
This commit is contained in:
John Stiles 2022-06-17 20:06:34 +00:00 committed by SkCQ
parent 024aeb09b1
commit 03b2e3aeee
7 changed files with 52 additions and 197 deletions

View File

@ -4,9 +4,7 @@ build:clang_linux --crosstool_top=//toolchain:clang_suite_linux
build:clang_linux --compiler=host_is_linux_amd64
build:clang_mac --crosstool_top=//toolchain:clang_suite_mac
build:clang_mac --apple_crosstool_top=//toolchain:clang_suite_mac
build:clang_mac --compiler=host_is_mac_m1
build:clang_mac --apple_platform_type=macos
# =============================================================================
# Alias to build configurations below. This makes configuring things from

View File

@ -29,11 +29,8 @@ cc_binary_with_flags(
},
deps = [
"//:skia_public",
] + select({
"@platforms//os:macos": ["//tools/sk_app:sk_app_objc"],
"@platforms//os:linux": ["//tools/sk_app:sk_app"],
"//conditions:default": [],
}),
"//tools/sk_app",
],
)
cc_binary_with_flags(

View File

@ -3,11 +3,3 @@ load("//bazel:macros.bzl", "exports_files_legacy")
licenses(["notice"])
exports_files_legacy()
filegroup(
name = "srcs",
srcs = [
"GrGLMakeNativeInterface_mac.cpp",
],
visibility = ["//src/gpu/ganesh/gl:__pkg__"],
)

View File

@ -29,7 +29,6 @@ cc_toolchain_suite(
"arm64|host_is_mac_m1": ":mac_m1_host",
"darwin|host_is_mac_m1": ":mac_m1_host",
"darwin_arm64|host_is_mac_m1": ":mac_m1_host",
"darwin_x86_64": ":mac_m1_host",
},
)

View File

@ -94,14 +94,6 @@ def _make_action_configs():
action_name = ACTION_NAMES.cpp_compile,
tools = [clang_tool],
)
objc_compile_action = action_config(
action_name = ACTION_NAMES.objc_compile,
tools = [clang_tool],
)
objcpp_compile_action = action_config(
action_name = ACTION_NAMES.objcpp_compile,
tools = [clang_tool],
)
linkstamp_compile_action = action_config(
action_name = ACTION_NAMES.linkstamp_compile,
tools = [clang_tool],
@ -126,58 +118,6 @@ def _make_action_configs():
tools = [lld_tool],
)
# objc archiver and cpp archiver actions use the same base flags
common_archive_flags = [
flag_set(
flag_groups = [
flag_group(
# https://llvm.org/docs/CommandGuide/llvm-ar.html
# [r]eplace existing files or insert them if they already exist,
# [c]reate the file if it doesn't already exist
# [s]ymbol table should be added
# [D]eterministic timestamps should be used
flags = ["rcsD", "%{output_execpath}"],
# Despite the name, output_execpath just refers to linker output,
# e.g. libFoo.a
expand_if_available = "output_execpath",
),
],
),
flag_set(
flag_groups = [
flag_group(
iterate_over = "libraries_to_link",
flag_groups = [
flag_group(
flags = ["%{libraries_to_link.name}"],
expand_if_equal = variable_with_value(
name = "libraries_to_link.type",
value = "object_file",
),
),
flag_group(
flags = ["%{libraries_to_link.object_files}"],
iterate_over = "libraries_to_link.object_files",
expand_if_equal = variable_with_value(
name = "libraries_to_link.type",
value = "object_file_group",
),
),
],
expand_if_available = "libraries_to_link",
),
],
),
flag_set(
flag_groups = [
flag_group(
flags = ["@%{linker_param_file}"],
expand_if_available = "linker_param_file",
),
],
),
]
# This is the same rule as
# https://github.com/emscripten-core/emsdk/blob/7f39d100d8cd207094decea907121df72065517e/bazel/emscripten_toolchain/crosstool.bzl#L143
# By default, there are no flags or libraries passed to the llvm-ar tool, so
@ -185,13 +125,56 @@ def _make_action_configs():
# https://docs.bazel.build/versions/main/cc-toolchain-config-reference.html#cctoolchainconfiginfo-build-variables
cpp_link_static_library_action = action_config(
action_name = ACTION_NAMES.cpp_link_static_library,
flag_sets = common_archive_flags,
tools = [ar_tool],
)
objc_archive_action = action_config(
action_name = ACTION_NAMES.objc_archive,
flag_sets = common_archive_flags,
flag_sets = [
flag_set(
flag_groups = [
flag_group(
# https://llvm.org/docs/CommandGuide/llvm-ar.html
# replace existing files or insert them if they already exist,
# create the file if it doesn't already exist
# symbol table should be added
# Deterministic timestamps should be used
flags = ["rcsD", "%{output_execpath}"],
# Despite the name, output_execpath just refers to linker output,
# e.g. libFoo.a
expand_if_available = "output_execpath",
),
],
),
flag_set(
flag_groups = [
flag_group(
iterate_over = "libraries_to_link",
flag_groups = [
flag_group(
flags = ["%{libraries_to_link.name}"],
expand_if_equal = variable_with_value(
name = "libraries_to_link.type",
value = "object_file",
),
),
flag_group(
flags = ["%{libraries_to_link.object_files}"],
iterate_over = "libraries_to_link.object_files",
expand_if_equal = variable_with_value(
name = "libraries_to_link.type",
value = "object_file_group",
),
),
],
expand_if_available = "libraries_to_link",
),
],
),
flag_set(
flag_groups = [
flag_group(
flags = ["@%{linker_param_file}"],
expand_if_available = "linker_param_file",
),
],
),
],
tools = [ar_tool],
)
@ -204,25 +187,16 @@ def _make_action_configs():
cpp_link_nodeps_dynamic_library_action,
cpp_link_static_library_action,
linkstamp_compile_action,
objc_archive_action,
objc_compile_action,
objcpp_compile_action,
preprocess_assemble_action,
]
return action_configs
# In addition to pointing the c and cpp compile actions to our toolchain, we also need to set objc
# and objcpp action flags as well. We build .m and .mm files with the objc_library rule, which
# will use the default toolchain if not specified here.
# https://docs.bazel.build/versions/3.3.0/be/objective-c.html#objc_library
def _make_default_flags():
"""Here we define the flags for certain actions that are always applied."""
cxx_compile_includes = flag_set(
actions = [
ACTION_NAMES.c_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.objc_compile,
ACTION_NAMES.objcpp_compile,
],
flag_groups = [
flag_group(
@ -237,17 +211,9 @@ def _make_default_flags():
XCODE_SYMLINK + "/include",
"-isystem",
EXTERNAL_TOOLCHAIN + "/lib/clang/13.0.0/include",
# Set the framework path to the Mac SDK framework directory. We can't include it
# through XCODE_SYMLINK because of infinite symlink recursion introduced in the
# framework folder.
# TODO(jmbetancourt): feed this path similarly to how we used xcode-select
# idea: set this in the trampoline script
"-F",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
# We do not want clang to search in absolute paths for files. This makes
# Bazel think we are using an outside resource and fail the compile.
"-no-canonical-prefixes",
"-Wno-deprecated-declarations",
],
),
],
@ -256,8 +222,6 @@ def _make_default_flags():
cpp_compile_includes = flag_set(
actions = [
ACTION_NAMES.cpp_compile,
ACTION_NAMES.objc_compile,
ACTION_NAMES.objcpp_compile,
],
flag_groups = [
flag_group(
@ -274,13 +238,6 @@ def _make_default_flags():
flag_groups = [
flag_group(
flags = [
# lld goes through dynamic library dependencies for dylib and tbh files through
# absolute paths (/System/Library/Frameworks). However, the dependencies live in
# [Xcode dir]/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
# -syslibroot appends to the beginning of the dylib dependency path.
# https://github.com/llvm/llvm-project/blob/d61341768cf0cff7ceeaddecc2f769b5c1b901c4/lld/MachO/InputFiles.cpp#L1418-L1420
"-Wl,-syslibroot",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/",
"-fuse-ld=lld",
# We chose to use the llvm runtime, not the gcc one because it is already
# included in the clang binary
@ -302,7 +259,6 @@ def _make_default_flags():
),
],
)
return [feature(
"default_flags",
enabled = True,

View File

@ -1,8 +1,5 @@
load("//bazel:macros.bzl", "cc_library", "exports_files_legacy", "select_multi", "selects")
#TODO: shim through macros.bzl for g3 compatability
load("@rules_cc//cc:defs.bzl", "objc_library")
licenses(["notice"])
exports_files_legacy()
@ -23,14 +20,6 @@ selects.config_setting_group(
],
)
selects.config_setting_group(
name = "gl_mac",
match_all = [
"//bazel/common_config_settings:gl_backend",
"@platforms//os:macos",
],
)
selects.config_setting_group(
name = "vulkan_unix",
match_all = [
@ -83,49 +72,3 @@ cc_library(
"//conditions:default": [],
}),
)
objc_library(
name = "sk_app_objc",
testonly = True,
srcs = [
"Window.cpp",
"WindowContext.cpp",
"RasterWindowContext.h",
] + select_multi(
{
"//bazel/common_config_settings:gl_backend": [
"GLWindowContext.cpp",
"GLWindowContext.h",
],
#TODO dawn and metal backend
},
default = [],
) + select({
"@platforms//os:macos": ["//tools/sk_app/mac:srcs"],
"//conditions:default": [],
# TODO ios support
}),
hdrs = [
"Application.h",
"DisplayParams.h",
"Window.h",
"WindowContext.h",
],
copts = [
"-Wno-deprecated-declarations",
],
sdk_frameworks = [
"QuartzCore",
"Cocoa",
"Foundation",
],
visibility = ["//:__subpackages__"],
deps = [
"//:skia_internal",
"//tools/skui",
"//tools/timer",
] + select({
"@platforms//os:macos": ["//tools/sk_app/mac:deps"],
"//conditions:default": [],
}),
)

View File

@ -1,30 +0,0 @@
load("//bazel:macros.bzl", "cc_library", "exports_files_legacy")
licenses(["notice"])
exports_files_legacy()
filegroup(
name = "srcs",
testonly = True,
srcs = [
"RasterWindowContext_mac.mm",
"WindowContextFactory_mac.h",
"Window_mac.mm",
"Window_mac.h",
"main_mac.mm",
] + select({
#TODO Metal and Dawn
"//bazel/common_config_settings:gl_backend": ["GLWindowContext_mac.mm"],
"//conditions:default": [],
}),
visibility = ["//tools/sk_app:__pkg__"],
)
cc_library(
name = "deps",
testonly = True,
linkopts = [],
visibility = ["//tools/sk_app:__pkg__"],
deps = ["//tools:tool_utils"],
)