Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions cmake/modules/DTrace.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

function(dtrace_usdt_probe script)
set(options)
set(single_parameter_options TARGET_NAME OUTPUT_SOURCES)
set(multiple_parameter_options)

cmake_parse_arguments("" "${options}" "${single_parameter_options}" "${multiple_parameter_options}" ${ARGN})

get_filename_component(script_we ${script} NAME_WE)

add_custom_command(OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h
COMMAND
${dtrace_EXECUTABLE} -h -s ${script} -o ${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h
DEPENDS
${script})
add_custom_target(dtrace-usdt-header-${script_we}
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h)
if(_TARGET_NAME)
set(${_TARGET_NAME} dtrace-usdt-header-${script_we} PARENT_SCOPE)
endif()
if(_OUTPUT_SOURCES)
set(${_OUTPUT_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${script_we}.h PARENT_SCOPE)
endif()
endfunction()
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

include(SwiftSupport)
include(DTrace)

add_library(dispatch
allocator.c
Expand Down Expand Up @@ -103,11 +104,20 @@ if(CMAKE_SWIFT_COMPILER)
swift/DispatchStubs.cc
${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o)
endif()
if(dtrace_EXECUTABLE)
dtrace_usdt_probe(${CMAKE_CURRENT_SOURCE_DIR}/provider.d
OUTPUT_SOURCES
dispatch_dtrace_provider_headers)
target_sources(dispatch
PRIVATE
${dispatch_dtrace_provider_headers})
endif()
target_include_directories(dispatch
PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/private)
if(WITH_PTHREAD_WORKQUEUES)
target_include_directories(dispatch
Expand Down