Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
shell: bash
- name: default build
run: |
tools/kconfig/defconfig.py --kconfig configs/Kconfig configs/defconfig
tools/kconfig/genconfig.py configs/Kconfig
make defconfig
make
coding-style:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tools/kconfig"]
path = tools/kconfig
url = https://github.com/sysprog21/Kconfiglib
58 changes: 39 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Ensure tools/kconfig submodule is initialized
ifeq ($(wildcard tools/kconfig/menuconfig.py),)
$(shell git submodule update --init tools/kconfig)
endif

-include .config

check_goal := $(strip $(MAKECMDGOALS))
ifneq ($(check_goal), config)
ifneq "$(CONFIG_CONFIGURED)" "y"
$(error You must first run 'make config')
endif
ifeq ($(filter $(check_goal),config defconfig),)
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping mk/common.mk whenever config/defconfig appears in MAKECMDGOALS means multi-goal invocations like "make defconfig all" can no longer build because the core rules are never included.

Prompt for AI agents
Address the following comment on Makefile at line 9:

<comment>Skipping mk/common.mk whenever config/defconfig appears in MAKECMDGOALS means multi-goal invocations like &quot;make defconfig all&quot; can no longer build because the core rules are never included.</comment>

<file context>
@@ -1,13 +1,18 @@
-ifneq &quot;$(CONFIG_CONFIGURED)&quot; &quot;y&quot;
-$(error You must first run &#39;make config&#39;)
-endif
+ifeq ($(filter $(check_goal),config defconfig),)
+    ifneq &quot;$(CONFIG_CONFIGURED)&quot; &quot;y&quot;
+        $(error You must first run &#39;make config&#39; or &#39;make defconfig&#39;)
</file context>
Fix with Cubic

ifneq "$(CONFIG_CONFIGURED)" "y"
$(error You must first run 'make config' or 'make defconfig')
endif
endif

# Rules
# Target variables initialization

target-y :=
target.o-y :=
Expand Down Expand Up @@ -58,11 +63,12 @@ libtwin.a_includes-y := \
include \
src

# Features
# Optional features

libtwin.a_files-$(CONFIG_LOGGING) += src/log.c
libtwin.a_files-$(CONFIG_CURSOR) += src/cursor.c

# Renderer
# Rendering backends
libtwin.a_files-$(CONFIG_RENDERER_BUILTIN) += src/draw-builtin.c
libtwin.a_files-$(CONFIG_RENDERER_PIXMAN) += src/draw-pixman.c
libtwin.a_cflags-$(CONFIG_RENDERER_PIXMAN) += $(shell pkg-config --cflags pixman-1)
Expand Down Expand Up @@ -156,29 +162,43 @@ demo-$(BACKEND)_ldflags-y := \
$(TARGET_LIBS)
endif

# Font editor tool

ifeq ($(CONFIG_TOOLS), y)
target-$(CONFIG_TOOL_FONTEDIT) += font-edit
font-edit_files-y = \
tools/font-edit/sfit.c \
tools/font-edit/font-edit.c
tools/font-edit/sfit.c \
tools/font-edit/font-edit.c
font-edit_includes-y := tools/font-edit
font-edit_cflags-y := \
$(shell pkg-config --cflags cairo) \
$(shell sdl2-config --cflags)
$(shell pkg-config --cflags cairo) \
$(shell sdl2-config --cflags)
font-edit_ldflags-y := \
$(shell pkg-config --libs cairo) \
$(shell sdl2-config --libs)
$(shell pkg-config --libs cairo) \
$(shell sdl2-config --libs)
endif

# Build system integration

CFLAGS += -include config.h

check_goal := $(strip $(MAKECMDGOALS))
ifneq ($(check_goal), config)
# Only include build rules when not running configuration targets
ifeq ($(filter $(check_goal),config defconfig),)
include mk/common.mk
endif

# Menuconfig
KCONFIGLIB := tools/kconfig/kconfiglib.py
$(KCONFIGLIB):
git submodule update --init tools/kconfig

# Load default configuration
.PHONY: defconfig
defconfig: $(KCONFIGLIB)
@tools/kconfig/defconfig.py --kconfig configs/Kconfig configs/defconfig
@tools/kconfig/genconfig.py configs/Kconfig

# Interactive configuration
.PHONY: config
config: configs/Kconfig
@tools/kconfig/menuconfig.py $<
@tools/kconfig/genconfig.py $<
config: $(KCONFIGLIB) configs/Kconfig
@tools/kconfig/menuconfig.py configs/Kconfig
@tools/kconfig/genconfig.py configs/Kconfig
19 changes: 18 additions & 1 deletion configs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ config CONFIGURED
bool
default y

# Dependency detection using Kbuild toolchain functions
config HAVE_SDL2
def_bool $(success,pkg-config --exists sdl2)
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def_bool cannot invoke Make functions like $(success,...); this introduces invalid syntax and causes Kconfig parsing to fail. Please replace the defaults with a valid Kconfig mechanism (e.g., deriving the value from another symbol or environment option).

Prompt for AI agents
Address the following comment on configs/Kconfig at line 9:

<comment>`def_bool` cannot invoke Make functions like `$(success,...)`; this introduces invalid syntax and causes Kconfig parsing to fail. Please replace the defaults with a valid Kconfig mechanism (e.g., deriving the value from another symbol or environment option).</comment>

<file context>
@@ -4,6 +4,19 @@ config CONFIGURED
 
+# Dependency detection using Kbuild toolchain functions
+config HAVE_SDL2
+    def_bool $(success,pkg-config --exists sdl2)
+
+config HAVE_PIXMAN
</file context>
Fix with Cubic


config HAVE_PIXMAN
def_bool $(success,pkg-config --exists pixman-1)

config HAVE_LIBPNG
def_bool $(success,pkg-config --exists libpng)

config HAVE_LIBJPEG
def_bool $(success,pkg-config --exists libjpeg)

choice
prompt "Backend Selection"
default BACKEND_SDL
Expand All @@ -14,6 +27,7 @@ config BACKEND_FBDEV

config BACKEND_SDL
bool "SDL video output support"
depends on HAVE_SDL2

config BACKEND_VNC
bool "VNC server output support"
Expand All @@ -28,6 +42,7 @@ config RENDERER_BUILTIN

config RENDERER_PIXMAN
bool "Pixman based rendering"
depends on HAVE_PIXMAN

endchoice

Expand Down Expand Up @@ -83,10 +98,12 @@ menu "Image Loaders"

config LOADER_PNG
bool "Enable PNG loader"
depends on HAVE_LIBPNG
default y

config LOADER_JPEG
bool "Enable JPEG loader"
depends on HAVE_LIBJPEG
default y

config LOADER_GIF
Expand Down Expand Up @@ -131,7 +148,7 @@ config DEMO_LINE
depends on DEMO_APPLICATIONS

config DEMO_SPLINE
bool "Build spline demp"
bool "Build spline demo"
default y
depends on DEMO_APPLICATIONS

Expand Down
15 changes: 13 additions & 2 deletions mk/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,17 @@ clean: __FORCE
__FORCE:
@true

ifneq "$(MAKECMDGOALS)" "clean"
-include $(target-depends)
# Only include dependencies when building known targets
build-goals := all clean $(target-builds)
ifneq ($(MAKECMDGOALS),)
# MAKECMDGOALS is not empty, check if it's a known target
ifneq ($(filter $(MAKECMDGOALS),$(build-goals)),)
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition only checks whether any goal is known. If a user runs a mix of known and unknown targets (e.g. make foo clean), $(filter ...) returns clean, so the block still includes $(target-depends) and the build fails with missing .d files. The guard needs to verify that all goals are known before including dependencies.

Prompt for AI agents
Address the following comment on mk/common.mk at line 685:

<comment>This condition only checks whether any goal is known. If a user runs a mix of known and unknown targets (e.g. `make foo clean`), `$(filter ...)` returns `clean`, so the block still includes `$(target-depends)` and the build fails with missing .d files. The guard needs to verify that **all** goals are known before including dependencies.</comment>

<file context>
@@ -678,6 +678,17 @@ clean: __FORCE
+build-goals := all clean $(target-builds)
+ifneq ($(MAKECMDGOALS),)
+    # MAKECMDGOALS is not empty, check if it&#39;s a known target
+    ifneq ($(filter $(MAKECMDGOALS),$(build-goals)),)
+        # Known target, include dependencies (except for clean)
+        ifneq &quot;$(MAKECMDGOALS)&quot; &quot;clean&quot;
</file context>
Suggested change
ifneq ($(filter $(MAKECMDGOALS),$(build-goals)),)
ifeq ($(filter-out $(build-goals),$(MAKECMDGOALS)),)
Fix with Cubic

# Known target, include dependencies (except for clean)
ifneq "$(MAKECMDGOALS)" "clean"
-include $(target-depends)
endif
endif
else
# Empty MAKECMDGOALS means building 'all', include dependencies
-include $(target-depends)
endif
1 change: 1 addition & 0 deletions tools/kconfig
Submodule kconfig added at e1f15e
4 changes: 0 additions & 4 deletions tools/kconfig/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions tools/kconfig/LICENSE

This file was deleted.

5 changes: 0 additions & 5 deletions tools/kconfig/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions tools/kconfig/defconfig.py

This file was deleted.

Loading
Loading