From e3e8625d085b42be68127b5e1295174a8e8dee44 Mon Sep 17 00:00:00 2001 From: nrnhines Date: Thu, 7 Mar 2024 10:07:36 -0500 Subject: [PATCH] More or less revert #2729 but print full path for mod files. (#2764) * Use PWD only in compile and printf lines --- bin/nrnivmodl.in | 12 ++++++++---- bin/nrnivmodl_makefile_cmake.in | 14 +++++++------- test/CMakeLists.txt | 6 ++++++ test/nmodl/Project Path Space/test.mod | 6 ++++++ test/nmodl/Project Path Space/test.py | 9 +++++++++ 5 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 test/nmodl/Project Path Space/test.mod create mode 100644 test/nmodl/Project Path Space/test.py diff --git a/bin/nrnivmodl.in b/bin/nrnivmodl.in index 7cc200a6e4..3df1ad6e4e 100755 --- a/bin/nrnivmodl.in +++ b/bin/nrnivmodl.in @@ -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 @@ -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 diff --git a/bin/nrnivmodl_makefile_cmake.in b/bin/nrnivmodl_makefile_cmake.in index 4894ac4c72..71eade96ae 100644 --- a/bin/nrnivmodl_makefile_cmake.in +++ b/bin/nrnivmodl_makefile_cmake.in @@ -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 = @@ -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 @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bb07cc86d7..d696d3b76a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 diff --git a/test/nmodl/Project Path Space/test.mod b/test/nmodl/Project Path Space/test.mod new file mode 100644 index 0000000000..d96827341a --- /dev/null +++ b/test/nmodl/Project Path Space/test.mod @@ -0,0 +1,6 @@ +NEURON {SUFFIX nothing} + +FUNCTION foo() { + foo = 3 +} + diff --git a/test/nmodl/Project Path Space/test.py b/test/nmodl/Project Path Space/test.py new file mode 100644 index 0000000000..c373e275ad --- /dev/null +++ b/test/nmodl/Project Path Space/test.py @@ -0,0 +1,9 @@ +from neuron import h + + +def test_space(): + assert h.foo() == 3.0 + + +if __name__ == "__main__": + test_space()