forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD
95 lines (81 loc) · 2.19 KB
/
BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
headers = [
"decode.h",
"encode.h",
"types.h",
]
libs = [
"webp",
"sharpyuv",
]
# libwebp at c1ffd9ac7593894c40a1de99d03f0b7af8af2577
filegroup(
name = "libwebp_sources",
srcs = glob([
"libwebp/**/*"
]),
)
genrule(
name = "webp_build",
srcs = [
"build-webp-bazel.sh",
":libwebp_sources",
"@cmake_tar_gz//file",
],
cmd_bash =
"""
set -ex
if [ "$(TARGET_CPU)" == "ios_arm64" ]; then
BUILD_ARCH="arm64"
elif [ "$(TARGET_CPU)" == "ios_sim_arm64" ]; then
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi
BUILD_DIR="$(RULEDIR)/build_$${BUILD_ARCH}"
rm -rf "$$BUILD_DIR"
mkdir -p "$$BUILD_DIR"
CMAKE_DIR="$$(pwd)/$$BUILD_DIR/cmake"
rm -rf "$$CMAKE_DIR"
mkdir -p "$$CMAKE_DIR"
tar -xzf "$(location @cmake_tar_gz//file)" -C "$$CMAKE_DIR"
cp $(location :build-webp-bazel.sh) "$$BUILD_DIR/"
SOURCE_PATH="third-party/webp/libwebp"
cp -R "$$SOURCE_PATH" "$$BUILD_DIR/"
mkdir -p "$$BUILD_DIR/Public/libwebp"
PATH="$$PATH:$$CMAKE_DIR/cmake-3.23.1-macos-universal/CMake.app/Contents/bin" sh $$BUILD_DIR/build-webp-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/libwebp" "$$BUILD_DIR"
""" +
"\n".join([
"cp -f \"$$BUILD_DIR/libwebp/src/webp/{}\" \"$(location Public/webp/{})\"".format(header, header) for header in headers
]) +
"\n" +
"\n".join([
"cp -f \"$$BUILD_DIR/build/lib{}.a\" \"$(location Public/webp/lib/lib{}.a)\"".format(lib, lib) for lib in libs
]),
outs = ["Public/webp/" + x for x in headers] +
["Public/webp/lib/lib{}.a".format(x) for x in libs],
visibility = [
"//visibility:public",
]
)
cc_library(
name = "webp_lib",
srcs = [":Public/webp/lib/lib" + x + ".a" for x in libs],
)
objc_library(
name = "webp",
module_name = "webp",
enable_modules = True,
hdrs = [":Public/webp/" + x for x in headers],
includes = [
"Public",
"Public/webp",
],
deps = [
":webp_lib",
],
visibility = [
"//visibility:public",
],
)