File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,13 +155,20 @@ if(NAPI_BUILD_ABI)
155155 message (STATUS "Selected ${NAPI_JAVASCRIPT_ENGINE} " )
156156endif ()
157157
158- # On Android the Node-API conformance addons are dlopen'd as standalone SHARED .node modules (matching
159- # nodejs/node-api-cts's add_node_api_cts_addon model). For an addon's napi_* imports to bind at load,
160- # napi must be a shared library that both the host and the addons depend on via a real DT_NEEDED
161- # (libnapi.so) -- bionic will not surface a statically-linked host's napi to a dlopen'd module. There
162- # is a single napi instance (one libnapi.so) shared by the host and every addon. Elsewhere (the
163- # child-process desktop runner) napi stays a static library.
158+ # On Android, native addons are dlopen'd as standalone .node modules and resolve their napi_* imports
159+ # from a shared napi at load time -- bionic will not surface a statically-linked host's napi to a
160+ # dlopen'd module, so the host and every addon must share a single libnapi.so. Default napi to a
161+ # shared library on Android so that model works out of the box; an integrator who wants a static napi
162+ # (e.g. for size/packaging) can override with -DJSR_NAPI_SHARED=OFF. The option defaults OFF on other
163+ # platforms, where napi keeps following the project's default library type (i.e. honors
164+ # BUILD_SHARED_LIBS).
165+ set (JSR_NAPI_SHARED_DEFAULT OFF )
164166if (ANDROID )
167+ set (JSR_NAPI_SHARED_DEFAULT ON )
168+ endif ()
169+ option (JSR_NAPI_SHARED "Build napi as a shared library (libnapi.so)" ${JSR_NAPI_SHARED_DEFAULT} )
170+
171+ if (JSR_NAPI_SHARED)
165172 add_library (napi SHARED ${SOURCES} )
166173else ()
167174 add_library (napi ${SOURCES} )
You can’t perform that action at this time.
0 commit comments