Skip to content

Commit a0973f0

Browse files
committed
Add metacall include path and metacall library path in c loader
1 parent 4f50014 commit a0973f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

source/loaders/c_loader/source/c_loader_impl.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <metacall/metacall.h>
3737

38+
#include <iostream>
3839
#include <iterator>
3940
#include <map>
4041
#include <new>
@@ -322,6 +323,23 @@ static loader_impl_c_handle c_loader_impl_handle_create(loader_impl_c c_impl)
322323

323324
/* TODO: Take the c_loader and add the execution paths for include (and library?) folders */
324325
/* tcc_add_include_path, tcc_add_library_path */
326+
std::string incl_path = c_impl->libtcc_runtime_path;
327+
std::string metacall_incl_dir = "include";
328+
329+
#if defined(_WIN32)
330+
auto i = incl_path.find_last_of('\\', incl_path.size() - 3);
331+
#else
332+
auto i = incl_path.find_last_of('/', incl_path.size() - 3);
333+
#endif
334+
335+
incl_path.replace(i + 1, metacall_incl_dir.size(), metacall_incl_dir);
336+
337+
/*Add metacall include path (so this works <metacall/metacall.h>.)*/
338+
tcc_add_include_path(c_handle->state, incl_path.c_str());
339+
340+
/*Add metacall library path (in other to find libmetacall.so)*/
341+
tcc_add_library_path(c_handle->state, c_impl->libtcc_runtime_path.c_str());
342+
325343
(void)c_impl;
326344

327345
return c_handle;

0 commit comments

Comments
 (0)