Skip to content

Commit bb9bc76

Browse files
authored
Switch to WAMR (#5416)
* Switch to WAMR
1 parent f03b588 commit bb9bc76

File tree

18 files changed

+2427
-802
lines changed

18 files changed

+2427
-802
lines changed

.github/actions/dependencies/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ runs:
1717
conan export external/rocksdb rocksdb/9.7.3@
1818
conan export external/soci soci/4.0.3@
1919
conan export external/nudb nudb/2.0.8@
20+
conan export -k external/wamr wamr/2.2.0@
2021
- name: add Ripple Conan remote
2122
shell: bash
2223
run: |

.github/workflows/nix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ jobs:
351351
conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_ASIO_DISABLE_CONCEPTS"]' default
352352
conan export external/snappy snappy/1.1.10@
353353
conan export external/soci soci/4.0.3@
354+
conan export -k external/wamr wamr/2.2.0@
354355
355356
- name: build dependencies
356357
run: |

BUILD.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ It fixes some source files to add missing `#include`s.
204204
conan export --version 2.0.8 external/nudb
205205
```
206206

207+
Export our [Conan recipe for WAMR](./external/wamr).
208+
It add metering and expose some internal structures.
209+
210+
211+
```
212+
# Conan 1.x
213+
conan export external/wamr wamr/2.2.0@
214+
# Conan 2.x
215+
conan export --version 2.2.0 external/wamr
216+
```
217+
207218
### Build and Test
208219

209220
1. Create a build directory and move into it.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ endif()
103103
find_package(nudb REQUIRED)
104104
find_package(date REQUIRED)
105105
find_package(xxHash REQUIRED)
106-
find_package(wasmedge REQUIRED)
106+
find_package(wamr REQUIRED)
107107

108108
target_link_libraries(ripple_libs INTERFACE
109109
ed25519::ed25519

cmake/RippledCore.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ target_link_libraries(xrpl.imports.main
6565
xrpl.libpb
6666
xxHash::xxhash
6767
$<$<BOOL:${voidstar}>:antithesis-sdk-cpp>
68-
wasmedge::wasmedge
68+
wamr::wamr
6969
)
7070

7171
include(add_module)

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Xrpl(ConanFile):
3333
'soci/4.0.3',
3434
'xxhash/0.8.2',
3535
'zlib/1.3.1',
36-
'wasmedge/0.14.1',
36+
'wamr/2.2.0',
3737
]
3838

3939
tool_requires = [

external/wamr/conandata.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
patches:
2+
2.2.0:
3+
- patch_description: add metering to iwasm interpreter
4+
patch_file: patches/ripp_metering.patch
5+
patch_type: conan
6+

external/wamr/conanfile.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
from conans import ConanFile, tools
2+
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
3+
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy
4+
import os
5+
import json
6+
7+
required_conan_version = ">=1.55.0"
8+
9+
class WamrConan(ConanFile):
10+
name = "wamr"
11+
version = "2.2.0"
12+
license = "Apache License v2.0"
13+
url = "https://github.com/bytecodealliance/wasm-micro-runtime.git"
14+
description = "Webassembly micro runtime"
15+
package_type = "library"
16+
settings = "os", "compiler", "build_type", "arch"
17+
options = {"shared": [True, False], "fPIC": [True, False]}
18+
default_options = {"shared": False, "fPIC": True}
19+
generators = "CMakeToolchain", "CMakeDeps"
20+
#requires = [("llvm/20.1.1@")]
21+
22+
def export_sources(self):
23+
export_conandata_patches(self)
24+
pass
25+
26+
27+
#def build_requirements(self):
28+
# self.tool_requires("llvm/20.1.1")
29+
30+
31+
def config_options(self):
32+
if self.settings.os == "Windows":
33+
del self.options.fPIC
34+
35+
36+
def layout(self):
37+
cmake_layout(self, src_folder="src")
38+
39+
40+
def source(self):
41+
git = tools.Git()
42+
git.clone("https://github.com/bytecodealliance/wasm-micro-runtime.git", "c883fafead005e87ad3122b05409886f507c1cb0",shallow=True)
43+
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
44+
45+
46+
def generate(self):
47+
tc = CMakeToolchain(self)
48+
49+
tc.variables["WAMR_BUILD_INTERP"] = 1
50+
tc.variables["WAMR_BUILD_FAST_INTERP"] = 1
51+
tc.variables["WAMR_BUILD_INSTRUCTION_METERING"] = 1
52+
tc.variables["WAMR_BUILD_AOT"] = 0
53+
tc.variables["WAMR_BUILD_JIT"] = 0
54+
tc.variables["WAMR_BUILD_FAST_JIT"] = 0
55+
tc.variables["WAMR_DISABLE_HW_BOUND_CHECK"] = 1
56+
tc.variables["WAMR_DISABLE_STACK_HW_BOUND_CHECK"] = 1
57+
#tc.variables["WAMR_BUILD_FAST_JIT"] = 0 if self.settings.os == "Windows" else 1
58+
#ll_dep = self.dependencies["llvm"]
59+
#self.output.info(f"-----------package_folder: {type(ll_dep.__dict__)}")
60+
#tc.variables["LLVM_DIR"] = os.path.join(ll_dep.package_folder, "lib", "cmake", "llvm")
61+
tc.generate()
62+
63+
# This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder
64+
deps = CMakeDeps(self)
65+
deps.generate()
66+
67+
68+
def build(self):
69+
apply_conandata_patches(self)
70+
cmake = CMake(self)
71+
cmake.verbose = True
72+
cmake.configure()
73+
cmake.build()
74+
#self.run(f'echo {self.source_folder}')
75+
# Explicit way:
76+
# self.run('cmake %s/hello %s' % (self.source_folder, cmake.command_line))
77+
# self.run("cmake --build . %s" % cmake.build_config)
78+
79+
80+
def package(self):
81+
cmake = CMake(self)
82+
cmake.verbose = True
83+
cmake.install()
84+
85+
86+
def package_info(self):
87+
self.cpp_info.libs = ["iwasm"]
88+
self.cpp_info.names["cmake_find_package"] = "wamr"
89+
self.cpp_info.names["cmake_find_package_multi"] = "wamr"
90+

0 commit comments

Comments
 (0)