I’ve written some code for a Teensy which allows communcation with an HID device for the display of a MIDI controller. I’m thinking about porting this code to a module for Rack.
Has anyone done a Makefile for building/linking the necessary dependencies for making the API available within a module?
2 Likes
For reference, I finally spent time on figuring this out, and it is more easy than expected:
- Add hidapi as dependency under
dep/hidapito your project. - Add to your Makefile:
FLAGS += -Idep/hidapi/hidapi
and after include $(RACK_DIR)/arch.mk:
ifdef ARCH_MAC
SOURCES += dep/hidapi/mac/hid.c
endif
ifdef ARCH_WIN
SOURCES += dep/hidapi/windows/hid.c
CFLAGS += -DHID_API_NO_EXPORT_DEFINE
endif
ifdef ARCH_LIN
SOURCES += dep/hidapi/linux/hid.c
endif
- If you are using a GitHub workflow to build your plugin, add this before the “Build plugin” step:
- name: Install required dependencies
if: ${{ matrix.platform == 'lin-x64' }}
run: |
apt-get update
apt-get install -y libudev-dev
# Copy libudev headers to cross-compiler sysroot (find it dynamically)
SYSROOT=$(find /home/build/rack-plugin-toolchain/local -type d -name 'sysroot' 2>/dev/null | grep ubuntu | head -1)
mkdir -p $SYSROOT/usr/include
cp /usr/include/libudev.h $SYSROOT/usr/include/
shell: bash
I did not test it under Linux, but it builds without issues.
3 Likes