example: allow passing in evmc path as an argument

This commit is contained in:
Alex Beregszaszi 2019-08-08 12:51:41 +02:00
parent bc5b31662d
commit 85498a1d42
2 changed files with 6 additions and 4 deletions

View File

@ -33,8 +33,7 @@ commands:
# Test statically linked end-to-end example
~/build/examples/evmc-example-static
# Test dynamically loaded end-to-end example
ln -s ~/build/examples/example_vm/libevmc-example-vm.so ~/build/examples/example-vm.so
~/build/examples/evmc-example
~/build/examples/evmc-example ~/build/examples/example_vm/libevmc-example-vm.so
- run:
name: "Install"
command: cmake --build ~/build --target install

View File

@ -14,17 +14,20 @@
#include <inttypes.h>
#include <stdio.h>
int main()
int main(int argc, char* argv[])
{
#ifdef STATICALLY_LINKED_EXAMPLE
(void)argc;
(void)argv;
struct evmc_instance* vm = evmc_create_example_vm();
if (!vm)
return EVMC_LOADER_INSTANCE_CREATION_FAILURE;
if (!evmc_is_abi_compatible(vm))
return EVMC_LOADER_ABI_VERSION_MISMATCH;
#else
const char* config_string = (argc > 1) ? argv[1] : "example-vm.so";
enum evmc_loader_error_code error_code;
struct evmc_instance* vm = evmc_load_and_configure("example-vm.so", &error_code);
struct evmc_instance* vm = evmc_load_and_configure(config_string, &error_code);
if (!vm)
{
printf("Loading error: %d\n", error_code);