Skip to content

Commit

Permalink
[opentelemetry_cpp dll] new procedure for exporting symbols (generate…
Browse files Browse the repository at this point in the history
… .def file)
  • Loading branch information
meastp committed Jan 5, 2024
1 parent 74db5e6 commit c9920e8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 3 deletions.
36 changes: 33 additions & 3 deletions ext/src/dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,44 @@ if(WITH_OTLP_HTTP)
PRIVATE opentelemetry_exporter_otlp_http_log)
endif()


# find Powershell executable
find_program(DUMPBIN_PATH NAMES dumpbin)

# find Powershell executable
find_program(POWERSHELL_PATH NAMES pwsh powershell)

set(OPENTELEMETRY_INPUT_DEF
"${CMAKE_CURRENT_SOURCE_DIR}/input.txt")

add_custom_command(
OUTPUT ${OPENTELEMETRY_EXPORT_DEF}
OUTPUT ${OPENTELEMETRY_INPUT_DEF}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/input.src"
COMMAND
${CMAKE_CXX_COMPILER}
"-D$<JOIN:$<TARGET_PROPERTY:opentelemetry_cpp,COMPILE_DEFINITIONS>,;-D>" /EP
${CMAKE_CURRENT_SOURCE_DIR}/opentelemetry_cpp.src >
${CMAKE_CURRENT_SOURCE_DIR}/input.src >
${OPENTELEMETRY_INPUT_DEF}
VERBATIM)

add_custom_command(
OUTPUT ${OPENTELEMETRY_EXPORT_DEF}
DEPENDS "${OPENTELEMETRY_INPUT_DEF}" "${CMAKE_CURRENT_SOURCE_DIR}/make_def.ps1"
COMMAND
${POWERSHELL_PATH}
"-ExecutionPolicy"
"Bypass"
"-File"
"${CMAKE_CURRENT_SOURCE_DIR}/make_def.ps1"
"-dumpbin"
${DUMPBIN_PATH}
"-bindir"
${PROJECT_BINARY_DIR}
"-inputfile"
${OPENTELEMETRY_INPUT_DEF}
"-targetfile"
${OPENTELEMETRY_EXPORT_DEF}
COMMAND_EXPAND_LISTS VERBATIM)
VERBATIM)

if(OPENTELEMETRY_INSTALL)
install(
Expand Down
73 changes: 73 additions & 0 deletions ext/src/dll/input.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// clang-format off
External\s+\|\s+(\?Create@OStreamSpanExporterFactory@trace@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@SimpleSpanProcessorFactory@trace@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@TracerProviderFactory@trace@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@LoggerProviderFactory@logs@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@BatchLogRecordProcessorFactory@logs@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@SimpleLogRecordProcessorFactory@logs@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@MultiLogRecordProcessorFactory@logs@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\??0OStreamLogRecordExporter@logs@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@MeterContextFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@ViewFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?AddView@MeterProvider@metrics@sdk@v1@opentelemetry[^\s]*)\s+\((.*)\)$

#if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP)
External\s+\|\s+(\?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultLogsTimeout@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultMetricsSslCertificatePath@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultLogsSslCertificatePath@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultTracesSslCertificateString@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultMetricsSslCertificateString@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultLogsSslCertificateString@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
#endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP)

#if defined(WITH_OTLP_GRPC)
External\s+\|\s+(\?Create@OtlpGrpcExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpGrpcExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpGrpcExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpGrpcMetricExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpGrpcMetricExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpGrpcLogRecordExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpGrpcLogRecordExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcMetricsEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcLogsEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcMetricsIsInsecure@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultGrpcLogsIsInsecure@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
#endif // defined(WITH_OTLP_GRPC)

#if defined(WITH_OTLP_HTTP)
External\s+\|\s+(\?Create@OtlpHttpExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpHttpExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpHttpExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpHttpMetricExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpHttpMetricExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?0OtlpHttpLogRecordExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?\?1OtlpHttpLogRecordExporterOptions@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
External\s+\|\s+(\?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry[^\s]*)\s+\((.*)\)$
#endif // defined(WITH_OTLP_HTTP)
// clang-format on
5 changes: 5 additions & 0 deletions ext/src/dll/make_def.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
param ($dumpbin, $bindir, $inputfile, $targetfile)

"LIBRARY opentelemetry_cpp`r`nEXPORTS`r`n" > $targetfile

Get-ChildItem -Verbose -Path $bindir/*.lib -Recurse | % { & "$dumpbin" /SYMBOLS $_ | Select-String -Pattern @(Get-Content -Verbose -Path "$inputfile" | Where-Object { $_.Trim() -ne '' }) | % { "; $($_.matches.groups[2])`r`n$($_.matches.groups[1])" } >> $targetfile }

0 comments on commit c9920e8

Please sign in to comment.