Skip to content

Commit

Permalink
More or less revert #2729 but print full path for mod files. (#2764)
Browse files Browse the repository at this point in the history
* Use PWD only in compile and printf lines
  • Loading branch information
nrnhines authored Mar 7, 2024
1 parent 8afc9de commit e3e8625
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
12 changes: 8 additions & 4 deletions bin/nrnivmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ mdir="$PWD"

# construct file to be included by makefile to specify mod to c rule when
# executed in $MODSUBDIR (child folder of launch location folder)
# Since $(PWD) may contain spaces in the path name, use the relative path.
# Otherwise, it is very difficult to pass around paths with spaces in
# makefiles. However, to help the user know where things are, when
# compiling use the full path to *.cpp
MODMAKE=makemod2c_inc
> "$MODMAKE"
for i in "${files[@]}" ; do
Expand All @@ -170,13 +174,13 @@ for i in "${files[@]}" ; do
f=${f// /\\ }
f=${f//:/\\:}
echo "\
\$(PWD)/${base_name// /\\ }.cpp: ${f}.mod \$(NOCMODL)
${base_name// /\\ }.cpp: ${f}.mod \$(NOCMODL)
@printf \" -> \$(C_GREEN)NMODL\$(C_RESET) \$<\\\n\"
(cd \"$dir_name\"; @NRN_NOCMODL_SANITIZER_ENVIRONMENT_STRING@ MODLUNIT=\$(NRNUNITS) \$(NOCMODL) \"$base_name.mod\" -o \"$mdir\" $UserNMODLFLAGS)
./${base_name// /\\ }.o: \$(PWD)/${base_name// /\\ }.cpp
@printf \" -> \$(C_GREEN)Compiling\$(C_RESET) \$<\\\n\"
\$(CXXCOMPILE) -I\"$dir_name\" \$(INCLUDES) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c \$< -o \$@
./${base_name// /\\ }.o: ${base_name// /\\ }.cpp
@printf \" -> \$(C_GREEN)Compiling\$(C_RESET) ${PWD}/\$<\\\n\"
\$(CXXCOMPILE) -I\"$dir_name\" \$(INCLUDES) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c \"${PWD}/\$<\" -o \$@
" >> "$MODMAKE"
done

Expand Down
14 changes: 7 additions & 7 deletions bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# Mechanisms version are by default 0.0, but should be overriden
MECH_NAME =
MECH_VERSION = 0.0
MODS_PATH = $(PWD)
MODS_PATH = .
# in the @CMAKE_HOST_SYSTEM_PROCESSOR@ folder
OUTPUT = $(PWD)
OUTPUT = .
DESTDIR =
UserINCFLAGS =
UserLDFLAGS =
Expand Down Expand Up @@ -78,8 +78,8 @@ endif
NRNUNITS = $(datadir_lib)/nrnunits.lib

# File path config (internal)
MODC_DIR = $(PWD)
OBJS_DIR = $(PWD)
MODC_DIR = .
OBJS_DIR = .
mod_objs = $(MODOBJFILES)

mod_func_o = $(OBJS_DIR)/mod_func.o
Expand Down Expand Up @@ -122,20 +122,20 @@ C_GREEN := \033[32m
# Take the main and link with nrnmech.
# RPATH is set for DESTDIR_RPATH and coreneuron lib
special: $(mech_lib)
@printf " => $(C_GREEN)LINKING$(C_RESET) executable $(special) LDFLAGS are: $(LDFLAGS)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) executable \"${PWD}/$(special)\" LDFLAGS are: $(LDFLAGS)\n"
$(CXX_LINK_EXE) -I $(incdir) -I $(incdir)/nrncvode -DAUTO_DLOPEN_NRNMECH=0 $(datadir)/nrnmain.cpp -o $(special) \
-L$(OBJS_DIR) -l$(mech_libname) $(NRNLIB_FLAGS) -l$(mech_libname) $(extra_lib_link) -Wl,-rpath,'$(DESTDIR_RPATH)' -Wl,-rpath,$(libdir) $(LDFLAGS) $(EXTRA_LDFLAGS)

$(mech_lib): $(mech_lib_type)

mech_lib_shared: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) shared library $(mech_lib)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) shared library \"${PWD}/$(mech_lib)\"\n"
$(CXX_LINK_SHARED) -I $(incdir) -o ${mech_lib} ${_SONAME} \
$(mod_func_o) $(mod_objs) $(NRNLIB_FLAGS) $(NRNLIB_RPATH_FLAGS) $(LDFLAGS)
rm -f $(OBJS_DIR)/.libs/libnrnmech.so ; mkdir -p $(OBJS_DIR)/.libs ; cp $(mech_lib) $(OBJS_DIR)/.libs/libnrnmech.so

mech_lib_static: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) static library $(mech_lib)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) static library \"${PWD}/$(mech_lib)\"\n"
ar cq ${mech_lib} $(mod_func_o) $(mod_objs) $(cobjs);

mod_func.o: mod_func.cpp
Expand Down
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ if(NRN_ENABLE_PYTHON)
SCRIPT_PATTERNS test/nmodl/test_random.py
ENVIRONMENT ${sonata_zero_gid_env} ${nrnpython_mpi_env}
COMMAND ${modtests_launch_py} test/nmodl/test_random.py)
nrn_add_test(
GROUP nmodl_tests
NAME "test_path_spaces"
SCRIPT_PATTERNS "test/nmodl/Project Path Space/test.*"
ENVIRONMENT ${sonata_zero_gid_env} ${nrnpython_mpi_env}
COMMAND bash -c "pwd && cd 'test/nmodl/Project Path Space' && nrnivmodl")

nrn_add_test_group(
CORENEURON
Expand Down
6 changes: 6 additions & 0 deletions test/nmodl/Project Path Space/test.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NEURON {SUFFIX nothing}

FUNCTION foo() {
foo = 3
}

9 changes: 9 additions & 0 deletions test/nmodl/Project Path Space/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from neuron import h


def test_space():
assert h.foo() == 3.0


if __name__ == "__main__":
test_space()

0 comments on commit e3e8625

Please sign in to comment.