forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#6083) Initial support for wasmtime package
* Initial support for wasmtime package * Fixed build package on Linux * Updates according the comments in review #0 * Update recipes/wasmtime/all/conanfile.py Update license type Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Updates according the comments in review #1 * Updates according the comments in review conan-io#2 * Updates according the comments in review conan-io#3 * Updates according the comments in review conan-io#4 * Updates according the comments in review conan-io#5 * Next iteration of fixes * Fixed cmake variable C_STANDARD -> CMAKE_C_STANDARD * Added check on minimal version of conan * Used copytree instead of copy individual files * Fixed the build * Added checking for architechure in validate(...) * Updated receipt for new comments from @madebr * Fixed calling method tools.cross_building(...) * Update def package(self) according the comments in review * Updated versions of wasmtime * Updated forgot version ugrade * Fixed sha256sum for macos * Fixed SHA256 for Linux * Updated all SHA256 to proer values Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
- Loading branch information
1 parent
b31859f
commit cc01ea9
Showing
6 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "57ba0732597c2fd8717738067e4067ff571f11ed87b32bd251fe0335bee107af" | ||
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: "9c5c5c2baa624a04506474ca488c875d4fd99268370e74eb4ce12e6d9db767d4" | ||
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: "e94a9a768270e86e7f7eac1a68575bb1f287702822e83b14c3b04bf7e865a84c" | ||
"armv8": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-aarch64-linux-c-api.tar.xz" | ||
sha256: "36a257aef36f5a0cabc8ce414e31ccede9c16ca996d6b07cb440a32aaa263164" | ||
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: "d80209990661e7cf8ae7a2db4ba931cd61da27e7956be05baf8cfe24d1951283" | ||
Android: | ||
"armv8": | ||
url: "https://github.com/bytecodealliance/wasmtime/releases/download/v0.29.0/wasmtime-v0.29.0-aarch64-linux-c-api.tar.xz" | ||
sha256: "36a257aef36f5a0cabc8ce414e31ccede9c16ca996d6b07cb440a32aaa263164" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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="] | ||
self.cpp_info.libs = ["wasmtime"] | ||
|
||
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
target_compile_options(example PRIVATE ${CONAN_COMPILE_DEFINITIONS_WASMTIME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.29.0": | ||
folder: all |