diff --git a/Makefile b/Makefile index 83aa811..c2c498e 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,24 @@ IOC_QT_PANEL := qt/$(IOC_NAME)_cpp_logic.ui IOC_QTGEN := $(CPP_LOGIC_ROOT)/utils/cpp_logic_ioc_qtgen.py IOC_SUBS_FILE := cfg/libmain.so_cpp_logic.subs +# Python's ctypes library is built locally, independently of the IOC module. +CXX ?= c++ +VIEWER_CXXFLAGS ?= -O2 -std=c++17 -Wall -Wextra -pedantic +ifeq ($(shell uname -s),Darwin) +VIEWER_LIBRARY := build/libhexapod.dylib +VIEWER_SHARED := -dynamiclib +else +VIEWER_LIBRARY := build/libhexapod.so +VIEWER_SHARED := -shared +endif + +.PHONY: viewer-lib +viewer-lib: $(VIEWER_LIBRARY) + +$(VIEWER_LIBRARY): src/c_api.cpp src/kinematics.hpp + mkdir -p $(@D) + $(CXX) $(VIEWER_CXXFLAGS) -fPIC $(VIEWER_SHARED) -o $@ src/c_api.cpp + .PHONY: pvs ui pvs: diff --git a/README.md b/README.md index 0970c0d..406a79e 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,15 @@ The quintic profile in the offline viewer is not an IOC trajectory generator. ## EPICS viewer +Build the viewer's local C API library separately from the IOC's `libmain.so`: + +```sh +make viewer-lib +``` + +This creates `build/libhexapod.so` (`.dylib` on macOS) from `src/c_api.cpp` +without EPICS dependencies. Rebuild it after changing the kinematics code. + For a running IOC, install the IOC viewer requirements and use the IOC record prefix, including the trailing colon: diff --git a/python/viewer.py b/python/viewer.py index 1ac34db..e68cee7 100644 --- a/python/viewer.py +++ b/python/viewer.py @@ -18,7 +18,7 @@ class Model: candidates = [ROOT / 'build' / ('libhexapod.' + ext) for ext in ('so', 'dylib')] path = next((p for p in candidates if p.exists()), None) if path is None: - raise RuntimeError('Build the C++ library first: make') + raise RuntimeError('Build the viewer C++ library first: make viewer-lib') self.lib = ct.CDLL(str(path)) pointer = ct.POINTER(ct.c_double) self.lib.hex_inverse.argtypes = [pointer] * 4