diff --git a/.gitignore b/.gitignore index f60f1b41e5cdbbb2ac445207ed0d2e41176e0104..a18a8b7d7af992216fe6d6bd229358fe0aa88b95 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,17 @@ Makefile # mechanism implementations generated my modparser include/mechanisms + +# external build stuff +external/bin +external/modparser-build +external/modparser-configure +external/modparser-done +external/modparser-download +external/modparser-install +external/modparser-mkdir +external/modparser-patch +external/modparser-update +external/tmp +mechanisms/*.hpp + diff --git a/CMakeLists.txt b/CMakeLists.txt index ccc56d8a708f7c3270277f2c54796656655aacfc..5d8497cbecea856af25a853ce399fe69ec0d63ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ cmake_minimum_required (VERSION 2.8) project (cell_algorithms) enable_language(CXX) +# save incoming CXX flags for forwarding to modparser external project +set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + # compilation flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -pthread -Wall") @@ -14,10 +17,26 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS "YES") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# targets for extermal dependencies +include(ExternalProject) +externalproject_add(modparser + PREFIX ${CMAKE_BINARY_DIR}/external + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external" + "-DCMAKE_CXX_FLAGS=${SAVED_CXX_FLAGS}" + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + BINARY_DIR "${CMAKE_BINARY_DIR}/external/modparser" + STAMP_DIR "${CMAKE_BINARY_DIR}/external/" + TMP_DIR "${CMAKE_BINARY_DIR}/external/tmp" + SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/modparser" + ) + + include_directories(${CMAKE_SOURCE_DIR}/external) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_SOURCE_DIR}) +add_subdirectory(mechanisms) add_subdirectory(src) add_subdirectory(tests) + diff --git a/README.md b/README.md index b47b3ac90a3815b7ba34de67c0dfd722de9d4b99..58e5cb0c2b5c3985cf981310ca74c50580e7c262 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ export CC=`which gcc` export CXX=`which g++` # build modparser -cd modparser +cd external/modparser cmake . make -j -cd .. +cd ../.. # create mechanisms cd mechanisms diff --git a/external/modparser b/external/modparser index b48972977a590b90cef6a142cda570984d79cb9e..588ca1a5ea28ef04d17b318e754d479e5489eb9a 160000 --- a/external/modparser +++ b/external/modparser @@ -1 +1 @@ -Subproject commit b48972977a590b90cef6a142cda570984d79cb9e +Subproject commit 588ca1a5ea28ef04d17b318e754d479e5489eb9a diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..203dedff949356b1a715146baf0ad6d6714aac56 --- /dev/null +++ b/mechanisms/CMakeLists.txt @@ -0,0 +1,18 @@ +set(mechanisms pas hh expsyn) + +set(modcc "${CMAKE_BINARY_DIR}/external/bin/modcc") + +foreach(mech ${mechanisms}) + set(mod "${CMAKE_CURRENT_SOURCE_DIR}/mod/${mech}.mod") + set(hpp "${CMAKE_CURRENT_SOURCE_DIR}/${mech}.hpp") + add_custom_command(OUTPUT "${hpp}" + DEPENDS modparser "${mod}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND "${modcc}" -t cpu -o "${hpp}" "${mod}") + set_source_files_properties("${hpp}" PROPERTIES GENERATED TRUE) + list(APPEND all_mod_hpps "${hpp}") +endforeach() + +# Fake target to always trigger .mod -> .hpp dependencies because wtf CMake +add_custom_target(build_all_mods DEPENDS ${all_mod_hpps}) + diff --git a/mechanisms/mod/expsyn.mod b/mechanisms/mod/expsyn.mod old mode 100755 new mode 100644 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a8286bda8e314d47f5e89b2b454bd6b84709e67..125f99dbf7db9a4900b5f402021e23eb463f1677 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,3 +9,5 @@ set(BASE_SOURCES ) add_library(cellalgo ${BASE_SOURCES} ${HEADERS}) +add_dependencies(cellalgo build_all_mods) + diff --git a/src/algorithms.hpp b/src/algorithms.hpp index b3943c688b33b7a2114f2dc88d2f3d22905d273c..83eeaf8dd7e32f776384d0c47fec5e5d0b43d1a8 100644 --- a/src/algorithms.hpp +++ b/src/algorithms.hpp @@ -1,8 +1,7 @@ #pragma once -#include <iostream> - #include <algorithm> +#include <iostream> #include <numeric> #include <type_traits> #include <vector> diff --git a/src/cell.hpp b/src/cell.hpp index 7b21909166a6e8d3dd4826b8dcf7ec8a125706de..2f336f8454bd8e3e4f4675865665c6bbb42ec654 100644 --- a/src/cell.hpp +++ b/src/cell.hpp @@ -5,9 +5,9 @@ #include <thread> #include <vector> -#include <segment.hpp> -#include <cell_tree.hpp> -#include <stimulus.hpp> +#include "segment.hpp" +#include "cell_tree.hpp" +#include "stimulus.hpp" namespace nest { namespace mc { diff --git a/src/cell_tree.hpp b/src/cell_tree.hpp index 785a4404e104e0f58db1e361b25ec13c81295c5c..1e04fc2c3bcc4e0fe887c7048997afd272fa4bff 100644 --- a/src/cell_tree.hpp +++ b/src/cell_tree.hpp @@ -9,7 +9,7 @@ #include <ostream> #include <vector> -#include "vector/include/Vector.hpp" +#include <vector/include/Vector.hpp> #include "tree.hpp" #include "util.hpp" diff --git a/src/fvm.hpp b/src/fvm.hpp index 600ff04d4faecd6fc2a854825b5663652623e8eb..4a908bba49887948e37bfa7fe3409b19df90bbb3 100644 --- a/src/fvm.hpp +++ b/src/fvm.hpp @@ -20,7 +20,7 @@ #include <vector/include/Vector.hpp> -#include <include/mechanisms/expsyn.hpp> +#include <mechanisms/expsyn.hpp> namespace nest { namespace mc { diff --git a/src/ion.hpp b/src/ion.hpp index 311e86003b4cfba2b4cd4ceb569fc97a346daca0..8f526ade3358dac54722f3bfd96a003870412623 100644 --- a/src/ion.hpp +++ b/src/ion.hpp @@ -1,6 +1,7 @@ #pragma once #include <vector/include/Vector.hpp> + #include "indexed_view.hpp" namespace nest { diff --git a/src/math.hpp b/src/math.hpp index 86eccfce67e7f53fe6645b15808c201c88634e19..006a429e06372412c1fa5dd7d84401a4df4e68f4 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -1,7 +1,8 @@ #pragma once -#include <utility> #include <cmath> +#include <utility> + namespace nest { namespace mc { diff --git a/src/matrix.hpp b/src/matrix.hpp index 615ace9d1c3f06a7c223c35d98f5a484b2a0868c..9e2c9e7d10d68c2f973cffaaf005ceb939fdcf41 100644 --- a/src/matrix.hpp +++ b/src/matrix.hpp @@ -1,11 +1,10 @@ #pragma once #include <type_traits> +#include <vector/include/Vector.hpp> #include "util.hpp" -#include <vector/include/Vector.hpp> - namespace nest { namespace mc { diff --git a/src/mechanism.hpp b/src/mechanism.hpp index 1afd8c31630faa017e95d8a7f48d444a5da93f2e..c9c801fd198c764d61f3acf653055c8957daf00e 100644 --- a/src/mechanism.hpp +++ b/src/mechanism.hpp @@ -1,14 +1,12 @@ #pragma once -#pragma once - #include <memory> #include <string> #include "indexed_view.hpp" +#include "ion.hpp" #include "parameter_list.hpp" #include "util.hpp" -#include "ion.hpp" namespace nest { namespace mc { diff --git a/src/mechanism_interface.cpp b/src/mechanism_interface.cpp index 10fad45fa0d9776c4f45302e6bf196f995765e99..f44d1f561d3efcc51b262b5bb32e0a95084bbcb5 100644 --- a/src/mechanism_interface.cpp +++ b/src/mechanism_interface.cpp @@ -7,6 +7,7 @@ #include <mechanisms/hh.hpp> #include <mechanisms/pas.hpp> + namespace nest { namespace mc { namespace mechanisms { diff --git a/src/segment.hpp b/src/segment.hpp index decb0cdd88665c421cf159b8d7f49e4f91e03f0f..c6c49b26a946d36fdc969d9473fa07105d30d4af 100644 --- a/src/segment.hpp +++ b/src/segment.hpp @@ -1,14 +1,13 @@ #pragma once #include <cmath> - #include <vector> +#include "algorithms.hpp" #include "compartment.hpp" #include "math.hpp" #include "parameter_list.hpp" #include "point.hpp" -#include "algorithms.hpp" #include "util.hpp" namespace nest { diff --git a/src/swcio.cpp b/src/swcio.cpp index f96676449d9526154d4f7d0cd3531da62bba715e..792d0fc7bdb3b4898b575dae552d0347efd85e9c 100644 --- a/src/swcio.cpp +++ b/src/swcio.cpp @@ -4,10 +4,10 @@ #include <sstream> #include <unordered_set> -#include <algorithms.hpp> -#include <point.hpp> -#include <swcio.hpp> -#include <util.hpp> +#include "algorithms.hpp" +#include "point.hpp" +#include "swcio.hpp" +#include "util.hpp" namespace nest { namespace mc { diff --git a/src/swcio.hpp b/src/swcio.hpp index a58bbac9aee9a32c03ae9bb33eb9289782a537b2..70f979cda362f503a81965c274a5cdeb23ea5056 100644 --- a/src/swcio.hpp +++ b/src/swcio.hpp @@ -6,8 +6,8 @@ #include <string> #include <vector> -#include <cell.hpp> -#include <point.hpp> +#include "cell.hpp" +#include "point.hpp" namespace nest { namespace mc { diff --git a/src/tree.hpp b/src/tree.hpp index 122d12e5951effa03fd3b97377da20c6c8f88453..3d76a9dc1e8171f62026320a98f71078e91f1dc5 100644 --- a/src/tree.hpp +++ b/src/tree.hpp @@ -1,12 +1,11 @@ #pragma once #include <algorithm> +#include <cassert> #include <numeric> #include <vector> +#include <vector/include/Vector.hpp> -#include <cassert> - -#include "vector/include/Vector.hpp" #include "algorithms.hpp" #include "util.hpp" diff --git a/src/util.hpp b/src/util.hpp index afa029ff9cfcba65258473875003c00f58c3d16b..c4362b25d0ad9e54e962b118e84ce974b422a636 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -1,6 +1,6 @@ #pragma once -#include "vector/include/Vector.hpp" +#include <vector/include/Vector.hpp> #ifdef DEBUG #define EXPECTS(expression) assert(expression) diff --git a/tests/test_algorithms.cpp b/tests/test_algorithms.cpp index f69569c9611068250cc3265524cfe64e1e10bd55..584bdf8ad10db170b44604d3db8f8047d3c29860 100644 --- a/tests/test_algorithms.cpp +++ b/tests/test_algorithms.cpp @@ -1,9 +1,9 @@ -#include "gtest.h" - #include <vector> -#include <algorithms.hpp> -#include <util.hpp> +#include "gtest.h" +#include "util.hpp" + +#include "../src/algorithms.hpp" TEST(algorithms, sum) { diff --git a/tests/test_matrix.cpp b/tests/test_matrix.cpp index 73663d6815d876e1740da4cee084c46255a74e3f..f74b47985649101a5bd4c79c07a911ed65b85c8b 100644 --- a/tests/test_matrix.cpp +++ b/tests/test_matrix.cpp @@ -1,10 +1,10 @@ #include <numeric> +#include <vector> #include "gtest.h" -#include <matrix.hpp> -#include <math.hpp> -#include <vector/include/Vector.hpp> +#include "../src/math.hpp" +#include "../src/matrix.hpp" TEST(matrix, construct_from_parent_only) { diff --git a/tests/test_mechanisms.cpp b/tests/test_mechanisms.cpp index d61c89d20b40136044dfd7556157b68947d8e56f..aef84890275263ca7ef9570c1017864736a6f331 100644 --- a/tests/test_mechanisms.cpp +++ b/tests/test_mechanisms.cpp @@ -1,7 +1,7 @@ #include "gtest.h" -#include <mechanism_interface.hpp> -#include <matrix.hpp> +#include "../src/mechanism_interface.hpp" +#include "../src/matrix.hpp" TEST(mechanisms, helpers) { nest::mc::mechanisms::setup_mechanism_helpers(); diff --git a/tests/test_parameters.cpp b/tests/test_parameters.cpp index 0dce58b0c5472de6db9d721ad78dece7a9b3de94..8a4b0d200785036d727fda4cae698a7950fbf040 100644 --- a/tests/test_parameters.cpp +++ b/tests/test_parameters.cpp @@ -1,10 +1,9 @@ - #include <fstream> #include "gtest.h" #include "util.hpp" -#include <parameter_list.hpp> +#include "../src/parameter_list.hpp" // test out the parameter infrastructure TEST(parameters, setting) diff --git a/tests/test_point.cpp b/tests/test_point.cpp index b5bfeb9c1783a6c921ca97f3eb6ae4afd535c311..27b5bf705ee2224f0dd1d12a18824d3b5d170b71 100644 --- a/tests/test_point.cpp +++ b/tests/test_point.cpp @@ -1,5 +1,5 @@ -#include <limits> #include <cmath> +#include <limits> #include "gtest.h" diff --git a/tests/test_segment.cpp b/tests/test_segment.cpp index 9c3df625db9ef87110474d35a5ce88f3f4e07f09..490f0e5ece7b8956de830029bf1188c4f912b7c6 100644 --- a/tests/test_segment.cpp +++ b/tests/test_segment.cpp @@ -4,7 +4,6 @@ #include "../src/segment.hpp" - TEST(segments, soma) { using namespace nest::mc; diff --git a/tests/test_swcio.cpp b/tests/test_swcio.cpp index 6968fd432a89842023807c8ed0ffb2ca8140b231..c3fc24d3926c86abd1ed3be760c1c6f5b7316ced 100644 --- a/tests/test_swcio.cpp +++ b/tests/test_swcio.cpp @@ -8,8 +8,8 @@ #include "gtest.h" -#include <cell.hpp> -#include <swcio.hpp> +#include "../src/cell.hpp" +#include "../src/swcio.hpp" // SWC tests void expect_record_equals(const nest::mc::io::swc_record &expected, diff --git a/tests/test_tree.cpp b/tests/test_tree.cpp index a468d80ca8d4a61804d4fd0e242cad466bff8f8c..c27c1674adbb4c5314be9ad0f4d65b80b06a2677 100644 --- a/tests/test_tree.cpp +++ b/tests/test_tree.cpp @@ -1,12 +1,12 @@ -#include <iostream> #include <fstream> +#include <iostream> +#include <json/src/json.hpp> #include <numeric> #include <vector> #include "gtest.h" -#include <cell_tree.hpp> -#include "json/src/json.hpp" +#include "../src/cell_tree.hpp" using json = nlohmann::json; using range = memory::Range; diff --git a/tests/util.hpp b/tests/util.hpp index aeb2f8d3e585a1603de6c7745b566a8b11aee12c..6252c7e439b334342c14b17285418a0e1f7a1c63 100644 --- a/tests/util.hpp +++ b/tests/util.hpp @@ -1,14 +1,13 @@ +#include <chrono> +#include <cmath> #include <fstream> +#include <iomanip> #include <iostream> #include <string> #include <vector> -#include <iomanip> -#include <chrono> -#include <cmath> - -#include <util.hpp> #include <json/src/json.hpp> +#include <util.hpp> // helpful code for running tests // a bit messy: refactor when it gets heavier and obvious patterns emerge... diff --git a/tests/validate_ball_and_stick.cpp b/tests/validate_ball_and_stick.cpp index a2aef0ada111aa7ecb8d150034a437016e987ce1..1a9bddb7e3aaa031cbf4212e0c1898767f3682bb 100644 --- a/tests/validate_ball_and_stick.cpp +++ b/tests/validate_ball_and_stick.cpp @@ -1,12 +1,11 @@ #include <fstream> +#include <json/src/json.hpp> #include "gtest.h" #include "util.hpp" -#include <cell.hpp> -#include <fvm.hpp> - -#include <json/src/json.hpp> +#include "../src/cell.hpp" +#include "../src/fvm.hpp" // compares results with those generated by nrn/ball_and_stick.py TEST(ball_and_stick, neuron_baseline) diff --git a/tests/validate_soma.cpp b/tests/validate_soma.cpp index b65b4ecb3a0de12d475c6380b24b43b824b65599..44d8235a4463e153c87fa58b325b7694440ed3a1 100644 --- a/tests/validate_soma.cpp +++ b/tests/validate_soma.cpp @@ -1,12 +1,11 @@ #include <fstream> +#include <json/src/json.hpp> #include "gtest.h" #include "util.hpp" -#include <cell.hpp> -#include <fvm.hpp> - -#include <json/src/json.hpp> +#include "../src/cell.hpp" +#include "../src/fvm.hpp" // compares results with those generated by nrn/soma.py // single compartment model with HH channels