Skip to content

Commit

Permalink
core, bugfix: crash when loading so in python.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Jun 20, 2023
1 parent da4f8e1 commit 1716e51
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fibjs/program/CMakeLists.txt
Expand Up @@ -39,7 +39,9 @@ foreach(lib ${libs})
target_link_libraries(${name}_gui "${BIN_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()

target_link_libraries(js "${BIN_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
if(NOT ${lib} STREQUAL "jemalloc")
target_link_libraries(js "${BIN_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
endforeach()

setup_result_library(${name})
Expand Down
4 changes: 2 additions & 2 deletions fibjs/program/src/so.cpp
Expand Up @@ -15,7 +15,7 @@ void main(int32_t argc, char** argv)
importBuiltinModule();

start(argc, argv, FiberProcJsEntry);
run_gui(argc, argv);
// run_gui(argc, argv);
}
}

Expand All @@ -25,7 +25,7 @@ extern "C"
#else
__attribute__((visibility("default")))
#endif
int32_t main(int32_t argc, char* argv[])
int32_t run_fibjs(int32_t argc, char* argv[])
{
fibjs::main(argc, argv);
return 0;
Expand Down
15 changes: 15 additions & 0 deletions fibjs/program/test/fibjs.py
@@ -0,0 +1,15 @@
import ctypes
from ctypes import c_int32, c_char_p

lib = ctypes.cdll.LoadLibrary("bin/Darwin_arm64_release/libjs.dylib")
run_fibjs = lib.run_fibjs

run_fibjs.argtypes = (c_int32, ctypes.POINTER(c_char_p))
run_fibjs.restype = c_int32

argv = [b"", b"-e", b"console.log('hello world')"]
argv_p = (c_char_p * len(argv))(*argv)

run_fibjs(len(argv), argv_p)

input();

0 comments on commit 1716e51

Please sign in to comment.