Skip to content

Commit 82a50e8

Browse files
authored
Adjust libwebp/BUILD.gn to match Skia's (#119)
Without the sse41 and avx2 targets, the android x86 and x64 builds failed.
1 parent b70195e commit 82a50e8

File tree

1 file changed

+45
-1
lines changed
  • build/secondary/third_party/libwebp

1 file changed

+45
-1
lines changed

build/secondary/third_party/libwebp/BUILD.gn

+45-1
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,59 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
# This file is based on:
6+
# https://skia.googlesource.com/skia/+/master/third_party/libwebp/BUILD.gn
57
config("libwebp_config") {
68
include_dirs = [ "src" ]
79
}
810

11+
config("libwebp_defines") {
12+
defines = [
13+
# WebP naturally decodes to RGB_565, Skia with BGR_565.
14+
# This makes WebP decode to BGR_565 when we ask for RGB_565.
15+
# (It also swaps the color order for 4444, but we don't care today.)
16+
"WEBP_SWAP_16BIT_CSP",
17+
]
18+
}
19+
20+
source_set("libwebp_sse41") {
21+
include_dirs = [ "//third_party/libwebp/src" ]
22+
configs += [ ":libwebp_defines" ]
23+
sources = [
24+
"//third_party/libwebp/src/dsp/alpha_processing_sse41.c",
25+
"//third_party/libwebp/src/dsp/dec_sse41.c",
26+
"//third_party/libwebp/src/dsp/enc_sse41.c",
27+
"//third_party/libwebp/src/dsp/lossless_enc_sse41.c",
28+
]
29+
if ((current_cpu == "x86" || current_cpu == "x64") &&
30+
(!is_win || is_clang)) {
31+
cflags_c = [ "-msse4.1" ]
32+
}
33+
}
34+
35+
source_set("libwebp_avx2") {
36+
include_dirs = [ "//third_party/libwebp/src" ]
37+
configs += [ ":libwebp_defines" ]
38+
sources = [
39+
"//third_party/libwebp/src/dsp/enc_avx2.c",
40+
]
41+
if ((current_cpu == "x86" || current_cpu == "x64") &&
42+
(!is_win || is_clang)) {
43+
cflags_c = [ "-mavx2" ]
44+
}
45+
}
46+
947
source_set("libwebp") {
1048
public_configs = [":libwebp_config"]
49+
deps = [
50+
":libwebp_avx2",
51+
":libwebp_sse41",
52+
]
53+
1154
if (is_android) {
12-
deps = [ "//third_party/cpu-features" ]
55+
deps += [ "//third_party/cpu-features" ]
1356
}
57+
1458
sources = [
1559
"//third_party/libwebp/src/dec/alpha_dec.c",
1660
"//third_party/libwebp/src/dec/buffer_dec.c",

0 commit comments

Comments
 (0)