| 1 |
# Copyright 2023 Google LLC |
| 2 |
# |
| 3 |
# Use of this source code is governed by a BSD-style license that can be |
| 4 |
# found in the LICENSE file. |
| 5 |
|
| 6 |
import("../../gn/skia.gni") |
| 7 |
import("../third_party.gni") |
| 8 |
|
| 9 |
# The following shells out to bazelisk to compile static library dependencies that bridge the |
| 10 |
# vello_cpp crate Rust code and its C++ FFI symbols. This produces a single static library target |
| 11 |
# that is reachable via the ":vello" target. |
| 12 |
# |
| 13 |
# Pre-compiled shader dependencies: |
| 14 |
# |
| 15 |
# The vello_shaders crate bundles compute shaders that are pre-compiled into a target format based |
| 16 |
# on the GPU backend. This is driven by build arguments defined in //gn/skia.gni. |
| 17 |
|
| 18 |
if (skia_enable_vello_shaders) { |
| 19 |
bazel_args = [] |
| 20 |
if (is_mac) { |
| 21 |
if (target_cpu == "arm64") { |
| 22 |
bazel_args += [ |
| 23 |
"--platforms=//bazel/platform:mac_arm64_hermetic", |
| 24 |
"--cc_output_directory_tag=mac_arm64", |
| 25 |
] |
| 26 |
} else { |
| 27 |
bazel_args += [ "--platforms=//bazel/platform:mac_x64_hermetic" ] |
| 28 |
} |
| 29 |
} |
| 30 |
if (!is_debug) { |
| 31 |
bazel_args += [ "--compilation_mode=opt" ] |
| 32 |
} |
| 33 |
if (skia_use_metal) { |
| 34 |
bazel_args += [ "--define=VELLO_MSL_SHADERS=true" ] |
| 35 |
} |
| 36 |
if (skia_use_dawn) { |
| 37 |
bazel_args += [ "--define=VELLO_WGSL_SHADERS=true" ] |
| 38 |
} |
| 39 |
action("compile_vello_ffi") { |
| 40 |
script = "../../gn/bazel_build.py" |
| 41 |
sources = [ |
| 42 |
"BUILD.bazel", |
| 43 |
"src/lib.rs", |
| 44 |
] |
| 45 |
outputs = [ |
| 46 |
"$root_out_dir/libvello_ffi.a", |
| 47 |
"$root_out_dir/third_party/vello/src/lib.rs.h", |
| 48 |
] |
| 49 |
args = [ |
| 50 |
"//third_party/vello:vello_ffi", |
| 51 |
rebase_path("//bazel-bin/third_party/vello/libvello_ffi.a", |
| 52 |
root_build_dir), |
| 53 |
|
| 54 |
# we want the header to not simply be copied into the output directory, |
| 55 |
# but in the same path as the Bazel build uses. |
| 56 |
rebase_path("//bazel-bin/third_party/vello/src/lib.rs.h", |
| 57 |
root_build_dir) + "=third_party/vello/src/lib.rs.h", |
| 58 |
] + bazel_args |
| 59 |
} |
| 60 |
|
| 61 |
action("compile_vello_rust") { |
| 62 |
script = "../../gn/bazel_build.py" |
| 63 |
sources = [ |
| 64 |
"BUILD.bazel", |
| 65 |
"src/encoding.rs", |
| 66 |
"src/lib.rs", |
| 67 |
"src/shaders.rs", |
| 68 |
] |
| 69 |
outputs = [ "$root_out_dir/libvello_rust.a" ] |
| 70 |
args = [ |
| 71 |
"//third_party/vello:vello_rust", |
| 72 |
rebase_path("//bazel-bin/third_party/vello/libvello_rust.a", |
| 73 |
root_build_dir), |
| 74 |
] + bazel_args |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
third_party("vello") { |
| 79 |
# this is where third_party/vello/src/lib.rs.h was generated and exists. |
| 80 |
public_include_dirs = [ "$root_out_dir" ] |
| 81 |
libs = [ |
| 82 |
"$root_out_dir/libvello_ffi.a", |
| 83 |
"$root_out_dir/libvello_rust.a", |
| 84 |
"c++", |
| 85 |
] |
| 86 |
deps = [ |
| 87 |
":compile_vello_ffi", |
| 88 |
":compile_vello_rust", |
| 89 |
] |
| 90 |
public_defines = [] |
| 91 |
if (skia_use_metal) { |
| 92 |
public_defines += [ "VELLO_MSL_SHADERS=true" ] |
| 93 |
} |
| 94 |
if (skia_use_dawn) { |
| 95 |
public_defines += [ "VELLO_WGSL_SHADERS=true" ] |
| 96 |
} |
| 97 |
} |