Skip to content

Commit

Permalink
lib: Add targets to build & install blender add-on
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vkoskiv committed Dec 16, 2023
1 parent cbe89e1 commit b4f570a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<"
Expand Down

0 comments on commit b4f570a

Please sign in to comment.