From b4f570a85fec7de705d0ac91518e559ea04cf2b7 Mon Sep 17 00:00:00 2001 From: Valtteri Koskivuori Date: Sat, 16 Dec 2023 20:28:10 +0200 Subject: [PATCH] lib: Add targets to build & install blender add-on make blsync syncs only the python scripts, which can then (most of the time) be reloaded in Blender. make fullblsync also builds and swaps in the library .so. Blender crashes if you do this while it's running and then reload add-ons, so only use that when restarting it anyway. I've also noticed that sometimes even scripts aren't reloaded properly, so if you see buggy python errors, just fullblsync and restart Blender. --- lib.mk | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib.mk b/lib.mk index 2c6256d8..86fad413 100644 --- a/lib.mk +++ b/lib.mk @@ -9,11 +9,33 @@ SRCS_lib=$(shell find src/lib src/common generated/ -name '*.c') OBJS_lib=$(patsubst %.c, $(OBJDIR_lib)/%.o, $(SRCS_lib)) SRCS_driver=$(shell find src/driver src/common -name '*.c') OBJS_driver=$(patsubst %.c, $(OBJDIR_driver)/%.o, $(SRCS_driver)) +SRCS_python=$(shell find bindings -name '*.py') lib: $(BIN_lib) pylib: bindings/cray_wrap.so +BLENDER_ROOT=$(HOME)/.config/blender/4.0 + +blsync: bindings/cray_wrap.so $(SRCS_python) + mkdir -p $(BLENDER_ROOT)/scripts/addons/c_ray + cp bindings/c_ray.py $(BLENDER_ROOT)/scripts/addons/c_ray/ + cp bindings/blender_init.py $(BLENDER_ROOT)/scripts/addons/c_ray/__init__.py + cp bindings/blender_properties.py $(BLENDER_ROOT)/scripts/addons/c_ray/properties.py + cp bindings/blender_ui.py $(BLENDER_ROOT)/scripts/addons/c_ray/ui.py + cp -r bindings/nodes $(BLENDER_ROOT)/scripts/addons/c_ray/ + +# Blender crashes if I swap out the .so, no idea why, so updating the library +# requires a restart of blender and the use of this target. +fullblsync: bindings/cray_wrap.so $(SRCS_python) + mkdir -p $(BLENDER_ROOT)/scripts/addons/c_ray + cp bindings/cray_wrap.so $(BLENDER_ROOT)/scripts/addons/c_ray/ + cp bindings/c_ray.py $(BLENDER_ROOT)/scripts/addons/c_ray/ + cp bindings/blender_init.py $(BLENDER_ROOT)/scripts/addons/c_ray/__init__.py + cp bindings/blender_properties.py $(BLENDER_ROOT)/scripts/addons/c_ray/properties.py + cp bindings/blender_ui.py $(BLENDER_ROOT)/scripts/addons/c_ray/ui.py + cp -r bindings/nodes $(BLENDER_ROOT)/scripts/addons/c_ray/ + $(OBJDIR_driver)/%.o: %.c $(OBJDIR_driver) @mkdir -p '$(@D)' @echo "CC $<"