2e0ede4761
* [0/N] git submodules
* [1/N] Update cmake, gitignore, external
- clang-tidy file
- update .gitignore
- update main CMakeLists.txt
- update external/CMakeLists.txt
- update rocprofiler_config_interfaces.cmake
- update rocprofiler_formatting.cmake
- update rocprofiler_interfaces.cmake
- update rocprofiler_linting.cmake
- update rocprofiler_options.cmake
- update rocprofiler_utilities.cmake
* [2/N] Update rocprofiler/config.h
- update to work with new rocprofiler.h
* [3/N] Update source/lib/rocprofiler/hsa
- hsa-types.h: static asserts
- hsa.cpp: copyTables scope
- hsa.gen.cpp: ACTIVITY_DOMAIN_HSA_API -> ROCPROFILER_TRACER_ACTIVITY_DOMAIN_HSA_API
- rename some files
- add rocprofiler_ prefix to types and enums
- HSA_API_TABLE_LOOKUP_DEFINITION macro
- get_saved_table() -> get_table()
* [4/N] Update source/lib/common
- CMake: change target_link_libraries
- defines.hpp: remove ppdefs defined in include/rocprofiler/defines.h
* [5/N] Update source/lib/rocprofiler
- updates due to changes in rocprofiler.h
- rocprofiler_config.cpp: remove unions which are now defined in include/rocprofiler
- CMakeLists.txt: rocprofiler.cpp and public hsa-runtime and hip libraries
- rocprofiler.cpp: dummy implementations for:
- rocprofiler_query_available_agents
- rocprofiler_create_context
- rocprofiler_start_context
- rocprofiler_stop_context
- rocprofiler_flush_buffer
- rocprofiler_destroy_buffer
* [6/N] Update license
- replace stale LBNL license
* [7/N] CMake format
[ROCm/rocprofiler-sdk commit: 351d825a8d]
105 lines
3.6 KiB
CMake
105 lines
3.6 KiB
CMake
# ------------------------------------------------------------------------------#
|
|
#
|
|
# creates following targets to format code:
|
|
# - format
|
|
# - format-source
|
|
# - format-cmake
|
|
# - format-python
|
|
# - format-rocprofiler-source
|
|
# - format-rocprofiler-cmake
|
|
# - format-rocprofiler-python
|
|
#
|
|
# ------------------------------------------------------------------------------#
|
|
|
|
include_guard(DIRECTORY)
|
|
|
|
find_program(ROCPROFILER_CLANG_FORMAT_EXE NAMES clang-format-11 clang-format-mp-11)
|
|
find_program(ROCPROFILER_CMAKE_FORMAT_EXE NAMES cmake-format)
|
|
find_program(ROCPROFILER_BLACK_FORMAT_EXE NAMES black)
|
|
|
|
add_custom_target(format-rocprofiler)
|
|
if(NOT TARGET format)
|
|
add_custom_target(format)
|
|
endif()
|
|
foreach(_TYPE source python cmake)
|
|
if(NOT TARGET format-${_TYPE})
|
|
add_custom_target(format-${_TYPE})
|
|
endif()
|
|
endforeach()
|
|
|
|
if(ROCPROFILER_CLANG_FORMAT_EXE
|
|
OR ROCPROFILER_BLACK_FORMAT_EXE
|
|
OR ROCPROFILER_CMAKE_FORMAT_EXE)
|
|
|
|
set(rocp_source_files)
|
|
set(rocp_header_files)
|
|
set(rocp_python_files)
|
|
set(rocp_cmake_files ${PROJECT_SOURCE_DIR}/CMakeLists.txt
|
|
${PROJECT_SOURCE_DIR}/external/CMakeLists.txt)
|
|
|
|
foreach(_DIR cmake samples source tests)
|
|
foreach(_TYPE header_files source_files cmake_files python_files)
|
|
set(${_TYPE})
|
|
endforeach()
|
|
file(GLOB_RECURSE header_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.h
|
|
${PROJECT_SOURCE_DIR}/${_DIR}/*.hpp ${PROJECT_SOURCE_DIR}/${_DIR}/*.h.in
|
|
${PROJECT_SOURCE_DIR}/${_DIR}/*.hpp.in)
|
|
file(GLOB_RECURSE source_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.c
|
|
${PROJECT_SOURCE_DIR}/${_DIR}/*.cpp)
|
|
file(GLOB_RECURSE cmake_files ${PROJECT_SOURCE_DIR}/${_DIR}/*CMakeLists.txt
|
|
${PROJECT_SOURCE_DIR}/${_DIR}/*.cmake)
|
|
file(GLOB_RECURSE python_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.py
|
|
${PROJECT_SOURCE_DIR}/${_DIR}/*.py.in)
|
|
foreach(_TYPE header_files source_files cmake_files python_files)
|
|
list(APPEND rocp_${_TYPE} ${${_TYPE}})
|
|
endforeach()
|
|
endforeach()
|
|
|
|
foreach(_TYPE header_files source_files cmake_files python_files)
|
|
if(rocp_${_TYPE})
|
|
list(REMOVE_DUPLICATES rocp_${_TYPE})
|
|
list(SORT rocp_${_TYPE})
|
|
endif()
|
|
endforeach()
|
|
|
|
if(ROCPROFILER_CLANG_FORMAT_EXE)
|
|
add_custom_target(
|
|
format-rocprofiler-source
|
|
${ROCPROFILER_CLANG_FORMAT_EXE} -i ${rocp_header_files} ${rocp_source_files}
|
|
COMMENT
|
|
"[rocprofiler] Running source formatter ${ROCPROFILER_CLANG_FORMAT_EXE}..."
|
|
)
|
|
endif()
|
|
|
|
if(ROCPROFILER_BLACK_FORMAT_EXE AND rocp_python_files)
|
|
add_custom_target(
|
|
format-rocprofiler-python
|
|
${ROCPROFILER_BLACK_FORMAT_EXE} -q ${rocp_python_files}
|
|
COMMENT
|
|
"[rocprofiler] Running python formatter ${ROCPROFILER_BLACK_FORMAT_EXE}..."
|
|
)
|
|
endif()
|
|
|
|
if(ROCPROFILER_CMAKE_FORMAT_EXE)
|
|
add_custom_target(
|
|
format-rocprofiler-cmake
|
|
${ROCPROFILER_CMAKE_FORMAT_EXE} -i ${rocp_cmake_files}
|
|
COMMENT
|
|
"[rocprofiler] Running cmake formatter ${ROCPROFILER_CMAKE_FORMAT_EXE}..."
|
|
)
|
|
endif()
|
|
|
|
foreach(_TYPE source python cmake)
|
|
if(TARGET format-rocprofiler-${_TYPE})
|
|
add_dependencies(format-rocprofiler format-rocprofiler-${_TYPE})
|
|
add_dependencies(format-${_TYPE} format-rocprofiler-${_TYPE})
|
|
endif()
|
|
endforeach()
|
|
|
|
foreach(_TYPE source python cmake)
|
|
if(TARGET format-rocprofiler-${_TYPE})
|
|
add_dependencies(format format-rocprofiler-${_TYPE})
|
|
endif()
|
|
endforeach()
|
|
endif()
|