Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit a3797b9

Browse files
authored
Add support for inserting nmodl flags in nrnivmodl-core calls (#398)
* Add support for inserting nmodl flags in nrnivmodl-core calls For example, this enables the call: nrnivmodl-core -a "sympy --analytic" mod/ * Runtime nmodl flags replace build nmodl flags
1 parent b772169 commit a3797b9

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

extra/nrnivmodl-core.in

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ params_MODS_PATH="."
2020
params_BUILD_TYPE="@COMPILE_LIBRARY_TYPE@"
2121

2222
# prefix for common options : make sure to rename these if options are changed.
23-
MAKE_OPTIONS="MECHLIB_SUFFIX NMODL_BINARY DEST_DIR INCFLAGS LINKFLAGS MODS_PATH VERBOSE BUILD_TYPE"
23+
MAKE_OPTIONS="MECHLIB_SUFFIX NMODL_BINARY NMODL_RUNTIME_FLAGS DEST_DIR INCFLAGS LINKFLAGS MODS_PATH VERBOSE BUILD_TYPE"
2424

2525
# parse CLI args
26-
while getopts "n:m:v:d:i:l:p:b:hV" OPT; do
26+
while getopts "n:m:a:d:i:l:V:p:b:h" OPT; do
2727
case "$OPT" in
2828
n)
2929
# suffix for mechanism library
3030
params_MECHLIB_SUFFIX="$OPTARG";;
3131
m)
3232
# nmodl or mod2c binary to use
3333
params_NMODL_BINARY="$OPTARG";;
34+
a)
35+
# additional nmodl flags to be used
36+
params_NMODL_RUNTIME_FLAGS="$OPTARG";;
3437
d)
3538
# destination install directory
3639
params_DEST_DIR="$OPTARG";;
@@ -52,14 +55,15 @@ while getopts "n:m:v:d:i:l:p:b:hV" OPT; do
5255
h)
5356
echo "$APP_NAME [options, ...] [mods_path]"
5457
echo "Options:"
55-
echo " -n <name> The model name, used as a suffix in the shared library"
56-
echo " -m <mod2c_bin> NMODL code generation compiler path"
57-
echo " -i <incl_flags> Definitions passed to the compiler, typically '-I dir..'"
58-
echo " -l <link_flags> Definitions passed to the linker, typically '-Lx -lylib..'"
59-
echo " -d <dest_dir> Install to dest_dir. Default: Off."
60-
echo " -V Verbose: show commands executed by make"
61-
echo " -p <n_procs> Number of parallel builds (Default: $PARALLEL_BUILDS)"
62-
echo " -b <STATIC|SHARED> libcorenrnmech library type"
58+
echo " -n <name> The model name, used as a suffix in the shared library"
59+
echo " -m <nmodl_bin> NMODL/mod2c code generation compiler path"
60+
echo " -a <nmodl_runtime_flags> Runtime flags for NMODL/mod2c"
61+
echo " -i <incl_flags> Definitions passed to the compiler, typically '-I dir..'"
62+
echo " -l <link_flags> Definitions passed to the linker, typically '-Lx -lylib..'"
63+
echo " -d <dest_dir> Install to dest_dir. Default: Off."
64+
echo " -V Verbose: show commands executed by make"
65+
echo " -p <n_procs> Number of parallel builds (Default: $PARALLEL_BUILDS)"
66+
echo " -b <STATIC|SHARED> libcorenrnmech library type"
6367
exit 0;;
6468
?)
6569
exit 1;;

extra/nrnivmodl_core_makefile.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ ALL_OBJS = $(MOD_FUNC_OBJ) $(DIMPLIC_OBJ) $(mod_cpp_objs) $(mod_ispc_objs)
141141
C_RESET := \033[0m
142142
C_GREEN := \033[32m
143143

144+
# Default nmodl flags. Override if NMODL_RUNTIME_FLAGS is not empty
145+
NMODL_FLAGS_ISPC = $(if $(NMODL_RUNTIME_FLAGS),$(NMODL_RUNTIME_FLAGS),@nmodl_arguments_ispc@)
146+
NMODL_FLAGS_C = $(if $(NMODL_RUNTIME_FLAGS),$(NMODL_RUNTIME_FLAGS),@nmodl_arguments_c@)
147+
$(info Default nmodl flags: $(if (@CORENRN_ENABLE_ISPC@ == ON), @nmodl_arguments_ispc@, @nmodl_arguments_c@))
148+
ifneq ($(NMODL_RUNTIME_FLAGS),)
149+
$(warning Runtime nmodl flags (they replace the default ones): $(NMODL_RUNTIME_FLAGS))
150+
endif
144151

145152
# ======== MAIN BUILD RULES ============
146153

@@ -186,11 +193,11 @@ $(MOD_OBJS_DIR)/%.obj: $(MOD_TO_CPP_DIR)/%.ispc | $(MOD_OBJS_DIR)
186193

187194
# translate MOD files to ISPC using NMODL
188195
$(mod_ispc_files): $(MOD_TO_CPP_DIR)/%.ispc: $(MODS_PATH)/%.mod | $(MOD_TO_CPP_DIR)
189-
$(NMODL_ENV_VAR) $(NMODL_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ @nmodl_arguments_ispc@
196+
$(NMODL_ENV_VAR) $(NMODL_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ $(NMODL_FLAGS_ISPC)
190197

191198
# translate MOD files to CPP using mod2c/NMODL
192199
$(mod_cpp_files): $(MOD_TO_CPP_DIR)/%.cpp: $(MODS_PATH)/%.mod | $(MOD_TO_CPP_DIR)
193-
$(NMODL_ENV_VAR) $(NMODL_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ @nmodl_arguments_c@
200+
$(NMODL_ENV_VAR) $(NMODL_BINARY_PATH) $< -o $(MOD_TO_CPP_DIR)/ $(NMODL_FLAGS_C)
194201

195202
# static pattern to set up the dependencies for the previous recipe
196203
$(mod_ispc_cpp_files): $(MOD_TO_CPP_DIR)/%.cpp: $(MOD_TO_CPP_DIR)/%.ispc

0 commit comments

Comments
 (0)