Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix /style functionality #1386

Merged
merged 10 commits into from
Jul 23, 2024
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
2 changes: 1 addition & 1 deletion .github/actions/apply-style/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ git checkout $branch
git submodule update --init --recursive

mkdir build && cd build
cmake $CMAKE_ARGS ..
cmake $CMAKE_ARGS ../src
make style
cd ..

Expand Down
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Cyrus D. Harrison <[email protected]> Cyrus <[email protected]>
Daniel Taller <[email protected]> Danny Taller <[email protected]>
Esteban Pauli <[email protected]> Esteban Pauli <[email protected]>
Evan Taylor Desantola <[email protected]> Evan Taylor DeSantola <[email protected]>
format-robot <[email protected]> format-robot <[email protected]>
George Zagaris <[email protected]> George Zagaris <[email protected]>
Jacob Spainhour <[email protected]> jcs15c <[email protected]>
Jacob Spainhour <[email protected]> Jacob Spainhour <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ if(AXOM_ENABLE_CUDA AND ${CMAKE_VERSION} VERSION_LESS 3.18.0)
message(FATAL_ERROR "Axom requires CMake version 3.18.0+ when CUDA is enabled.")
endif()

axom_add_code_checks()

#------------------------------------------------------------------------------
# Add source directories
#------------------------------------------------------------------------------
Expand Down
13 changes: 2 additions & 11 deletions src/axom/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,25 @@
* since it might be included from a C file
*/


/*
* Axom Version Information
*/
#define AXOM_VERSION_MAJOR @AXOM_VERSION_MAJOR@
#define AXOM_VERSION_MINOR @AXOM_VERSION_MINOR@
#define AXOM_VERSION_PATCH @AXOM_VERSION_PATCH@
#define AXOM_VERSION_FULL "@AXOM_VERSION_FULL@"
#define AXOM_VERSION_FULL "@AXOM_VERSION_FULL@"
/*NOTE: Do not add AXOM_GIT_SHA here. This will force
* full rebuild on all local changes. It is added in axom::getVersion()
* and axom::about(), as well as accessible from axom::gitSha().
*/


/*
* Axom source location
*/
#define AXOM_SRC_DIR "@AXOM_SRC_DIR@"
#define AXOM_BIN_DIR "@AXOM_BIN_DIR@"
#cmakedefine AXOM_DATA_DIR "@AXOM_DATA_DIR@"


/*
* Platform specific definitions
*/
Expand All @@ -46,7 +43,6 @@
#cmakedefine AXOM_USE_64BIT_INDEXTYPE
#endif


/*
* Compiler tests
*/
Expand All @@ -62,7 +58,6 @@
#cmakedefine AXOM_USE_MPIF_HEADER
#cmakedefine AXOM_USE_OPENMP


/*
* Compiler defines for libraries (built-in and third party)
*/
Expand Down Expand Up @@ -97,7 +92,6 @@
#define NOMINMAX
#endif


/*
* Compiler defines for Axom components
*/
Expand All @@ -120,7 +114,6 @@
*/
#cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N@


/*
* Compiler defines to configure the built-in fmt library
*/
Expand All @@ -133,11 +126,9 @@
#cmakedefine SPARSEHASH_HASHFUN_HEADER @SPARSEHASH_HASHFUN_HEADER@
#cmakedefine SPARSEHASH_HASHFUN_NAMESPACE @SPARSEHASH_HASHFUN_NAMESPACE@


/*
* Disable some MSVC warnings related to shared libraries, if applicable
*/
@AXOM_MSVC_PRAGMAS@


#endif /* AXOM_COMMON_CONFIG_HPP */
#endif /* AXOM_COMMON_CONFIG_HPP */
5 changes: 0 additions & 5 deletions src/axom/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,3 @@ endif()
if(AXOM_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX core)
5 changes: 0 additions & 5 deletions src/axom/inlet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX inlet)
6 changes: 0 additions & 6 deletions src/axom/klee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,3 @@ axom_install_component( NAME klee
if (AXOM_ENABLE_TESTS AND ENABLE_GMOCK)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX klee)

5 changes: 0 additions & 5 deletions src/axom/lumberjack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX lumberjack)
5 changes: 0 additions & 5 deletions src/axom/mint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX mint)
6 changes: 2 additions & 4 deletions src/axom/mint/core/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#ifndef MINT_CONFIG_HPP_
#define MINT_CONFIG_HPP_

#include "axom/config.hpp"// for compile-time definitions
#include "axom/core/Types.hpp" // for fixed-width types
#include "axom/config.hpp" // for compile-time definitions
#include "axom/core/Types.hpp" // for fixed-width types

#cmakedefine AXOM_MINT_USE_SIDRE

Expand All @@ -22,6 +22,4 @@ using int64 = std::int64_t;
} /* end namespace mint */
} /* end namespace axom */



#endif /* MINT_CONFIG_HPP_ */
8 changes: 0 additions & 8 deletions src/axom/multimat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,3 @@ endif()
if (AXOM_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()


#------------------------------------------------------------------------------
# Add docs and code checks
#------------------------------------------------------------------------------
axom_add_code_checks(
PREFIX multimat
)
5 changes: 0 additions & 5 deletions src/axom/primal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX primal)
2 changes: 0 additions & 2 deletions src/axom/quest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

axom_add_code_checks(PREFIX quest)
6 changes: 0 additions & 6 deletions src/axom/sidre/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,3 @@ endif()
if(AXOM_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX sidre
EXCLUDES sidre/examples/lulesh2)
11 changes: 0 additions & 11 deletions src/axom/slam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,3 @@ endif()
if (AXOM_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()


#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(
PREFIX slam
EXCLUDES
slam/examples/lulesh2.0.3
slam/examples/tinyHydro )

5 changes: 0 additions & 5 deletions src/axom/slic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX slic)
5 changes: 0 additions & 5 deletions src/axom/spin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,3 @@ endif()
if (AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX spin)
76 changes: 39 additions & 37 deletions src/cmake/AxomMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
# SPDX-License-Identifier: (BSD-3-Clause)

##------------------------------------------------------------------------------
## axom_add_code_checks( PREFIX <Prefix used for created targets>
## EXCLUDES [path1 [path2 ...]])
## axom_add_code_checks()
##
## Adds code checks to all source files under this directory.
##
## PREFIX is used in the creation of all the underlying targets. For example:
## <PREFIX>_clangformat_check.
##
## EXCLUDES is used to exclude any files from the code checks. It is done with
## a simple CMake reg exp MATCHES check.
## Adds code checks for all source files recursively in the Axom repository.
##
## This creates the following parent build targets:
## check - Runs a non file changing style check and CppCheck
## style - In-place code formatting
##
## Creates various child build targets that follow this pattern:
## axom_<check|style>
## axom_<cppcheck|clangformat>_<check|style>
##------------------------------------------------------------------------------
macro(axom_add_code_checks)

set(options)
set(singleValueArgs PREFIX )
set(multiValueArgs EXCLUDES )
set(singleValueArgs)
set(multiValueArgs)

# Parse the arguments to the macro
cmake_parse_arguments(arg
Expand All @@ -29,34 +29,36 @@ macro(axom_add_code_checks)
# Only do code checks if building Axom by itself and not included in
# another project
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
set(_all_sources)
file(GLOB_RECURSE _all_sources
"*.cpp" "*.hpp" "*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh"
"*.F" "*.f" "*.f90" "*.F90")

# Check for excludes
if (NOT DEFINED arg_EXCLUDES)
set(_sources ${_all_sources})
else()
set(_sources)
foreach(_source ${_all_sources})
set(_to_be_excluded FALSE)
foreach(_exclude ${arg_EXCLUDES})
if (${_source} MATCHES ${_exclude})
set(_to_be_excluded TRUE)
break()
endif()
endforeach()

if (NOT ${_to_be_excluded})
list(APPEND _sources ${_source})
endif()
# Create file globbing expressions that only include directories that contain source
set(_base_dirs "axom" "examples" "thirdparty/tests" "tools")
set(_ext_expressions "*.cpp" "*.hpp" "*.inl"
"*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh"
"*.F" "*.f" "*.f90" "*.F90")

set(_glob_expressions)
foreach(_exp ${_ext_expressions})
foreach(_base_dir ${_base_dirs})
list(APPEND _glob_expressions "${PROJECT_SOURCE_DIR}/${_base_dir}/${_exp}")
endforeach()
endif()
endforeach()

# Glob for list of files to run code checks on
set(_sources)
file(GLOB_RECURSE _sources ${_glob_expressions})

# Filter out exclusions
set(_exclude_expressions
"${PROJECT_SOURCE_DIR}/axom/sidre/examples/lulesh2/*"
"${PROJECT_SOURCE_DIR}/axom/slam/examples/lulesh2.0.3/*"
"${PROJECT_SOURCE_DIR}/axom/slam/examples/tinyHydro/*")
foreach(_exp ${_exclude_expressions})
list(FILTER _sources EXCLUDE REGEX ${_exp})
endforeach()

blt_add_code_checks(PREFIX ${arg_PREFIX}
SOURCES ${_sources}
CLANGFORMAT_CFG_FILE ${PROJECT_SOURCE_DIR}/.clang-format)
blt_add_code_checks(PREFIX axom
SOURCES ${_sources}
CLANGFORMAT_CFG_FILE ${PROJECT_SOURCE_DIR}/.clang-format
CPPCHECK_FLAGS --enable=all --inconclusive)

# Set FOLDER property for code check targets
foreach(_suffix clangformat_check clangformat_style clang_tidy_check clang_tidy_style)
Expand Down
13 changes: 1 addition & 12 deletions src/docs/sphinx/dev_guide/component_org.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,9 @@ The top-level component directory contains a ``CMakeLists.txt``, e.g.,

install(EXPORT <component name>-targets DESTINATION lib/cmake)

#. Code formatting and static analysis targets; e.g.,::

axom_add_code_checks(BASE_NAME <component name>)



.. note:: Each Axom component should use the common ``clang-format``
configuration file defined for the project at ``src/.clang-format``.
The file is used to define source code formatting options that are
applied when the *clang-format* tool is run on the code.


Component src directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^

The ``CMakeLists.txt`` file in the component ``src`` directory defines:

Expand Down
18 changes: 9 additions & 9 deletions src/examples/using-with-blt/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
// SPDX-License-Identifier: (BSD-3-Clause)


//-----------------------------------------------------------------------------
///
/// file: example.cpp
Expand All @@ -17,14 +16,15 @@

int main()
{
// Using fmt library exported by axom
std::cout << axom::fmt::format(
"Example of using an installed version of Axom {}",
axom::getVersion()) << std::endl << std::endl;
// Using fmt library exported by axom
std::cout << axom::fmt::format(
"Example of using an installed version of Axom {}",
axom::getVersion())
<< std::endl
<< std::endl;

// Uses installed axom library
axom::about();
// Uses installed axom library
axom::about();

return 0;
return 0;
}

Loading