File tree 7 files changed +67
-0
lines changed
7 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ libnanobind-abi3.so
6
6
nanobind.dll
7
7
nanobind-abi3.dll
8
8
9
+ libinter_module.dylib
10
+ libinter_module.so
11
+ inter_module.dll
12
+
9
13
/.ninja_deps
10
14
/.ninja_log
11
15
/build.ninja
Original file line number Diff line number Diff line change @@ -19,6 +19,21 @@ nanobind_add_module(test_intrusive_ext test_intrusive.cpp object.cpp object.h ${
19
19
nanobind_add_module(test_exception_ext test_exception.cpp object.cpp object.h ${NB_EXTRA_ARGS} )
20
20
nanobind_add_module(test_make_iterator_ext test_make_iterator.cpp ${NB_EXTRA_ARGS} )
21
21
22
+ add_library (
23
+ inter_module
24
+ SHARED
25
+ inter_module.h
26
+ inter_module.cpp
27
+ )
28
+ target_compile_definitions (inter_module PRIVATE -DSHARED_BUILD)
29
+ nanobind_cpp17(inter_module)
30
+ nanobind_headers(inter_module)
31
+
32
+ nanobind_add_module(test_inter_module_1_ext test_inter_module_1.cpp ${NB_EXTRA_ARGS} )
33
+ nanobind_add_module(test_inter_module_2_ext test_inter_module_2.cpp ${NB_EXTRA_ARGS} )
34
+ target_link_libraries (test_inter_module_1_ext PRIVATE inter_module)
35
+ target_link_libraries (test_inter_module_2_ext PRIVATE inter_module)
36
+
22
37
set (TEST_FILES
23
38
test_functions.py
24
39
test_classes.py
@@ -29,6 +44,7 @@ set(TEST_FILES
29
44
test_intrusive.py
30
45
test_exception.py
31
46
test_make_iterator.py
47
+ test_inter_module.py
32
48
)
33
49
34
50
if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR ) OR MSVC )
Original file line number Diff line number Diff line change
1
+ #include " inter_module.h"
2
+
3
+ Shared create_shared () {
4
+ return { 123 };
5
+ }
6
+
7
+ bool check_shared (const Shared &shared) {
8
+ return shared.value == 123 ;
9
+ }
Original file line number Diff line number Diff line change
1
+ #include <nanobind/nb_defs.h>
2
+
3
+ #if defined(SHARED_BUILD )
4
+ # define EXPORT_SHARED NB_EXPORT
5
+ #else
6
+ # define EXPORT_SHARED NB_IMPORT
7
+ #endif
8
+
9
+ struct EXPORT_SHARED Shared {
10
+ int value ;
11
+ };
12
+
13
+ extern EXPORT_SHARED Shared create_shared ();
14
+ extern EXPORT_SHARED bool check_shared (const Shared & shared );
Original file line number Diff line number Diff line change
1
+ import test_inter_module_1_ext as t1
2
+ import test_inter_module_2_ext as t2
3
+
4
+
5
+ def test01_inter_module ():
6
+ s = t1 .create_shared ()
7
+ assert t2 .check_shared (s )
Original file line number Diff line number Diff line change
1
+ #include < nanobind/nanobind.h>
2
+ #include " inter_module.h"
3
+
4
+ namespace nb = nanobind;
5
+
6
+ NB_MODULE (test_inter_module_1_ext, m) {
7
+ m.def (" create_shared" , &create_shared);
8
+ }
Original file line number Diff line number Diff line change
1
+ #include < nanobind/nanobind.h>
2
+ #include " inter_module.h"
3
+
4
+ namespace nb = nanobind;
5
+
6
+ NB_MODULE (test_inter_module_2_ext, m) {
7
+ nb::class_<Shared>(m, " Shared" );
8
+ m.def (" check_shared" , &check_shared);
9
+ }
You can’t perform that action at this time.
0 commit comments