Skip to content

Commit

Permalink
Merge branch 'master' into hines/cvlocal-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nrnhines authored Jan 8, 2025
2 parents ac1c6a9 + d68acad commit 8e1e0e5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ jobs:
brew install cmake
echo "$(brew --prefix)/opt/cmake/bin" >> $GITHUB_PATH
fi
# workaround for fmt 11.1 (see https://github.com/gabime/spdlog/pull/3312)
brew unlink fmt
echo "$(brew --prefix)/opt/flex/bin:$(brew --prefix)/opt/bison/bin" >> $GITHUB_PATH
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
if [[ "${{matrix.os}}" == "macOS-13" ]]; then
Expand Down
24 changes: 0 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -789,30 +789,6 @@ add_custom_target(
COMMENT "Format only files modified with respect to master branch."
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

# =============================================================================
# ~~~
# Update hh.mod for CoreNEURON compatibility
# - Replace GLOBAL variable by RANGE
# - Comment out TABLE
# ~~~
# =============================================================================
if(NRN_ENABLE_CORENEURON OR NRN_ENABLE_MOD_COMPATIBILITY)
set(GLOBAL_VAR_TOGGLE_COMMAND "'s/ GLOBAL minf/ RANGE minf/'")
else()
set(GLOBAL_VAR_TOGGLE_COMMAND "'s/ RANGE minf/ GLOBAL minf/'")
endif()
separate_arguments(GLOBAL_VAR_TOGGLE_COMMAND UNIX_COMMAND "${GLOBAL_VAR_TOGGLE_COMMAND}")
add_custom_target(
hh_update
COMMAND sed ${GLOBAL_VAR_TOGGLE_COMMAND} ${CMAKE_SOURCE_DIR}/src/nrnoc/hh.mod >
${CMAKE_BINARY_DIR}/hh.mod.1
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/hh.mod.1
${CMAKE_SOURCE_DIR}/src/nrnoc/hh.mod
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/hh.mod.1
COMMENT "Update hh.mod for CoreNEURON compatibility"
VERBATIM)
add_dependencies(nrniv_lib hh_update)

# =============================================================================
# Generate help_data.dat
# =============================================================================
Expand Down
6 changes: 3 additions & 3 deletions ci/win_install_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ mingw-w64-x86_64-cmake ^
mingw-w64-x86_64-ninja ^
mingw-w64-x86_64-ncurses ^
mingw-w64-x86_64-readline ^
mingw-w64-x86_64-python3 ^
mingw-w64-x86_64-python ^
mingw-w64-x86_64-python-setuptools ^
mingw-w64-x86_64-python3-packaging ^
mingw-w64-x86_64-python3-pip ^
mingw-w64-x86_64-python-packaging ^
mingw-w64-x86_64-python-pip ^
mingw64/mingw-w64-x86_64-dlfcn ^
mingw-w64-x86_64-toolchain || goto :error

Expand Down
35 changes: 23 additions & 12 deletions cmake/MacroHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,40 @@ endmacro()
# =============================================================================
# Run nocmodl to convert NMODL to C
# =============================================================================
macro(nocmodl_mod_to_cpp modfile_basename)
macro(nocmodl_mod_to_cpp modfile_basename modfile_compat)
set(NOCMODL_SED_EXPR "s/_reg()/_reg_()/")
if(NOT MSVC)
set(NOCMODL_SED_EXPR "'${NOCMODL_SED_EXPR}'")
endif()
set(REMOVE_CMAKE_COMMAND "rm")
if(CMAKE_VERSION VERSION_LESS "3.17")
set(REMOVE_CMAKE_COMMAND "remove")
set(MODFILE_INPUT_PATH "${PROJECT_SOURCE_DIR}/${modfile_basename}.mod")
set(MODFILE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/${modfile_basename}.mod")

# for coreNEURON only
if(modfile_compat)
file(READ "${MODFILE_INPUT_PATH}" FILE_CONTENT)
string(REGEX REPLACE " GLOBAL minf" " RANGE minf" FILE_CONTENT "${FILE_CONTENT}")
file(WRITE "${MODFILE_OUTPUT_PATH}" "${FILE_CONTENT}")
else()
configure_file("${MODFILE_INPUT_PATH}" "${MODFILE_OUTPUT_PATH}" COPYONLY)
endif()
get_filename_component(modfile_output_dir ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod DIRECTORY)

get_filename_component(modfile_output_dir "${MODFILE_OUTPUT_PATH}" DIRECTORY)
get_filename_component(modfile_name "${MODFILE_OUTPUT_PATH}" NAME_WE)
set(CPPFILE_OUTPUT_PATH "${modfile_output_dir}/${modfile_name}.cpp")

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/${modfile_basename}.cpp
OUTPUT ${CPPFILE_OUTPUT_PATH}
COMMAND
${CMAKE_COMMAND} -E env "MODLUNIT=${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib"
${NRN_NOCMODL_SANITIZER_ENVIRONMENT} $<TARGET_FILE:${NRN_CODEGENERATOR_TARGET}>
${PROJECT_SOURCE_DIR}/${modfile_basename}.mod ${NRN_NMODL_--neuron} -o ${modfile_output_dir}
COMMAND sed ${NOCMODL_SED_EXPR} ${PROJECT_SOURCE_DIR}/${modfile_basename}.cpp >
${PROJECT_BINARY_DIR}/${modfile_basename}.cpp
COMMAND ${CMAKE_COMMAND} -E ${REMOVE_CMAKE_COMMAND}
${PROJECT_SOURCE_DIR}/${modfile_basename}.cpp
DEPENDS ${NRN_CODEGENERATOR_TARGET} ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod
${MODFILE_OUTPUT_PATH} ${NRN_NMODL_--neuron} -o ${modfile_output_dir}
COMMAND sed ${NOCMODL_SED_EXPR} ${CPPFILE_OUTPUT_PATH} > ${CPPFILE_OUTPUT_PATH}.tmp
COMMAND ${CMAKE_COMMAND} -E copy ${CPPFILE_OUTPUT_PATH}.tmp ${CPPFILE_OUTPUT_PATH}
COMMAND ${CMAKE_COMMAND} -E remove ${CPPFILE_OUTPUT_PATH}.tmp
DEPENDS ${NRN_CODEGENERATOR_TARGET} ${MODFILE_INPUT_PATH}
${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/nrniv)

endmacro()

# =============================================================================
Expand Down
6 changes: 5 additions & 1 deletion src/nrniv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ endif()
# Translate all MOD files to C and mark them generated
# =============================================================================
foreach(modfile ${NRN_MODFILE_BASE_NAMES})
nocmodl_mod_to_cpp(${modfile})
set(modfile_compat OFF)
if((NRN_ENABLE_CORENEURON OR NRN_ENABLE_MOD_COMPATIBILITY) AND modfile MATCHES "hh$")
set(modfile_compat ON)
endif()
nocmodl_mod_to_cpp(${modfile} ${modfile_compat})
list(APPEND NRN_MODFILE_CPP ${PROJECT_BINARY_DIR}/${modfile}.cpp)
endforeach()
set_property(
Expand Down

0 comments on commit 8e1e0e5

Please sign in to comment.