Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit 540a079

Browse files
author
Dilawar Singh
committed
Merge branch 'master' of https://github.com/BhallaLab/moose-core
2 parents 6fb344c + b4aac15 commit 540a079

File tree

300 files changed

+46180
-13999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+46180
-13999
lines changed

.ci/travis_prepare_osx.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ $PYTHON3 -m pip install matplotlib --user --upgrade
4545
$PYTHON3 -m pip install pyNeuroML libNeuroML --user
4646
$PYTHON3 -m pip install scipy --user
4747
$PYTHON3 -m pip install pylint --user
48+
$PYTHON3 -m pip install pytest --user

.clang-format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
AccessModifierOffset: -4
3+
SortIncludes: false
4+
ConstructorInitializerIndentWidth: 4
5+
AlignEscapedNewlinesLeft: true
6+
AlignTrailingComments: true
7+
AllowAllParametersOfDeclarationOnNextLine: false
8+
AllowShortFunctionsOnASingleLine: false
9+
AllowShortIfStatementsOnASingleLine: false
10+
AllowShortLoopsOnASingleLine: false
11+
AlwaysBreakTemplateDeclarations: true
12+
AlwaysBreakBeforeMultilineStrings: true
13+
BreakBeforeBinaryOperators: false
14+
BreakBeforeTernaryOperators: true
15+
BreakConstructorInitializersBeforeComma: false
16+
BinPackParameters: true
17+
ColumnLimit: 80
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
DerivePointerBinding: true
20+
ExperimentalAutoDetectBinPacking: false
21+
IndentCaseLabels: true
22+
MaxEmptyLinesToKeep: 1
23+
NamespaceIndentation: None
24+
ObjCSpaceBeforeProtocolList: false
25+
PenaltyBreakBeforeFirstCallParameter: 1
26+
PenaltyBreakComment: 60
27+
PenaltyBreakString: 1000
28+
PenaltyBreakFirstLessLess: 120
29+
PenaltyExcessCharacter: 1000000
30+
PenaltyReturnTypeOnItsOwnLine: 200
31+
PointerBindsToType: true
32+
SpacesBeforeTrailingComments: 2
33+
Cpp11BracedListStyle: true
34+
Standard: Auto
35+
IndentWidth: 4
36+
TabWidth: 4
37+
UseTab: Never
38+
BreakBeforeBraces: Stroustrup
39+
IndentFunctionDeclarationAfterType: true
40+
SpacesInParentheses: false
41+
SpacesInAngles: false
42+
SpaceInEmptyParentheses: false
43+
SpacesInCStyleCastParentheses: false
44+
SpaceAfterControlStatementKeyword: false
45+
SpaceBeforeAssignmentOperators: true
46+
ContinuationIndentWidth: 4
47+
Standard : C++11
48+
...
49+

.gitlab-ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ build:
1717
- python3 -m pip install python-libsbml --user --upgrade
1818
- python3 -m pip install pyneuroml --user --upgrade
1919
- python3 -m pip install sympy scipy --user --upgrade
20+
- python3 -m pip install pytest --user --upgrade
2021
- python3 setup.py build test
2122
- python3 setup.py install --user
22-
- python3 -c "import moose; moose.test()"
23+
- python3 -c "import moose.tests; moose.tests.test()"
24+
25+
except:
26+
- pybind11
27+
- devel
28+

CMakeLists.txt

Lines changed: 37 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.2.3 FATAL_ERROR)
22

33
# Project to build MOOSE's python module.
44
project(PyMOOSE)
@@ -18,11 +18,7 @@ if(NOT PYTHONINTERP_FOUND)
1818
find_package(PythonInterp 2.7)
1919
endif()
2020

21-
# Disable rpath on OSX.
22-
if(APPLE)
23-
set(CMAKE_MACOSX_RPATH OFF)
24-
endif()
25-
21+
set(CMAKE_MACOSX_RPATH OFF)
2622

2723
# NOTE: version should be changed in setup.py file.
2824
# If moose version is not given, use setup.py file to get the default version.
@@ -55,19 +51,20 @@ if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
5551
endif()
5652

5753
################################ CMAKE OPTIONS ##################################
58-
option(WITH_NSDF "Enable NSDF support. Requires hdf5" OFF )
59-
6054
option(DEBUG "Build with debug support" OFF)
6155
option(GPROF "Build for profiling using gprof" OFF)
6256
option(ENABLE_UNIT_TESTS "Enable unit tests (DEBUG should also be ON)" OFF)
6357
option(WITH_MPI "Enable Openmpi support" OFF)
58+
6459
option(WITH_BOOST "Enable boost. Prefer boost over stl" OFF)
6560
option(WITH_BOOST_ODE "Use boost library ode2 library instead of GSL" OFF)
6661
option(WITH_GSL "Use gsl-library. Alternative is WITH_BOOST" ON)
67-
option(PARALLELIZED_CLOCK "High level parallelization of moose::Clock (alpha)" OFF )
68-
option(USE_PRIVATE_RNG "Stochastic Objects use their private RNG" ON)
62+
6963
option(WITH_ASAN "Use AddressSanitizer in DEBUG mode." OFF)
7064

65+
option(WITH_NSDF "Enable NSDF support. Requires hdf5" OFF )
66+
67+
option(WITH_LEGACY_BINDING "Use legacy python-bindings" OFF)
7168

7269
############################ BUILD CONFIGURATION #################################
7370

@@ -102,10 +99,8 @@ if(WITH_ASAN AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
10299
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
103100
endif()
104101

105-
if(WITH_GSL)
106-
set(WITH_BOOST OFF)
107-
set(WITH_BOOST_ODE OFF)
108-
elseif(WITH_BOOST)
102+
# Override default GSL solvers when BOOST is enabled.
103+
if(WITH_BOOST OR WITH_BOOST_ODE)
109104
set(WITH_BOOST_ODE ON)
110105
set(WITH_GSL OFF)
111106
endif()
@@ -114,19 +109,16 @@ endif()
114109

115110
link_directories(${CMAKE_BINARY_DIR})
116111
add_library(libmoose SHARED basecode/main.cpp)
112+
set_target_properties(libmoose PROPERTIES PREFIX "")
117113
add_executable(moose.bin basecode/main.cpp)
118114

119115

120116
################################### SETUP BUILD ################################
121-
# default include paths.
122-
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
123-
set_target_properties(libmoose PROPERTIES COMPILE_DEFINITIONS "MOOSE_LIB")
124-
set_target_properties(libmoose PROPERTIES PREFIX "")
125117

126-
## Variable to collect all static libraries.
118+
# Variable to collect all static libraries.
127119
set(STATIC_LIBRARIES "" )
128120
# Collect all shared libraries here.
129-
set(SYSTEM_SHARED_LIBS ${LibXML2_LIBRARIES})
121+
set(SYSTEM_SHARED_LIBS "")
130122

131123
# BOOST ode library performs better than GSL and ideally should be made default.
132124
# Unfortunately Boost does not have a very good matrix library; it has ublas
@@ -231,7 +223,7 @@ add_subdirectory(device)
231223
add_subdirectory(kinetics)
232224
add_subdirectory(synapse)
233225
add_subdirectory(intfire)
234-
add_subdirectory(external/libsoda)
226+
add_subdirectory(external)
235227

236228
# development related.
237229
add_subdirectory(devel)
@@ -271,7 +263,7 @@ endif( )
271263
# especially section 'Mac OS X and the RPATH'
272264
# Switching is OFF since all libraries are statically linked in module.
273265
if(APPLE)
274-
set_target_properties( libmoose PROPERTIES MACOSX_RPATH OFF)
266+
set_target_properties(libmoose PROPERTIES MACOSX_RPATH OFF)
275267
endif(APPLE)
276268

277269
# MAC linker does not understand many of gnu-ld options.
@@ -304,12 +296,16 @@ if( WITH_BOOST )
304296
target_link_libraries( moose.bin ${Boost_LIBRARIES} )
305297
endif( WITH_BOOST )
306298

307-
308299
######################### BUILD PYMOOSE ########################################
309300

301+
if(NOT WITH_LEGACY_BINDING)
302+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/pybind11)
303+
add_subdirectory(pybind11)
304+
else()
305+
message(STATUS "Building legacy python binding.")
306+
add_subdirectory(pymoose)
307+
endif()
310308

311-
# This target is built by pymoose/CMakeLists.txt file.
312-
add_subdirectory(pymoose)
313309

314310
# always override debian default installation directory. It will be installed in
315311
# site-packages instead of dist-packages.
@@ -338,9 +334,6 @@ endif()
338334
install(TARGETS moose.bin DESTINATION bin CONFIGURATIONS Debug)
339335
install(TARGETS libmoose DESTINATION lib CONFIGURATIONS Debug)
340336

341-
# NOTE: Install macro for _moose (pymoose) has been moved to
342-
# pymoose/CMakeLists.txt file.
343-
344337
# Print message to start build process
345338
if(${CMAKE_BUILD_TOOL} MATCHES "make")
346339
message(
@@ -353,123 +346,8 @@ endif()
353346

354347

355348
############################ CTEST ######################################
356-
include( CTest )
357-
set(CTEST_NIGHTLY_START_TIME "05:30:00 UTC")
358-
set(CTEST_SUBMIT_URL "http://my.cdash.org/submit.php?project=moose")
359-
360-
if(DEBUG OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
361-
# Run this test in debug mode. In Release mode, this does not do anything.
362-
set(MOOSE_BIN_LOCATION $<TARGET_FILE:moose.bin>)
363-
message(STATUS "Executable moose.bin will be at ${MOOSE_BIN_LOCATION}" )
364-
365-
add_test(NAME moose.bin-raw-run COMMAND moose.bin -u -q)
366-
endif()
367-
368-
# Core tests.
369-
set(PYMOOSE_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/py_moose)
370-
file(GLOB PY_TEST_SCRIPTS "${PYMOOSE_TEST_DIRECTORY}/test_*.py" )
371-
foreach(_test_script ${PY_TEST_SCRIPTS} )
372-
get_filename_component(_name_we ${_test_script} NAME_WE)
373-
set(_test_name "core_${_name_we}")
374-
add_test(NAME ${_test_name}
375-
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
376-
WORKING_DIRECTORY ${PYMOOSE_TEST_DIRECTORY})
377-
set_tests_properties(${_test_name}
378-
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
379-
)
380-
endforeach()
381-
382-
# Tests for supported formats such as neuroml, sbml etc.
383-
set(SUPPORT_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/support)
384-
file(GLOB PY_TEST_SCRIPTS "${SUPPORT_TEST_DIRECTORY}/test_*.py" )
385-
foreach(_test_script ${PY_TEST_SCRIPTS} )
386-
get_filename_component(_name_we ${_test_script} NAME_WE)
387-
set(_test_name "support_${_name_we}")
388-
add_test(NAME ${_test_name}
389-
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
390-
WORKING_DIRECTORY ${SUPPORT_TEST_DIRECTORY})
391-
set_tests_properties(${_test_name}
392-
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
393-
)
394-
endforeach()
395-
396-
# rdesigneur tests. These tests require matplotlib.
397-
set(RDES_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/py_rdesigneur)
398-
file(GLOB RDES_TEST_SCRIPTS "${RDES_TEST_DIRECTORY}/test_*.py" )
399-
foreach(_test_script ${RDES_TEST_SCRIPTS})
400-
get_filename_component(_name_we ${_test_script} NAME_WE)
401-
set(_test_name "rdes_${_name_we}")
402-
add_test(NAME ${_test_name}
403-
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
404-
WORKING_DIRECTORY ${RDES_TEST_DIRECTORY}
405-
)
406-
set_tests_properties(${_test_name} PROPERTIES
407-
ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python;MOOSE_NUM_THREADS=4"
408-
)
409-
endforeach()
410-
411-
# FIXME TESTS. These should not run by default. We need to fix them.
412-
set(PYMOOSE_FIXME_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/devel/fixme)
413-
file(GLOB PY_FIXME_TEST_SCRIPTS "${PYMOOSE_FIXME_TEST_DIRECTORY}/*.py" )
414-
foreach( _test_script ${PY_FIXME_TEST_SCRIPTS} )
415-
get_filename_component( _name_we ${_test_script} NAME_WE)
416-
set(_test_name "alpha_${_name_we}")
417-
add_test( NAME ${_test_name}
418-
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
419-
CONFIGURATIONS alpha
420-
WORKING_DIRECTORY ${PYMOOSE_ALPHA_TEST_DIRECTORY}
421-
)
422-
set_tests_properties( ${_test_name}
423-
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
424-
)
425-
endforeach( )
426-
427-
# Regression and github issues. These should not run by default.
428-
set(PYMOOSE_ISSUES_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/devel/issues)
429-
file(GLOB PY_ISSUES_SCRIPTS "${PYMOOSE_ISSUES_DIRECTORY}/*.py" )
430-
foreach(_test_script ${PY_ISSUES_SCRIPTS})
431-
get_filename_component( _test_name ${_test_script} NAME_WE)
432-
add_test(NAME ${_test_name}
433-
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
434-
CONFIGURATIONS Devel
435-
WORKING_DIRECTORY ${PYMOOSE_ISSUES_DIRECTORY}
436-
)
437-
set_tests_properties(${_test_name}
438-
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
439-
)
440-
endforeach()
441-
442-
################################# COVERAGE ###################################
443-
444-
add_custom_target(coverage)
445-
set(PYTEST_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
446-
file(GLOB_RECURSE PYTEST_TEST_SCRIPTS ${PYTEST_TEST_DIRECTORY}/test_*.py)
447-
448-
foreach(_test_script ${PYTEST_TEST_SCRIPTS})
449-
get_filename_component(_name_we ${_test_script} NAME_WE)
450-
set(_test_name "pytest_${_name_we}")
451-
# message(STATUS "Adding test ${_test_name}")
452-
add_custom_target(${_test_name}
453-
# We collect coverage data but do not show report during each test.
454-
# We show report at the end of all tests. Set `--cov-report=`
455-
COMMAND ${PYTHON_EXECUTABLE} -m pytest
456-
--cov=moose --cov=rdesigneur --cov-append --cov-report=
457-
${_test_script}
458-
DEPENDS _moose
459-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
460-
COMMENT "Executing ${_test_script} using pytest"
461-
VERBATIM)
462-
add_dependencies(coverage ${_test_name})
463-
endforeach()
464-
465-
# Generate report at the end.
466-
add_custom_command(TARGET coverage POST_BUILD
467-
COMMAND ${PYTHON_EXECUTABLE} -m coverage report
468-
COMMAND ${PYTHON_EXECUTABLE} -m coverage html
469-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
470-
COMMENT "Genearting coverage report"
471-
VERBATIM)
472-
349+
include(CTest)
350+
add_subdirectory(tests)
473351

474352
########################### RELEASE #########################################
475353
set(PYMOOSE_SDIST_FILE ${CMAKE_BINARY_DIR}/pymoose-${VERSION_MOOSE}.tar.gz)
@@ -519,3 +397,17 @@ foreach(_py_script ${PY_SCRIPTS})
519397
add_dependencies(pylint ${TGT_NAME} )
520398
endforeach( )
521399

400+
######################## DOCS ###############################################
401+
find_package(Doxygen)
402+
if(DOXYGEN_FOUND)
403+
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/devel/Doxyfile.in)
404+
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
405+
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
406+
add_custom_target(doc
407+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
408+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
409+
COMMENT "Generating API documentation using Doxygen."
410+
VERBATIM)
411+
else()
412+
message(STATUS "Doxygen needs to be installed to generate API docs")
413+
endif()

CheckCXXCompiler.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Compiler check.
2-
# Must support c++11
2+
# Must support c++14
33
# If python2 is supported then we can not use c++17.
44
if(COMPILER_IS_TESTED)
55
return()
@@ -20,12 +20,11 @@ add_definitions(-Wall
2020
)
2121

2222
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
23-
# gcc-4.9.0 has regex supports though moose will compile with 4.8.x;
24-
# <regex> won't work.
2523
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
2624
message(FATAL_ERROR "Insufficient gcc version. Minimum requried 4.9")
2725
endif()
2826
add_definitions( -Wno-unused-local-typedefs )
27+
add_definitions( -fmax-errors=5 )
2928
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
3029
add_definitions( -Wno-unused-local-typedef )
3130
endif()
@@ -50,7 +49,7 @@ if(COMPILER_SUPPORTS_CXX11)
5049
endif(APPLE)
5150
else(COMPILER_SUPPORTS_CXX11)
5251
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} is too old. \n"
53-
"Please use a compiler which has c++11 support."
52+
"Please use a compiler which has full c++11 support."
5453
)
5554
endif(COMPILER_SUPPORTS_CXX11)
5655

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ recursive-include signeur *
3434
recursive-include synapse *
3535
recursive-include tests *
3636
recursive-include utility *
37+
recursive-include pybind11 *
38+
recursive-include devel *

basecode/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 2.8)
22
include( ${CMAKE_CURRENT_SOURCE_DIR}/../CheckCXXCompiler.cmake )
33
add_library(basecode
4-
consts.cpp
54
Element.cpp
65
DataElement.cpp
76
GlobalDataElement.cpp
@@ -26,3 +25,9 @@ add_library(basecode
2625
doubleEq.cpp
2726
testAsync.cpp
2827
)
28+
29+
add_executable(test_globals testGlobals.cpp global.cpp)
30+
31+
enable_testing()
32+
add_test(NAME cpp_test_globals COMMAND $<TARGET_FILE:test_globals>)
33+

0 commit comments

Comments
 (0)