Skip to content

Commit 4b45194

Browse files
compnerddas
authored andcommitted
build: add dtrace USDT probe support
Add the missing support for dtrace header script support. Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 2daa1d7 commit 4b45194

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

cmake/modules/DTrace.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
function(dtrace_usdt_probe script)
3+
set(options)
4+
set(single_parameter_options TARGET_NAME OUTPUT_SOURCES)
5+
set(multiple_parameter_options)
6+
7+
cmake_parse_arguments("" "${options}" "${single_parameter_options}" "${multiple_parameter_options}" ${ARGN})
8+
9+
get_filename_component(script_we ${script} NAME_WE)
10+
11+
add_custom_command(OUTPUT
12+
${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h
13+
COMMAND
14+
${dtrace_EXECUTABLE} -h -s ${script} -o ${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h
15+
DEPENDS
16+
${script})
17+
add_custom_target(dtrace-usdt-header-${script_we}
18+
DEPENDS
19+
${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h)
20+
if(_TARGET_NAME)
21+
set(${_TARGET_NAME} dtrace-usdt-header-${script_we} PARENT_SCOPE)
22+
endif()
23+
if(_OUTPUT_SOURCES)
24+
set(${_OUTPUT_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h PARENT_SCOPE)
25+
endif()
26+
endfunction()

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
include(SwiftSupport)
3+
include(DTrace)
34

45
add_library(dispatch
56
allocator.c
@@ -103,11 +104,20 @@ if(CMAKE_SWIFT_COMPILER)
103104
swift/DispatchStubs.cc
104105
${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o)
105106
endif()
107+
if(dtrace_EXECUTABLE)
108+
dtrace_usdt_probe(${CMAKE_CURRENT_SOURCE_DIR}/provider.d
109+
OUTPUT_SOURCES
110+
dispatch_dtrace_provider_headers)
111+
target_sources(dispatch
112+
PRIVATE
113+
${dispatch_dtrace_provider_headers})
114+
endif()
106115
target_include_directories(dispatch
107116
PRIVATE
108117
${CMAKE_BINARY_DIR}
109118
${CMAKE_SOURCE_DIR}
110119
${CMAKE_CURRENT_SOURCE_DIR}
120+
${CMAKE_CURRENT_BINARY_DIR}
111121
${CMAKE_SOURCE_DIR}/private)
112122
if(WITH_PTHREAD_WORKQUEUES)
113123
target_include_directories(dispatch

0 commit comments

Comments
 (0)