Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean headers dependencies in nrn #2389

Closed
wants to merge 19 commits into from
Closed
  •  
  •  
  •  
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,6 @@ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/share/lib/cleanup

# Copy NEURON headers that will be included in the installation into the build directory.
set(headers_in_build_dir)
foreach(header_below_src ${HEADER_FILES_TO_INSTALL})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment for other reviewers: I understand the idea here is that src/dir/header.h used to get installed as include/header.h, but now it gets installed as include/dir/header.h.

get_filename_component(header_name "${header_below_src}" NAME)
set(output_name "${PROJECT_BINARY_DIR}/include/${header_name}")
cpp_cc_build_time_copy(
INPUT "${PROJECT_SOURCE_DIR}/src/${header_below_src}"
OUTPUT "${output_name}"
NO_TARGET)
list(APPEND headers_in_build_dir "${output_name}")
endforeach()
foreach(header_below_src ${STRUCTURED_HEADER_FILES_TO_INSTALL})
set(output_name "${PROJECT_BINARY_DIR}/include/${header_below_src}")
cpp_cc_build_time_copy(
Expand Down
2 changes: 1 addition & 1 deletion bin/nrnivmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ MODOBJS=

{
echo '#include <stdio.h>
#include "hocdec.h"
#include <oc/hocdec.h>
extern int nrnmpi_myid;
extern int nrn_nobanner_;
'
Expand Down
8 changes: 4 additions & 4 deletions bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ UserLDFLAGS =
# install dirs
bindir := ${ROOT}/@CMAKE_INSTALL_BINDIR@
libdir := ${ROOT}/@CMAKE_INSTALL_LIBDIR@
incdir := ${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@
incdir := -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@ -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/crout -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/neuron -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/newton -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/nrncvode -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/nrniv -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/nrnmpi -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/nrnoc -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/oc -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/scopmath -I${ROOT}/@CMAKE_INSTALL_INCLUDEDIR@/sparse13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this change. If we are now including a lot more of these directory names in the #include <...> statements, why do we need these here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because mod files still include "raw" files from the old grouped <BUILD>/include directory

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that is widespread in VERBATIM blocks, not just in the code generated by nocmodl?

I'm not sure it's a step forwards to introduce two different #include schemes, one for the library source files and one for the generated .cpp...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can slowly clean all mod files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't buy that; the cost/reward for updating all of ModelDB for that is such that it will never happen, in my view.

So: this seems like it's creating and locking in a new source of inconsistency between different bits of C++. Is that really worth it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on the first part that it will never happens.

For the second part, I, personnaly, think, it worse it, to clean more the code and know who include what.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't buy that; the cost/reward for updating all of ModelDB for that is such that it will never happen, in my view.

I agree on the first part that it will never happens.

We are on the same page!

So: this seems like it's creating and locking in a new source of inconsistency between different bits of C++. Is that really worth it?

For the second part, I, personnaly, think, it worse it, to clean more the code and know who include what.

I understand the "inconsistency" aspects that Olli mentioned (i.e. having a single way would be better).

I don't have recent enough hands-on experience to assess the impact or propose a better solution here. Maybe @olupton you can propose what should be done here?

datadir:= ${ROOT}/@CMAKE_INSTALL_DATADIR@
datadir_lib := ${ROOT}/@CMAKE_INSTALL_DATADIR@/lib

Expand Down Expand Up @@ -47,7 +47,7 @@ OS_NAME := $(shell uname)
_cm =,

# We rebuild the include dirs since a lot of stuff changes place
INCLUDES = -I. $(INCFLAGS) $(UserINCFLAGS) -I$(incdir)
INCLUDES = -I. $(INCFLAGS) $(UserINCFLAGS) $(incdir)
ifeq (@NRN_INCLUDE_MPI_HEADERS@, ON)
INCLUDES += $(if @MPI_C_INCLUDE_PATH@, -I$(subst ;, -I,@MPI_C_INCLUDE_PATH@),)
endif
Expand Down Expand Up @@ -116,14 +116,14 @@ C_GREEN := \033[32m
# RPATH is set for DESTDIR_RPATH and coreneuron lib
special: $(mech_lib)
@printf " => $(C_GREEN)LINKING$(C_RESET) executable $(special) LDFLAGS are: $(LDFLAGS)\n"
$(CXX_LINK_EXE) -I $(incdir) -I $(incdir)/nrncvode -DAUTO_DLOPEN_NRNMECH=0 $(datadir)/nrnmain.cpp -o $(special) \
$(CXX_LINK_EXE) $(incdir) -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"
$(CXX_LINK_SHARED) -I $(incdir) -o ${mech_lib} ${_SONAME} \
$(CXX_LINK_SHARED) $(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

Expand Down
2 changes: 1 addition & 1 deletion bin/nrnocmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ else
fi

echo '#include <stdio.h>
#include "hocdec.h"
#include <oc/hocdec.h>
extern "C" void modl_reg() {
fprintf(stderr, "Additional mechanisms from files'$newline'");
' > mod_func.cpp
Expand Down
2 changes: 1 addition & 1 deletion cmake/MacroHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ endmacro()
# Transform PROJECT_SOURCE_DIR/sdir/sfile.in to PROJECT_BINARY_DIR/bdir/bfile
# =============================================================================
# ~~~
# This 4 arg macro transformsPROJECT_SOURCE_DIR/sdir/sfile.in into
# This 4 arg macro transforms PROJECT_SOURCE_DIR/sdir/sfile.in into
# PROJECT_BINARY_DIR/bdir/bfile .
# THE shorter two arg form transforms PROJECT_SOURCE_DIR/dir/file.in into
# PROJECT_BINARY_DIR/dir/file
Expand Down
12 changes: 6 additions & 6 deletions cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# =======================================================================================
# Lists of header files to install. Difference is whether the dir structure is preserved.
# Lists of header files to install.
#
# * HEADER_FILES_TO_INSTALL: ${src}/src/dir/header.h -> {bld}/include/header.h
# * STRUCTURED_HEADER_FILES_TO_INSTALL: {src}/src/a/b.h -> {bld}/include/a/b.h
# =======================================================================================
set(STRUCTURED_HEADER_FILES_TO_INSTALL
neuron/cache/mechanism_range.hpp neuron/container/data_handle.hpp
neuron/container/generic_data_handle.hpp neuron/container/non_owning_soa_identifier.hpp
neuron/model_data_fwd.hpp)
set(HEADER_FILES_TO_INSTALL
neuron/cache/mechanism_range.hpp
neuron/container/data_handle.hpp
neuron/container/generic_data_handle.hpp
neuron/container/non_owning_soa_identifier.hpp
neuron/model_data_fwd.hpp
nrniv/backtrace_utils.h
nrniv/bbsavestate.h
nrnmpi/nrnmpidec.h
Expand Down
4 changes: 2 additions & 2 deletions mingw_files/nrnmingwenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ copyinc() {

# we rely on a couple of include groups, one from nocmodl and the other one hoisted from old gcc days and all (most) ModelDB include
copyinc '
"mech_api.h"
"section.h"
<oc/mech_api.h>
<nrnoc/section.h>
<math.h>
<stdio.h>
<stdlib.h>
Expand Down
1 change: 0 additions & 1 deletion src/gnu/HypGeom.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright (C) 1988 Free Software Foundation
written by Dirk Grunwald (grunwald@cs.uiuc.edu)
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/apwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#ifdef WIN32
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/axis.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <cstdio>
Expand All @@ -11,7 +11,7 @@
#include "scenevie.h"
#include "mymath.h"
#include "axis.h"
#include "hocdec.h"
#include <oc/hocdec.h>
#include "rect.h"
#include "graph.h"
#include "idraw.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/bndedval.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include "bndedval.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/cbwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <InterViews/window.h>
Expand Down
12 changes: 6 additions & 6 deletions src/ivoc/checkpnt.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

/*
Expand Down Expand Up @@ -91,17 +91,17 @@ data depending on type. eg for VAR && NOTUSER it is
#include <OS/list.h>
#include <OS/table.h>
#include "oc2iv.h"
#include "ocfunc.h"
#include <oc/ocfunc.h>
#if HAVE_XDR
#include <rpc/xdr.h>
#endif
#include "checkpnt.h"

#include "redef.h"
#include "hoclist.h"
#include <oc/redef.h>
#include <oc/hoclist.h>
#include "parse.hpp"
#include "code.h"
#include "equation.h"
#include <oc/code.h>
#include <oc/equation.h>
int hoc_readcheckpoint(char*);
extern int hoc_resize_toplevel(int);

Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/classreg.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
// interface c++ class to oc

#include <InterViews/resource.h>
#include <stdio.h>
#include "classreg.h"
#include <oc/classreg.h>
#ifndef OC_CLASSES
#define OC_CLASSES "occlass.h"
#define OC_CLASSES <ivoc/occlass.h>
#endif

#define EXTERNS 1
Expand Down
8 changes: 4 additions & 4 deletions src/ivoc/datapath.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#include <map>
#include <cstdio>
#include <InterViews/resource.h>
#include <OS/string.h>
#include <OS/list.h>
#include "hoclist.h"
#include <oc/hoclist.h>
#if HAVE_IV
#include "graph.h"
#endif
#include "datapath.h"
#include "ivocvect.h"

#include "nrnoc2iv.h"
#include "membfunc.h"
#include <nrniv/nrnoc2iv.h>
#include <nrnoc/membfunc.h>

#include "parse.hpp"
extern Symlist* hoc_built_in_symlist;
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/epsprint.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include "epsprint.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/field.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

/*
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/fourier.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
/* (C) Copr. 1986-92 Numerical Recipes Software #.,. */

/* Algorithms for Fourier Transform Spectral Methods */
Expand All @@ -18,7 +18,7 @@
#undef myfabs
#define myfabs fabs

#include "oc_ansi.h"
#include <oc/oc_ansi.h>

// Apple LLVM version 5.1 (clang-503.0.38) generates "unsequenced modification warning".
// #define SQUARE(a) ((x_=(a)) == 0.0 ? 0.0 : x_*x_)
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/gifimage.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions src/ivoc/graph.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>

#include <string.h>
#include <stdio.h>
Expand Down Expand Up @@ -36,7 +36,7 @@ extern Image* gif_image(const char*);
#include "idraw.h"
#include "symchoos.h"
#include "scenepic.h"
#include "oc_ansi.h"
#include <oc/oc_ansi.h>
#include "oc2iv.h"
#include "objcmd.h"
#include "ocjump.h"
Expand All @@ -46,8 +46,8 @@ extern Image* gif_image(const char*);
#include "ivocvect.h"
#endif /* HAVE_IV */

#include "classreg.h"
#include "gui-redirect.h"
#include <oc/classreg.h>
#include <nrnoc/gui-redirect.h>

#if HAVE_IV
#define Graph_Crosshair_ "Crosshair Graph"
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/graphvec.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#define USEGNU 1
Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/grglyph.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
// hoc level Glyph implementation for graphing
#include <stdio.h>
#include "classreg.h"
#include <oc/classreg.h>
#include "oc2iv.h"
#if HAVE_IV
#include "ivoc.h"
Expand All @@ -24,7 +24,7 @@ class GrGlyph: public Resource {
};
#endif // HAVE_IV

#include "gui-redirect.h"
#include <nrnoc/gui-redirect.h>

double gr_addglyph(void* v) {
TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.addglyph", v);
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/grmanip.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <InterViews/canvas.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/hocmark.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/htlist.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifdef HAVE_CONFIG_H
#include <../../nrnconf.h>
#include <nrnconf.h>
#endif
/*
Based on Unidraw UList but UList changed to HTList (head tail list)
Expand Down Expand Up @@ -34,7 +34,7 @@ for fast insertion, deletion, iteration

#include <stdio.h>
#include <OS/enter-scope.h>
#include <htlist.h>
#include "htlist.h"

/*****************************************************************************/

Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/idraw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>
#if HAVE_IV // to end of file

#include <stdio.h>
Expand All @@ -13,8 +13,8 @@
#include <InterViews/style.h>
#include <OS/string.h>

#include "hocdec.h"
#include "oc_ansi.h"
#include <oc/hocdec.h>
#include <oc/oc_ansi.h>
#include "scenevie.h"
#include "mymath.h"
#include "idraw.h"
Expand Down
10 changes: 5 additions & 5 deletions src/ivoc/ivoc.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <../../nrnconf.h>
#include <nrnconf.h>

#include <vector>
#include <ocnotify.h>
#include "ocnotify.h"
#include <stdio.h>
#include <stdlib.h>
#include "neuron/container/soa_container.hpp"
#include <nrnmutdec.h>
#include "nrnmutdec.h"
#include "oc2iv.h"
#include "ocfunc.h"
#include <oc/ocfunc.h>
#include "ocnotify.h"
#include "oc_ansi.h"
#include <oc/oc_ansi.h>
#include "ocjump.h"

#if HAVE_IV
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/ivoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <InterViews/session.h>
#include <OS/string.h>
#include <stdio.h>
#include "gui-redirect.h"
#include <nrnoc/gui-redirect.h>
extern int nrn_err_dialog_active_;

#include <ostream>
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/ivocmac.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <../../nrnconf.h>
#include <nrnconf.h>

#include <CodeFragments.h>

Expand Down