Skip to content

Commit

Permalink
Adding HPX dependency tool (adapted from Boostdep tool)
Browse files Browse the repository at this point in the history
- adding target to build dependency report
- adding dependency report generation to CircleCI
- flyby: fixing circular dependency between config and preprocessor,
  and between hashing and serialization
- flyby: generate config_registry only if needed
  • Loading branch information
hkaiser committed Apr 21, 2022
1 parent c7d1b9f commit 8b1dab8
Show file tree
Hide file tree
Showing 26 changed files with 3,761 additions and 58 deletions.
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,27 @@ jobs:
paths:
- ./build

depreport:
<<: *defaults
steps:
- attach_workspace:
at: /hpx
- run:
name: Building HPX Dependency Report Tool
command: |
ninja -j2 tools.hpxdep
- run:
name: Building HPX Dependency Report Documentation
command: |
ninja -j1 depreport
no_output_timeout: 10m
- persist_to_workspace:
root: /hpx
paths:
- ./build
- store_artifacts:
path: /hpx/build/share/hpx/docs/report

docs-singlehtml:
<<: *defaults
steps:
Expand Down Expand Up @@ -877,6 +898,10 @@ workflows:
# have conflicts
- tests.examples
<<: *gh_pages_filter
- depreport:
requires:
- configure
<<: *gh_pages_filter
- docs-singlehtml:
requires:
- configure
Expand All @@ -896,6 +921,7 @@ workflows:
- docs-html
- docs-singlehtml
- docs-latexpdf
- depreport
<<: *docs_push_filter
- install:
requires:
Expand Down
3 changes: 2 additions & 1 deletion .cmake-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@
'MODULE_DEPENDENCIES': '+',
'SOURCES': '+'},
'pargs': { 'flags': ['CUDA',
'CONFIG_FILES'],
'CONFIG_FILES',
'NO_CONFIG_IN_GENERATED_HEADERS'],
'nargs': '1+'}},
'add_hpx_performance_test': {'pargs': {'nargs': 2}},
'add_hpx_pseudo_dependencies': {'pargs': {'nargs': 0}},
Expand Down
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ unset(HPX_COMPONENTS CACHE)
unset(HPX_EXPORT_TARGETS CACHE)
unset(HPX_EXPORT_INTERNAL_TARGETS CACHE)
unset(HPX_ENABLED_MODULES CACHE)
unset(HPX_CORE_ENABLED_MODULES CACHE)
unset(HPX_FULL_ENABLED_MODULES CACHE)
unset(HPX_STATIC_PARCELPORT_PLUGINS CACHE)

# ##############################################################################
Expand Down Expand Up @@ -2217,14 +2219,6 @@ add_subdirectory(wrap)
# ##############################################################################
hpx_include(Documentation)

# ##############################################################################
# Target specification
# ##############################################################################
if(HPX_WITH_TOOLS OR HPX_WITH_TESTS_BENCHMARKS)
add_hpx_pseudo_target(tools)
add_subdirectory(tools)
endif()

# ##############################################################################
# Add core configuration
# ##############################################################################
Expand All @@ -2250,6 +2244,9 @@ if(HPX_WITH_TESTS)
add_subdirectory(tests)
endif()

# ##############################################################################
# Target specification
# ##############################################################################
if(HPX_WITH_EXAMPLES)
add_subdirectory(examples)
endif()
Expand All @@ -2258,6 +2255,12 @@ if(HPX_WITH_DOCUMENTATION)
add_subdirectory(docs)
endif()

# this must come after docs as it creates a dependency on the target git_docs
if(HPX_WITH_TOOLS OR HPX_WITH_TESTS_BENCHMARKS)
add_hpx_pseudo_target(tools)
add_subdirectory(tools)
endif()

# Configure hpxrun.py
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/hpxrun.py.in"
Expand Down
55 changes: 42 additions & 13 deletions cmake/HPX_AddModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

include(HPX_ExportTargets)
include(HPX_PrintSummary)

function(add_hpx_module libname modulename)
# Retrieve arguments
set(options CUDA CONFIG_FILES)
set(options CUDA CONFIG_FILES NO_CONFIG_IN_GENERATED_HEADERS)
set(one_value_args GLOBAL_HEADER_GEN)
set(multi_value_args
SOURCES
Expand Down Expand Up @@ -43,20 +44,26 @@ function(add_hpx_module libname modulename)
string(TOUPPER ${modulename} modulename_upper)

# Mark the module as enabled (see hpx/libs/CMakeLists.txt)
set(modules ${HPX_ENABLED_MODULES})
list(APPEND modules ${modulename})
list(SORT modules)
list(REMOVE_DUPLICATES modules)

set(HPX_ENABLED_MODULES
${HPX_ENABLED_MODULES} ${modulename}
${modules}
CACHE INTERNAL "List of enabled HPX modules" FORCE
)
list(SORT HPX_ENABLED_MODULES)
list(REMOVE_DUPLICATES HPX_ENABLED_MODULES)

set(modules ${HPX_${libname_upper}_ENABLED_MODULES})
list(APPEND modules ${modulename})
list(SORT modules)
list(REMOVE_DUPLICATES modules)

set(HPX_${libname_upper}_ENABLED_MODULES
${HPX_${libname_upper}_ENABLED_MODULES} ${modulename}
${modules}
CACHE INTERNAL "List of enabled HPX modules in the ${libname} library"
FORCE
)
list(SORT HPX_${libname_upper}_ENABLED_MODULES)
list(REMOVE_DUPLICATES HPX_${libname_upper}_ENABLED_MODULES)

# Main directories of the module
set(SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/src")
Expand Down Expand Up @@ -93,6 +100,11 @@ function(add_hpx_module libname modulename)
message(FATAL_ERROR "Invalid compatibility header ${compat_header}")
endif()

set(config_file)
if(NOT ${modulename}_NO_CONFIG_IN_GENERATED_HEADERS)
set(config_file "#include <hpx/config.hpp>\n")
endif()

list(GET compat_header 0 old_header)
list(GET compat_header 1 new_header)
configure_file(
Expand Down Expand Up @@ -122,7 +134,12 @@ function(add_hpx_module libname modulename)
set(global_header
"${CMAKE_CURRENT_BINARY_DIR}/include/hpx/modules/${modulename}.hpp"
)
set(module_headers)
if(NOT ${modulename}_NO_CONFIG_IN_GENERATED_HEADERS)
set(module_headers "#include <hpx/config.hpp>\n\n")
set(module_headers
"${module_headers}#if defined(HPX_HAVE_MODULE_${modulename_upper})\n"
)
endif()
foreach(header_file ${${modulename}_HEADERS})
# Exclude the files specified
if((NOT (${header_file} IN_LIST ${modulename}_EXCLUDE_FROM_GLOBAL_HEADER))
Expand All @@ -131,16 +148,23 @@ function(add_hpx_module libname modulename)
set(module_headers "${module_headers}#include <${header_file}>\n")
endif()
endforeach(header_file)
if(NOT ${modulename}_NO_CONFIG_IN_GENERATED_HEADERS)
set(module_headers "${module_headers}#endif\n")
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/global_module_header.hpp.in"
"${global_header}"
)
set(generated_headers ${global_header})
endif()

set(config_entries_source
"${CMAKE_CURRENT_BINARY_DIR}/src/config_entries.cpp"
)
set(has_config_info)
has_configuration_summary(${modulename} has_config_info)
if(has_config_info)
set(config_entries_source
"${CMAKE_CURRENT_BINARY_DIR}/src/config_entries.cpp"
)
endif()

# generate configuration header for this module
set(config_header
Expand Down Expand Up @@ -201,6 +225,12 @@ function(add_hpx_module libname modulename)
set(module_library_type OBJECT)
endif()

set(source_group_root ${SOURCE_ROOT})
if(NOT sources AND NOT config_entries_source)
set(source_group_root "${HPX_SOURCE_DIR}/libs/src/")
set(sources "${source_group_root}/empty.cpp")
endif()

# create library modules
add_library(
hpx_${modulename}
Expand Down Expand Up @@ -286,7 +316,7 @@ function(add_hpx_module libname modulename)
)
add_hpx_source_group(
NAME hpx_${modulename}
ROOT ${SOURCE_ROOT}
ROOT ${source_group_root}
CLASS "Source Files"
TARGETS ${sources}
)
Expand Down Expand Up @@ -423,7 +453,6 @@ function(add_hpx_module libname modulename)
add_subdirectory(${dir})
endforeach(dir)

include(HPX_PrintSummary)
create_configuration_summary(
" Module configuration (${modulename}):" "${modulename}"
)
Expand Down
114 changes: 114 additions & 0 deletions cmake/HPX_GenerateDependencyReport.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (c) 2022 Hartmut Kaiser
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

# Generate HPX Dependency Report

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)

separate_arguments(HPX_CORE_ENABLED_MODULES)
separate_arguments(HPX_FULL_ENABLED_MODULES)

# common options
set(hpxdep_common_options --hpx-root "${HPX_SOURCE_DIR}" --hpx-build-root
"${HPX_BINARY_DIR}"
)

set(HPXDEP_OUTPUT_DIR
"${HPX_BINARY_DIR}/share/hpx/docs/report/${HPX_DEPREPORT_VERSION}"
)

# create module-list
set(hpxdep_module_list_output "module-list.txt")
message("Generating ${hpxdep_module_list_output}")

set(module_list)
foreach(module ${HPX_CORE_ENABLED_MODULES})
set(module_list ${module_list} "core/${module}\n")
endforeach()
foreach(module ${HPX_FULL_ENABLED_MODULES})
set(module_list ${module_list} "full/${module}\n")
endforeach()
file(MAKE_DIRECTORY "${HPXDEP_OUTPUT_DIR}")
file(WRITE "${HPXDEP_OUTPUT_DIR}/${hpxdep_module_list_output}" ${module_list})

# module-overview, module-levels, and module-weights reports
macro(generate_module_overview_report option)
string(SUBSTRING ${option} 0 1 first_letter)
string(TOUPPER ${first_letter} first_letter)
string(REGEX REPLACE "^.(.*)" "${first_letter}\\1" option_cap "${option}")

set(hpxdep_module_${option}_output "module-${option}.html")
message("Generating ${hpxdep_module_${option}_output}")

# cmake-format: off
set(hpxdep_module_${option}_build_command
${HPXDEP_OUTPUT_NAME}
${hpxdep_common_options}
--module-list "${HPXDEP_OUTPUT_DIR}/${hpxdep_module_list_output}"
--html-title "\"HPX Module ${option_cap}\""
--html
--module-${option}
)
# cmake-format: on

execute_process(
COMMAND ${hpxdep_module_${option}_build_command}
WORKING_DIRECTORY "${HPXDEP_OUTPUT_DIR}"
OUTPUT_FILE "${HPXDEP_OUTPUT_DIR}/${hpxdep_module_${option}_output}"
RESULT_VARIABLE hpxdep_result
ERROR_VARIABLE hpxdep_error
)
if(NOT "${hpxdep_result}" EQUAL "0")
message(
FATAL_ERROR
"Generating ${hpxdep_module_${option}_output} failed: ${hpxdep_error}."
)
endif()
endmacro()

generate_module_overview_report("overview")
generate_module_overview_report("levels")
generate_module_overview_report("weights")

# module-specific reports
macro(generate_module_report libname)
file(MAKE_DIRECTORY "${HPXDEP_OUTPUT_DIR}/${libname}")
foreach(module ${ARGN})
set(module_name "${libname}/${module}")
set(hpxdep_module_output "${module_name}.html")
message("Generating ${hpxdep_module_output}")

# cmake-format: off
set(hpxdep_module_build_command
${HPXDEP_OUTPUT_NAME}
${hpxdep_common_options}
--module-list "${HPXDEP_OUTPUT_DIR}/${hpxdep_module_list_output}"
--html-title "\"HPX Dependency Report for ${module_name}\""
--html
--primary ${module_name}
--secondary ${module_name}
--reverse ${module_name}
)
# cmake-format: on

execute_process(
COMMAND ${hpxdep_module_build_command}
WORKING_DIRECTORY "${HPXDEP_OUTPUT_DIR}"
OUTPUT_FILE "${HPXDEP_OUTPUT_DIR}/${hpxdep_module_output}"
RESULT_VARIABLE hpxdep_result
ERROR_VARIABLE hpxdep_error
)
if(NOT "${hpxdep_result}" EQUAL "0")
message(
FATAL_ERROR
"Generating ${hpxdep_module_output} failed: ${hpxdep_error}."
)
endif()
endforeach()
endmacro()

generate_module_report("core" ${HPX_CORE_ENABLED_MODULES})
generate_module_report("full" ${HPX_FULL_ENABLED_MODULES})
Loading

0 comments on commit 8b1dab8

Please sign in to comment.