build: add Ninjatracing support

This commit is contained in:
Gabriel Ferreira
2022-11-12 12:27:47 -03:00
parent 5473752af8
commit 87c85c8156
3 changed files with 39 additions and 0 deletions

View File

@@ -74,6 +74,11 @@ option(NS3_MONOLIB
)
option(NS3_MPI "Build with MPI support" OFF)
option(NS3_NATIVE_OPTIMIZATIONS "Build with -march=native -mtune=native" OFF)
option(
NS3_NINJA_TRACING
"Use ninjatracing to convert Ninja's build log to the about://tracing format"
OFF
)
set(NS3_OUTPUT_DIRECTORY "" CACHE STRING "Directory to store built artifacts")
option(NS3_PRECOMPILE_HEADERS
"Precompile module headers to speed up compilation" ON

View File

@@ -876,6 +876,37 @@ macro(process_options)
endif()
endif()
if(${NS3_NINJA_TRACING})
if(${CMAKE_GENERATOR} STREQUAL Ninja)
include(ExternalProject)
ExternalProject_Add(
NinjaTracing
GIT_REPOSITORY "https://github.com/nico/ninjatracing.git"
GIT_TAG "f9d21e973cfdeafa913b83a927fef56258f70b9a"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(NinjaTracing SOURCE_DIR)
set(embed_time_trace)
if(${NS3_CLANG_TIMETRACE} AND ${CLANG})
set(embed_time_trace --embed-time-trace)
endif()
add_custom_target(
ninjaTrace
COMMAND
${Python3_EXECUTABLE} ${SOURCE_DIR}/ninjatracing -a
${embed_time_trace} ${PROJECT_BINARY_DIR}/.ninja_log >
${PROJECT_SOURCE_DIR}/ninja_performance_trace.json
DEPENDS NinjaTracing
)
unset(embed_time_trace)
unset(SOURCE_DIR)
else()
message(FATAL_ERROR "Ninjatracing requires the Ninja generator")
endif()
endif()
# Disable the below warning from bindings built in debug mode with clang++:
# "expression with side effects will be evaluated despite being used as an
# operand to 'typeid'"

3
ns3
View File

@@ -142,6 +142,7 @@ def parse_args(argv):
("logs", "the logs regardless of the compile mode"),
("monolib", "a single shared library with all ns-3 modules"),
("mpi", "the MPI support for distributed simulation"),
("ninja-tracing", "the conversion of the Ninja generator log file into about://tracing format"),
("precompiled-headers", "precompiled headers"),
("python-bindings", "python bindings"),
("tests", "the ns-3 tests"),
@@ -583,6 +584,7 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener
("LOG", "logs"),
("MONOLIB", "monolib"),
("MPI", "mpi"),
("NINJA_TRACING", "ninja_tracing"),
("PRECOMPILE_HEADERS", "precompiled_headers"),
("PYTHON_BINDINGS", "python_bindings"),
("SANITIZE", "sanitizers"),
@@ -979,6 +981,7 @@ def build_step(args,
"sphinx",
"manual",
"models",
"ninjaTrace",
"timeTraceReport",
"tutorial",
"contributing",