Skip to content

Commit ddfcded

Browse files
kraenhansenclaude
andcommitted
Multi addon projects (#413)
* Add --namespaced-targets to gyp-to-cmake * Use namespaced targets in node-addon-examples * Support building multiple addons * Limit spawn concurrency * Emit prebuilds per target, next to their sources A project declaring multiple addons wrote every prebuild into a single output directory, named after the CMake target. Both the location and the name are now derived per target from the CMake File API: - The output directory defaults to {targetSourceDir}/build/{configuration}, where the new {targetSourceDir} placeholder expands to the target's own source directory. A single-addon project reports "." and so resolves to the same path as before. - The prebuild is named after the artifact on disk (the target's OUTPUT_NAME) rather than the target name, so a target renamed to avoid a clash within the project still produces the name the JS require expects. Together this keeps a prebuild where the Babel plugin and auto-linking resolve it from, and reduces --namespaced-targets to an internal concern. Also fixes, in the same area: - gyp-to-cmake emitted OUTPUT_NAME regardless of --namespaced-targets, due to an always-truthy condition, and never emitted it for Apple framework targets, which CMake names after it. - The Apple build ran a full "cmake --build" once per shared library, concurrently against one build tree, and called "xcodebuild -list" (a synchronous spawn) once per library per triplet. - xcodebuild invocations now run in sequence per build directory, as concurrent invocations against a single Xcode project are not reliable. - postBuild looked for "<target name>.framework" while createAppleFramework names it after the artifact, so the two diverged under namespacing. - --concurrency accepted any value, and did not implement the documented fallback to 1 under --verbose. Max listeners is now derived from it. - verify-prebuilds globbed a directory the prebuilds had moved out of, so it passed by finding nothing. It now covers tests/ too and requires a non-zero count. - The root example project globbed recursively, which both missed examples copied in after configure and would add a nested project twice. It is now generated from the same script pipeline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KfKQDvEkxNtkSE4aaF9yG8 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ba85f07 commit ddfcded

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/node-addon-examples/tests/threadsafe-function/CMakeLists.txt‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@ project(threadsafe-function-test)
33

44
find_package(weak-node-api REQUIRED CONFIG)
55

6-
add_library(addon SHARED addon.c)
6+
add_library(threadsafe-function-test-addon SHARED addon.c)
77

88
option(BUILD_APPLE_FRAMEWORK "Wrap addon in an Apple framework" ON)
99

1010
if(APPLE AND BUILD_APPLE_FRAMEWORK)
11-
set_target_properties(addon PROPERTIES
11+
set_target_properties(threadsafe-function-test-addon PROPERTIES
1212
FRAMEWORK TRUE
1313
MACOSX_FRAMEWORK_IDENTIFIER threadsafe-function-test.addon
1414
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.0
1515
MACOSX_FRAMEWORK_BUNDLE_VERSION 1.0
1616
XCODE_ATTRIBUTE_SKIP_INSTALL NO
17+
OUTPUT_NAME addon
1718
)
1819
else()
19-
set_target_properties(addon PROPERTIES
20+
set_target_properties(threadsafe-function-test-addon PROPERTIES
2021
PREFIX ""
2122
SUFFIX .node
23+
OUTPUT_NAME addon
2224
)
2325
endif()
2426

25-
target_link_libraries(addon PRIVATE weak-node-api)
26-
target_compile_features(addon PRIVATE cxx_std_17)
27+
target_link_libraries(threadsafe-function-test-addon PRIVATE weak-node-api)
28+
target_compile_features(threadsafe-function-test-addon PRIVATE cxx_std_17)

0 commit comments

Comments
 (0)