From bf46e722537ef93bf40c28d55c8dc740dc72801e Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 00:44:42 -0500 Subject: [PATCH 01/19] ignore .DS_Store --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9ecdf95..09d9735 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ python_modules/**/*.pyd python_modules/**/.ipynb_checkpoints .idea +.DS_Store From 87a6f5447e98fbee63488db13e3a0b5978689ab9 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 01:53:15 -0500 Subject: [PATCH 02/19] initial cmake files... work still needed --- CMakeLists.txt | 303 +++++++++++++++++++++++++++++++++++++++++ FindLibFreetype2.cmake | 72 ++++++++++ FindLibZMQ.cmake | 78 +++++++++++ 3 files changed, 453 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 FindLibFreetype2.cmake create mode 100644 FindLibZMQ.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..36d2ac9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,303 @@ +cmake_minimum_required(VERSION 3.8) +project(PythonPlugin) + +set(PLUGIN_NAME PythonPlugin) + +# define LINUX if you're building on linux. +# for now we assume that you're building to run on the build machine +if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) + set(LINUX TRUE) +endif() + +# set build type to debug by default +if(NOT DEFINED CONFIG) + set(CMAKE_BUILD_TYPE Debug) +endif() + +if(NOT (CMAKE_BUILD_TYPE STREQUAL Debug) OR (CMAKE_BUILD_TYPE STREQUAL Release)) + message(FATAL_ERROR, "Unsupported CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE}) +endif() +message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) + +# Find Python (users can override by specifying the three vars printed out below) +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) +message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) +message(STATUS "Python library: " ${PYTHON_LIBRARIES}) +message(STATUS "Python include dir: " ${PYTHON_INCLUDE_DIRS}) + + + +# PYTHON_LIBRARIES = /Users/benacland/anaconda/envs/online/lib/libpython3.4m.dylib +# PYTHON_INCLUDE_DIRS = /Users/benacland/anaconda/envs/online/include/python3.4m + + + +# we need to know where the open ephys source is +set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") +string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) +if(NOT OPEN_EPHYS_DIR) + message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please call ccmake.") + return() +else() + get_filename_component(OPEN_EPHYS_DIR ${OPEN_EPHYS_DIR} ABSOLUTE) + message("Open Ephys Source: " ${OPEN_EPHYS_DIR}) +endif() + +# put together path for common plugin libraries +get_filename_component(COMMON_DIR ${OPEN_EPHYS_DIR}/Source/Plugins/CommonLibs ABSOLUTE) +message("CommonLibs: " ${COMMON_DIR}) + +# add project dir to module path so the library finding .cmake files are found +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +# our headers +file(GLOB PLUGIN_HEADER_FILES "PythonPlugin/*.h") +set(HEADER_FILES "${PLUGIN_HEADER_FILES}") + +# our c and cpp files +file(GLOB PLUGIN_SOURCES "PythonPlugin/*.cpp" "PythonPlugin/*.c") +set(SOURCES "${PLUGIN_SOURCES}") + +# generate shared library +add_library(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES} ${PLUGIN_HEADER_FILES}) +set(CMAKE_SHARED_LIBRARY_PREFIX "") +set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) + +target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_11) + +## +## cmake should set these automatically... so I'm just going to set some +## CMAKE_CXX_FLAGS and add defines below +## +# Debug Only: +# Release Only: +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") + +# cross-platform CFLAGS +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") + +# link libraries +# target_link_libraries(${PLUGIN_NAME} pthread) + +# preprocessor definitions +add_definitions(-DOEPLUGIN) +add_definitions(-DJUCE_APP_VERSION=0.4.2) +add_definitions(-DJUCE_APP_VERSION_HEX=0x402) + +# include directories for the plugin +target_include_directories(${PLUGIN_NAME} PUBLIC + $ + # $ + ) + +target_include_directories(${PLUGIN_NAME} PUBLIC + ${OPEN_EPHYS_DIR}/JuceLibraryCode + ${OPEN_EPHYS_DIR}/JuceLibraryCode/modules + ${OPEN_EPHYS_DIR}/Source/Plugins/Headers + ) + +# platform specific stuff +if(APPLE) + # macros for working with apple stuff + macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} + ${XCODE_VALUE}) + endmacro (set_xcode_property) + + # we need to know where the package dir is + set(MAC_PACKAGE_DIR "/usr/local" CACHE PATH "Where do you install custom libs on this mac?") + string(STRIP "${MAC_PACKAGE_DIR}" MAC_PACKAGE_DIR) + if(NOT MAC_PACKAGE_DIR) + message(FATAL_ERROR, "MAC_PACKAGE_DIR not specified... please call ccmake.") + endif() + get_filename_component(MAC_PACKAGE_DIR ${MAC_PACKAGE_DIR} ABSOLUTE) + + # install location + # IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX + "$ENV{HOME}/Library/Application Support/open-ephys/PlugIns" + CACHE PATH + "Plugin install location. See Open Ephys docs for details." + FORCE) + # ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + + set_xcode_property(${PLUGIN_NAME} INSTALL_PATH ${CMAKE_INSTALL_PREFIX}) + set_xcode_property(${PLUGIN_NAME} GCC_INLINES_ARE_PRIVATE_EXTERN NO) + + # rpath stuff + set(CMAKE_MACOSX_RPATH ON) + set(CMAKE_SKIP_BUILD_RPATH FALSE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + # link the IOKit framework + target_link_libraries(${PLUGIN_NAME} debug "-framework IOKit") + target_link_libraries(${PLUGIN_NAME} optimized "-framework IOKit") + + # mac-specific preprocessor definitions + add_definitions(-DMAC_PACKAGE_DIR=${MAC_PACKAGE_DIR}) + add_definitions(-DJUCER_XCODE_MAC_F6D2F4CF=1) + # add_definitions(-D_ANSI_SOURCE) # needed for nanosleep() + + # mac-specific cxx flags + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") + + # mac-specific c flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-inconsistent-missing-override") + + # # mac-specific library include directories + # target_include_directories(${PLUGIN_NAME} PUBLIC + # ${MAC_PACKAGE_DIR}/include + # ) + + # mac-specific library search paths + link_directories(${MAC_PACKAGE_DIR}/lib) + + # mac-specific linker flags + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -undefined dynamic_lookup") + + # xcode properties + set_xcode_property(${PLUGIN_NAME} WRAPPER_EXTENSION bundle) + + # # dir for config files + # file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Config) + + # # copy and configure Env.xcconfig + # configure_file(${PROJECT_SOURCE_DIR}/resources/Env.xcconfig.in Config/Env.xcconfig @ONLY) + + # # copy plugin xcconfig files from open ephys + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Base.xcconfig Config COPYONLY) + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Debug.xcconfig Config COPYONLY) + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Release.xcconfig Config COPYONLY) + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin_Debug.xcconfig Config COPYONLY) + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin_Release.xcconfig Config COPYONLY) + # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin.xcconfig Config COPYONLY) + +elseif(LINUX) + if(TARGET_ARCH) + # (this disables dependency generation if multiple architectures are set) + list(LENGTH TARGET_ARCH ARCH_COUNT) + if(${ARCH_COUNT} GREATER 1) + message("ARCH_COUNT = " ${ARCH_COUNT}) + set(DEPFLAGS "") + else() + set(DEPFLAGS -MMD) + endif() + else() + # -march=native really only supported on for GCC, Clang and ICC on i386 and x86_64. + # ... fix this, if ever needed + set(TARGET_ARCH -march=native) + set(DEPFLAGS -MMD) + endif() + + # find freetype (needed on linux only) + find_package(LibFreetype2 REQUIRED) + file(GLOB LIBFREETYPE2_HEADER_FILES "${LIBFREETYPE2_INCLUDE_DIRS}/libserialport.h") + + # generate shared library + # TODO: do I really need the freetype header files here? I add its include dir below... + # add_library(${PLUGIN_NAME} SHARED ${SOURCES} ${HEADER_FILES} ${LIBFREETYPE2_HEADER_FILES}) + + # install into the open ephy plugins directory + get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + SET(CMAKE_INSTALL_PREFIX + ${OE_PLUGIN_DIR} + CACHE PATH + "Plugin install location. See Open Ephys docs for details." + FORCE) + + # no 'lib' prefix, please... the other plugins will laugh + SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") + + # linux-specific c flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEPFLAGS} -O3 -fPIC -rdynamic -lcap") + + # linux-specific preprocessor definitions + add_definitions(-DLINUX=1) + add_definitions(-DJUCER_LINUX_MAKE_7346DA2A=1) + add_definitions(-DJUCE_DISABLE_NATIVE_FILECHOOSERS=1) + add_definitions(-D_XOPEN_SOURCE=700) + + # linux-specific include directories + target_include_directories(${PLUGIN_NAME} PUBLIC + /usr/include # TODO: always right? + ${COMMON_DIR} + ) + + # linker flags + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg -fPIC -rdynamic") + set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} -L/usr/local/include") # is this really needed? + + # STRONGLY consider removing fvisibility call... it's what lead to the keypress issue + # https://github.com/open-ephys/plugin-GUI/issues/89 + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -fvisibility=hidden") + + ## + ## TODO: there's a more robust way to link libs using add_libra() w/SHARED, but + ## we'll do that later if there's time / a need + ## + + # look for libraries in build dirs first + link_directories(${CMAKE_BINARY_DIR}) + link_directories(${CMAKE_CURRENT_BINARY_DIR}) + + # add standard library locations + link_directories("/usr/X11R6/lib") + + # link libraries that "should" be in standard locations + target_link_libraries(${PLUGIN_NAME} GL) + target_link_libraries(${PLUGIN_NAME} X11) + target_link_libraries(${PLUGIN_NAME} Xext) + target_link_libraries(${PLUGIN_NAME} Xinerama) + target_link_libraries(${PLUGIN_NAME} asound) + target_link_libraries(${PLUGIN_NAME} dl) + target_link_libraries(${PLUGIN_NAME} rt) + target_link_libraries(${PLUGIN_NAME} dl) + target_link_libraries(${PLUGIN_NAME} Xext) + target_link_libraries(${PLUGIN_NAME} GLU) + + # link freetype + if(LIBFREETYPE2_FOUND) + target_include_directories(${PLUGIN_NAME} PUBLIC ${LIBFREETYPE2_INCLUDE_DIRS}) + target_link_libraries(${PLUGIN_NAME} ${LIBFREETYPE2_LIBRARIES}) + endif() + + # TODO: run makefiles in subdirs of COMMON_DIR + # TODO: figure out how to link against these... + # previously, it was by doing this: # $(COMMONDIRS): OUTDIR := $(BINDIR) + # $(COMMONDIRS): LIB_PREFIX := lib + # ... causes these common libs to put output into build dir... which gets + # picked up thanks to link_directories(${CMAKE_CURRENT_BINARY_DIR})... i think + # COMMONDIRS := $(wildcard $(COMMON_DIR)/*) + # libs: $(COMMONDIRS) +elseif(WIN32) + # TODO: this is surely broken... fix it (if you ever need to) + + # compile flags + set(WIN32_COMPILE_FLAGS + "/nologo /Zc:wchar_t /Zc:forScope /GX /GL /GF /GR /GS- /Zi /fp:precise /MP /W4 " + ) + set(DEFAULT_COMPILE_FLAGS ${WIN32_COMPILE_FLAGS}) + + target_link_libraries(${PLUGIN_NAME} debug ${LIBSERIAL_LIBRARIES} "setupapi.lib" ) + target_link_libraries(${PLUGIN_NAME} optimized ${LIBSERIAL_LIBRARIES} "setupapi.lib") +else() + # maybe non-apple unix + message(FATAL_ERROR, "Build Platform Not Recognized: Aborting...") + return() +endif() + +message("Install location: " ${CMAKE_INSTALL_PREFIX}) + +# Set the library installation location +install(TARGETS ${PLUGIN_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/FindLibFreetype2.cmake b/FindLibFreetype2.cmake new file mode 100644 index 0000000..4b46a48 --- /dev/null +++ b/FindLibFreetype2.cmake @@ -0,0 +1,72 @@ +# - Try to find libfreetype2 +# Once done this will define +# +# LIBFREETYPE2_FOUND - system has libfreetype2 +# LIBFREETYPE2_INCLUDE_DIRS - the libfreetype2 include directory +# LIBFREETYPE2_LIBRARIES - Link these to use libfreetype2 +# LIBFREETYPE2_DEFINITIONS - Compiler switches required for using libfreetype2 +# +# Adapted from cmake-modules Google Code project +# +# Copyright (c) 2006 Andreas Schneider +# +# (Changes for libfreetype2) Copyright (c) 2018 Ben Acland +# +# Redistribution and use is allowed according to the terms of the New BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +if (LIBFREETYPE2_LIBRARIES AND LIBFREETYPE2_INCLUDE_DIRS) + # in cache already + set(LIBFREETYPE2_FOUND TRUE) +else (LIBFREETYPE2_LIBRARIES AND LIBFREETYPE2_INCLUDE_DIRS) + find_path(LIBFREETYPE2_INCLUDE_DIR + NAMES + freetype.h + PATHS + /usr/include + /usr/local/include + /opt/local/include + /sw/include + /usr/include/freetype2/freetype + ) + + set(CMAKE_FIND_LIBRARY_PREFIXES lib) + find_library(LIBFREETYPE2_LIBRARY + NAMES + freetype + PATHS + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + /usr/lib/x86_64-linux-gnu + ) + + set(LIBFREETYPE2_INCLUDE_DIRS + ${LIBFREETYPE2_INCLUDE_DIR} + ) + set(LIBFREETYPE2_LIBRARIES + ${LIBFREETYPE2_LIBRARY} +) + + if (LIBFREETYPE2_INCLUDE_DIRS AND LIBFREETYPE2_LIBRARIES) + set(LIBFREETYPE2_FOUND TRUE) + endif (LIBFREETYPE2_INCLUDE_DIRS AND LIBFREETYPE2_LIBRARIES) + + if (LIBFREETYPE2_FOUND) + if (NOT libfreetype2_FIND_QUIETLY) + message(STATUS "Found libfreetype2:") + message(STATUS " - Includes: ${LIBFREETYPE2_INCLUDE_DIRS}") + message(STATUS " - Libraries: ${LIBFREETYPE2_LIBRARIES}") + endif (NOT libfreetype2_FIND_QUIETLY) + else (LIBFREETYPE2_FOUND) + if (libfreetype2_FIND_REQUIRED) + message(FATAL_ERROR "Could not find libfreetype2") + endif (libfreetype2_FIND_REQUIRED) + endif (LIBFREETYPE2_FOUND) + + # show the LIBFREETYPE2_INCLUDE_DIRS and LIBFREETYPE2_LIBRARIES variables only in the advanced view + mark_as_advanced(LIBFREETYPE2_INCLUDE_DIRS LIBFREETYPE2_LIBRARIES) + +endif (LIBFREETYPE2_LIBRARIES AND LIBFREETYPE2_INCLUDE_DIRS) diff --git a/FindLibZMQ.cmake b/FindLibZMQ.cmake new file mode 100644 index 0000000..3700ac4 --- /dev/null +++ b/FindLibZMQ.cmake @@ -0,0 +1,78 @@ +# - Try to find libzmq +# Once done this will define +# +# LIBZMQ_FOUND - system has libzmq +# LIBZMQ_INCLUDE_DIRS - the libzmq include directory +# LIBZMQ_LIBRARIES - Link these to use libzmq +# LIBZMQ_DEFINITIONS - Compiler switches required for using libzmq +# +# Adapted from cmake-modules Google Code project +# +# Copyright (c) 2006 Andreas Schneider +# +# (Changes for libzmq) Copyright (c) 2018 Ben Acland +# +# Redistribution and use is allowed according to the terms of the New BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +# first we'll try with pkg-config +if (PKG_CONFIG_FOUND) + pkg_check_modules(LIBZMQ libzmq) +else (PKG_CONFIG_FOUND) + if (NOT libzmq_FIND_QUIETLY) + message(STATUS "Could not find pkg-config!!") + endif (NOT libzmq_FIND_QUIETLY) +endif (PKG_CONFIG_FOUND) + +if (LIBZMQ_LIBRARIES AND LIBZMQ_INCLUDE_DIRS) + # in cache already + set(LIBZMQ_FOUND TRUE) +else (LIBZMQ_LIBRARIES AND LIBZMQ_INCLUDE_DIRS) + find_path(LIBZMQ_INCLUDE_DIR + NAMES + zmq.h + PATHS + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + + set(CMAKE_FIND_LIBRARY_PREFIXES lib l) + find_library(LIBZMQ_LIBRARY + NAMES + zmq + PATHS + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + set(LIBZMQ_INCLUDE_DIRS + ${LIBZMQ_INCLUDE_DIR} + ) + set(LIBZMQ_LIBRARIES + ${LIBZMQ_LIBRARY} +) + + if (LIBZMQ_INCLUDE_DIRS AND LIBZMQ_LIBRARIES) + set(LIBZMQ_FOUND TRUE) + endif (LIBZMQ_INCLUDE_DIRS AND LIBZMQ_LIBRARIES) +endif (LIBZMQ_LIBRARIES AND LIBZMQ_INCLUDE_DIRS) + +if (LIBZMQ_FOUND) + if (NOT libzmq_FIND_QUIETLY) + message(STATUS "Found libzmq:") + message(STATUS " - Includes: ${LIBZMQ_INCLUDE_DIRS}") + message(STATUS " - Libraries: ${LIBZMQ_LIBRARIES}") + endif (NOT libzmq_FIND_QUIETLY) +else (LIBZMQ_FOUND) + if (libzmq_FIND_REQUIRED) + message(FATAL_ERROR "Could not find libzmq") + endif (libzmq_FIND_REQUIRED) +endif (LIBZMQ_FOUND) + +# show the LIBZMQ_INCLUDE_DIRS and LIBZMQ_LIBRARIES variables only in the advanced view +mark_as_advanced(LIBZMQ_INCLUDE_DIRS LIBZMQ_LIBRARIES) From f428f05e60707a350e5806e722b61670c0a24834 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 02:52:54 -0500 Subject: [PATCH 03/19] first pass at python stuff for mac and linux --- CMakeLists.txt | 56 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d2ac9..6ea866d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,25 +19,28 @@ if(NOT (CMAKE_BUILD_TYPE STREQUAL Debug) OR (CMAKE_BUILD_TYPE STREQUAL Release)) endif() message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) -# Find Python (users can override by specifying the three vars printed out below) +# Find Python. Users can specify by providing the following in the call to cmake: + # -DPYTHON_EXECUTABLE + # -DPYTHON_LIBRARIES + # -DPYTHON_INCLUDE_DIRS + # -DPYTHON_HOME find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) +set(PYTHON_HOME $ENV{CONDA_PREFIX} CACHE PATH "Where is the root of your python installation?") +get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} DIRECTORY) +message(STATUS "Python home: " ${PYTHON_HOME}) message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) message(STATUS "Python library: " ${PYTHON_LIBRARIES}) +message(STATUS "Python lib dir: " ${PYTHON_LIB_DIR}) message(STATUS "Python include dir: " ${PYTHON_INCLUDE_DIRS}) - - - -# PYTHON_LIBRARIES = /Users/benacland/anaconda/envs/online/lib/libpython3.4m.dylib -# PYTHON_INCLUDE_DIRS = /Users/benacland/anaconda/envs/online/include/python3.4m - - +target_include_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) +target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) # we need to know where the open ephys source is set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) if(NOT OPEN_EPHYS_DIR) - message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please call ccmake.") + message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please call ccmake or use -DOPEN_EPHYS_DIR.") return() else() get_filename_component(OPEN_EPHYS_DIR ${OPEN_EPHYS_DIR} ABSOLUTE) @@ -113,7 +116,7 @@ if(APPLE) set(MAC_PACKAGE_DIR "/usr/local" CACHE PATH "Where do you install custom libs on this mac?") string(STRIP "${MAC_PACKAGE_DIR}" MAC_PACKAGE_DIR) if(NOT MAC_PACKAGE_DIR) - message(FATAL_ERROR, "MAC_PACKAGE_DIR not specified... please call ccmake.") + message(FATAL_ERROR, "MAC_PACKAGE_DIR not specified... please call ccmake or use -DMAC_PACKAGE_DIR.") endif() get_filename_component(MAC_PACKAGE_DIR ${MAC_PACKAGE_DIR} ABSOLUTE) @@ -130,14 +133,15 @@ if(APPLE) set_xcode_property(${PLUGIN_NAME} GCC_INLINES_ARE_PRIVATE_EXTERN NO) # rpath stuff + # see: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling set(CMAKE_MACOSX_RPATH ON) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${PYTHON_LIB_DIR}" isSystemDir) if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") endif() # link the IOKit framework @@ -204,10 +208,6 @@ elseif(LINUX) find_package(LibFreetype2 REQUIRED) file(GLOB LIBFREETYPE2_HEADER_FILES "${LIBFREETYPE2_INCLUDE_DIRS}/libserialport.h") - # generate shared library - # TODO: do I really need the freetype header files here? I add its include dir below... - # add_library(${PLUGIN_NAME} SHARED ${SOURCES} ${HEADER_FILES} ${LIBFREETYPE2_HEADER_FILES}) - # install into the open ephy plugins directory get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) SET(CMAKE_INSTALL_PREFIX @@ -238,12 +238,12 @@ elseif(LINUX) set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg -fPIC -rdynamic") set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} -L/usr/local/include") # is this really needed? - # STRONGLY consider removing fvisibility call... it's what lead to the keypress issue + # STRONGLY consider removing fvisibility call... # https://github.com/open-ephys/plugin-GUI/issues/89 set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -fvisibility=hidden") ## - ## TODO: there's a more robust way to link libs using add_libra() w/SHARED, but + ## TODO LATER: there's a more robust way to link libs using add_library() w/SHARED, but ## we'll do that later if there's time / a need ## @@ -272,14 +272,16 @@ elseif(LINUX) target_link_libraries(${PLUGIN_NAME} ${LIBFREETYPE2_LIBRARIES}) endif() - # TODO: run makefiles in subdirs of COMMON_DIR - # TODO: figure out how to link against these... - # previously, it was by doing this: # $(COMMONDIRS): OUTDIR := $(BINDIR) - # $(COMMONDIRS): LIB_PREFIX := lib - # ... causes these common libs to put output into build dir... which gets - # picked up thanks to link_directories(${CMAKE_CURRENT_BINARY_DIR})... i think - # COMMONDIRS := $(wildcard $(COMMON_DIR)/*) - # libs: $(COMMONDIRS) + # rpath stuff + # see: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling + set(CMAKE_SKIP_BUILD_RPATH FALSE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") # TODO: can I delete this as long as I have the line below? + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${PYTHON_LIB_DIR}" isSystemDir) + if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") + endif() elseif(WIN32) # TODO: this is surely broken... fix it (if you ever need to) From 569024572ecd67b634201881e7090b3b92f2d551 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 04:39:25 -0500 Subject: [PATCH 04/19] =?UTF-8?q?can=E2=80=99t=20do=20these=20until=20you?= =?UTF-8?q?=20define=20the=20target?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ea866d..d5aa595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,6 @@ message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) message(STATUS "Python library: " ${PYTHON_LIBRARIES}) message(STATUS "Python lib dir: " ${PYTHON_LIB_DIR}) message(STATUS "Python include dir: " ${PYTHON_INCLUDE_DIRS}) -target_include_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) -target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) # we need to know where the open ephys source is set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") @@ -86,6 +84,7 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") # link libraries # target_link_libraries(${PLUGIN_NAME} pthread) +target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) # preprocessor definitions add_definitions(-DOEPLUGIN) @@ -104,6 +103,8 @@ target_include_directories(${PLUGIN_NAME} PUBLIC ${OPEN_EPHYS_DIR}/Source/Plugins/Headers ) +target_include_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) + # platform specific stuff if(APPLE) # macros for working with apple stuff From 83529926ee07a00ae9caf776e60fe12f94b2c05f Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 04:39:48 -0500 Subject: [PATCH 05/19] slightly more helpful message --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5aa595..c49b6b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ message(STATUS "Python include dir: " ${PYTHON_INCLUDE_DIRS}) set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) if(NOT OPEN_EPHYS_DIR) - message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please call ccmake or use -DOPEN_EPHYS_DIR.") + message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please set using ccmake or use -DOPEN_EPHYS_DIR.") return() else() get_filename_component(OPEN_EPHYS_DIR ${OPEN_EPHYS_DIR} ABSOLUTE) @@ -117,7 +117,7 @@ if(APPLE) set(MAC_PACKAGE_DIR "/usr/local" CACHE PATH "Where do you install custom libs on this mac?") string(STRIP "${MAC_PACKAGE_DIR}" MAC_PACKAGE_DIR) if(NOT MAC_PACKAGE_DIR) - message(FATAL_ERROR, "MAC_PACKAGE_DIR not specified... please call ccmake or use -DMAC_PACKAGE_DIR.") + message(FATAL_ERROR, "MAC_PACKAGE_DIR not specified... please set using ccmake or use -DMAC_PACKAGE_DIR.") endif() get_filename_component(MAC_PACKAGE_DIR ${MAC_PACKAGE_DIR} ABSOLUTE) From 4c20874e94d0a7a00ad5cdd1e881036701ffc79c Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 08:33:36 -0500 Subject: [PATCH 06/19] update cmake version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c49b6b5..fc370b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.14) project(PythonPlugin) set(PLUGIN_NAME PythonPlugin) From c47cf7ca5489deb2f0e21e79dfa0e784c917e635 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 08:34:24 -0500 Subject: [PATCH 07/19] remove dead code and notes --- CMakeLists.txt | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc370b7..84d716f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,12 +67,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_11) -## -## cmake should set these automatically... so I'm just going to set some -## CMAKE_CXX_FLAGS and add defines below -## -# Debug Only: -# Release Only: +# compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") @@ -83,7 +78,6 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") # link libraries -# target_link_libraries(${PLUGIN_NAME} pthread) target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) # preprocessor definitions @@ -174,20 +168,6 @@ if(APPLE) # xcode properties set_xcode_property(${PLUGIN_NAME} WRAPPER_EXTENSION bundle) - # # dir for config files - # file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Config) - - # # copy and configure Env.xcconfig - # configure_file(${PROJECT_SOURCE_DIR}/resources/Env.xcconfig.in Config/Env.xcconfig @ONLY) - - # # copy plugin xcconfig files from open ephys - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Base.xcconfig Config COPYONLY) - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Debug.xcconfig Config COPYONLY) - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Release.xcconfig Config COPYONLY) - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin_Debug.xcconfig Config COPYONLY) - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin_Release.xcconfig Config COPYONLY) - # configure_file(${OPEN_EPHYS_DIR}/Builds/MacOSX/Plugins/Config/Plugin.xcconfig Config COPYONLY) - elseif(LINUX) if(TARGET_ARCH) # (this disables dependency generation if multiple architectures are set) @@ -292,8 +272,8 @@ elseif(WIN32) ) set(DEFAULT_COMPILE_FLAGS ${WIN32_COMPILE_FLAGS}) - target_link_libraries(${PLUGIN_NAME} debug ${LIBSERIAL_LIBRARIES} "setupapi.lib" ) - target_link_libraries(${PLUGIN_NAME} optimized ${LIBSERIAL_LIBRARIES} "setupapi.lib") + # target_link_libraries(${PLUGIN_NAME} debug ${LIBSERIAL_LIBRARIES} "setupapi.lib" ) + # target_link_libraries(${PLUGIN_NAME} optimized ${LIBSERIAL_LIBRARIES} "setupapi.lib") else() # maybe non-apple unix message(FATAL_ERROR, "Build Platform Not Recognized: Aborting...") From 3121ed752145fb87e29c7dec3c2e24b9e135bcf1 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 08:35:17 -0500 Subject: [PATCH 08/19] fix python linking for mac (and maybe linux) --- CMakeLists.txt | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84d716f..7effc84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,26 +79,26 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") # link libraries target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) +target_link_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) # preprocessor definitions add_definitions(-DOEPLUGIN) add_definitions(-DJUCE_APP_VERSION=0.4.2) add_definitions(-DJUCE_APP_VERSION_HEX=0x402) - -# include directories for the plugin -target_include_directories(${PLUGIN_NAME} PUBLIC - $ - # $ - ) - -target_include_directories(${PLUGIN_NAME} PUBLIC - ${OPEN_EPHYS_DIR}/JuceLibraryCode - ${OPEN_EPHYS_DIR}/JuceLibraryCode/modules - ${OPEN_EPHYS_DIR}/Source/Plugins/Headers +add_definitions(-DJUCE_APP_VERSION_HEX=0x402) +add_definitions(-DPYTHON_HOME="${PYTHON_HOME}") + +# include directories +target_include_directories(${PLUGIN_NAME} + PUBLIC + $ + $ + ${OPEN_EPHYS_DIR}/JuceLibraryCode + ${OPEN_EPHYS_DIR}/JuceLibraryCode/modules + ${OPEN_EPHYS_DIR}/Source/Plugins/Headers + ${PYTHON_INCLUDE_DIRS} ) -target_include_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) - # platform specific stuff if(APPLE) # macros for working with apple stuff @@ -116,28 +116,27 @@ if(APPLE) get_filename_component(MAC_PACKAGE_DIR ${MAC_PACKAGE_DIR} ABSOLUTE) # install location - # IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - SET(CMAKE_INSTALL_PREFIX - "$ENV{HOME}/Library/Application Support/open-ephys/PlugIns" - CACHE PATH - "Plugin install location. See Open Ephys docs for details." - FORCE) - # ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX + "$ENV{HOME}/Library/Application Support/open-ephys/PlugIns" + CACHE PATH + "Plugin install location. See Open Ephys docs for details." + FORCE) set_xcode_property(${PLUGIN_NAME} INSTALL_PATH ${CMAKE_INSTALL_PREFIX}) set_xcode_property(${PLUGIN_NAME} GCC_INLINES_ARE_PRIVATE_EXTERN NO) # rpath stuff # see: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling - set(CMAKE_MACOSX_RPATH ON) - set(CMAKE_SKIP_BUILD_RPATH FALSE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set_target_properties(${PLUGIN_NAME} PROPERTIES MACOSX_RPATH TRUE) + set_target_properties(${PLUGIN_NAME} PROPERTIES SKIP_BUILD_RPATH FALSE) + set_target_properties(${PLUGIN_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE) + set_target_properties(${PLUGIN_NAME} PROPERTIES INSTALL_RPATH "${PYTHON_LIB_DIR}") + set_target_properties(${PLUGIN_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${PYTHON_LIB_DIR}" isSystemDir) if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") + set_target_properties(${PLUGIN_NAME} PROPERTIES INSTALL_RPATH "${PYTHON_LIB_DIR}") endif() + message("install rpath: " ${CMAKE_INSTALL_RPATH}) # link the IOKit framework target_link_libraries(${PLUGIN_NAME} debug "-framework IOKit") From bb264254e52d8fb4dfdec21a95a4dbb34985bff2 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 08:35:35 -0500 Subject: [PATCH 09/19] install location for win32 build --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7effc84..380bd80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,6 +265,17 @@ elseif(LINUX) elseif(WIN32) # TODO: this is surely broken... fix it (if you ever need to) + # install into the open ephy plugins directory + get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + SET(CMAKE_INSTALL_PREFIX + ${OE_PLUGIN_DIR} + CACHE PATH + "Plugin install location. See Open Ephys docs for details." + FORCE) + + # no 'lib' prefix, please... + SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") + # compile flags set(WIN32_COMPILE_FLAGS "/nologo /Zc:wchar_t /Zc:forScope /GX /GL /GF /GR /GS- /Zi /fp:precise /MP /W4 " From ae5f960adcd1019b67a986432adadf83f0d10751 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 09:49:14 -0500 Subject: [PATCH 10/19] remove quotes around PYTHON_HOME --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 380bd80..bdb77f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ add_definitions(-DOEPLUGIN) add_definitions(-DJUCE_APP_VERSION=0.4.2) add_definitions(-DJUCE_APP_VERSION_HEX=0x402) add_definitions(-DJUCE_APP_VERSION_HEX=0x402) -add_definitions(-DPYTHON_HOME="${PYTHON_HOME}") +add_definitions(-DPYTHON_HOME=${PYTHON_HOME}) # include directories target_include_directories(${PLUGIN_NAME} From 53d0509c3bb6a1c8e00405659809b3c747d547dd Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 09:51:20 -0500 Subject: [PATCH 11/19] pass pythonpath environment variable to plugin --- CMakeLists.txt | 2 ++ PythonPlugin/PythonPlugin.cpp | 64 +++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdb77f7..25d49a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) set(PYTHON_HOME $ENV{CONDA_PREFIX} CACHE PATH "Where is the root of your python installation?") get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} DIRECTORY) +set(PYTHON_PATH $ENV{PYTHONPATH} CACHE PATH "What do you want on your PYTHONPATH?") # TODO: add python_modules + subdirs message(STATUS "Python home: " ${PYTHON_HOME}) message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) message(STATUS "Python library: " ${PYTHON_LIBRARIES}) @@ -87,6 +88,7 @@ add_definitions(-DJUCE_APP_VERSION=0.4.2) add_definitions(-DJUCE_APP_VERSION_HEX=0x402) add_definitions(-DJUCE_APP_VERSION_HEX=0x402) add_definitions(-DPYTHON_HOME=${PYTHON_HOME}) +add_definitions(-DPYTHON_PATH=${PYTHON_PATH}) # include directories target_include_directories(${PLUGIN_NAME} diff --git a/PythonPlugin/PythonPlugin.cpp b/PythonPlugin/PythonPlugin.cpp index 2bd26ed..672ac8d 100644 --- a/PythonPlugin/PythonPlugin.cpp +++ b/PythonPlugin/PythonPlugin.cpp @@ -1,28 +1,28 @@ /* ------------------------------------------------------------------ - + Python Plugin Copyright (C) 2016 FP Battaglia - + based on Open Ephys GUI Copyright (C) 2013, 2015 Open Ephys - + ------------------------------------------------------------------ -v +v This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . - + */ /* ============================================================================== @@ -56,7 +56,7 @@ v #include #include #elif !defined(_WIN32) -#include +#include #endif #endif @@ -159,19 +159,19 @@ void PythonPlugin::process(AudioSampleBuffer& buffer) { lastChan = (uint16)pyEvents->eventId; uint8 ttlData = 1 << lastChan; - + // std::cout << "in Python plugin ts is " << getTimestamp(0) + pyEvents->sampleNum << " and sampleNum is " << // pyEvents->sampleNum << " eventId: " << uint16(pyEvents->eventId) << " ttlData: " << int(ttlData) << std::endl; // FIXME now we set the ts at the first samble in the block TTLEventPtr event = TTLEvent::createTTLEvent(ttlChannel, getTimestamp(0) + pyEvents->sampleNum, &ttlData, sizeof(uint8), lastChan); addEvent(ttlChannel, event, pyEvents->sampleNum); - + PythonEvent *lastEvent = pyEvents; PythonEvent *nextEvent = lastEvent->nextEvent; free((void *)lastEvent); wasTriggered = true; - + // std::cout << "lastChan is " << lastChan << std::endl; while (nextEvent) { lastChan = (uint16)nextEvent->eventId; @@ -185,7 +185,7 @@ void PythonPlugin::process(AudioSampleBuffer& buffer) lastEvent = nextEvent; nextEvent = nextEvent->nextEvent; free((void *)lastEvent); - + wasTriggered = true; } } @@ -200,12 +200,12 @@ void PythonPlugin::handleEvent(const EventChannel* eventInfo, const MidiMessage& double timestamp; int sourceIndex; const void* ptr; - + if (eventInfo->getChannelType() == EventChannel::TTL) { - + TTLEventPtr ttl = TTLEvent::deserializeFromMessage(event, eventInfo); - + eventType = int(ttl->getEventType()); sourceID = int(ttl->getSourceID()); subProcessorIdx = int(ttl->getSubProcessorIdx()); @@ -216,7 +216,7 @@ void PythonPlugin::handleEvent(const EventChannel* eventInfo, const MidiMessage& } else if (eventInfo->getChannelType() == EventChannel::TEXT) { - + TextEventPtr txt = TextEvent::deserializeFromMessage(event, eventInfo); eventType = int(txt->getEventType()); sourceID = int(txt->getSourceID()); @@ -228,7 +228,7 @@ void PythonPlugin::handleEvent(const EventChannel* eventInfo, const MidiMessage& } else if (eventInfo->getChannelType() == EventChannel::TEXT) { - + BinaryEventPtr bi = BinaryEvent::deserializeFromMessage(event, eventInfo); eventType = int(bi->getEventType()); sourceID = int(bi->getSourceID()); @@ -243,7 +243,7 @@ void PythonPlugin::handleEvent(const EventChannel* eventInfo, const MidiMessage& void PythonPlugin::sendEventPlugin(int eventType, int sourceID, int subProcessorIdx, double timestamp, int sourceIndex) { LOG_ENTER("sendEventPlugin"); - + const PythonLock pyLock; (*eventFunction)(eventType, sourceID, subProcessorIdx,timestamp,sourceIndex); } @@ -275,7 +275,7 @@ void PythonPlugin::handleSpike(const SpikeChannel* spikeInfo, const MidiMessage& ParamConfig *getParamConfig(void) this will allow generating the editor GUI TODO void setIntParameter(char *name, int value) set integer parameter void set FloatParameter(char *name, float value) set float parameter - + */ String lastError() @@ -305,7 +305,7 @@ String lastError() void PythonPlugin::setFile(String fullpath) { LOG_ENTER("setFile"); - + filePath = fullpath; if (!plugin.open(filePath)) { @@ -316,16 +316,16 @@ void PythonPlugin::setFile(String fullpath) } String pluginName = File(filePath).getFileName().upToFirstOccurrenceOf(".", false, true); - + #if PY_MAJOR_VERSION>=3 String initPluginName = String("PyInit_"); #else String initPluginName = String("init"); #endif initPluginName.append(pluginName, 200); - + std::cout << "init function is: " << initPluginName << std::endl; - + void *initializer = plugin.getFunction(initPluginName); DEBUG_LOG("initializer: " << initializer); if (!initializer) @@ -486,7 +486,7 @@ void PythonPlugin::setFile(String fullpath) getFloatParamFunction = (getfloatparamfunc_t)cfunc; // now the API should be fully loaded - + const PythonLock pyLock; // initialize the plugin @@ -496,7 +496,6 @@ void PythonPlugin::setFile(String fullpath) DEBUG_LOG("after initplugin"); - (*pluginStartupFunction)(nChans, dataSampleRate, chanEnabled.getRawDataPointer()); // load the parameter configuration @@ -505,10 +504,10 @@ void PythonPlugin::setFile(String fullpath) params = (ParamConfig *)calloc(numPythonParams, sizeof(ParamConfig)); paramsControl = (Component **)calloc(numPythonParams, sizeof(Component *)); - + (*getParamConfigFunction)(params); DEBUG_LOG("release paramconfig"); - + auto ed = static_cast(getEditor()); for(int i = 0; i < numPythonParams; i++) { @@ -582,7 +581,7 @@ void PythonPlugin::channelChanged(int chan, bool state) void PythonPlugin::setIntPythonParameter(String name, int value) { LOG_ENTER("setIntPythonParameter"); - + const PythonLock pyLock; (*setIntParamFunction)(name.getCharPointer().getAddress(), value); } @@ -608,7 +607,7 @@ int PythonPlugin::getIntPythonParameter(String name) float PythonPlugin::getFloatPythonParameter(String name) { LOG_ENTER("getFloatPythonParameter"); - + float value; const PythonLock pyLock; value = (*getFloatParamFunction)(name.getCharPointer().getAddress()); @@ -694,6 +693,13 @@ static PyThreadState* startInterpreter() #ifdef _WIN32 // set PYTHONPATH to avoid error described here: https://stackoverflow.com/questions/5694706/py-initialize-fails-unable-to-load-the-file-system-codec _putenv_s("PYTHONPATH", PYTHON_HOME_NAME "\\DLLs;" PYTHON_HOME_NAME "\\Lib;" PYTHON_HOME_NAME "\\Lib\\site-packages"); +#else + setenv("PYTHONPATH", PYTHON_PATH_NAME, 1); +#endif + +#ifdef PYTHON_DEBUG + std::cout << "PYTHONPATH: " << getenv("PYTHONPATH") << std::endl; + std::cout << "PYTHON VERSION: " << Py_GetVersion() << std::endl; #endif #if PY_MAJOR_VERSION==3 From 4579cb99e53b74ddb6af5fffdf28a3e9c601ada8 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 12:25:56 -0500 Subject: [PATCH 12/19] pass full python path to plugin --- CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25d49a7..f0ff967 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,13 +28,29 @@ find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) set(PYTHON_HOME $ENV{CONDA_PREFIX} CACHE PATH "Where is the root of your python installation?") get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} DIRECTORY) -set(PYTHON_PATH $ENV{PYTHONPATH} CACHE PATH "What do you want on your PYTHONPATH?") # TODO: add python_modules + subdirs message(STATUS "Python home: " ${PYTHON_HOME}) message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) message(STATUS "Python library: " ${PYTHON_LIBRARIES}) message(STATUS "Python lib dir: " ${PYTHON_LIB_DIR}) message(STATUS "Python include dir: " ${PYTHON_INCLUDE_DIRS}) +# extend PYTHONPATH to include python_modules +if(WIN32) + set(PY_PATH_SEP ;) +else() + set(PY_PATH_SEP :) +endif() +# might have to get file(TO_NATIVE_PATH "" ) involved for windows... +set(PLUGIN_MODULES_PATH "${PROJECT_SOURCE_DIR}/python_modules" CACHE PATH "Where are the python modules you want to plug in?") +file(TO_NATIVE_PATH "${PLUGIN_MODULES_PATH}" NATIVE_PLUGIN_MODULES_PATH) + +execute_process(COMMAND python -c "import sys; import os; print(os.pathsep.join(sys.path))" OUTPUT_VARIABLE ORIG_PY_PATH) +string(STRIP "${ORIG_PY_PATH}" ORIG_PY_PATH) + +set(PYTHON_PATH "${ORIG_PY_PATH}${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") +message(STATUS "ORIG PYTHONPATH: " ${ORIG_PY_PATH}) +message(STATUS "PYTHONPATH: " ${PYTHON_PATH}) + # we need to know where the open ephys source is set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) From 2082302ec2b3e6a8a9fb8ff9a0502a366e3c6e26 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 10 May 2019 12:33:39 -0500 Subject: [PATCH 13/19] nevermind... don't pass the whole path --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0ff967..98f2ea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,9 +44,11 @@ endif() set(PLUGIN_MODULES_PATH "${PROJECT_SOURCE_DIR}/python_modules" CACHE PATH "Where are the python modules you want to plug in?") file(TO_NATIVE_PATH "${PLUGIN_MODULES_PATH}" NATIVE_PLUGIN_MODULES_PATH) -execute_process(COMMAND python -c "import sys; import os; print(os.pathsep.join(sys.path))" OUTPUT_VARIABLE ORIG_PY_PATH) -string(STRIP "${ORIG_PY_PATH}" ORIG_PY_PATH) +# TODO: remove if you're sure this is overkill +# execute_process(COMMAND python -c "import sys; import os; print(os.pathsep.join(sys.path))" OUTPUT_VARIABLE ORIG_PY_PATH) +# string(STRIP "${ORIG_PY_PATH}" ORIG_PY_PATH) +# TODO: remove orig_py_path if you remove the bit above set(PYTHON_PATH "${ORIG_PY_PATH}${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") message(STATUS "ORIG PYTHONPATH: " ${ORIG_PY_PATH}) message(STATUS "PYTHONPATH: " ${PYTHON_PATH}) From a57cef3531cc4b11de4607b94eba194679c2c3d3 Mon Sep 17 00:00:00 2001 From: Ben Acland Date: Fri, 14 Jun 2019 09:53:34 -0500 Subject: [PATCH 14/19] reinstate line lost during merge --- PythonPlugin/PythonPlugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/PythonPlugin/PythonPlugin.cpp b/PythonPlugin/PythonPlugin.cpp index 672ac8d..1c6b259 100644 --- a/PythonPlugin/PythonPlugin.cpp +++ b/PythonPlugin/PythonPlugin.cpp @@ -670,6 +670,7 @@ static PyThreadState* startInterpreter() #define QUOTE(name) #name #define STR(macro) QUOTE(macro) #define PYTHON_HOME_NAME STR(PYTHON_HOME) +#define PYTHON_PATH_NAME STR(PYTHON_PATH) #endif char * old_python_home = getenv("PYTHONHOME"); From 926e399aab9c25dd469b83588ea9e0eb6d38baa4 Mon Sep 17 00:00:00 2001 From: Mark Schatza Date: Tue, 5 Nov 2019 12:43:51 -0600 Subject: [PATCH 15/19] Updated cmakelists to follow OE format and work with windows - needs cleaning --- Builds/.gitignore | 2 + Builds/MacOSX/Config/Plugin.xcconfig | 55 --- Builds/MacOSX/Config/Plugin.xcconfig.tmpl | 55 --- Builds/MacOSX/Config/Plugin_Debug.xcconfig | 9 - Builds/MacOSX/Config/Plugin_Release.xcconfig | 7 - Builds/MacOSX/Config/get_depends.sh | 23 - .../PythonPlugin.xcodeproj/project.pbxproj | 436 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - Builds/MacOSX/PythonPlugin/Info.plist | 26 -- CMakeLists.txt | 175 ++++--- PythonPlugin/PythonPlugin.cpp | 4 +- python_modules/test/test.pyx | 2 +- python_modules/yPowerThresh/setup.py | 33 ++ python_modules/yPowerThresh/yPowerThresh.pyx | 147 ++++++ 15 files changed, 297 insertions(+), 692 deletions(-) create mode 100644 Builds/.gitignore delete mode 100644 Builds/MacOSX/Config/Plugin.xcconfig delete mode 100644 Builds/MacOSX/Config/Plugin.xcconfig.tmpl delete mode 100644 Builds/MacOSX/Config/Plugin_Debug.xcconfig delete mode 100644 Builds/MacOSX/Config/Plugin_Release.xcconfig delete mode 100755 Builds/MacOSX/Config/get_depends.sh delete mode 100644 Builds/MacOSX/PythonPlugin.xcodeproj/project.pbxproj delete mode 100644 Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Builds/MacOSX/PythonPlugin/Info.plist create mode 100644 python_modules/yPowerThresh/setup.py create mode 100644 python_modules/yPowerThresh/yPowerThresh.pyx diff --git a/Builds/.gitignore b/Builds/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/Builds/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/Builds/MacOSX/Config/Plugin.xcconfig b/Builds/MacOSX/Config/Plugin.xcconfig deleted file mode 100644 index b567290..0000000 --- a/Builds/MacOSX/Config/Plugin.xcconfig +++ /dev/null @@ -1,55 +0,0 @@ -PYTHON_DIR = /usr/local/anaconda/envs/oeEnv -PYTHON_VERSION = python3.6m - -OPENEPHYS_SOURCE_DIR = $(PROJECT_DIR)/../../../plugin-GUI - -ALWAYS_SEARCH_USER_PATHS = NO -CLANG_CXX_LANGUAGE_STANDARD = c++0x -CLANG_CXX_LIBRARY = libc++ -CLANG_ENABLE_MODULES = NO -CLANG_ENABLE_OBJC_ARC = NO -CLANG_LINK_OBJC_RUNTIME = NO -CLANG_WARN_BOOL_CONVERSION = YES -CLANG_WARN_CONSTANT_CONVERSION = YES -CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR -CLANG_WARN_EMPTY_BODY = YES -CLANG_WARN_ENUM_CONVERSION = YES -CLANG_WARN_INT_CONVERSION = YES -CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR -CLANG_WARN_UNREACHABLE_CODE = YES -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CODE_SIGN_IDENTITY = -COMBINE_HIDPI_IMAGES = YES -CONFIGURATION_BUILD_DIR = $(PROJECT_DIR)/../../build/$(CONFIGURATION)/open-ephys.app/Contents/PlugIns -COPY_PHASE_STRIP = NO -DEBUG_INFORMATION_FORMAT = dwarf -ENABLE_STRICT_OBJC_MSGSEND = YES -GCC_C_LANGUAGE_STANDARD = c99 -GCC_GENERATE_DEBUGGING_SYMBOLS = YES -GCC_INLINES_ARE_PRIVATE_EXTERN = YES -GCC_NO_COMMON_BLOCKS = YES -GCC_OPTIMIZATION_LEVEL = 3 -COMMON_PREPROCESSOR_DEFINITIONS = $(inherited) OEPLUGIN JUCER_XCODE_MAC_F6D2F4CF=1 JUCE_APP_VERSION=0.3.5 JUCE_APP_VERSION_HEX=0x305 PYTHON_HOME=$(PYTHON_DIR) - -GCC_VERSION = com.apple.compilers.llvm.clang.1_0 -GCC_WARN_64_TO_32_BIT_CONVERSION = NO -GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR -GCC_WARN_CHECK_SWITCH_STATEMENTS = YES -GCC_WARN_MISSING_PARENTHESES = YES -GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES -GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES -GCC_WARN_UNDECLARED_SELECTOR = YES -GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE -GCC_WARN_UNUSED_FUNCTION = YES -GCC_WARN_UNUSED_VARIABLE = YES -HEADER_SEARCH_PATHS = $(OPENEPHYS_SOURCE_DIR)/Source/Plugins/Headers $(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode $(PYTHON_DIR)/include/$(PYTHON_VERSION) $(inherited) -LIBRARY_SEARCH_PATHS = $(PYTHON_DIR)/lib -OTHER_LDFLAGS = -l$(PYTHON_VERSION) $(inherited) -undefined dynamic_lookup -LD_RUNPATH_SEARCH_PATHS = $(PYTHON_DIR)/lib -INSTALL_PATH = $(HOME)/Applications/open-ephys.app/Contents/PlugIns - -OTHER_LDFLAGS = $(inherited) -undefined dynamic_lookup -L$(PYTHON_DIR)/lib -SDKROOT = macosx -SKIP_INSTALL = YES -WARNING_CFLAGS = $(inherited) -Wpartial-availability -Wreorder -Wno-inconsistent-missing-override -WRAPPER_EXTENSION = bundle diff --git a/Builds/MacOSX/Config/Plugin.xcconfig.tmpl b/Builds/MacOSX/Config/Plugin.xcconfig.tmpl deleted file mode 100644 index a220ca7..0000000 --- a/Builds/MacOSX/Config/Plugin.xcconfig.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -PYTHON_DIR = #PYTHON_DIR# -PYTHON_VERSION = #PYTHON_VERSION# - -OPENEPHYS_SOURCE_DIR = $(PROJECT_DIR)/../../../plugin-GUI - -ALWAYS_SEARCH_USER_PATHS = NO -CLANG_CXX_LANGUAGE_STANDARD = c++0x -CLANG_CXX_LIBRARY = libc++ -CLANG_ENABLE_MODULES = NO -CLANG_ENABLE_OBJC_ARC = NO -CLANG_LINK_OBJC_RUNTIME = NO -CLANG_WARN_BOOL_CONVERSION = YES -CLANG_WARN_CONSTANT_CONVERSION = YES -CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR -CLANG_WARN_EMPTY_BODY = YES -CLANG_WARN_ENUM_CONVERSION = YES -CLANG_WARN_INT_CONVERSION = YES -CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR -CLANG_WARN_UNREACHABLE_CODE = YES -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CODE_SIGN_IDENTITY = -COMBINE_HIDPI_IMAGES = YES -CONFIGURATION_BUILD_DIR = $(PROJECT_DIR)/../../build/$(CONFIGURATION)/open-ephys.app/Contents/PlugIns -COPY_PHASE_STRIP = NO -DEBUG_INFORMATION_FORMAT = dwarf -ENABLE_STRICT_OBJC_MSGSEND = YES -GCC_C_LANGUAGE_STANDARD = c99 -GCC_GENERATE_DEBUGGING_SYMBOLS = YES -GCC_INLINES_ARE_PRIVATE_EXTERN = YES -GCC_NO_COMMON_BLOCKS = YES -GCC_OPTIMIZATION_LEVEL = 3 -COMMON_PREPROCESSOR_DEFINITIONS = $(inherited) OEPLUGIN JUCER_XCODE_MAC_F6D2F4CF=1 JUCE_APP_VERSION=0.3.5 JUCE_APP_VERSION_HEX=0x305 PYTHON_HOME=$(PYTHON_DIR) - -GCC_VERSION = com.apple.compilers.llvm.clang.1_0 -GCC_WARN_64_TO_32_BIT_CONVERSION = NO -GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR -GCC_WARN_CHECK_SWITCH_STATEMENTS = YES -GCC_WARN_MISSING_PARENTHESES = YES -GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES -GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES -GCC_WARN_UNDECLARED_SELECTOR = YES -GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE -GCC_WARN_UNUSED_FUNCTION = YES -GCC_WARN_UNUSED_VARIABLE = YES -HEADER_SEARCH_PATHS = $(OPENEPHYS_SOURCE_DIR)/Source/Plugins/Headers $(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode $(PYTHON_DIR)/include/$(PYTHON_VERSION) $(inherited) -LIBRARY_SEARCH_PATHS = $(PYTHON_DIR)/lib -OTHER_LDFLAGS = -l$(PYTHON_VERSION) $(inherited) -undefined dynamic_lookup -LD_RUNPATH_SEARCH_PATHS = $(PYTHON_DIR)/lib -INSTALL_PATH = $(HOME)/Applications/open-ephys.app/Contents/PlugIns - -OTHER_LDFLAGS = $(inherited) -undefined dynamic_lookup -L$(PYTHON_DIR)/lib -SDKROOT = macosx -SKIP_INSTALL = YES -WARNING_CFLAGS = $(inherited) -Wpartial-availability -Wreorder -Wno-inconsistent-missing-override -WRAPPER_EXTENSION = bundle diff --git a/Builds/MacOSX/Config/Plugin_Debug.xcconfig b/Builds/MacOSX/Config/Plugin_Debug.xcconfig deleted file mode 100644 index ff72115..0000000 --- a/Builds/MacOSX/Config/Plugin_Debug.xcconfig +++ /dev/null @@ -1,9 +0,0 @@ -#include "Plugin.xcconfig" - -ENABLE_TESTABILITY = YES -GCC_DYNAMIC_NO_PIC = NO -//GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1 _DEBUG=1 -GCC_PREPROCESSOR_DEFINITIONS = $(COMMON_PREPROCESSOR_DEFINITIONS) DEBUG=1 _DEBUG=1 - -MTL_ENABLE_DEBUG_INFO = YES -ONLY_ACTIVE_ARCH = YES diff --git a/Builds/MacOSX/Config/Plugin_Release.xcconfig b/Builds/MacOSX/Config/Plugin_Release.xcconfig deleted file mode 100644 index b82a5f4..0000000 --- a/Builds/MacOSX/Config/Plugin_Release.xcconfig +++ /dev/null @@ -1,7 +0,0 @@ -#include "Plugin.xcconfig" - -DEAD_CODE_STRIPPING = YES -ENABLE_NS_ASSERTIONS = NO -GCC_PREPROCESSOR_DEFINITIONS = $(COMMON_PREPROCESSOR_DEFINITIONS) NDEBUG=1 _NDEBUG=1 -GCC_SYMBOLS_PRIVATE_EXTERN = YES -MTL_ENABLE_DEBUG_INFO = NO diff --git a/Builds/MacOSX/Config/get_depends.sh b/Builds/MacOSX/Config/get_depends.sh deleted file mode 100755 index 7e8a5cb..0000000 --- a/Builds/MacOSX/Config/get_depends.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - - -. ~/.bash_profile -. activate oeEnv - -CONFIG_DIR=${PROJECT_DIR}/Config - -PYTHON_DIR=$(python -c "from distutils import sysconfig; \ -import re; \ -z = sysconfig.get_config_var('prefix'); \ -print(z)") - -PYTHON_VERSION=$(python -c "from distutils import sysconfig; \ -import re; \ -z = sysconfig.get_config_var('BLDLIBRARY'); \ -m = re.search(r'-l(.*)', z); \ -print(m.group(1))") - -echo $PYTHON_DIR -echo $PYTHON_VERSION - -sed -e "s%#PYTHON_DIR#%${PYTHON_DIR}%" -e "s%#PYTHON_VERSION#%${PYTHON_VERSION}%" <${CONFIG_DIR}/Plugin.xcconfig.tmpl >${CONFIG_DIR}/Plugin.xcconfig diff --git a/Builds/MacOSX/PythonPlugin.xcodeproj/project.pbxproj b/Builds/MacOSX/PythonPlugin.xcodeproj/project.pbxproj deleted file mode 100644 index 0ecf21c..0000000 --- a/Builds/MacOSX/PythonPlugin.xcodeproj/project.pbxproj +++ /dev/null @@ -1,436 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - F7804A9121707A2E00401274 /* get_depends.sh in Resources */ = {isa = PBXBuildFile; fileRef = F7804A9021707A2E00401274 /* get_depends.sh */; }; - F7956D431D58C04C00C2EF56 /* OpenEphysLib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7956D421D58C04C00C2EF56 /* OpenEphysLib.cpp */; }; - F7F7D1671D58C55E00DCF6CF /* PythonEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F7D1571D58C55E00DCF6CF /* PythonEditor.cpp */; }; - F7F7D16A1D58C55E00DCF6CF /* PythonPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F7D15F1D58C55E00DCF6CF /* PythonPlugin.cpp */; }; - F7F7D16B1D58C55E00DCF6CF /* PythonSink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F7D1611D58C55E00DCF6CF /* PythonSink.cpp */; }; - F7F7D16C1D58C55E00DCF6CF /* PythonSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F7D1631D58C55E00DCF6CF /* PythonSource.cpp */; }; - F7F7D16E1D58C5D000DCF6CF /* PythonFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F7D16D1D58C5D000DCF6CF /* PythonFilter.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 3CB430A8215819B600F21E3C /* en */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = en; path = en.lproj/PythonPlugin.bundle; sourceTree = ""; }; - 3CB430AA21581E6E00F21E3C /* PythonPlugin.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PythonPlugin.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; - F7804A9021707A2E00401274 /* get_depends.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = get_depends.sh; sourceTree = ""; }; - F7956D381D58BBA100C2EF56 /* Plugin_Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Plugin_Debug.xcconfig; sourceTree = ""; }; - F7956D391D58BBA100C2EF56 /* Plugin_Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Plugin_Release.xcconfig; sourceTree = ""; }; - F7956D3A1D58BBA100C2EF56 /* Plugin.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Plugin.xcconfig; sourceTree = ""; }; - F7956D421D58C04C00C2EF56 /* OpenEphysLib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenEphysLib.cpp; path = ../../PythonPlugin/OpenEphysLib.cpp; sourceTree = SOURCE_ROOT; }; - F7F7D1571D58C55E00DCF6CF /* PythonEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonEditor.cpp; path = ../../PythonPlugin/PythonEditor.cpp; sourceTree = SOURCE_ROOT; }; - F7F7D1581D58C55E00DCF6CF /* PythonEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonEditor.h; path = ../../PythonPlugin/PythonEditor.h; sourceTree = SOURCE_ROOT; }; - F7F7D1591D58C55E00DCF6CF /* PythonEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonEvent.h; path = ../../PythonPlugin/PythonEvent.h; sourceTree = SOURCE_ROOT; }; - F7F7D15D1D58C55E00DCF6CF /* PythonFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonFilter.h; path = ../../PythonPlugin/PythonFilter.h; sourceTree = SOURCE_ROOT; }; - F7F7D15E1D58C55E00DCF6CF /* PythonParamConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonParamConfig.h; path = ../../PythonPlugin/PythonParamConfig.h; sourceTree = SOURCE_ROOT; }; - F7F7D15F1D58C55E00DCF6CF /* PythonPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonPlugin.cpp; path = ../../PythonPlugin/PythonPlugin.cpp; sourceTree = SOURCE_ROOT; }; - F7F7D1601D58C55E00DCF6CF /* PythonPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonPlugin.h; path = ../../PythonPlugin/PythonPlugin.h; sourceTree = SOURCE_ROOT; }; - F7F7D1611D58C55E00DCF6CF /* PythonSink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonSink.cpp; path = ../../PythonPlugin/PythonSink.cpp; sourceTree = SOURCE_ROOT; }; - F7F7D1621D58C55E00DCF6CF /* PythonSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonSink.h; path = ../../PythonPlugin/PythonSink.h; sourceTree = SOURCE_ROOT; }; - F7F7D1631D58C55E00DCF6CF /* PythonSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonSource.cpp; path = ../../PythonPlugin/PythonSource.cpp; sourceTree = SOURCE_ROOT; }; - F7F7D1641D58C55E00DCF6CF /* PythonSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonSource.h; path = ../../PythonPlugin/PythonSource.h; sourceTree = SOURCE_ROOT; }; - F7F7D16D1D58C5D000DCF6CF /* PythonFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonFilter.cpp; path = ../../PythonPlugin/PythonFilter.cpp; sourceTree = SOURCE_ROOT; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - F7956D251D579E1900C2EF56 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - F7956D1D1D579DDF00C2EF56 = { - isa = PBXGroup; - children = ( - F7956D311D58BB2600C2EF56 /* Config */, - F7956D2A1D579E1900C2EF56 /* PythonPlugin */, - F7956D291D579E1900C2EF56 /* Products */, - ); - sourceTree = ""; - }; - F7956D291D579E1900C2EF56 /* Products */ = { - isa = PBXGroup; - children = ( - 3CB430A9215819B600F21E3C /* PythonPlugin.bundle */, - 3CB430AA21581E6E00F21E3C /* PythonPlugin.bundle */, - ); - name = Products; - sourceTree = ""; - }; - F7956D2A1D579E1900C2EF56 /* PythonPlugin */ = { - isa = PBXGroup; - children = ( - F7F7D1571D58C55E00DCF6CF /* PythonEditor.cpp */, - F7F7D1581D58C55E00DCF6CF /* PythonEditor.h */, - F7F7D1591D58C55E00DCF6CF /* PythonEvent.h */, - F7F7D16D1D58C5D000DCF6CF /* PythonFilter.cpp */, - F7F7D15D1D58C55E00DCF6CF /* PythonFilter.h */, - F7F7D15E1D58C55E00DCF6CF /* PythonParamConfig.h */, - F7F7D15F1D58C55E00DCF6CF /* PythonPlugin.cpp */, - F7F7D1601D58C55E00DCF6CF /* PythonPlugin.h */, - F7F7D1611D58C55E00DCF6CF /* PythonSink.cpp */, - F7F7D1621D58C55E00DCF6CF /* PythonSink.h */, - F7F7D1631D58C55E00DCF6CF /* PythonSource.cpp */, - F7F7D1641D58C55E00DCF6CF /* PythonSource.h */, - F7956D421D58C04C00C2EF56 /* OpenEphysLib.cpp */, - ); - path = PythonPlugin; - sourceTree = ""; - }; - F7956D311D58BB2600C2EF56 /* Config */ = { - isa = PBXGroup; - children = ( - F7804A9021707A2E00401274 /* get_depends.sh */, - F7956D381D58BBA100C2EF56 /* Plugin_Debug.xcconfig */, - F7956D391D58BBA100C2EF56 /* Plugin_Release.xcconfig */, - F7956D3A1D58BBA100C2EF56 /* Plugin.xcconfig */, - ); - path = Config; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - F7956D271D579E1900C2EF56 /* PythonPlugin */ = { - isa = PBXNativeTarget; - buildConfigurationList = F7956D2C1D579E1900C2EF56 /* Build configuration list for PBXNativeTarget "PythonPlugin" */; - buildPhases = ( - F76C0DB8216FD73B000197D9 /* ShellScript */, - F7956D241D579E1900C2EF56 /* Sources */, - F7956D251D579E1900C2EF56 /* Frameworks */, - F7956D261D579E1900C2EF56 /* Resources */, - F7F7D16F1D58E44D00DCF6CF /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = PythonPlugin; - productName = PythonPlugin; - productReference = 3CB430AA21581E6E00F21E3C /* PythonPlugin.bundle */; - productType = "com.apple.product-type.bundle"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - F7956D1E1D579DDF00C2EF56 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1020; - TargetAttributes = { - F7956D271D579E1900C2EF56 = { - CreatedOnToolsVersion = 7.3.1; - }; - }; - }; - buildConfigurationList = F7956D211D579DDF00C2EF56 /* Build configuration list for PBXProject "PythonPlugin" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - English, - en, - ); - mainGroup = F7956D1D1D579DDF00C2EF56; - productRefGroup = F7956D291D579E1900C2EF56 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - F7956D271D579E1900C2EF56 /* PythonPlugin */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - F7956D261D579E1900C2EF56 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - F7804A9121707A2E00401274 /* get_depends.sh in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - F76C0DB8216FD73B000197D9 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "${PROJECT_DIR}/Config/get_depends.sh\n"; - }; - F7F7D16F1D58E44D00DCF6CF /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "cp -R ${PROJECT_DIR}/../../build/Debug/open-ephys.app/Contents/PlugIns/PythonPlugin.bundle ${PROJECT_DIR}/../../../plugin-GUI/Builds/MacOSX/build/Debug/open-ephys.app/Contents/PlugIns\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - F7956D241D579E1900C2EF56 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - F7F7D16B1D58C55E00DCF6CF /* PythonSink.cpp in Sources */, - F7F7D16E1D58C5D000DCF6CF /* PythonFilter.cpp in Sources */, - F7F7D16A1D58C55E00DCF6CF /* PythonPlugin.cpp in Sources */, - F7956D431D58C04C00C2EF56 /* OpenEphysLib.cpp in Sources */, - F7F7D16C1D58C55E00DCF6CF /* PythonSource.cpp in Sources */, - F7F7D1671D58C55E00DCF6CF /* PythonEditor.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 3CB430A9215819B600F21E3C /* PythonPlugin.bundle */ = { - isa = PBXVariantGroup; - children = ( - 3CB430A8215819B600F21E3C /* en */, - ); - name = PythonPlugin.bundle; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - F7956D221D579DDF00C2EF56 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F7956D381D58BBA100C2EF56 /* Plugin_Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - LD_RUNPATH_SEARCH_PATHS = ""; - }; - name = Debug; - }; - F7956D231D579DDF00C2EF56 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F7956D391D58BBA100C2EF56 /* Plugin_Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - LD_RUNPATH_SEARCH_PATHS = ""; - }; - name = Release; - }; - F7956D2D1D579E1900C2EF56 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F7956D381D58BBA100C2EF56 /* Plugin_Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = NO; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = ""; - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "DEBUG=1", - "_DEBUG=1", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode/modules/**", - "(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode", - "$(OPENEPHYS_SOURCE_DIR)/Source/Plugins/Headers/**", - ); - INFOPLIST_FILE = PythonPlugin/Info.plist; - INSTALL_PATH = "$(HOME)/Applications/open-ephys.app/Contents/PlugIns"; - LIBRARY_SEARCH_PATHS = ""; - MACOSX_DEPLOYMENT_TARGET = 10.12; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - OTHER_LDFLAGS = ( - "$(inherited)", - "-bundle", - "-undefined", - dynamic_lookup, - ); - PRODUCT_BUNDLE_IDENTIFIER = nl.battaglia.PythonPlugin; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - WARNING_CFLAGS = ( - "-Wreorder", - "-Wpartial-availability", - "-Wno-inconsistent-missing-override", - ); - WRAPPER_EXTENSION = bundle; - }; - name = Debug; - }; - F7956D2E1D579E1900C2EF56 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F7956D391D58BBA100C2EF56 /* Plugin_Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = NO; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = ""; - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - "DEAD_CODE_STRIPPING[arch=*]" = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "_NDEBUG=1", - "NDEBUG=1", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode/modules/**", - "(OPENEPHYS_SOURCE_DIR)/JuceLibraryCode", - "$(OPENEPHYS_SOURCE_DIR)/Source/Plugins/Headers/**", - ); - INFOPLIST_FILE = PythonPlugin/Info.plist; - INSTALL_PATH = "$(HOME)/Applications/open-ephys.app/Contents/PlugIns"; - LIBRARY_SEARCH_PATHS = ""; - MACOSX_DEPLOYMENT_TARGET = 10.12; - MTL_ENABLE_DEBUG_INFO = NO; - OTHER_LDFLAGS = ( - "$(inherited)", - "-bundle", - "-undefined", - dynamic_lookup, - ); - PRODUCT_BUNDLE_IDENTIFIER = nl.battaglia.PythonPlugin; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - WARNING_CFLAGS = ( - "-Wreorder", - "-Wpartial-availability", - "-Wno-inconsistent-missing-override", - ); - WRAPPER_EXTENSION = bundle; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - F7956D211D579DDF00C2EF56 /* Build configuration list for PBXProject "PythonPlugin" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F7956D221D579DDF00C2EF56 /* Debug */, - F7956D231D579DDF00C2EF56 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - F7956D2C1D579E1900C2EF56 /* Build configuration list for PBXNativeTarget "PythonPlugin" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F7956D2D1D579E1900C2EF56 /* Debug */, - F7956D2E1D579E1900C2EF56 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = F7956D1E1D579DDF00C2EF56 /* Project object */; -} diff --git a/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index d2518b3..0000000 --- a/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Builds/MacOSX/PythonPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Builds/MacOSX/PythonPlugin/Info.plist b/Builds/MacOSX/PythonPlugin/Info.plist deleted file mode 100644 index 95e09f8..0000000 --- a/Builds/MacOSX/PythonPlugin/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - NSPrincipalClass - - - diff --git a/CMakeLists.txt b/CMakeLists.txt index 98f2ea1..984c815 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,49 @@ -cmake_minimum_required(VERSION 3.14) -project(PythonPlugin) - -set(PLUGIN_NAME PythonPlugin) +cmake_minimum_required(VERSION 3.5.0) +# MS: Updated to follow the regular cmake format (11/5/19) +# Needed to change some paths to follow new cmake file structure. If using old GUI build you may need to change them back. Also needs to be tested to make sure the changes didn't break apple/linux building. + +# Get GUI Base Dir +if (NOT DEFINED GUI_BASE_DIR) + if (DEFINED ENV{GUI_BASE_DIR}) + set(GUI_BASE_DIR $ENV{GUI_BASE_DIR}) + else() + set(GUI_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../plugin-GUI) + endif() +endif() -# define LINUX if you're building on linux. -# for now we assume that you're building to run on the build machine -if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) - set(LINUX TRUE) +# Get plugin info +get_filename_component(PROJECT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) +get_filename_component(PLUGIN_NAME ${PROJECT_FOLDER} NAME) +# Set plugin info +project(OE_PLUGIN_${PLUGIN_NAME}) +set(CMAKE_SHARED_LIBRARY_PREFIX "") +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(LINUX 1) + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) + endif() endif() +# Compiler definitions +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS + OEPLUGIN + "$<$:JUCE_API=__declspec(dllimport)>" + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:JUCE_DISABLE_NATIVE_FILECHOOSERS=1> + $<$:DEBUG=1> + $<$:_DEBUG=1> + $<$>:NDEBUG=1> + ) + +# Get source files +set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PythonPlugin) +file(GLOB_RECURSE SRC_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/*.cpp" "${SOURCE_PATH}/*.h") +set(GUI_COMMONLIB_DIR ${GUI_BASE_DIR}/installed_libs) + # set build type to debug by default -if(NOT DEFINED CONFIG) +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() - if(NOT (CMAKE_BUILD_TYPE STREQUAL Debug) OR (CMAKE_BUILD_TYPE STREQUAL Release)) message(FATAL_ERROR, "Unsupported CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE}) endif() @@ -26,7 +56,7 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) # -DPYTHON_HOME find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) -set(PYTHON_HOME $ENV{CONDA_PREFIX} CACHE PATH "Where is the root of your python installation?") +set(PYTHON_HOME $ENV{CONDA_HOME} CACHE PATH "Where is the root of your python installation?") get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} DIRECTORY) message(STATUS "Python home: " ${PYTHON_HOME}) message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) @@ -40,65 +70,51 @@ if(WIN32) else() set(PY_PATH_SEP :) endif() + +# TODO: MS, will test this (also do we need this???) # might have to get file(TO_NATIVE_PATH "" ) involved for windows... set(PLUGIN_MODULES_PATH "${PROJECT_SOURCE_DIR}/python_modules" CACHE PATH "Where are the python modules you want to plug in?") file(TO_NATIVE_PATH "${PLUGIN_MODULES_PATH}" NATIVE_PLUGIN_MODULES_PATH) - -# TODO: remove if you're sure this is overkill -# execute_process(COMMAND python -c "import sys; import os; print(os.pathsep.join(sys.path))" OUTPUT_VARIABLE ORIG_PY_PATH) -# string(STRIP "${ORIG_PY_PATH}" ORIG_PY_PATH) - -# TODO: remove orig_py_path if you remove the bit above -set(PYTHON_PATH "${ORIG_PY_PATH}${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") -message(STATUS "ORIG PYTHONPATH: " ${ORIG_PY_PATH}) +# Need this??? +set(PYTHON_PATH "${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") message(STATUS "PYTHONPATH: " ${PYTHON_PATH}) -# we need to know where the open ephys source is -set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") -string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) -if(NOT OPEN_EPHYS_DIR) - message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please set using ccmake or use -DOPEN_EPHYS_DIR.") - return() -else() - get_filename_component(OPEN_EPHYS_DIR ${OPEN_EPHYS_DIR} ABSOLUTE) - message("Open Ephys Source: " ${OPEN_EPHYS_DIR}) -endif() - # put together path for common plugin libraries -get_filename_component(COMMON_DIR ${OPEN_EPHYS_DIR}/Source/Plugins/CommonLibs ABSOLUTE) +#get_filename_component(COMMON_DIR ${GUI_BASE_DIR}/Source/Plugins/CommonLibs ABSOLUTE) +# MS: Above looks like old GUI file format? +get_filename_component(COMMON_DIR ${GUI_BASE_DIR}/installed_libs ABSOLUTE) message("CommonLibs: " ${COMMON_DIR}) # add project dir to module path so the library finding .cmake files are found list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) -# our headers -file(GLOB PLUGIN_HEADER_FILES "PythonPlugin/*.h") -set(HEADER_FILES "${PLUGIN_HEADER_FILES}") - -# our c and cpp files -file(GLOB PLUGIN_SOURCES "PythonPlugin/*.cpp" "PythonPlugin/*.c") -set(SOURCES "${PLUGIN_SOURCES}") # generate shared library -add_library(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES} ${PLUGIN_HEADER_FILES}) +if (APPLE) + add_library(${PLUGIN_NAME} MODULE ${SRC_FILES}) +else() + add_library(${PLUGIN_NAME} SHARED ${SRC_FILES}) +endif() + set(CMAKE_SHARED_LIBRARY_PREFIX "") -set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) -target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_11) -# compiler flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") -set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") +target_compile_features(${PLUGIN_NAME} PUBLIC cxx_auto_type cxx_generalized_initializers) + +# MS: I believe this can be deleted +# compiler flags +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +#set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") # cross-platform CFLAGS -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") # link libraries target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) -target_link_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) +#target_link_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) # preprocessor definitions add_definitions(-DOEPLUGIN) @@ -109,18 +125,39 @@ add_definitions(-DPYTHON_HOME=${PYTHON_HOME}) add_definitions(-DPYTHON_PATH=${PYTHON_PATH}) # include directories -target_include_directories(${PLUGIN_NAME} - PUBLIC - $ - $ - ${OPEN_EPHYS_DIR}/JuceLibraryCode - ${OPEN_EPHYS_DIR}/JuceLibraryCode/modules - ${OPEN_EPHYS_DIR}/Source/Plugins/Headers - ${PYTHON_INCLUDE_DIRS} - ) +target_include_directories(${PLUGIN_NAME} PUBLIC + ${GUI_BASE_DIR}/JuceLibraryCode + ${GUI_BASE_DIR}/JuceLibraryCode/modules + ${GUI_BASE_DIR}/Plugins/Headers + ${GUI_COMMONLIB_DIR}/include + ${PYTHON_INCLUDE_DIRS}) + +# Check if configuration types are set up by GUI and common libs are installed. +set(GUI_BIN_DIR ${GUI_BASE_DIR}/Build/$) +foreach(config ${CMAKE_CONFIGURATION_TYPES}) + if (NOT EXISTS ${GUI_BASE_DIR}/Build/${config}) + if (EXISTS ${GUI_BASE_DIR}/Build/Release) + # default to release + message(WARNING "${config} ${PLUGIN_NAME} build will link to Release GUI build") + set(GUI_BIN_DIR $,${GUI_BASE_DIR}/Build/Release,${GUI_BIN_DIR}>) + else() + message(WARNING "${config} ${PLUGIN_NAME} build will not be available") + endif() + endif() +endforeach() + +# Check for 64bit compiler +if (NOT CMAKE_LIBRARY_ARCHITECTURE) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_LIBRARY_ARCHITECTURE "x64") + else() + set(CMAKE_LIBRARY_ARCHITECTURE "x86") + endif() +endif() # platform specific stuff if(APPLE) + set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) # macros for working with apple stuff macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} @@ -188,6 +225,7 @@ if(APPLE) set_xcode_property(${PLUGIN_NAME} WRAPPER_EXTENSION bundle) elseif(LINUX) + # MS: Don't know anything about how Linux building is different, but the regular cmake file format is much more condensed. Can probably use it as a baseline. if(TARGET_ARCH) # (this disables dependency generation if multiple architectures are set) list(LENGTH TARGET_ARCH ARCH_COUNT) @@ -209,7 +247,7 @@ elseif(LINUX) file(GLOB LIBFREETYPE2_HEADER_FILES "${LIBFREETYPE2_INCLUDE_DIRS}/libserialport.h") # install into the open ephy plugins directory - get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + get_filename_component(OE_PLUGIN_DIR ${GUI_BASE_DIR}/Builds/Linux/build/plugins ABSOLUTE) SET(CMAKE_INSTALL_PREFIX ${OE_PLUGIN_DIR} CACHE PATH @@ -283,10 +321,10 @@ elseif(LINUX) set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") endif() elseif(WIN32) - # TODO: this is surely broken... fix it (if you ever need to) + # MS: Working! # install into the open ephy plugins directory - get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + get_filename_component(OE_PLUGIN_DIR ${GUI_BASE_DIR}/Build/Plugins ABSOLUTE) SET(CMAKE_INSTALL_PREFIX ${OE_PLUGIN_DIR} CACHE PATH @@ -296,14 +334,25 @@ elseif(WIN32) # no 'lib' prefix, please... SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") + + # TODO: MS, not sure if all of this is needed. Added stuff from generic cmake file. # compile flags set(WIN32_COMPILE_FLAGS "/nologo /Zc:wchar_t /Zc:forScope /GX /GL /GF /GR /GS- /Zi /fp:precise /MP /W4 " ) set(DEFAULT_COMPILE_FLAGS ${WIN32_COMPILE_FLAGS}) - # target_link_libraries(${PLUGIN_NAME} debug ${LIBSERIAL_LIBRARIES} "setupapi.lib" ) - # target_link_libraries(${PLUGIN_NAME} optimized ${LIBSERIAL_LIBRARIES} "setupapi.lib") + target_link_libraries(${PLUGIN_NAME} ${GUI_BIN_DIR}/open-ephys.lib) + target_compile_options(${PLUGIN_NAME} PRIVATE /sdl-) + + install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION ${GUI_BIN_DIR}/plugins) + + # also install dependency DLLs for runtime loading + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/bin/${CMAKE_LIBRARY_ARCHITECTURE}/ + DESTINATION ${GUI_BIN_DIR}/shared OPTIONAL) + + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../libs) + else() # maybe non-apple unix message(FATAL_ERROR, "Build Platform Not Recognized: Aborting...") diff --git a/PythonPlugin/PythonPlugin.cpp b/PythonPlugin/PythonPlugin.cpp index 1c6b259..d30b2be 100644 --- a/PythonPlugin/PythonPlugin.cpp +++ b/PythonPlugin/PythonPlugin.cpp @@ -124,6 +124,7 @@ bool PythonPlugin::isReady() else { const PythonLock pyLock; + if (pluginIsReady && !(*pluginIsReady)()) { CoreServices::sendStatusMessage("Python Plugin is not ready"); @@ -359,7 +360,6 @@ void PythonPlugin::setFile(String fullpath) return; } pluginStartupFunction = (startupfunc_t)cfunc; - std::cout << "loaded pluginStartup \n \n \n \n \n "; cfunc = plugin.getFunction("getParamNum"); if (!cfunc) @@ -488,12 +488,12 @@ void PythonPlugin::setFile(String fullpath) // now the API should be fully loaded const PythonLock pyLock; + // initialize the plugin DEBUG_LOG("before initplugin"); (*initF)(); - DEBUG_LOG("after initplugin"); (*pluginStartupFunction)(nChans, dataSampleRate, chanEnabled.getRawDataPointer()); diff --git a/python_modules/test/test.pyx b/python_modules/test/test.pyx index d15c0d2..3c67764 100644 --- a/python_modules/test/test.pyx +++ b/python_modules/test/test.pyx @@ -3,7 +3,7 @@ import numpy as np cimport numpy as np from cython cimport view -isDebug = False +isDebug = True class test(object): def __init__(self): diff --git a/python_modules/yPowerThresh/setup.py b/python_modules/yPowerThresh/setup.py new file mode 100644 index 0000000..dd6aba9 --- /dev/null +++ b/python_modules/yPowerThresh/setup.py @@ -0,0 +1,33 @@ +from distutils.core import setup, Extension +from Cython.Build import cythonize +import numpy +import runpy + +cfg = runpy.run_path('../.config.py') + +setup( + name="yPowerThresh", + include_dirs=[numpy.get_include(), cfg['PYTHON_PLUGIN_SRC_DIR']], + ext_modules=cythonize( + Extension( + 'yPowerThresh', + sources=["yPowerThresh.pyx"], + export_symbols=[ + 'pluginStartup', + 'pluginisready', + 'getParamNum', + 'getParamConfig', + 'pluginFunction', + 'eventFunction', + 'spikeFunction', + 'setIntParam', + 'setFloatParam', + 'getIntParam', + 'getFloatParam', + 'updateSettings', + 'channelChanged' + ] + ), + language_level=3 + ) +) diff --git a/python_modules/yPowerThresh/yPowerThresh.pyx b/python_modules/yPowerThresh/yPowerThresh.pyx new file mode 100644 index 0000000..9204959 --- /dev/null +++ b/python_modules/yPowerThresh/yPowerThresh.pyx @@ -0,0 +1,147 @@ +import sys +import numpy as np +cimport numpy as np +from cython cimport view +from scipy.signal import butter, lfilter, hilbert +import pandas as pd + +isDebug = False + +class yPowerThresh(object): + def __init__(self): + """initialize object data""" + self.Enabled = 1 + self.mean = 0 + self.count = 0 + self.std = 0 + self.thresh = 0 + + self.activeChan = 1 + self.freq = 100 + self.prevMax = 0 + + # Wait 100 milliseconds between peaks(remove long lasting peaks counting mulitple times) + self.waitTime = 100 + self.curWait = 101 + self.f = open('C:\\Users\\Ephys\\Desktop\\buffersize.txt', 'w') + + self.buffer = pd.DataFrame() + + def startup(self, sr): + """to be run upon startup""" + self.fs = sr + self.prelimLen = 1 * 10 + self.peaks = np.zeros(3) + # Keep track of how long we've been creating our threshold + self.threshTime = 0 + def plugin_name(self): + """tells OE the name of the program""" + return "yPowerThresh" + def is_ready(self): + """tells OE everything ran smoothly""" + self.peaks = np.zeros(3) + # Keep track of how long we've been creating our threshold + self.threshTime = 0 + self.sampPerRev = self.fs / self.freq + + return self.Enabled + def param_config(self): + """return button, sliders, etc to be present in the editor OE side""" + chanLabels = range(1, 33) + freqIn = [8,20,40,80,100] + #channel = {"int_set", "Active Channel", chanLabels} + #self.activeChan = 0 # Create dropdown from activeChans? + return [("int_set", "activeChan", chanLabels),("int_set", "freq", freqIn)] + + def update_settings(self, nchans, srate): + """handle changing number of channels and sample rates""" + self.samplingRate = srate + + old_nchans = len(self.chan_enabled) + if old_nchans > nchans: + del self.chan_enabled[nchans:] + elif len(self.chan_enabled) < nchans: + self.chan_enabled.extend([True] * (nchans - old_nchans)) + + def channel_changed(self, chan, state): + """do something when channels are turned on or off in PARAMS tab""" + self.chan_enabled[chan] = state + + def bufferfunction(self, n_arr): + """Access to voltage data buffer. Returns events""" + events = [] + # Change from human readable to software channel + chanIn = self.activeChan - 1 + + # If still buidling threshold + if self.threshTime < self.prelimLen: + nSamp = len(n_arr[chanIn][:]) + wave = pd.DataFrame(n_arr[chanIn][:]) + self.threshTime += nSamp / self.fs + + # At least one full revolution in buffer + if nSamp > self.sampPerRev: + self.handlePeak(wave.max()[0]) + + # Fill a buffer until at least 1 full revolution + elif nSamp < self.sampPerRev: + self.f.write('filling' + '\n') + self.buffer = self.buffer.append(wave, ignore_index = True) + if self.buffer.size > self.sampPerRev: + self.f.write(self.buffer + '\n') + self.handlePeak(self.buffer.max()[0]) + self.buffer = pd.DataFrame() # Create empty dataframe to append data to + + # Output threshold to selected channel + else: + if self.f.closed==False: + self.f.close() + for i in range(len(n_arr[chanIn][:])): + n_arr[chanIn][i] = self.peaks[-1] + + return events + def handleEvents(self,eventType,sourceID,subProcessorIdx,timestamp,sourceIndex): + """handle events passed from OE""" + def handleSpike(self, electrode, sortedID, n_arr): + """handle spikes passed from OE""" + def handlePeak(self, max): + """handles peaks when creating threshold""" + # If a max was found last buffer, check if this buffer's max is larger and only save one + # Prevents a rising slope of the end of one buffer being counted a second time when it reaches its peak at the start of the next buffer + if self.prevMax != 0: + if max > self.prevMax: + newMax = max + else: + newMax = self.prevMax + self.prevMax = 0 + self.f.write(str(newMax) + '\n') + for i in range(len(self.peaks)): # Loop through peaks so we can insert the new peak into the correct place (Makes it sorted) + if newMax >= self.peaks[i]: + self.peaks = np.concatenate((self.peaks[:i], [newMax], self.peaks[i:])) # INSERT our new peak in its correct spot. + self.peaks = self.peaks[:-1].copy() # Remove the last (now unwanted peak), because everything was shifted when new peak was added + break + self.prevMax = 0 # Reset prevMax so we dont keep adding the same peak + # If a max is found wait until next buffer to make sure it's the peak of the wave + elif max > self.peaks[-1]: + self.prevMax = max + + +pluginOp = yPowerThresh() + +include '../plugin.pyx' + +''' +if self.curWait > self.waitTime: + wave = pd.DataFrame(n_arr[chanIn][:]) + max = wave.max() + self.f.write(str(n_arr[chanIn][0:29]) + "\n") + if max[0] > self.peaks[-1]: + for i in range(len(self.peaks)): + if max[0] >= self.peaks[i]: + self.peaks = np.concatenate((self.peaks[:i], [max[0]], self.peaks[i:])) + self.peaks = self.peaks[:-1].copy() + self.curWait = 0 + break + else: + self.curWait += len(n_arr[chanIn]) / self.fs * 1000 +''' From a858d2c31fba323058286632017fb35324bdf4bb Mon Sep 17 00:00:00 2001 From: Mark Schatza Date: Wed, 6 Nov 2019 13:02:04 -0600 Subject: [PATCH 16/19] Working windows port. Updated to cmake-gui plugin style folder/building structure. --- Builds/.gitignore | 2 - Builds/Linux/Makefile | 51 ------ PythonPlugin/CMAKE_README.txt | 22 +++ CMakeLists.txt => PythonPlugin/CMakeLists.txt | 22 +-- .../FindLibFreetype2.cmake | 0 .../FindLibZMQ.cmake | 0 PythonPlugin/PythonPlugin | 1 - PythonPlugin/{ => Source}/Info.plist | 0 PythonPlugin/{ => Source}/Makefile | 0 PythonPlugin/{ => Source}/OpenEphysLib.cpp | 0 PythonPlugin/{ => Source}/PythonEditor.cpp | 0 PythonPlugin/{ => Source}/PythonEditor.h | 0 PythonPlugin/{ => Source}/PythonEvent.h | 0 PythonPlugin/{ => Source}/PythonFilter.cpp | 0 PythonPlugin/{ => Source}/PythonFilter.h | 0 PythonPlugin/{ => Source}/PythonParamConfig.h | 0 PythonPlugin/Source/PythonPlugin | 1 + PythonPlugin/{ => Source}/PythonPlugin.cpp | 0 PythonPlugin/{ => Source}/PythonPlugin.h | 0 PythonPlugin/{ => Source}/PythonSink.cpp | 0 PythonPlugin/{ => Source}/PythonSink.h | 0 PythonPlugin/{ => Source}/PythonSource.cpp | 0 PythonPlugin/{ => Source}/PythonSource.h | 0 WindowsPlugin/Python.vcxproj | 172 ------------------ WindowsPlugin/Python.vcxproj.filters | 60 ------ build-linux.sh | 24 --- 26 files changed, 26 insertions(+), 329 deletions(-) delete mode 100644 Builds/.gitignore delete mode 100644 Builds/Linux/Makefile create mode 100644 PythonPlugin/CMAKE_README.txt rename CMakeLists.txt => PythonPlugin/CMakeLists.txt (93%) rename FindLibFreetype2.cmake => PythonPlugin/FindLibFreetype2.cmake (100%) rename FindLibZMQ.cmake => PythonPlugin/FindLibZMQ.cmake (100%) delete mode 120000 PythonPlugin/PythonPlugin rename PythonPlugin/{ => Source}/Info.plist (100%) rename PythonPlugin/{ => Source}/Makefile (100%) rename PythonPlugin/{ => Source}/OpenEphysLib.cpp (100%) rename PythonPlugin/{ => Source}/PythonEditor.cpp (100%) rename PythonPlugin/{ => Source}/PythonEditor.h (100%) rename PythonPlugin/{ => Source}/PythonEvent.h (100%) rename PythonPlugin/{ => Source}/PythonFilter.cpp (100%) rename PythonPlugin/{ => Source}/PythonFilter.h (100%) rename PythonPlugin/{ => Source}/PythonParamConfig.h (100%) create mode 100644 PythonPlugin/Source/PythonPlugin rename PythonPlugin/{ => Source}/PythonPlugin.cpp (100%) rename PythonPlugin/{ => Source}/PythonPlugin.h (100%) rename PythonPlugin/{ => Source}/PythonSink.cpp (100%) rename PythonPlugin/{ => Source}/PythonSink.h (100%) rename PythonPlugin/{ => Source}/PythonSource.cpp (100%) rename PythonPlugin/{ => Source}/PythonSource.h (100%) delete mode 100644 WindowsPlugin/Python.vcxproj delete mode 100644 WindowsPlugin/Python.vcxproj.filters delete mode 100755 build-linux.sh diff --git a/Builds/.gitignore b/Builds/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/Builds/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile deleted file mode 100644 index db75279..0000000 --- a/Builds/Linux/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -PYTHON_HOME := $(CONDA_HOME) -PYTHON_INCDIR := $(CONDA_HOME)/include/python3.5m -PYTHON_LIBDIR := $(CONDA_HOME)/lib -PYTHON_RTLIBDIR := $(PYTHON_LIBDIR) - -LIBNAME := $(notdir $(CURDIR)) -OBJDIR := $(OBJDIR)/$(LIBNAME) -TARGET := $(LIBNAME).so -OS := $(shell uname) - -SRC_DIR := ${shell find ./ -type d -print} -VPATH := $(SOURCE_DIRS) - -SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp)) -OBJ := $(addprefix $(OBJDIR)/,$(notdir $(SRC:.cpp=.o))) - - - -#Extra macros and libraries needed by the plugin -#CXXFLAGS := $(CXXFLAGS) -D "PYTHON_HOME=$(PYTHON_HOME)" -I $(PYTHON_INCDIR) -CXXFLAGS := $(CXXFLAGS) -D "PYTHON_HOME=$(PYTHON_HOME)" -I $(PYTHON_INCDIR) -LDFLAGS := $(LDFLAGS) -lpython3.5m -L$(PYTHON_LIBDIR) -Wl,-rpath=$(PYTHON_RTLIBDIR) - - -BLDCMD := $(CXX) -shared -o $(OUTDIR)/$(TARGET) $(OBJ) $(LDFLAGS) $(RESOURCES) $(TARGET_ARCH) - -VPATH = $(SRC_DIR) - -.PHONY: objdir - -$(OUTDIR)/$(TARGET): objdir $(OBJ) - -@mkdir -p $(BINDIR) - -@mkdir -p $(LIBDIR) - -@mkdir -p $(OUTDIR) - @echo "Building $(TARGET)" - @$(BLDCMD) - -$(OBJDIR)/%.o : %.cpp - @echo "Compiling $<" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - - -objdir: - -@mkdir -p $(OBJDIR) - -clean: - @echo "Cleaning $(LIBNAME)" - -@rm -rf $(OBJDIR) - -@rm -f $(OUTDIR)/$(TARGET) - --include $(OBJ:%.o=%.d) diff --git a/PythonPlugin/CMAKE_README.txt b/PythonPlugin/CMAKE_README.txt new file mode 100644 index 0000000..e748297 --- /dev/null +++ b/PythonPlugin/CMAKE_README.txt @@ -0,0 +1,22 @@ + +To generate build files for your platform run in a command terminal: +cd Build +cmake -G GENERATOR .. + +Valid generators are: +Windows: +"Visual Studio 12 2013 Win64" +"Visual Studio 14 2015 Win64" +"Visual Studio 15 2017 Win64" +Mac: +"Xcode" +Linux: (see note below) +"Unix Makefiles" + +Example: cmake -G "Visual Studio 12 2013 Win64" .. + +For Linux Only: +On linux, Debug and Release options are generated by cmake and must be specified like so: +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. +or +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .. \ No newline at end of file diff --git a/CMakeLists.txt b/PythonPlugin/CMakeLists.txt similarity index 93% rename from CMakeLists.txt rename to PythonPlugin/CMakeLists.txt index 984c815..478812e 100644 --- a/CMakeLists.txt +++ b/PythonPlugin/CMakeLists.txt @@ -7,7 +7,7 @@ if (NOT DEFINED GUI_BASE_DIR) if (DEFINED ENV{GUI_BASE_DIR}) set(GUI_BASE_DIR $ENV{GUI_BASE_DIR}) else() - set(GUI_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../plugin-GUI) + set(GUI_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../plugin-GUI) endif() endif() @@ -36,7 +36,7 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ) # Get source files -set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PythonPlugin) +set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/SOURCE) file(GLOB_RECURSE SRC_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/*.cpp" "${SOURCE_PATH}/*.h") set(GUI_COMMONLIB_DIR ${GUI_BASE_DIR}/installed_libs) @@ -71,14 +71,6 @@ else() set(PY_PATH_SEP :) endif() -# TODO: MS, will test this (also do we need this???) -# might have to get file(TO_NATIVE_PATH "" ) involved for windows... -set(PLUGIN_MODULES_PATH "${PROJECT_SOURCE_DIR}/python_modules" CACHE PATH "Where are the python modules you want to plug in?") -file(TO_NATIVE_PATH "${PLUGIN_MODULES_PATH}" NATIVE_PLUGIN_MODULES_PATH) -# Need this??? -set(PYTHON_PATH "${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") -message(STATUS "PYTHONPATH: " ${PYTHON_PATH}) - # put together path for common plugin libraries #get_filename_component(COMMON_DIR ${GUI_BASE_DIR}/Source/Plugins/CommonLibs ABSOLUTE) # MS: Above looks like old GUI file format? @@ -320,7 +312,7 @@ elseif(LINUX) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") endif() -elseif(WIN32) +elseif(MSVC) # MS: Working! # install into the open ephy plugins directory @@ -334,14 +326,6 @@ elseif(WIN32) # no 'lib' prefix, please... SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") - - # TODO: MS, not sure if all of this is needed. Added stuff from generic cmake file. - # compile flags - set(WIN32_COMPILE_FLAGS - "/nologo /Zc:wchar_t /Zc:forScope /GX /GL /GF /GR /GS- /Zi /fp:precise /MP /W4 " - ) - set(DEFAULT_COMPILE_FLAGS ${WIN32_COMPILE_FLAGS}) - target_link_libraries(${PLUGIN_NAME} ${GUI_BIN_DIR}/open-ephys.lib) target_compile_options(${PLUGIN_NAME} PRIVATE /sdl-) diff --git a/FindLibFreetype2.cmake b/PythonPlugin/FindLibFreetype2.cmake similarity index 100% rename from FindLibFreetype2.cmake rename to PythonPlugin/FindLibFreetype2.cmake diff --git a/FindLibZMQ.cmake b/PythonPlugin/FindLibZMQ.cmake similarity index 100% rename from FindLibZMQ.cmake rename to PythonPlugin/FindLibZMQ.cmake diff --git a/PythonPlugin/PythonPlugin b/PythonPlugin/PythonPlugin deleted file mode 120000 index 4237948..0000000 --- a/PythonPlugin/PythonPlugin +++ /dev/null @@ -1 +0,0 @@ -../../../PythonPlugin/PythonPlugin/ \ No newline at end of file diff --git a/PythonPlugin/Info.plist b/PythonPlugin/Source/Info.plist similarity index 100% rename from PythonPlugin/Info.plist rename to PythonPlugin/Source/Info.plist diff --git a/PythonPlugin/Makefile b/PythonPlugin/Source/Makefile similarity index 100% rename from PythonPlugin/Makefile rename to PythonPlugin/Source/Makefile diff --git a/PythonPlugin/OpenEphysLib.cpp b/PythonPlugin/Source/OpenEphysLib.cpp similarity index 100% rename from PythonPlugin/OpenEphysLib.cpp rename to PythonPlugin/Source/OpenEphysLib.cpp diff --git a/PythonPlugin/PythonEditor.cpp b/PythonPlugin/Source/PythonEditor.cpp similarity index 100% rename from PythonPlugin/PythonEditor.cpp rename to PythonPlugin/Source/PythonEditor.cpp diff --git a/PythonPlugin/PythonEditor.h b/PythonPlugin/Source/PythonEditor.h similarity index 100% rename from PythonPlugin/PythonEditor.h rename to PythonPlugin/Source/PythonEditor.h diff --git a/PythonPlugin/PythonEvent.h b/PythonPlugin/Source/PythonEvent.h similarity index 100% rename from PythonPlugin/PythonEvent.h rename to PythonPlugin/Source/PythonEvent.h diff --git a/PythonPlugin/PythonFilter.cpp b/PythonPlugin/Source/PythonFilter.cpp similarity index 100% rename from PythonPlugin/PythonFilter.cpp rename to PythonPlugin/Source/PythonFilter.cpp diff --git a/PythonPlugin/PythonFilter.h b/PythonPlugin/Source/PythonFilter.h similarity index 100% rename from PythonPlugin/PythonFilter.h rename to PythonPlugin/Source/PythonFilter.h diff --git a/PythonPlugin/PythonParamConfig.h b/PythonPlugin/Source/PythonParamConfig.h similarity index 100% rename from PythonPlugin/PythonParamConfig.h rename to PythonPlugin/Source/PythonParamConfig.h diff --git a/PythonPlugin/Source/PythonPlugin b/PythonPlugin/Source/PythonPlugin new file mode 100644 index 0000000..4237948 --- /dev/null +++ b/PythonPlugin/Source/PythonPlugin @@ -0,0 +1 @@ +../../../PythonPlugin/PythonPlugin/ \ No newline at end of file diff --git a/PythonPlugin/PythonPlugin.cpp b/PythonPlugin/Source/PythonPlugin.cpp similarity index 100% rename from PythonPlugin/PythonPlugin.cpp rename to PythonPlugin/Source/PythonPlugin.cpp diff --git a/PythonPlugin/PythonPlugin.h b/PythonPlugin/Source/PythonPlugin.h similarity index 100% rename from PythonPlugin/PythonPlugin.h rename to PythonPlugin/Source/PythonPlugin.h diff --git a/PythonPlugin/PythonSink.cpp b/PythonPlugin/Source/PythonSink.cpp similarity index 100% rename from PythonPlugin/PythonSink.cpp rename to PythonPlugin/Source/PythonSink.cpp diff --git a/PythonPlugin/PythonSink.h b/PythonPlugin/Source/PythonSink.h similarity index 100% rename from PythonPlugin/PythonSink.h rename to PythonPlugin/Source/PythonSink.h diff --git a/PythonPlugin/PythonSource.cpp b/PythonPlugin/Source/PythonSource.cpp similarity index 100% rename from PythonPlugin/PythonSource.cpp rename to PythonPlugin/Source/PythonSource.cpp diff --git a/PythonPlugin/PythonSource.h b/PythonPlugin/Source/PythonSource.h similarity index 100% rename from PythonPlugin/PythonSource.h rename to PythonPlugin/Source/PythonSource.h diff --git a/WindowsPlugin/Python.vcxproj b/WindowsPlugin/Python.vcxproj deleted file mode 100644 index ec0729c..0000000 --- a/WindowsPlugin/Python.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {03F9F201-3F09-48C1-B4EC-73C5904632F6} - Win32Proj - Python - PythonPlugin - - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - true - v120 - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - DynamicLibrary - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - - - Console - true - true - true - %(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WindowsPlugin/Python.vcxproj.filters b/WindowsPlugin/Python.vcxproj.filters deleted file mode 100644 index bfcf981..0000000 --- a/WindowsPlugin/Python.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/build-linux.sh b/build-linux.sh deleted file mode 100755 index f5da5ff..0000000 --- a/build-linux.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -if hash python 2>/dev/null; then - PYTHON_COMMAND=python -else - PYTHON_COMMAND=python3 -fi - -export CONDA_HOME=$(${PYTHON_COMMAND} -c "from distutils import sysconfig; \ -import re; \ -z = sysconfig.get_config_var('prefix'); \ -print(z)") - -export PYTHON_VERSION=$(${PYTHON_COMMAND} -c "from distutils import sysconfig; \ -import re; \ -z = sysconfig.get_config_var('BLDLIBRARY'); \ -m = re.search(r'-l(.*)', z); \ -print(m.group(1))") - -export CONFIG=Debug -ln -s ../../../PythonPlugin/PythonPlugin/ ../plugin-GUI/Source/Plugins/PythonPlugin -cd ../plugin-GUI/Builds/Linux/ -make -f Makefile.plugins - From 2b96326da8a305789a592c7b175db5f69aa0eba5 Mon Sep 17 00:00:00 2001 From: Mark Schatza Date: Wed, 6 Nov 2019 13:06:49 -0600 Subject: [PATCH 17/19] Remove TNEL files --- python_modules/yPowerThresh/setup.py | 33 ----- python_modules/yPowerThresh/yPowerThresh.pyx | 147 ------------------- 2 files changed, 180 deletions(-) delete mode 100644 python_modules/yPowerThresh/setup.py delete mode 100644 python_modules/yPowerThresh/yPowerThresh.pyx diff --git a/python_modules/yPowerThresh/setup.py b/python_modules/yPowerThresh/setup.py deleted file mode 100644 index dd6aba9..0000000 --- a/python_modules/yPowerThresh/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -from distutils.core import setup, Extension -from Cython.Build import cythonize -import numpy -import runpy - -cfg = runpy.run_path('../.config.py') - -setup( - name="yPowerThresh", - include_dirs=[numpy.get_include(), cfg['PYTHON_PLUGIN_SRC_DIR']], - ext_modules=cythonize( - Extension( - 'yPowerThresh', - sources=["yPowerThresh.pyx"], - export_symbols=[ - 'pluginStartup', - 'pluginisready', - 'getParamNum', - 'getParamConfig', - 'pluginFunction', - 'eventFunction', - 'spikeFunction', - 'setIntParam', - 'setFloatParam', - 'getIntParam', - 'getFloatParam', - 'updateSettings', - 'channelChanged' - ] - ), - language_level=3 - ) -) diff --git a/python_modules/yPowerThresh/yPowerThresh.pyx b/python_modules/yPowerThresh/yPowerThresh.pyx deleted file mode 100644 index 9204959..0000000 --- a/python_modules/yPowerThresh/yPowerThresh.pyx +++ /dev/null @@ -1,147 +0,0 @@ -import sys -import numpy as np -cimport numpy as np -from cython cimport view -from scipy.signal import butter, lfilter, hilbert -import pandas as pd - -isDebug = False - -class yPowerThresh(object): - def __init__(self): - """initialize object data""" - self.Enabled = 1 - self.mean = 0 - self.count = 0 - self.std = 0 - self.thresh = 0 - - self.activeChan = 1 - self.freq = 100 - self.prevMax = 0 - - # Wait 100 milliseconds between peaks(remove long lasting peaks counting mulitple times) - self.waitTime = 100 - self.curWait = 101 - self.f = open('C:\\Users\\Ephys\\Desktop\\buffersize.txt', 'w') - - self.buffer = pd.DataFrame() - - def startup(self, sr): - """to be run upon startup""" - self.fs = sr - self.prelimLen = 1 * 10 - self.peaks = np.zeros(3) - # Keep track of how long we've been creating our threshold - self.threshTime = 0 - def plugin_name(self): - """tells OE the name of the program""" - return "yPowerThresh" - def is_ready(self): - """tells OE everything ran smoothly""" - self.peaks = np.zeros(3) - # Keep track of how long we've been creating our threshold - self.threshTime = 0 - self.sampPerRev = self.fs / self.freq - - return self.Enabled - def param_config(self): - """return button, sliders, etc to be present in the editor OE side""" - chanLabels = range(1, 33) - freqIn = [8,20,40,80,100] - #channel = {"int_set", "Active Channel", chanLabels} - #self.activeChan = 0 # Create dropdown from activeChans? - return [("int_set", "activeChan", chanLabels),("int_set", "freq", freqIn)] - - def update_settings(self, nchans, srate): - """handle changing number of channels and sample rates""" - self.samplingRate = srate - - old_nchans = len(self.chan_enabled) - if old_nchans > nchans: - del self.chan_enabled[nchans:] - elif len(self.chan_enabled) < nchans: - self.chan_enabled.extend([True] * (nchans - old_nchans)) - - def channel_changed(self, chan, state): - """do something when channels are turned on or off in PARAMS tab""" - self.chan_enabled[chan] = state - - def bufferfunction(self, n_arr): - """Access to voltage data buffer. Returns events""" - events = [] - # Change from human readable to software channel - chanIn = self.activeChan - 1 - - # If still buidling threshold - if self.threshTime < self.prelimLen: - nSamp = len(n_arr[chanIn][:]) - wave = pd.DataFrame(n_arr[chanIn][:]) - self.threshTime += nSamp / self.fs - - # At least one full revolution in buffer - if nSamp > self.sampPerRev: - self.handlePeak(wave.max()[0]) - - # Fill a buffer until at least 1 full revolution - elif nSamp < self.sampPerRev: - self.f.write('filling' + '\n') - self.buffer = self.buffer.append(wave, ignore_index = True) - if self.buffer.size > self.sampPerRev: - self.f.write(self.buffer + '\n') - self.handlePeak(self.buffer.max()[0]) - self.buffer = pd.DataFrame() # Create empty dataframe to append data to - - # Output threshold to selected channel - else: - if self.f.closed==False: - self.f.close() - for i in range(len(n_arr[chanIn][:])): - n_arr[chanIn][i] = self.peaks[-1] - - return events - def handleEvents(self,eventType,sourceID,subProcessorIdx,timestamp,sourceIndex): - """handle events passed from OE""" - def handleSpike(self, electrode, sortedID, n_arr): - """handle spikes passed from OE""" - def handlePeak(self, max): - """handles peaks when creating threshold""" - # If a max was found last buffer, check if this buffer's max is larger and only save one - # Prevents a rising slope of the end of one buffer being counted a second time when it reaches its peak at the start of the next buffer - if self.prevMax != 0: - if max > self.prevMax: - newMax = max - else: - newMax = self.prevMax - self.prevMax = 0 - self.f.write(str(newMax) + '\n') - for i in range(len(self.peaks)): # Loop through peaks so we can insert the new peak into the correct place (Makes it sorted) - if newMax >= self.peaks[i]: - self.peaks = np.concatenate((self.peaks[:i], [newMax], self.peaks[i:])) # INSERT our new peak in its correct spot. - self.peaks = self.peaks[:-1].copy() # Remove the last (now unwanted peak), because everything was shifted when new peak was added - break - self.prevMax = 0 # Reset prevMax so we dont keep adding the same peak - # If a max is found wait until next buffer to make sure it's the peak of the wave - elif max > self.peaks[-1]: - self.prevMax = max - - -pluginOp = yPowerThresh() - -include '../plugin.pyx' - -''' -if self.curWait > self.waitTime: - wave = pd.DataFrame(n_arr[chanIn][:]) - max = wave.max() - self.f.write(str(n_arr[chanIn][0:29]) + "\n") - if max[0] > self.peaks[-1]: - for i in range(len(self.peaks)): - if max[0] >= self.peaks[i]: - self.peaks = np.concatenate((self.peaks[:i], [max[0]], self.peaks[i:])) - self.peaks = self.peaks[:-1].copy() - self.curWait = 0 - break - else: - self.curWait += len(n_arr[chanIn]) / self.fs * 1000 -''' From d608130b735a0f49492fa1e4c661dd37febfc400 Mon Sep 17 00:00:00 2001 From: Mark Schatza Date: Mon, 11 Nov 2019 15:11:14 -0600 Subject: [PATCH 18/19] Update config path and add gitignore to python_modules to hide personal folders --- python_modules/.config.py | 2 +- python_modules/.gitignore | 1 + python_modules/test2/test2.pyx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 python_modules/.gitignore diff --git a/python_modules/.config.py b/python_modules/.config.py index 2c7c68a..62fa54e 100644 --- a/python_modules/.config.py +++ b/python_modules/.config.py @@ -1,2 +1,2 @@ # Location of Python Plugin source (absolute or relative to the location of setup.py) -PYTHON_PLUGIN_SRC_DIR = "../../PythonPlugin" +PYTHON_PLUGIN_SRC_DIR = "../../PythonPlugin/Source" diff --git a/python_modules/.gitignore b/python_modules/.gitignore new file mode 100644 index 0000000..bdf7e13 --- /dev/null +++ b/python_modules/.gitignore @@ -0,0 +1 @@ +magnitudeThreshold/ diff --git a/python_modules/test2/test2.pyx b/python_modules/test2/test2.pyx index 106c928..edc9079 100644 --- a/python_modules/test2/test2.pyx +++ b/python_modules/test2/test2.pyx @@ -30,7 +30,7 @@ class test2(object): def param_config(self): """return button, sliders, etc to be present in the editor OE side""" - return [] + return [("toggle", "enabled", True)] def update_settings(self, nchans, srate): """handle changing number of channels and sample rates""" From 1df724357e56927ca6c1b312b492704ff0d4b7ad Mon Sep 17 00:00:00 2001 From: Francesco Battaglia Date: Fri, 15 Nov 2019 15:37:03 -0800 Subject: [PATCH 19/19] fixed Linux compile --- CMakeLists.txt | 178 +++++++++++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98f2ea1..20a058e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,49 @@ -cmake_minimum_required(VERSION 3.14) -project(PythonPlugin) - -set(PLUGIN_NAME PythonPlugin) +cmake_minimum_required(VERSION 3.5.0) +# MS: Updated to follow the regular cmake format (11/5/19) +# Needed to change some paths to follow new cmake file structure. If using old GUI build you may need to change them back. Also needs to be tested to make sure the changes didn't break apple/linux building. + +# Get GUI Base Dir +if (NOT DEFINED GUI_BASE_DIR) + if (DEFINED ENV{GUI_BASE_DIR}) + set(GUI_BASE_DIR $ENV{GUI_BASE_DIR}) + else() + set(GUI_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../plugin-GUI) + endif() +endif() -# define LINUX if you're building on linux. -# for now we assume that you're building to run on the build machine -if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) - set(LINUX TRUE) +# Get plugin info +get_filename_component(PROJECT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) +get_filename_component(PLUGIN_NAME ${PROJECT_FOLDER} NAME) +# Set plugin info +project(OE_PLUGIN_${PLUGIN_NAME}) +set(CMAKE_SHARED_LIBRARY_PREFIX "") +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(LINUX 1) + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) + endif() endif() +# Compiler definitions +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS + OEPLUGIN + "$<$:JUCE_API=__declspec(dllimport)>" + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:JUCE_DISABLE_NATIVE_FILECHOOSERS=1> + $<$:DEBUG=1> + $<$:_DEBUG=1> + $<$>:NDEBUG=1> + ) + +# Get source files +set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Source) +file(GLOB_RECURSE SRC_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/*.cpp" "${SOURCE_PATH}/*.h") +set(GUI_COMMONLIB_DIR ${GUI_BASE_DIR}/installed_libs) + # set build type to debug by default -if(NOT DEFINED CONFIG) +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() - if(NOT (CMAKE_BUILD_TYPE STREQUAL Debug) OR (CMAKE_BUILD_TYPE STREQUAL Release)) message(FATAL_ERROR, "Unsupported CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE}) endif() @@ -26,7 +56,7 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) # -DPYTHON_HOME find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) -set(PYTHON_HOME $ENV{CONDA_PREFIX} CACHE PATH "Where is the root of your python installation?") +set(PYTHON_HOME $ENV{CONDA_HOME} CACHE PATH "Where is the root of your python installation?") get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} DIRECTORY) message(STATUS "Python home: " ${PYTHON_HOME}) message(STATUS "Python executable: " ${PYTHON_EXECUTABLE}) @@ -40,65 +70,43 @@ if(WIN32) else() set(PY_PATH_SEP :) endif() -# might have to get file(TO_NATIVE_PATH "" ) involved for windows... -set(PLUGIN_MODULES_PATH "${PROJECT_SOURCE_DIR}/python_modules" CACHE PATH "Where are the python modules you want to plug in?") -file(TO_NATIVE_PATH "${PLUGIN_MODULES_PATH}" NATIVE_PLUGIN_MODULES_PATH) - -# TODO: remove if you're sure this is overkill -# execute_process(COMMAND python -c "import sys; import os; print(os.pathsep.join(sys.path))" OUTPUT_VARIABLE ORIG_PY_PATH) -# string(STRIP "${ORIG_PY_PATH}" ORIG_PY_PATH) - -# TODO: remove orig_py_path if you remove the bit above -set(PYTHON_PATH "${ORIG_PY_PATH}${PY_PATH_SEP}${NATIVE_PLUGIN_MODULES_PATH}" CACHE PATH "What do you want on your PYTHONPATH?") -message(STATUS "ORIG PYTHONPATH: " ${ORIG_PY_PATH}) -message(STATUS "PYTHONPATH: " ${PYTHON_PATH}) - -# we need to know where the open ephys source is -set(OPEN_EPHYS_DIR "" CACHE PATH "Where is the Open Ephys repo's base directory?") -string(STRIP "${OPEN_EPHYS_DIR}" OPEN_EPHYS_DIR) -if(NOT OPEN_EPHYS_DIR) - message(FATAL_ERROR, "OPEN_EPHYS_DIR not specified... please set using ccmake or use -DOPEN_EPHYS_DIR.") - return() -else() - get_filename_component(OPEN_EPHYS_DIR ${OPEN_EPHYS_DIR} ABSOLUTE) - message("Open Ephys Source: " ${OPEN_EPHYS_DIR}) -endif() # put together path for common plugin libraries -get_filename_component(COMMON_DIR ${OPEN_EPHYS_DIR}/Source/Plugins/CommonLibs ABSOLUTE) +#get_filename_component(COMMON_DIR ${GUI_BASE_DIR}/Source/Plugins/CommonLibs ABSOLUTE) +# MS: Above looks like old GUI file format? +get_filename_component(COMMON_DIR ${GUI_BASE_DIR}/installed_libs ABSOLUTE) message("CommonLibs: " ${COMMON_DIR}) # add project dir to module path so the library finding .cmake files are found list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) -# our headers -file(GLOB PLUGIN_HEADER_FILES "PythonPlugin/*.h") -set(HEADER_FILES "${PLUGIN_HEADER_FILES}") - -# our c and cpp files -file(GLOB PLUGIN_SOURCES "PythonPlugin/*.cpp" "PythonPlugin/*.c") -set(SOURCES "${PLUGIN_SOURCES}") # generate shared library -add_library(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES} ${PLUGIN_HEADER_FILES}) +if (APPLE) + add_library(${PLUGIN_NAME} MODULE ${SRC_FILES}) +else() + add_library(${PLUGIN_NAME} SHARED ${SRC_FILES}) +endif() + set(CMAKE_SHARED_LIBRARY_PREFIX "") -set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) -target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_11) +target_compile_features(${PLUGIN_NAME} PUBLIC cxx_auto_type cxx_generalized_initializers) + +# MS: I believe this can be deleted # compiler flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") -set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +#set(CMAKE_CXX_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1") # cross-platform CFLAGS -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1") +#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG=1") # link libraries target_link_libraries(${PLUGIN_NAME} ${PYTHON_LIBRARIES}) -target_link_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) +#target_link_directories(${PLUGIN_NAME} PUBLIC ${PYTHON_INCLUDE_DIRS}) # preprocessor definitions add_definitions(-DOEPLUGIN) @@ -109,18 +117,39 @@ add_definitions(-DPYTHON_HOME=${PYTHON_HOME}) add_definitions(-DPYTHON_PATH=${PYTHON_PATH}) # include directories -target_include_directories(${PLUGIN_NAME} - PUBLIC - $ - $ - ${OPEN_EPHYS_DIR}/JuceLibraryCode - ${OPEN_EPHYS_DIR}/JuceLibraryCode/modules - ${OPEN_EPHYS_DIR}/Source/Plugins/Headers - ${PYTHON_INCLUDE_DIRS} - ) +target_include_directories(${PLUGIN_NAME} PUBLIC + ${GUI_BASE_DIR}/JuceLibraryCode + ${GUI_BASE_DIR}/JuceLibraryCode/modules + ${GUI_BASE_DIR}/Plugins/Headers + ${GUI_COMMONLIB_DIR}/include + ${PYTHON_INCLUDE_DIRS}) + +# Check if configuration types are set up by GUI and common libs are installed. +set(GUI_BIN_DIR ${GUI_BASE_DIR}/Build/$) +foreach(config ${CMAKE_CONFIGURATION_TYPES}) + if (NOT EXISTS ${GUI_BASE_DIR}/Build/${config}) + if (EXISTS ${GUI_BASE_DIR}/Build/Release) + # default to release + message(WARNING "${config} ${PLUGIN_NAME} build will link to Release GUI build") + set(GUI_BIN_DIR $,${GUI_BASE_DIR}/Build/Release,${GUI_BIN_DIR}>) + else() + message(WARNING "${config} ${PLUGIN_NAME} build will not be available") + endif() + endif() +endforeach() + +# Check for 64bit compiler +if (NOT CMAKE_LIBRARY_ARCHITECTURE) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_LIBRARY_ARCHITECTURE "x64") + else() + set(CMAKE_LIBRARY_ARCHITECTURE "x86") + endif() +endif() # platform specific stuff if(APPLE) + set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) # macros for working with apple stuff macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} @@ -188,6 +217,8 @@ if(APPLE) set_xcode_property(${PLUGIN_NAME} WRAPPER_EXTENSION bundle) elseif(LINUX) + set_target_properties(${PLUGIN_NAME} PROPERTIES LINKER_LANGUAGE CXX) + # MS: Don't know anything about how Linux building is different, but the regular cmake file format is much more condensed. Can probably use it as a baseline. if(TARGET_ARCH) # (this disables dependency generation if multiple architectures are set) list(LENGTH TARGET_ARCH ARCH_COUNT) @@ -209,7 +240,7 @@ elseif(LINUX) file(GLOB LIBFREETYPE2_HEADER_FILES "${LIBFREETYPE2_INCLUDE_DIRS}/libserialport.h") # install into the open ephy plugins directory - get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + get_filename_component(OE_PLUGIN_DIR ${GUI_BASE_DIR}/Build/${CMAKE_BUILD_TYPE}/plugins/ ABSOLUTE) SET(CMAKE_INSTALL_PREFIX ${OE_PLUGIN_DIR} CACHE PATH @@ -282,11 +313,11 @@ elseif(LINUX) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${PYTHON_LIB_DIR}") endif() -elseif(WIN32) - # TODO: this is surely broken... fix it (if you ever need to) +elseif(MSVC) + # MS: Working! # install into the open ephy plugins directory - get_filename_component(OE_PLUGIN_DIR ${OPEN_EPHYS_DIR}/Builds/Linux/build/plugins ABSOLUTE) + get_filename_component(OE_PLUGIN_DIR ${GUI_BASE_DIR}/Build/Plugins ABSOLUTE) SET(CMAKE_INSTALL_PREFIX ${OE_PLUGIN_DIR} CACHE PATH @@ -296,14 +327,17 @@ elseif(WIN32) # no 'lib' prefix, please... SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") - # compile flags - set(WIN32_COMPILE_FLAGS - "/nologo /Zc:wchar_t /Zc:forScope /GX /GL /GF /GR /GS- /Zi /fp:precise /MP /W4 " - ) - set(DEFAULT_COMPILE_FLAGS ${WIN32_COMPILE_FLAGS}) + target_link_libraries(${PLUGIN_NAME} ${GUI_BIN_DIR}/open-ephys.lib) + target_compile_options(${PLUGIN_NAME} PRIVATE /sdl-) + + install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION ${GUI_BIN_DIR}/plugins) + + # also install dependency DLLs for runtime loading + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/bin/${CMAKE_LIBRARY_ARCHITECTURE}/ + DESTINATION ${GUI_BIN_DIR}/shared OPTIONAL) + + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../libs) - # target_link_libraries(${PLUGIN_NAME} debug ${LIBSERIAL_LIBRARIES} "setupapi.lib" ) - # target_link_libraries(${PLUGIN_NAME} optimized ${LIBSERIAL_LIBRARIES} "setupapi.lib") else() # maybe non-apple unix message(FATAL_ERROR, "Build Platform Not Recognized: Aborting...")