Skip to content

Commit 1c4a643

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

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
@@ -40,6 +40,7 @@
4040
#include <new>
4141
#include <string>
4242
#include <vector>
43+
#include <iostream>
4344

4445
#include <cstring>
4546

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