This commit is contained in:
Mayukha Vadari
2025-11-25 02:31:51 +05:30
parent 0db564d261
commit 35f7cbf772
9 changed files with 247 additions and 122 deletions

View File

@@ -1,5 +1,11 @@
# Do not update. Maintained by programmability team.
sources:
"0.42.1":
sha256: 2a5697be33c7afce8f671af4a5a3621d9e93ce55d253d31bd8201458e465fbb8
url: https://github.com/wasmi-labs/wasmi/archive/refs/tags/v0.42.1.tar.gz
patches:
0.42.1:
- patch_description: install only static lib (to prevent conflict with shared)
patch_file: patches/wasmi.patch
patch_type: conan
"0.42.1":
- patch_file: "patches/0001-xrplf-0.42.1.patch"
patch_type: conan
patch_description: Integration patch. Make wasmi lib to be able to build with existing smart-escrow branch.

View File

@@ -1,16 +1,9 @@
from conan import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import (
apply_conandata_patches,
export_conandata_patches,
# get,
)
from conan.tools.scm import Git
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get
import os
# import json
required_conan_version = ">=1.55.0"
required_conan_version = ">=2.0.0"
class WasmiConan(ConanFile):
name = "wasmi"
@@ -18,73 +11,38 @@ class WasmiConan(ConanFile):
url = "https://github.com/wasmi-labs/wasmi.git"
description = "WebAssembly (Wasm) interpreter"
package_type = "library"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [False]}
default_options = {"shared": False}
# generators = "CMakeToolchain", "CMakeDeps"
#requires = [("llvm/20.1.1@")]
def export_sources(self):
export_conandata_patches(self)
pass
# def build_requirements(self):
# self.tool_requires("llvm/20.1.1")
def config_options(self):
#if self.settings.os == "Windows":
# del self.options.fPIC
pass
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
git = Git(self)
git.fetch_commit(
url="https://github.com/wasmi-labs/wasmi.git",
commit="f628a7a86c9715f2c306f6ef9aea1cc2bdca5fa7",
)
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)
apply_conandata_patches(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["CMAKE_CXX_STANDARD"] = 20
tc.variables["BUILD_SHARED_LIBS"] = 0
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.generate()
# This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder
deps = CMakeDeps(self)
deps.generate()
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.verbose = True
cmake.configure(build_script_folder=os.path.join(self.source_folder, "crates", "c_api"))
cmake.build()
#self.run(f'echo {self.source_folder}')
# Explicit way:
# self.run('cmake %s/hello %s' % (self.source_folder, cmake.command_line))
# self.run("cmake --build . %s" % cmake.build_config)
def package(self):
cmake = CMake(self)
cmake.verbose = True
cmake.install()
def package_info(self):
self.cpp_info.libs = ["wasmi"]
self.cpp_info.names["cmake_find_package"] = "wasmi"
self.cpp_info.names["cmake_find_package_multi"] = "wasmi"

View File

@@ -1,19 +1,54 @@
diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt
index b15c787a..0d0a04b7 100644
index b15c787a..4e6de690 100644
--- a/crates/c_api/CMakeLists.txt
+++ b/crates/c_api/CMakeLists.txt
@@ -43,6 +43,11 @@ endif()
@@ -43,6 +43,10 @@ endif()
list(TRANSFORM WASMI_SHARED_FILES PREPEND ${WASMI_TARGET_DIR}/)
list(TRANSFORM WASMI_STATIC_FILES PREPEND ${WASMI_TARGET_DIR}/)
+if(NOT BUILD_SHARED_LIBS)
+ set(WASMI_SHARED_FILES )
+ set(WASMI_SHARED_FILES)
+endif()
+
+
# Instructions on how to build and install the Wasmi Rust crate.
find_program(WASMI_CARGO_BINARY cargo REQUIRED)
include(ExternalProject)
@@ -112,6 +116,7 @@ install(
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+if(BUILD_SHARED_LIBS)
if(WASMI_TARGET MATCHES "darwin")
set(INSTALLED_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmi.dylib")
install(
@@ -131,6 +136,7 @@ if(WASMI_TARGET MATCHES "darwin")
install(CODE "execute_process(COMMAND ${install_name_tool_cmd})")
endif()
endif()
+endif()
# Documentation Generation via Doxygen:
set(DOXYGEN_CONF_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in)
@@ -141,19 +147,3 @@ add_custom_target(doc
DEPENDS ${WASMI_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
-
-# C-Header Formatting via clang-format:
-find_program(CLANG_FORMAT clang-format REQUIRED)
-file(GLOB_RECURSE HEADER_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi.h
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.h
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.hh
-)
-add_custom_target(check-format
- COMMAND ${CLANG_FORMAT} -style=llvm -Werror --dry-run ${HEADER_FILES}
- COMMENT "clang-format: Check formatting for Wasmi C-API header files"
-)
-add_custom_target(format
- COMMAND ${CLANG_FORMAT} -style=llvm -i ${HEADER_FILES}
- COMMENT "clang-format: Apply formatting rules for Wasmi C-API header files"
-)
diff --git a/crates/c_api/include/wasm.h b/crates/c_api/include/wasm.h
index 5ee617ff..0199192d 100644
--- a/crates/c_api/include/wasm.h

View File

@@ -1,15 +0,0 @@
diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt
index b15c787..97dd294 100644
--- a/crates/c_api/CMakeLists.txt
+++ b/crates/c_api/CMakeLists.txt
@@ -43,6 +43,10 @@ endif()
list(TRANSFORM WASMI_SHARED_FILES PREPEND ${WASMI_TARGET_DIR}/)
list(TRANSFORM WASMI_STATIC_FILES PREPEND ${WASMI_TARGET_DIR}/)
+if(NOT BUILD_SHARED_LIBS)
+ set(WASMI_SHARED_FILES )
+endif()
+
# Instructions on how to build and install the Wasmi Rust crate.
find_program(WASMI_CARGO_BINARY cargo REQUIRED)
include(ExternalProject)