-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IT-1228: Refactor repo to use isxcore C++ API (#54)
- Loading branch information
1 parent
999ead9
commit becec97
Showing
29 changed files
with
11,994 additions
and
984 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# secrets | ||
.ideas-github-token | ||
apiTestResults.xml | ||
|
||
# IDE | ||
*.sublime-workspace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "isxcore"] | ||
path = isxcore | ||
url = [email protected]:inscopix/isxcore.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
set(ISX_CMAKE_TOOLS_DIR ${CMAKE_CURRENT_LIST_DIR}/isxcore/tools/cmake) | ||
include(${ISX_CMAKE_TOOLS_DIR}/configure.cmake) | ||
include(${ISX_CMAKE_TOOLS_DIR}/core.cmake) | ||
|
||
# | ||
# Public API | ||
# | ||
set(TARGET_NAME_PUBLIC_API "isxpublicapi") | ||
set(PUBLIC_API_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/isxcore/wrapper/src) | ||
set(PUBLIC_API_API_DIR ${CMAKE_CURRENT_LIST_DIR}/isxcore/wrapper/api) | ||
set(PUBLIC_API_SRCS ${PUBLIC_API_SRC_DIR}/isxCoreC.cpp ${PUBLIC_API_SRC_DIR}/isxUtilsC.cpp) | ||
set(PUBLIC_API_HDRS ${PUBLIC_API_SRC_DIR}/isxUtilsC.h) | ||
set(PUBLIC_API_API_HDRS ${PUBLIC_API_API_DIR}/isxCoreC.h) | ||
|
||
add_library(${TARGET_NAME_PUBLIC_API} SHARED ${PUBLIC_API_SRCS} ${PUBLIC_API_HDRS} ${PUBLIC_API_API_HDRS}) | ||
|
||
target_include_directories(${TARGET_NAME_PUBLIC_API} PUBLIC ${PUBLIC_API_API_DIR}) | ||
target_include_directories(${TARGET_NAME_PUBLIC_API} PRIVATE | ||
${CORE_API_DIR} | ||
${OPENCV_HEADER_SEARCH_PATHS} | ||
${JSON_HEADER_SEARCH_PATHS}) | ||
|
||
set(API_DEST_DIR ${CMAKE_BINARY_DIR}/../bin) | ||
set(PYTHON_API_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||
set(APP_LIB_DIR ${API_DEST_DIR}/isx/lib) | ||
|
||
if (${ISX_OS_MACOS}) | ||
set(QT_CORE_SHARED_LIB_FILES ${QT_DIR}/lib/QtCore.framework/Versions/5/QtCore) | ||
installFiles(${TARGET_NAME_PUBLIC_API} ${APP_LIB_DIR}/QtCore.framework/Versions/5 "${QT_CORE_SHARED_LIB_FILES}") | ||
elseif (${ISX_OS_LINUX}) | ||
set(QT_CORE_SHARED_LIB_FILES | ||
${QT_DIR}/lib/libQt5Core.so.5 | ||
${QT_DIR}/lib/libicui18n.so.56 | ||
${QT_DIR}/lib/libicuuc.so.56 | ||
${QT_DIR}/lib/libicudata.so.56 | ||
) | ||
installFiles(${TARGET_NAME_PUBLIC_API} ${APP_LIB_DIR} "${QT_CORE_SHARED_LIB_FILES}") | ||
elseif (${ISX_OS_WIN32}) | ||
set(QT_CORE_SHARED_LIB_FILES | ||
${QT_DIR}/bin/Qt5Core.dll | ||
) | ||
installFiles(${TARGET_NAME_PUBLIC_API} ${APP_LIB_DIR} "${QT_CORE_SHARED_LIB_FILES}") | ||
endif() | ||
|
||
installFfmpegSharedLibs(${TARGET_NAME_PUBLIC_API} ${APP_LIB_DIR}) | ||
|
||
set_target_properties(${TARGET_NAME_PUBLIC_API} PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${APP_LIB_DIR} | ||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${APP_LIB_DIR} | ||
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${APP_LIB_DIR} | ||
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${APP_LIB_DIR} | ||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${APP_LIB_DIR} | ||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${APP_LIB_DIR} | ||
) | ||
setCommonCxxOptionsForTarget(${TARGET_NAME_PUBLIC_API}) | ||
setOsDefinesForTarget(${TARGET_NAME_PUBLIC_API}) | ||
disableVisualStudioWarnings(${TARGET_NAME_PUBLIC_API}) | ||
|
||
# OS-specific properties for shared lib | ||
# mac: change output lib name to *.so (default *.dylib) | ||
# mac & linux: set rpath | ||
if(${ISX_OS_MACOS}) | ||
string(APPEND SO_NAME_PUBLIC_API ${TARGET_NAME_PUBLIC_API} ".so") | ||
|
||
set_target_properties(${TARGET_NAME_PUBLIC_API} PROPERTIES | ||
PREFIX "lib" | ||
OUTPUT_NAME ${SO_NAME_PUBLIC_API} | ||
SUFFIX "" | ||
#SOVERSION "1.0.0.0" | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
INSTALL_RPATH "@loader_path" | ||
) | ||
elseif(${ISX_OS_LINUX}) | ||
set_target_properties(${TARGET_NAME_PUBLIC_API} PROPERTIES | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
INSTALL_RPATH "$ORIGIN/" | ||
# Interposition of symbols from static libraries in MATLAB was causing | ||
# major problems, so we only export a few select symbols now. | ||
# We may want to do the same for macOS, which also exposes these | ||
# symbols (but hasn't caused a problem yet). | ||
LINK_FLAGS "-Wl,--version-script=${PUBLIC_API_API_DIR}/export_map" | ||
) | ||
endif() | ||
|
||
target_link_libraries(${TARGET_NAME_PUBLIC_API} PRIVATE | ||
${TARGET_NAME_CORE} | ||
${QT_CORE_LINK_LIBRARIES} | ||
) | ||
|
||
# Deploy Python files | ||
set(PYTHON_API_DEST_DIR ${API_DEST_DIR}/isx) | ||
file(COPY ${PYTHON_API_SRC_DIR}/isx/ DESTINATION ${PYTHON_API_DEST_DIR}) | ||
file(COPY ${PYTHON_API_SRC_DIR}/setup.py DESTINATION ${API_DEST_DIR}) | ||
file(COPY ${PYTHON_API_SRC_DIR}/MANIFEST.in DESTINATION ${API_DEST_DIR}) | ||
file(COPY ${PYTHON_API_SRC_DIR}/README.md DESTINATION ${API_DEST_DIR}) | ||
file(COPY ${PYTHON_API_SRC_DIR}/LICENSE.txt DESTINATION ${API_DEST_DIR}) | ||
file(COPY ${PYTHON_API_SRC_DIR}/isx/test DESTINATION ${API_DEST_DIR}/../) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
recursive-include isx/lib * | ||
include README.md | ||
include LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,113 @@ | ||
repo=$(shell basename $(CURDIR)) | ||
.PHONY: build test | ||
|
||
.PHONY: test coverage-report jupyter | ||
BUILD_DIR_ROOT=build | ||
BUILD_DIR_MODULES=modules | ||
BUILD_TYPE=Release | ||
BUILD_DIR_CMAKE=cmake | ||
BUILD_DIR_BIN=bin | ||
BUILD_PATH=$(BUILD_DIR_ROOT)/$(BUILD_TYPE)/$(BUILD_DIR_CMAKE) | ||
BUILD_PATH_BIN=$(BUILD_DIR_ROOT)/$(BUILD_TYPE)/$(BUILD_DIR_BIN) | ||
|
||
jupyter: | ||
@echo "Installing kernel $(repo) in jupyter" | ||
-yes | jupyter kernelspec uninstall $(repo) | ||
poetry run python -m ipykernel install --user --name $(repo) | ||
API_TEST_RESULTS_PATH=$(PWD)/apiTestResults.xml | ||
PYTHON_TEST_DIR=$(BUILD_DIR_ROOT)/$(BUILD_TYPE)/bin/isx | ||
|
||
ifndef TEST_DATA_DIR | ||
TEST_DATA_DIR=test_data | ||
endif | ||
|
||
install-poetry: | ||
@bash install-poetry.sh | ||
ifndef THIRD_PARTY_DIR | ||
THIRD_PARTY_DIR=third_party | ||
endif | ||
|
||
install: install-poetry | ||
@echo "Installing py_isx..." | ||
poetry check --lock || poetry lock | ||
poetry install --verbose | ||
PYTHON_VERSION=$(shell python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') | ||
|
||
install-test: install-poetry | ||
@echo "Installing py_isx & dependencies for testing..." | ||
poetry check --lock || poetry lock | ||
poetry install --extras "test" --verbose | ||
ifeq ($(OS), Windows_NT) | ||
DETECTED_OS = windows | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S), Linux) | ||
DETECTED_OS = linux | ||
else ifeq ($(UNAME_S), Darwin) | ||
DETECTED_OS = mac | ||
|
||
ifeq ($(PYTHON_VERSION), 3.9) | ||
_MACOSX_DEPLOYMENT_TARGET=10.11 | ||
else ifeq ($(PYTHON_VERSION), 3.10) | ||
_MACOSX_DEPLOYMENT_TARGET=10.11 | ||
else ifeq ($(PYTHON_VERSION), 3.11) | ||
_MACOSX_DEPLOYMENT_TARGET=10.11 | ||
else ifeq ($(PYTHON_VERSION), 3.12) | ||
_MACOSX_DEPLOYMENT_TARGET=10.15 | ||
endif | ||
endif | ||
endif | ||
|
||
test: install-test | ||
poetry run pytest -sx --failed-first | ||
VERSION_MAJOR=2 | ||
VERSION_MINOR=0 | ||
VERSION_PATCH=0 | ||
VERSION_BUILD=0 | ||
IS_BETA=1 | ||
WITH_CUDA=0 | ||
ASYNC_API=1 | ||
WITH_ALGOS=0 | ||
|
||
test-pip: | ||
@echo "Testing code installed on base env using pip..." | ||
pytest -s | ||
CMAKE_OPTIONS=\ | ||
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)\ | ||
-DISX_VERSION_MAJOR=${VERSION_MAJOR}\ | ||
-DISX_VERSION_MINOR=${VERSION_MINOR}\ | ||
-DISX_VERSION_PATCH=${VERSION_PATCH}\ | ||
-DISX_VERSION_BUILD=${VERSION_BUILD}\ | ||
-DISX_IS_BETA=${IS_BETA}\ | ||
-DISX_WITH_CUDA=${WITH_CUDA}\ | ||
-DISX_ASYNC_API=${ASYNC_API} \ | ||
-DISX_WITH_ALGOS=${WITH_ALGOS} \ | ||
|
||
ifeq ($(DETECTED_OS), windows) | ||
CMAKE_GENERATOR = Visual Studio 14 2015 Win64 | ||
else ifeq ($(DETECTED_OS), linux) | ||
CMAKE_GENERATOR = Unix Makefiles | ||
CMAKE_OPTIONS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ | ||
else ifeq ($(DETECTED_OS), mac) | ||
CMAKE_GENERATOR = Xcode | ||
endif | ||
|
||
serve: install-poetry | ||
@echo "Serving docs locally..." | ||
poetry run mkdocs serve | ||
check_os: | ||
@echo "Verifying detected OS" | ||
ifndef DETECTED_OS | ||
@echo "Failed to detect supported OS"; exit 1 | ||
else | ||
@echo "Detected OS: ${DETECTED_OS}" | ||
endif | ||
ifeq ($(DETECTED_OS), mac) | ||
@echo "Detected python version: ${PYTHON_VERSION}, using mac osx deployment target: ${MACOSX_DEPLOYMENT_TARGET}" | ||
endif | ||
|
||
setup.py: pyproject.toml README.md | ||
poetry run poetry2setup > setup.py | ||
clean: | ||
@rm -rf build | ||
|
||
ifeq ($(DETECTED_OS), mac) | ||
build: export MACOSX_DEPLOYMENT_TARGET=${_MACOSX_DEPLOYMENT_TARGET} | ||
endif | ||
build: check_os | ||
mkdir -p $(BUILD_PATH) && \ | ||
cd $(BUILD_PATH) && \ | ||
THIRD_PARTY_DIR=$(THIRD_PARTY_DIR) cmake $(CMAKE_OPTIONS) -G "$(CMAKE_GENERATOR)" ../../../ | ||
ifeq ($(DETECTED_OS), windows) | ||
cd $(BUILD_PATH) && \ | ||
"/c/Program Files (x86)/MSBuild/14.0/Bin/MSBuild.exe" Project.sln //p:Configuration=$(BUILD_TYPE) //maxcpucount:8 | ||
else ifeq ($(DETECTED_OS), linux) | ||
cd $(BUILD_PATH) && \ | ||
make -j2 | ||
else ifeq ($(DETECTED_OS), mac) | ||
cd $(BUILD_PATH) && \ | ||
xcodebuild -alltargets -configuration $(BUILD_TYPE) -project Project.xcodeproj CODE_SIGN_IDENTITY="" | ||
endif | ||
cd $(BUILD_PATH_BIN) && \ | ||
python -m build | ||
|
||
deploy: install-poetry | ||
@echo "Deploying documentation to GitHub pages..." | ||
poetry run mkdocs build | ||
poetry run mkdocs gh-deploy | ||
rebuild: clean build | ||
|
||
test: build | ||
cd $(BUILD_PATH_BIN)/dist && pip install --force-reinstall isx-*.whl | ||
cd build/Release && \ | ||
ISX_TEST_DATA_PATH=$(TEST_DATA_DIR) python -m pytest --disable-warnings -v -s --junit-xml=$(API_TEST_RESULTS_PATH) test $(TEST_ARGS) |
Oops, something went wrong.