aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2025-08-08 22:27:29 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2025-08-15 21:46:37 +0100
commit3f19ae7b18ae681fbd959e9099b70489053da874 (patch)
treea37a11e83643191cb1d56c056c87b75c08912fa5
parentd7a6aa81ef4506b7d4e10ddf09ee1662e0eebbd0 (diff)
downloadkutter-3f19ae7b18ae681fbd959e9099b70489053da874.tar.gz
kutter-3f19ae7b18ae681fbd959e9099b70489053da874.tar.xz
kutter-3f19ae7b18ae681fbd959e9099b70489053da874.zip
Use makefiles instead of auto-building
-rw-r--r--klippy/chelper/.gitignore3
-rw-r--r--klippy/chelper/GNUmakefile24
-rw-r--r--klippy/chelper/__init__.py22
-rwxr-xr-xklippy/chelper/clean3
-rw-r--r--lib/hub-ctrl/GNUmakefile6
5 files changed, 38 insertions, 20 deletions
diff --git a/klippy/chelper/.gitignore b/klippy/chelper/.gitignore
new file mode 100644
index 00000000..c68a14b8
--- /dev/null
+++ b/klippy/chelper/.gitignore
@@ -0,0 +1,3 @@
+*.o
+*.d
+c_helper.so
diff --git a/klippy/chelper/GNUmakefile b/klippy/chelper/GNUmakefile
new file mode 100644
index 00000000..acad5b62
--- /dev/null
+++ b/klippy/chelper/GNUmakefile
@@ -0,0 +1,24 @@
+filter_cc_option = $(shell $(CC) $(1) -E -x c /dev/null -o /dev/null >/dev/null 2>&1 && printf %s $(1))
+
+objs := itersolve.o kin_cartesian.o kin_corexy.o kin_corexz.o kin_delta.o \
+ kin_deltesian.o kin_extruder.o kin_generic.o kin_idex.o kin_polar.o \
+ kin_rotary_delta.o kin_shaper.o kin_winch.o msgblock.o pollreactor.o \
+ pyhelper.o serialqueue.o stepcompress.o trapq.o trdispatch.o
+
+hub_ctrl := hub-ctrl
+hub_ctrl_objs := hub-ctrl.o
+
+sse_flags = $(call filter_cc_option -mfpmath=sse) $(call filter_cc_option -fno-use-linker-plugin)
+CFLAGS ?= -Wall -O2 -flto -fno-fat-lto-objects $(sse_flags)
+CFLAGS += -std=gnu17 -MMD -MP
+LDFLAGS ?= -flto
+
+
+c_helper.so: CFLAGS += -fPIC
+c_helper.so: LDFLAGS += -shared -fPIC
+c_helper.so: $(objs)
+ $(LINK.o) $^ $(LDLIBS) -o $@
+
+$(objs): GNUmakefile
+
+-include: $(objs:.o=.d)
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 0a40dfeb..9bb2ebad 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -325,20 +325,11 @@ def logging_callback(msg):
def get_ffi():
global FFI_main, FFI_lib, pyhelper_logging_callback
if FFI_lib is None:
- srcdir = os.path.dirname(os.path.realpath(__file__))
- srcfiles = get_abs_files(srcdir, SOURCE_FILES)
- ofiles = get_abs_files(srcdir, OTHER_FILES)
- destlib = get_abs_files(srcdir, [DEST_LIB])[0]
- if check_build_code(srcfiles + ofiles + [__file__], destlib):
- if check_gcc_option(SSE_FLAGS):
- cmd = "%s %s %s" % (GCC_CMD, SSE_FLAGS, COMPILE_ARGS)
- else:
- cmd = "%s %s" % (GCC_CMD, COMPILE_ARGS)
- logging.info("Building C code module %s", DEST_LIB)
- do_build_code(cmd % (destlib, " ".join(srcfiles)))
FFI_main = cffi.FFI()
for d in defs_all:
FFI_main.cdef(d)
+ srcdir = os.path.dirname(os.path.realpath(__file__))
+ destlib = os.path.join(srcdir, "c_helper.so")
FFI_lib = FFI_main.dlopen(destlib)
# Setup error logging
pyhelper_logging_callback = FFI_main.callback(
@@ -362,13 +353,4 @@ HC_CMD = "sudo %s/hub-ctrl -h 0 -P 2 -p %d"
def run_hub_ctrl(enable_power):
srcdir = os.path.dirname(os.path.realpath(__file__))
hubdir = os.path.join(srcdir, HC_SOURCE_DIR)
- srcfiles = get_abs_files(hubdir, HC_SOURCE_FILES)
- destlib = get_abs_files(hubdir, [HC_TARGET])[0]
- if check_build_code(srcfiles, destlib):
- logging.info("Building C code module %s", HC_TARGET)
- do_build_code(HC_COMPILE_CMD % (destlib, " ".join(srcfiles)))
os.system(HC_CMD % (hubdir, enable_power))
-
-
-if __name__ == "__main__":
- get_ffi()
diff --git a/klippy/chelper/clean b/klippy/chelper/clean
new file mode 100755
index 00000000..5e56fb9d
--- /dev/null
+++ b/klippy/chelper/clean
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rm -rf *.o *.d c_helper.so
diff --git a/lib/hub-ctrl/GNUmakefile b/lib/hub-ctrl/GNUmakefile
new file mode 100644
index 00000000..ac9e4a9b
--- /dev/null
+++ b/lib/hub-ctrl/GNUmakefile
@@ -0,0 +1,6 @@
+CFLAGS ?= -Wall -O2
+CFLAGS += -std=gnu17
+CFLAGS += $(shell pkg-config --cflags libusb)
+LDLIBS += $(shell pkg-config --libs libusb)
+
+hub-ctrl: hub-ctrl.o