-
-
Notifications
You must be signed in to change notification settings - Fork 330
/
BUILD.bazel
254 lines (235 loc) · 6.57 KB
/
BUILD.bazel
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@npm//:defs.bzl", "npm_link_all_packages")
load(
"//bazel:core.bzl",
"MLN_CORE_HEADERS",
"MLN_CORE_SOURCE",
"MLN_DRAWABLES_GL_HEADERS",
"MLN_DRAWABLES_GL_SOURCE",
"MLN_DRAWABLES_HEADERS",
"MLN_DRAWABLES_MTL_HEADERS",
"MLN_DRAWABLES_MTL_SOURCE",
"MLN_DRAWABLES_SOURCE",
"MLN_GENERATED_OPENGL_SHADER_HEADERS",
"MLN_GENERATED_SHADER_HEADERS",
"MLN_GENERATED_STYLE_SOURCE",
"MLN_OPENGL_HEADERS",
"MLN_OPENGL_SOURCE",
"MLN_PRIVATE_GENERATED_STYLE_HEADERS",
"MLN_PUBLIC_GENERATED_STYLE_HEADERS",
)
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
# Generate code required by the core
js_run_binary(
name = "generated_style_code",
srcs = glob(
["**/*.ejs"],
allow_empty = False,
),
outs = MLN_PUBLIC_GENERATED_STYLE_HEADERS +
MLN_PRIVATE_GENERATED_STYLE_HEADERS +
MLN_GENERATED_STYLE_SOURCE,
tool = ":generate-style-code-script",
)
js_run_binary(
name = "generated_shaders",
srcs = ["shaders/manifest.json"] + glob(
["shaders/*.glsl"],
allow_empty = False,
),
outs = MLN_GENERATED_SHADER_HEADERS +
MLN_GENERATED_OPENGL_SHADER_HEADERS,
tool = ":generate-shader-code-script",
)
# This header only target strips the __generated__ prefix for the compiler
# search paths, making the location of generated code transparent to the build
cc_library(
name = "mbgl-core-generated-public-artifacts",
hdrs = [
":generated_shaders",
":generated_style_code",
] + MLN_PUBLIC_GENERATED_STYLE_HEADERS +
MLN_GENERATED_SHADER_HEADERS +
select({
"//:metal_renderer": [],
"//conditions:default": MLN_GENERATED_OPENGL_SHADER_HEADERS,
}),
visibility = ["//visibility:public"],
)
# ditto, but for private headers (under the src/ path)
cc_library(
name = "mbgl-core-generated-private-artifacts",
hdrs = [":generated_style_code"] + MLN_PRIVATE_GENERATED_STYLE_HEADERS,
visibility = ["//visibility:private"],
)
# Generated source is inserted directly into the core target, no need to remove
# the prefix from the path.
cc_library(
name = "mbgl-core",
srcs = MLN_CORE_SOURCE +
MLN_GENERATED_STYLE_SOURCE + select({
":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE,
":legacy_renderer": MLN_OPENGL_SOURCE,
":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE,
"//conditions:default": [],
}),
hdrs = MLN_CORE_HEADERS + select({
":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS,
":legacy_renderer": MLN_OPENGL_HEADERS,
":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS,
"//conditions:default": [],
}),
copts = CPP_FLAGS + MAPLIBRE_FLAGS,
defines = select({
":legacy_renderer": [
"MLN_RENDER_BACKEND_OPENGL=1",
"MLN_LEGACY_RENDERER=1",
"MLN_DRAWABLE_RENDERER=0",
],
":drawable_renderer": [
"MLN_RENDER_BACKEND_OPENGL=1",
"MLN_LEGACY_RENDERER=0",
"MLN_DRAWABLE_RENDERER=1",
],
":metal_renderer": [
"MLN_RENDER_BACKEND_METAL=1",
"MLN_LEGACY_RENDERER=0",
"MLN_DRAWABLE_RENDERER=1",
],
}) + select({
"@platforms//os:ios": ["GLES_SILENCE_DEPRECATION=1"],
"//conditions:default": [],
}),
includes = [
"include",
"src",
] + select({
":metal_renderer": [
"vendor/metal-cpp",
],
"//conditions:default": [],
}),
local_defines = [
r"MLN_VERSION_REV=\"standalone\"",
],
visibility = ["//visibility:public"],
deps = [
":mbgl-core-generated-private-artifacts",
":mbgl-core-generated-public-artifacts",
"//vendor:boost",
"//vendor:csscolorparser",
"//vendor:earcut.hpp",
"//vendor:eternal",
"//vendor:mapbox-base",
"//vendor:parsedate",
"//vendor:polylabel",
"//vendor:protozero",
"//vendor:unique_resource",
"//vendor:unordered_dense",
"//vendor:vector-tile",
"//vendor:wagyu",
] + select({
"@platforms//os:ios": [
"//vendor:icu",
],
"@platforms//os:osx": [
"//vendor:icu",
],
"//conditions:default": [],
}) + select({
":metal_renderer": [
"//vendor:metal-cpp",
],
"//conditions:default": [],
}),
)
genrule(
name = "git_hash",
outs = ["hash"],
cmd = """
git rev-parse HEAD > $@
""",
local = True,
visibility = ["//visibility:public"],
)
# Selects the rendering implementation to utilize in the core
string_flag(
name = "renderer",
build_setting_default = "legacy",
values = [
"legacy",
"drawable",
"metal",
],
)
config_setting(
name = "legacy_renderer",
flag_values = {
":renderer": "legacy",
},
)
config_setting(
name = "drawable_renderer",
flag_values = {
":renderer": "drawable",
},
)
config_setting(
name = "metal_renderer",
flag_values = {
":renderer": "metal",
},
)
exports_files(
[
"LICENSE.md",
"scripts/style-spec-reference/v8.json",
],
visibility = ["//visibility:public"],
)
npm_link_all_packages(
name = "node_modules",
)
js_binary(
name = "generate-style-code-script",
data = [
":node_modules/argparse",
":node_modules/csscolorparser",
":style-code",
":style-spec",
],
entry_point = "scripts/generate-style-code.mjs",
)
js_binary(
name = "generate-shader-code-script",
data = [
":node_modules/argparse",
],
entry_point = "shaders/generate_shader_code.mjs",
)
js_library(
name = "style-spec",
srcs = ["scripts/style-spec.mjs"],
data = glob([
"scripts/style-spec-reference/*.json",
]),
visibility = ["//visibility:public"],
)
js_library(
name = "style-code",
srcs = ["scripts/style-code.mjs"],
visibility = ["//visibility:public"],
deps = [
":node_modules/ejs",
],
)
cc_library(
name = "maplibre_lib",
srcs = [],
visibility = ["//visibility:public"],
deps = select({
"@platforms//os:macos": ["//platform:macos-objcpp"],
"//conditions:default": [],
}),
)