|
| 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