Skip to content

Commit ce595eb

Browse files
authored
Provide fmt and spdlog as Bazel dependencies for WasmEdge 0.16.1 build
1 parent 67c3f3d commit ce595eb

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

bazel/external/fmt.BUILD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # MIT
16+
17+
package(default_visibility = ["//visibility:public"])
18+
19+
cc_library(
20+
name = "fmt",
21+
srcs = [
22+
"src/format.cc",
23+
"src/os.cc",
24+
],
25+
hdrs = glob([
26+
"include/fmt/*.h",
27+
]),
28+
includes = ["include"],
29+
)

bazel/external/spdlog.BUILD

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # MIT
16+
17+
package(default_visibility = ["//visibility:public"])
18+
19+
cc_library(
20+
name = "spdlog",
21+
srcs = glob(
22+
[
23+
"src/*.cpp",
24+
],
25+
exclude = [
26+
"src/bundled*",
27+
],
28+
),
29+
hdrs = glob(
30+
[
31+
"include/**/*.h",
32+
],
33+
exclude = [
34+
"include/spdlog/fmt/bundled/**",
35+
],
36+
),
37+
defines = [
38+
"SPDLOG_FMT_EXTERNAL",
39+
"SPDLOG_COMPILED_LIB",
40+
],
41+
includes = ["include"],
42+
deps = ["@fmt"],
43+
)

bazel/external/wasmedge.BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ cmake(
3838
generate_args = ["-GNinja"],
3939
lib_source = ":srcs",
4040
out_static_libs = ["libwasmedge.a"],
41+
deps = [
42+
"@fmt",
43+
"@spdlog",
44+
],
4145
)

bazel/external/wasmedge.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff -urN WasmEdge-0.16.1/cmake/Helper.cmake WasmEdge-0.16.1-patched/cmake/Helper.cmake
2+
--- WasmEdge-0.16.1/cmake/Helper.cmake 2026-01-05 22:09:55.000000000 +0000
3+
+++ WasmEdge-0.16.1-patched/cmake/Helper.cmake 2026-01-15 07:37:20.896411038 +0000
4+
@@ -362,6 +362,12 @@
5+
endfunction()
6+
7+
function(wasmedge_setup_spdlog)
8+
+ # When building under Bazel with external dependencies, skip setup
9+
+ # Bazel handles fmt and spdlog separately through its dependency system
10+
+ if(DEFINED ENV{EXT_BUILD_DEPS})
11+
+ message(STATUS "Using fmt and spdlog from Bazel dependencies - skipping setup")
12+
+ return()
13+
+ endif()
14+
if(TARGET spdlog::spdlog)
15+
return()
16+
endif()
17+
diff -urN WasmEdge-0.16.1/lib/api/CMakeLists.txt WasmEdge-0.16.1-patched/lib/api/CMakeLists.txt
18+
--- WasmEdge-0.16.1/lib/api/CMakeLists.txt 2026-01-05 22:09:55.000000000 +0000
19+
+++ WasmEdge-0.16.1-patched/lib/api/CMakeLists.txt 2026-01-15 07:37:20.896411038 +0000
20+
@@ -151,8 +151,11 @@
21+
endif()
22+
23+
if(WASMEDGE_BUILD_STATIC_LIB)
24+
- wasmedge_add_static_lib_component_command(fmt::fmt)
25+
- wasmedge_add_static_lib_component_command(spdlog::spdlog)
26+
+ # Skip fmt and spdlog when building under Bazel - they're provided separately
27+
+ if(NOT DEFINED ENV{EXT_BUILD_DEPS})
28+
+ wasmedge_add_static_lib_component_command(fmt::fmt)
29+
+ wasmedge_add_static_lib_component_command(spdlog::spdlog)
30+
+ endif()
31+
wasmedge_add_static_lib_component_command(wasmedgeSystem)
32+
wasmedge_add_static_lib_component_command(wasmedgeCommon)
33+
wasmedge_add_static_lib_component_command(wasmedgePO)

bazel/repositories.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,35 @@ def proxy_wasm_cpp_host_repositories():
344344

345345
# WasmEdge with dependencies.
346346

347+
# fmt library required by WasmEdge
348+
maybe(
349+
http_archive,
350+
name = "fmt",
351+
build_file = "@proxy_wasm_cpp_host//bazel/external:fmt.BUILD",
352+
sha256 = "40fc58bebcf38c759e11a7bd8fdc163507d2423ef5058bba7f26280c5b9c5465",
353+
strip_prefix = "fmt-11.0.2",
354+
url = "https://github.com/fmtlib/fmt/releases/download/11.0.2/fmt-11.0.2.zip",
355+
)
356+
357+
# spdlog library required by WasmEdge
358+
maybe(
359+
http_archive,
360+
name = "spdlog",
361+
build_file = "@proxy_wasm_cpp_host//bazel/external:spdlog.BUILD",
362+
sha256 = "534f2ee1a4dcbeb22249856edfb2be76a1cf4f708a20b0ac2ed090ee24cfdbc9",
363+
strip_prefix = "spdlog-1.13.0",
364+
url = "https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.tar.gz",
365+
)
366+
347367
maybe(
348368
http_archive,
349369
name = "com_github_wasmedge_wasmedge",
350370
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
351371
sha256 = "2354d90a67e3eb396179663bdc0b457abbbc70dca967ec4528f211599a49f62a",
352372
strip_prefix = "WasmEdge-0.16.1",
353373
url = "https://github.com/WasmEdge/WasmEdge/archive/refs/tags/0.16.1.tar.gz",
374+
patches = ["@proxy_wasm_cpp_host//bazel/external:wasmedge.patch"],
375+
patch_args = ["-p1"],
354376
)
355377

356378
# Wasmtime with dependencies.

0 commit comments

Comments
 (0)