-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Initial support for wasmtime package #6083
Changes from 22 commits
455e9a4
15736c9
30ad84c
638e944
326e85d
43445ea
2746861
45b7d00
7aa47ca
dddb52d
fe85d9e
c3a4642
6304223
c75ea1a
2e49fa7
8af9461
7b0b19c
728690c
59f9c9f
dca562b
7eeed40
c1fa065
20d43a9
ed7f493
3012cca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
sources: | ||
"0.29.0": | ||
Windows: | ||
"x86_64": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-x86_64-windows-c-api.zip" | ||
sha256: "83d42ab6b78804f6dcd58f4bfc1bebb3a56a21309fce28e07a5bfbecc07dc8fa" | ||
MinGW: | ||
"x86_64": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-x86_64-mingw-c-api.zip" | ||
sha256: "d44b1345a7e3f86c71af6cc225b83bdb3aef874fb1eaac7a8f06ad3b3a6a5c3e" | ||
Linux: | ||
"x86_64": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-x86_64-linux-c-api.tar.xz" | ||
sha256: "b8ee53ddebfc60a0cf981ce225837b998b984ee94326e03cac135d9d78af57e5" | ||
"armv8": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-aarch64-linux-c-api.tar.xz" | ||
sha256: "c13f906ca84c3321644cb9cd93fef4db431572e554a7527dc30a795994cbcc05" | ||
Macos: | ||
"x86_64": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-x86_64-macos-c-api.tar.xz" | ||
sha256: "e6e38b1837509af3ce5ca490d90c59d6082f54eb71dcbb49414ee5f295137bcb" | ||
Android: | ||
"armv8": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-aarch64-linux-c-api.tar.xz" | ||
sha256: "c9036f82c2fb2c3ed8291c6d37068dce6b08dff83f6292938edc0c8907284549" |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||||||||||||||||
from conans import ConanFile, CMake, tools | ||||||||||||||||||||||||||||||||||||||||||
from conans.errors import ConanInvalidConfiguration, ConanException | ||||||||||||||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||||||||||||||
import shutil | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
required_conan_version = ">=1.33.0" | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
class WasmtimeConan(ConanFile): | ||||||||||||||||||||||||||||||||||||||||||
name = 'wasmtime' | ||||||||||||||||||||||||||||||||||||||||||
homepage = 'https://github.com/bytecodealliance/wasmtime' | ||||||||||||||||||||||||||||||||||||||||||
license = 'Apache-2.0' | ||||||||||||||||||||||||||||||||||||||||||
url = 'https://github.com/conan-io/conan-center-index' | ||||||||||||||||||||||||||||||||||||||||||
description = "Standalone JIT-style runtime for WebAssembly, using Cranelift" | ||||||||||||||||||||||||||||||||||||||||||
topics = ("webassembly", "wasm", "wasi") | ||||||||||||||||||||||||||||||||||||||||||
settings = "os", "compiler", "arch" | ||||||||||||||||||||||||||||||||||||||||||
options = { "shared": [True, False] } | ||||||||||||||||||||||||||||||||||||||||||
default_options = { 'shared': False } | ||||||||||||||||||||||||||||||||||||||||||
no_copy_source = True | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||||||||||||||||||
def _minimum_cpp_standard(self): | ||||||||||||||||||||||||||||||||||||||||||
return 11 | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||||||||||||||||||
def _minimum_compilers_version(self): | ||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||
"Visual Studio": "15", | ||||||||||||||||||||||||||||||||||||||||||
"apple-clang": "9.4", | ||||||||||||||||||||||||||||||||||||||||||
"clang": "3.3", | ||||||||||||||||||||||||||||||||||||||||||
"gcc": "5.1" | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||||||||||||||||||
def _sources_key(self): | ||||||||||||||||||||||||||||||||||||||||||
if self.settings.compiler == "Visual Studio": | ||||||||||||||||||||||||||||||||||||||||||
return "Windows" | ||||||||||||||||||||||||||||||||||||||||||
elif self.settings.os == "Windows" and self.settings.compiler == "gcc": | ||||||||||||||||||||||||||||||||||||||||||
return "MinGW" | ||||||||||||||||||||||||||||||||||||||||||
return str(self.settings.os) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def configure(self): | ||||||||||||||||||||||||||||||||||||||||||
del self.settings.compiler.libcxx | ||||||||||||||||||||||||||||||||||||||||||
del self.settings.compiler.cppstd | ||||||||||||||||||||||||||||||||||||||||||
del self.settings.compiler.runtime | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def validate(self): | ||||||||||||||||||||||||||||||||||||||||||
compiler = self.settings.compiler | ||||||||||||||||||||||||||||||||||||||||||
min_version = self._minimum_compilers_version[str(compiler)] | ||||||||||||||||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||||||||||||||||
if tools.Version(compiler.version) < min_version: | ||||||||||||||||||||||||||||||||||||||||||
msg = ( | ||||||||||||||||||||||||||||||||||||||||||
"{} requires C{} features which are not supported by compiler {} {} !!" | ||||||||||||||||||||||||||||||||||||||||||
).format(self.name, self._minimum_cpp_standard, compiler, compiler.version) | ||||||||||||||||||||||||||||||||||||||||||
raise ConanInvalidConfiguration(msg) | ||||||||||||||||||||||||||||||||||||||||||
except KeyError: | ||||||||||||||||||||||||||||||||||||||||||
msg = ( | ||||||||||||||||||||||||||||||||||||||||||
"{} recipe lacks information about the {} compiler, " | ||||||||||||||||||||||||||||||||||||||||||
"support for the required C{} features is assumed" | ||||||||||||||||||||||||||||||||||||||||||
).format(self.name, compiler, self._minimum_cpp_standard) | ||||||||||||||||||||||||||||||||||||||||||
self.output.warn(msg) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||||||||||||||||
self.conan_data["sources"][self.version][self._sources_key][str(self.settings.arch)] | ||||||||||||||||||||||||||||||||||||||||||
except KeyError: | ||||||||||||||||||||||||||||||||||||||||||
raise ConanInvalidConfiguration("Binaries for this combination of architecture/version/os not available") | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
if (self.settings.compiler, self.settings.os) == ("gcc", "Windows") and self.options.shared: | ||||||||||||||||||||||||||||||||||||||||||
# FIXME: https://github.com/bytecodealliance/wasmtime/issues/3168 | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was merged in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, but we will need to wait for the next release to have shared mingw avaialble. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh I did not look, but thats for checking! |
||||||||||||||||||||||||||||||||||||||||||
raise ConanInvalidConfiguration("Shared mingw is currently not possible") | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def source(self): | ||||||||||||||||||||||||||||||||||||||||||
tools.get(**self.conan_data["sources"][self.version][self._sources_key][str(self.settings.arch)], destination=self.source_folder, strip_root=True) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def package(self): | ||||||||||||||||||||||||||||||||||||||||||
shutil.copytree(os.path.join(self.source_folder, "include"), | ||||||||||||||||||||||||||||||||||||||||||
os.path.join(self.package_folder, "include")) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
srclibdir = os.path.join(self.source_folder, "lib") | ||||||||||||||||||||||||||||||||||||||||||
if self.options.shared: | ||||||||||||||||||||||||||||||||||||||||||
self.copy("wasmtime.dll.lib", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
self.copy("wasmtime.dll", src=srclibdir, dst="bin", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
self.copy("libwasmtime.dll.a", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
self.copy("libwasmtime.so*", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
self.copy("libwasmtime.dylib", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
self.copy("wasmtime.lib", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
self.copy("libwasmtime.a", src=srclibdir, dst="lib", keep_path=False) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
self.copy('LICENSE', dst='licenses', src=self.source_folder) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def package_info(self): | ||||||||||||||||||||||||||||||||||||||||||
if self.options.shared: | ||||||||||||||||||||||||||||||||||||||||||
if self.settings.os == "Windows": | ||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.libs = ["wasmtime.dll"] | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.libs = ["wasmtime"] | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
if self.settings.os == "Windows": | ||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.defines= ["/DWASM_API_EXTERN=", "/DWASI_API_EXTERN="] | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conan should handle the rest
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without set(CONAN_DEFINES_WASMTIME "-DWASM_API_EXTERN"
"-DWASI_API_EXTERN")
set(CONAN_BUILD_MODULES_PATHS_WASMTIME )
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
set(CONAN_COMPILE_DEFINITIONS_WASMTIME "WASM_API_EXTERN"
"WASI_API_EXTERN") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works for a lot of other recipes. https://github.com/conan-io/conan-center-index/search?p=2&q=cpp_info+defines You need to use it in tandem with the other comment https://github.com/conan-io/conan-center-index/pull/6083/files#r663361146 I update the suggestion with a better syntax There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better syntax, but it is not working ... |
||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.libs = ["wasmtime"] | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+92
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you do the rename of the import library in https://github.com/conan-io/conan-center-index/pull/6083/files#r670899230, then these lines can become:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You miss This package has library like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated my suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. The I've updated the suggestion again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see any updates ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not translated to proper MSVC flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What client version and generator are you using? I use this and it works perfectly conan-center-index/recipes/cpprestsdk/all/conanfile.py Lines 125 to 128 in 467c833
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
if self.settings.os == 'Windows': | ||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.system_libs = ['ws2_32', 'bcrypt', 'advapi32', 'userenv', 'ntdll', 'shell32', 'ole32'] | ||||||||||||||||||||||||||||||||||||||||||
elif self.settings.os == 'Linux': | ||||||||||||||||||||||||||||||||||||||||||
self.cpp_info.system_libs = ['pthread', 'dl', 'm'] |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||
cmake_minimum_required(VERSION 3.1) | ||||
project(PackageTest C) | ||||
|
||||
set(CMAKE_C_STANDARD 11) | ||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||||
conan_basic_setup() | ||||
|
||||
find_package(wasmtime REQUIRED) | ||||
|
||||
add_executable(example example.c) | ||||
target_link_libraries(example PRIVATE wasmtime::wasmtime) | ||||
redradist marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
target_compile_options(example PRIVATE ${CONAN_COMPILE_DEFINITIONS_WASMTIME}) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be included with the targets
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot do this, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also very strange behavior: set(CONAN_DEFINES_WASMTIME "-D/DWASM_API_EXTERN="
"-D/DWASI_API_EXTERN=")
set(CONAN_BUILD_MODULES_PATHS_WASMTIME )
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
set(CONAN_COMPILE_DEFINITIONS_WASMTIME "/DWASM_API_EXTERN="
"/DWASI_API_EXTERN=")
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With https://github.com/conan-io/conan-center-index/pull/6083/files#r670901897, this should be correct now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it is not, see comment above for it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class WasmtimeTestConan(ConanFile): | ||
settings = 'os', 'compiler', 'build_type', 'arch' | ||
generators = 'cmake', 'cmake_find_package' | ||
redradist marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It breaks build
I do not see any issue with verifing using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What breaks? It should not. I tested my pr on Linux and Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @madebr If something else would be wrong that Ci did not pass ... The difference between It is just much easier to write with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't understand this.
Easy is relative. I'm referring to this section in the docs: https://github.com/conan-io/conan-center-index/blob/master/docs/reviewing.md#test-package |
||
|
||
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', 'example') | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <wasmtime.h> | ||
|
||
int main() { | ||
char* wat = ""; | ||
wasm_byte_vec_t ret; | ||
wasmtime_error_t *error = wasmtime_wat2wasm(wat, sizeof(wat), &ret); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.29.0": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree, because later I will add package for
wasmtime-cpp
and it would be weird to have two projects with the same home directoryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should be the same recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be separate receipts
wasmtime
(only C API) andwasmtime-cpp
(C++ API)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also
https://wasmtime.dev/
is not descriptive enough for understanding how to use this packageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you will still need this package
As I mentioned previously I will create support with dependency on this package when I will create
wasmtime-cpp
See the issue:
bytecodealliance/wasmtime-cpp#1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay to have two recipes share the same homepage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Home page should be meaningful
https://wasmtime.dev/ does not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you're right.
The c api lives in the
main/crates/c-api
subfolder.How does this project relate to
wasm-c-api
at https://github.com/WebAssembly/wasm-c-api/?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madebr It is unrelated project