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

Fiddle CI. #1480

Closed
wants to merge 21 commits into from
Closed
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
14 changes: 9 additions & 5 deletions .github/workflows/nmodl-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
env:
CTEST_PARALLEL_LEVEL: 1
PYTHON_VERSION: 3.8
DESIRED_CMAKE_VERSION: 3.15.0
DESIRED_CMAKE_VERSION: 3.30.3

jobs:
ci:
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:
enable_usecases: On
update_references: On
- config:
flag_warnings: ON
os: ubuntu-22.04
flag_warnings: ON
sanitizer: undefined
fail-fast: true
steps:
Expand All @@ -71,7 +71,7 @@ jobs:
run: |
brew install [email protected] || true
brew link --overwrite [email protected]
brew install ccache coreutils bison boost flex ninja
brew install ccache coreutils bison boost flex ninja fmt spdlog
echo /usr/local/opt/flex/bin:/usr/local/opt/bison/bin >> $GITHUB_PATH
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Install apt packages
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get install bison ccache flex libfl-dev ninja-build python3-dev python3-pip
sudo apt-get install bison ccache flex libfl-dev ninja-build python3-dev python3-pip libfmt-dev libspdlog-dev
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV
shell: bash
Expand Down Expand Up @@ -133,7 +133,11 @@ jobs:
echo "------- Configure -------"
cmake_args=(-G Ninja
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR)
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
-DNMODL_3RDPARTY_USE_SPDLOG=Off \
-DNMODL_3RDPARTY_USE_FMT=Off \
-DNMODL_3RDPARTY_USE_CATCH2=On)

if [[ -n "${{matrix.config.flag_warnings}}" ]]; then
cmake_args+=(-DNMODL_EXTRA_CXX_FLAGS="-Wall \
-Wno-reorder \
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/sonarsource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install packages
run: |
sudo apt-get install bison ccache flex lcov libfl-dev \
python3-dev python3-pip
python3-dev python3-pip catch2 libfmt-dev libspdlog-dev
shell: bash
- name: Set up Python3
uses: actions/setup-python@v5
Expand All @@ -42,7 +42,10 @@ jobs:
mkdir build
cmake -S . -B build \
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_BUILD_TYPE=Release
-DNMODL_3RDPARTY_USE_SPDLOG=Off \
-DNMODL_3RDPARTY_USE_FMT=Off \
-DNMODL_3RDPARTY_USE_CATCH2=Off \
-DCMAKE_BUILD_TYPE=Debug

- name: Run build-wrapper
working-directory: ${{runner.workspace}}/nmodl
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ include(cmake/GitRevision.cmake)
include(cmake/PythonLinkHelper.cmake)
include(cmake/RpathHelper.cmake)
include(cmake/ExternalProjectHelper.cmake)
include(cmake/PrecompileHeaders.cmake)

# This should apply to all NMODL targets but should not leak out when NMODL is built as a submodule.
add_compile_options(${NMODL_COMPILER_WARNING_SUPPRESSIONS})
Expand Down Expand Up @@ -139,11 +140,11 @@ endif()
# installation for consistency. This line should be harmless if we use an external spdlog.
option(SPDLOG_FMT_EXTERNAL "Force to use an external {{fmt}}" ON)
option(SPDLOG_SYSTEM_INCLUDE "Include spdlog as a system lib" ON)
cpp_cc_git_submodule(spdlog BUILD PACKAGE spdlog REQUIRED)
if(NMODL_3RDPARTY_USE_SPDLOG)
# See above, same logic as fmt
option(SPDLOG_BUILD_PIC "Needed to be PIC to be put compiled as a lib" ON)
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
cpp_cc_git_submodule(spdlog BUILD PACKAGE spdlog REQUIRED)

if(NMODL_ENABLE_BACKWARD)
cpp_cc_git_submodule(backward BUILD EXCLUDE_FROM_ALL PACKAGE backward REQUIRED)
Expand Down
13 changes: 13 additions & 0 deletions cmake/PrecompileHeaders.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function(target_precompile_nmodl_headers target_name)

if(COMMAND target_precompile_headers)
# target_precompile_headers(${target_name}
# # PRIVATE <string>
# # PRIVATE <filesystem>
# PRIVATE <utils/logger.hpp>
# PRIVATE <ast/ast.hpp>
# PRIVATE <ast/all.hpp>)
else()
message(WARNING "CMake doesn't support `target_precompile_headers`.")
endif()
endfunction()
15 changes: 9 additions & 6 deletions src/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# =============================================================================
# Codegen library
# =============================================================================
add_library(
codegen STATIC
add_library(codegen STATIC
codegen_acc_visitor.cpp
codegen_transform_visitor.cpp
codegen_compatibility_visitor.cpp
codegen_coreneuron_cpp_visitor.cpp
codegen_neuron_cpp_visitor.cpp
codegen_cpp_visitor.cpp
codegen_compatibility_visitor.cpp
codegen_helper_visitor.cpp
codegen_info.cpp
codegen_utils.cpp)
codegen_neuron_cpp_visitor.cpp
codegen_transform_visitor.cpp
codegen_utils.cpp
${NMODL_CODEGEN_SOURCES})

target_precompile_nmodl_headers(codegen)

add_dependencies(codegen lexer util visitor)
target_link_libraries(codegen PRIVATE util)
4 changes: 2 additions & 2 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@
* representation (1e+20, 1E-15) then keep it as it is.
*/
std::string CodegenCppVisitor::format_double_string(const std::string& s_value) {
return utils::format_double_string<CodegenCppVisitor>(s_value);
return utils::format_double_string(s_value);
}


std::string CodegenCppVisitor::format_float_string(const std::string& s_value) {
return utils::format_float_string<CodegenCppVisitor>(s_value);
return utils::format_float_string(s_value);
}


Expand Down Expand Up @@ -1728,7 +1728,7 @@
auto rhs = get_variable_name(state_name + "0");

if (state->is_array()) {
auto size = state->get_length();

Check warning on line 1731 in src/codegen/codegen_cpp_visitor.cpp

View workflow job for this annotation

GitHub Actions / { "flag_warnings": "ON", "glibc_asserts": "ON", "os": "ubuntu-22.04" }

unused variable ‘size’ [-Wunused-variable]

Check warning on line 1731 in src/codegen/codegen_cpp_visitor.cpp

View workflow job for this annotation

GitHub Actions / { "os": "ubuntu-22.04", "flag_warnings": "ON", "sanitizer": "undefined" }

unused variable 'size' [-Wunused-variable]
for (int i = 0; i < state->get_length(); ++i) {
printer->fmt_line("{}[{}] = {};", lhs, i, rhs);
}
Expand Down
6 changes: 2 additions & 4 deletions src/codegen/codegen_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ namespace utils {
* they are represented in the mod file by user. If the value is in scientific
* representation (1e+20, 1E-15) then keep it as it is.
*/
template <>
std::string format_double_string<CodegenCppVisitor>(const std::string& s_value) {
std::string format_double_string(const std::string& s_value) {
double value = std::stod(s_value);
if (std::ceil(value) == value && s_value.find_first_of("eE") == std::string::npos) {
return fmt::format("{:.1f}", value);
Expand All @@ -30,8 +29,7 @@ std::string format_double_string<CodegenCppVisitor>(const std::string& s_value)
}


template <>
std::string format_float_string<CodegenCppVisitor>(const std::string& s_value) {
std::string format_float_string(const std::string& s_value) {
float value = std::stof(s_value);
if (std::ceil(value) == value && s_value.find_first_of("eE") == std::string::npos) {
return fmt::format("{:.1f}", value);
Expand Down
2 changes: 0 additions & 2 deletions src/codegen/codegen_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace utils {
* \param s_value The double constant as string
* \return The proper string to be printed in the generated file.
*/
template <typename T>
std::string format_double_string(const std::string& s_value);


Expand All @@ -43,7 +42,6 @@ std::string format_double_string(const std::string& s_value);
* \param s_value The double constant as string
* \return The proper string to be printed in the generated file.
*/
template <typename T>
std::string format_float_string(const std::string& s_value);

} // namespace utils
Expand Down
1 change: 1 addition & 0 deletions src/lexer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ add_custom_command(

add_library(lexer STATIC ${LEXER_SOURCE_FILES} ${BISON_GENERATED_SOURCE_FILES}
${AST_GENERATED_SOURCES} ${UNIT_SOURCE_FILES})
target_precompile_nmodl_headers(lexer)
set_property(TARGET lexer PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(lexer PRIVATE util)

Expand Down
1 change: 0 additions & 1 deletion src/lexer/nmodl_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* \brief Lexer implementations
*/

#include "ast/ast.hpp"
#include "parser/nmodl/nmodl_parser.hpp"


Expand Down
3 changes: 2 additions & 1 deletion src/symtab/symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

#include "symtab/symbol.hpp"
#include "utils/logger.hpp"

#include <utils/fmt.h>
#include <ast/ast.hpp>

namespace nmodl {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(
${PROJECT_BINARY_DIR}/src/config/config.cpp)

set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(util PUBLIC fmt::fmt nlohmann_json::nlohmann_json spdlog::spdlog_header_only)
target_link_libraries(util PUBLIC fmt::fmt nlohmann_json::nlohmann_json spdlog::spdlog)

if(NMODL_ENABLE_BACKWARD)
target_link_libraries(util PRIVATE Backward::Interface)
Expand Down
2 changes: 2 additions & 0 deletions src/visitors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ add_library(
verbatim_visitor.cpp
visitor_utils.cpp
${VISITORS_GENERATED_SOURCES})

target_precompile_nmodl_headers(visitor)
set_property(TARGET visitor PROPERTY POSITION_INDEPENDENT_CODE ON)
add_dependencies(visitor pywrapper)
target_link_libraries(visitor PUBLIC lexer util)
Expand Down
1 change: 1 addition & 0 deletions src/visitors/perf_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <cassert>
#include <utility>
#include <cassert>

#include "ast/all.hpp"
#include "printer/json_printer.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/visitors/sympy_solver_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "visitors/sympy_solver_visitor.hpp"

#include "visitors/sympy_replace_solutions_visitor.hpp"

#include "ast/all.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/visitors/sympy_solver_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <unordered_set>
#include <vector>

#include "ast/ast.hpp"
#include "ast/ast_decl.hpp"
#include "symtab/symbol.hpp"
#include "visitors/ast_visitor.hpp"
#include "visitors/visitor_utils.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/visitors/visitor_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
#include <nlohmann/json.hpp>

#include "ast/all.hpp"
#include "codegen/codegen_naming.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/visitors/visitor_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <string>
#include <unordered_set>

#include <ast/ast_decl.hpp>
#include <ast/all.hpp>
#include <utils/common_utils.hpp>

namespace nmodl {
Expand Down
Loading
Loading