Skip to content

Commit

Permalink
Add metacall include path and metacall library path in c loader
Browse files Browse the repository at this point in the history
  • Loading branch information
rxbryan committed May 2, 2022
1 parent 4f50014 commit 1c4a643
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions source/loaders/c_loader/source/c_loader_impl.cpp
Expand Up @@ -40,6 +40,7 @@
#include <new>
#include <string>
#include <vector>
#include <iostream>

#include <cstring>

Expand Down Expand Up @@ -322,6 +323,23 @@ static loader_impl_c_handle c_loader_impl_handle_create(loader_impl_c c_impl)

/* TODO: Take the c_loader and add the execution paths for include (and library?) folders */
/* tcc_add_include_path, tcc_add_library_path */
std::string incl_path = c_impl->libtcc_runtime_path;
std::string metacall_incl_dir = "include";

#if defined(_WIN32)
auto i = incl_path.find_last_of('\\', incl_path.size()-3);
#else
auto i = incl_path.find_last_of('/', incl_path.size()-3);
#endif

incl_path.replace(i+1, metacall_incl_dir.size(), metacall_incl_dir);

/*Add metacall include path (so this works <metacall/metacall.h>)*/
tcc_add_include_path(c_handle->state, incl_path.c_str());

/*Add metacall library path (in other to find libmetacall.so)*/
tcc_add_library_path(c_handle->state, c_impl->libtcc_runtime_path.c_str());

(void)c_impl;

return c_handle;
Expand Down

0 comments on commit 1c4a643

Please sign in to comment.