Skip to content

Commit 29708be

Browse files
authored
build: move global copts/linkopts into specific targets. (#269)
Signed-off-by: Piotr Sikora <[email protected]>
1 parent a0db71f commit 29708be

File tree

2 files changed

+52
-9
lines changed

2 files changed

+52
-9
lines changed

.bazelrc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,10 @@ build:zig-cc-linux-aarch64 --test_env=QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/
6464

6565
build --enable_platform_specific_config
6666

67+
# Use C++17.
6768
build:linux --cxxopt=-std=c++17
68-
# See https://bytecodealliance.github.io/wasmtime/c-api/
69-
build:linux --linkopt=-lm
70-
build:linux --linkopt=-lpthread
71-
build:linux --linkopt=-ldl
72-
7369
build:macos --cxxopt=-std=c++17
70+
build:windows --cxxopt="/std:c++17"
7471

72+
# Enable runfiles on Windows (enabled by default on other platforms).
7573
build:windows --enable_runfiles
76-
build:windows --cxxopt="/std:c++17"
77-
# See https://bytecodealliance.github.io/wasmtime/c-api/
78-
build:windows --copt="/DWASM_API_EXTERN="
79-
build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib bcrypt.lib"

BUILD

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,31 @@ cc_library(
141141
"src/wasmtime/wasmtime.cc",
142142
],
143143
hdrs = ["include/proxy-wasm/wasmtime.h"],
144+
copts = [
145+
"-DWASM_API_EXTERN=",
146+
],
144147
defines = [
145148
"PROXY_WASM_HAS_RUNTIME_WASMTIME",
146149
"PROXY_WASM_HOST_ENGINE_WASMTIME",
147150
],
151+
# See: https://bytecodealliance.github.io/wasmtime/c-api/
152+
linkopts = select({
153+
"@platforms//os:macos": [],
154+
"@platforms//os:windows": [
155+
"ws2_32.lib",
156+
"advapi32.lib",
157+
"userenv.lib",
158+
"ntdll.lib",
159+
"shell32.lib",
160+
"ole32.lib",
161+
"bcrypt.lib",
162+
],
163+
"//conditions:default": [
164+
"-ldl",
165+
"-lm",
166+
"-lpthread",
167+
],
168+
}),
148169
deps = [
149170
":wasm_vm_headers",
150171
"//external:wasmtime",
@@ -179,10 +200,31 @@ cc_library(
179200
"src/wasmtime/prefixed_wasmtime.cc",
180201
],
181202
hdrs = ["include/proxy-wasm/wasmtime.h"],
203+
copts = [
204+
"-DWASM_API_EXTERN=",
205+
],
182206
defines = [
183207
"PROXY_WASM_HAS_RUNTIME_WASMTIME",
184208
"PROXY_WASM_HOST_ENGINE_WASMTIME",
185209
],
210+
# See: https://bytecodealliance.github.io/wasmtime/c-api/
211+
linkopts = select({
212+
"@platforms//os:macos": [],
213+
"@platforms//os:windows": [
214+
"ws2_32.lib",
215+
"advapi32.lib",
216+
"userenv.lib",
217+
"ntdll.lib",
218+
"shell32.lib",
219+
"ole32.lib",
220+
"bcrypt.lib",
221+
],
222+
"//conditions:default": [
223+
"-ldl",
224+
"-lm",
225+
"-lpthread",
226+
],
227+
}),
186228
deps = [
187229
":wasm_vm_headers",
188230
"//external:prefixed_wasmtime",
@@ -204,6 +246,13 @@ cc_library(
204246
"PROXY_WASM_HAS_RUNTIME_WAVM",
205247
"PROXY_WASM_HOST_ENGINE_WAVM",
206248
],
249+
linkopts = select({
250+
"@platforms//os:macos": [],
251+
"@platforms//os:windows": [],
252+
"//conditions:default": [
253+
"-ldl",
254+
],
255+
}),
207256
deps = [
208257
":wasm_vm_headers",
209258
"//external:wavm",

0 commit comments

Comments
 (0)