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

Commit eb7315a

Browse files
ferdonlineOmar Awile
authored andcommitted
nrnivmodl-core: adding -n name and dropping install script (#223)
* added output name suffix option and adjusted options - `-n` model name used in the shared library name as suffix - `-m` path to mod2c/NMODL code generator - `-o` removed this option * Install script was transformed into a config file being saved/loaded
1 parent 557f256 commit eb7315a

File tree

5 files changed

+55
-33
lines changed

5 files changed

+55
-33
lines changed

coreneuron/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ set_target_properties(coreneuron corenrnmech scopmath ${link_cudacoreneuron}
184184
# =============================================================================
185185
add_custom_command(TARGET coreneuron
186186
POST_BUILD
187-
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -i
188-
"-I${CORENEURON_PROJECT_SOURCE_DIR} -I${CORENRN_NMODL_INCLUDE}"
189-
-n ${CORENRN_NMODL_BINARY}
187+
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core
188+
-i "-I${CORENEURON_PROJECT_SOURCE_DIR} -I${CORENRN_NMODL_INCLUDE}"
189+
-m "${CORENRN_NMODL_BINARY}"
190190
${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod
191191
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
192192
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/special-core

extra/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ set(nmodl_binary_name ${nmodl_name})
6565
# =============================================================================
6666

6767
configure_file(nrnivmodl_core_makefile.in ${CMAKE_BINARY_DIR}/share/coreneuron/nrnivmodl_core_makefile @ONLY)
68-
configure_file(nrnivmodl-core ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core COPYONLY)
68+
configure_file(nrnivmodl-core.in ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core @ONLY)
6969

7070
install(FILES ${CMAKE_BINARY_DIR}/share/coreneuron/nrnivmodl_core_makefile DESTINATION share/coreneuron)
7171
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core DESTINATION bin)
Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ set -e
88
APP_NAME=$(basename $0)
99
_PARENT="$(dirname $BASH_SOURCE)/.."
1010
ROOTDIR=$(perl -e "use Cwd 'abs_path'; print abs_path('$_PARENT')")
11-
MAKE_OPTIONS="NMODL_BINARY OUTPUT INCFLAGS LINKFLAGS MODS_PATH VERBOSE"
11+
MAKE_OPTIONS="MECH_NAME NMODL_BINARY DESTDIR INCFLAGS LINKFLAGS MODS_PATH VERBOSE"
1212
PARALLELISM=4
13+
SAVE_FILE="@CMAKE_HOST_SYSTEM_PROCESSOR@/nrnivmodl_options.txt"
1314

14-
while getopts "n:v:o:i:l:p:hV" OPT; do
15+
while getopts "n:m:v:d:i:l:p:hV" OPT; do
1516
case "$OPT" in
1617
n)
18+
params_MECH_NAME="$OPTARG";;
19+
m)
1720
params_NMODL_BINARY="$OPTARG";;
18-
o)
19-
params_OUTPUT="$OPTARG";;
21+
d)
22+
params_DESTDIR="$OPTARG";;
2023
i)
2124
params_INCFLAGS="$OPTARG";;
2225
l)
@@ -28,10 +31,12 @@ while getopts "n:v:o:i:l:p:hV" OPT; do
2831
h)
2932
echo "$APP_NAME [options, ...] [mods_path]"
3033
echo "Options:"
31-
echo " -n <binary> NMODL code generation compiler path"
32-
echo " -o <output_dir> Set the output dir (default: <arch>-core)"
34+
echo " -n <name> The model name, used as a suffix in the shared library"
35+
echo " -m <mod2c_bin> NMODL code generation compiler path"
3336
echo " -i <incl_flags> Definitions passed to the compiler, typically '-I dir..'"
3437
echo " -l <link_flags> Definitions passed to the linker, typically '-Lx -lylib..'"
38+
echo " -d <dest_dir> Install to dest_dir. Default: off - Only build in {ARCH}"\
39+
" Consider using this option on a second call. Params are preserved."
3540
echo " -V Verbose: show commands executed by make"
3641
echo " -p <n_procs> Make parallelism. Default: 4"
3742
exit 0;;
@@ -47,33 +52,39 @@ if [ $# -gt 1 ]; then
4752
exit 1
4853
fi
4954

55+
# To support build + install later we save/restore options
56+
# Attempt to load previous definitions
57+
if [ -f "$SAVE_FILE" ]; then
58+
while read line; do
59+
echo "$line"
60+
eval "$line"
61+
done < "$SAVE_FILE"
62+
fi
63+
5064
# If defined mods dir be in $1
5165
# Note: due to bug #712 makefile wont handle mod dir with spaces, so we let it fail here
5266
params_MODS_PATH=$1
5367

68+
mkdir -p "$(dirname "$SAVE_FILE")"
69+
echo "# nrnivmodl-core options. Mods location: $params_MODS_PATH" > $SAVE_FILE
70+
5471
make_params=("ROOT=${ROOTDIR}")
5572

5673
for param in $MAKE_OPTIONS; do
5774
var="params_${param}"
58-
[ "${!var+x}" ] && make_params+=("$param=${!var}")
59-
done
75+
if [ "${!var+x}" ]; then
76+
make_params+=("$param=${!var}")
77+
echo "$var=\"${!var}\""
78+
fi
79+
done >> "$SAVE_FILE"
80+
81+
# If -I (install) provided, call "make install"
82+
if [ "$params_DESTDIR" ]; then
83+
make_params+=("install")
84+
fi
6085

6186
# warn if no mod files provided
62-
ls "${params_MODS_PATH:-.}"/*.mod || echo "Warning: No mods found!"
87+
ls "${params_MODS_PATH:-.}"/*.mod || echo "WARNING: No mods found!"
6388
make -j$PARALLELISM -f "${ROOTDIR}/share/coreneuron/nrnivmodl_core_makefile" "${make_params[@]}"
6489

65-
# Create a little script to call make install (relinks w right RPATH)
66-
# This should allow splitting the build of special-core into two phases:
67-
# 1. build the binary from the libcoreneuron.so library and the compiled models
68-
# 2. install into the final destination directory and relinking as necessary
69-
# TODO: instead of outputting a script we could output an options file which would be read by
70-
# this script when installing to ensure the same arguments are being used.
71-
echo "#!/bin/bash
72-
set -e
73-
[ \$# -eq 1 ] || { echo 'Required install destination. Syntax: ' \$(basename \$0) '<directory>'; false; }
74-
set -x
75-
make -f '${ROOTDIR}/share/coreneuron/nrnivmodl_core_makefile' " $(printf "'%s' " "${make_params[@]}") "DESTDIR=\$1 install
76-
" > nrnivmech_install.sh
77-
chmod 755 nrnivmech_install.sh
78-
79-
echo "mods built successfully. Install script written to nrnivmech_install.sh"
90+
echo "mods built successfully."

extra/nrnivmodl_core_makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# Mechanisms version are by default 0.0, but should be overriden
77

8+
MECH_NAME =
89
MODS_PATH = .
910
OUTPUT = @CMAKE_HOST_SYSTEM_PROCESSOR@
1011
DESTDIR =
@@ -90,7 +91,7 @@ dimplic_c = $(MODC_DIR)/_dimplic.cpp
9091
dimplic_o = $(OBJS_DIR)/_dimplic.o
9192

9293
special = $(OUTPUT)/special-core
93-
coremech_libname = corenrnmech
94+
coremech_libname = corenrnmech$(if $(MECH_NAME),_$(MECH_NAME),)
9495
coremech_lib = $(OUTPUT)/lib$(coremech_libname)@CMAKE_SHARED_LIBRARY_SUFFIX@
9596

9697
# If no DESTDIR (we are probably just building) we use $ORIGIN (@loader_path in OSX)

tests/jenkins/nrnivmodl-core.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@ set -e
66
module load intel hpe-mpi
77
TEST_DIR="$1"
88
CORENRN_TYPE="$2"
9+
910
cd $WORKSPACE/${TEST_DIR}
10-
rm -rf $WORKSPACE/${TEST_DIR}/${CORENRN_TYPE}
11+
rm -rf ${CORENRN_TYPE}
12+
mkdir -p ${CORENRN_TYPE}
13+
14+
pushd ${CORENRN_TYPE}
15+
1116
if [ "${TEST_DIR}" = "ringtest" ]; then
12-
$WORKSPACE/install_${CORENRN_TYPE}/bin/nrnivmodl-core -o ${CORENRN_TYPE} mod-ext
17+
$WORKSPACE/install_${CORENRN_TYPE}/bin/nrnivmodl-core ../mod-ext
1318
else
14-
$WORKSPACE/install_${CORENRN_TYPE}/bin/nrnivmodl-core -o ${CORENRN_TYPE} mod
15-
fi
19+
$WORKSPACE/install_${CORENRN_TYPE}/bin/nrnivmodl-core ../mod
20+
fi
21+
22+
# rpath $ORIGIN should make it relocatable
23+
find * -mindepth 1 -maxdepth 1 -type f -exec mv "{}" ./ \;
24+
25+
popd

0 commit comments

Comments
 (0)