Skip to content

Update build system + minor .gitignore changes#6

Open
DVProjects wants to merge 1 commit into
turrnutorg:mainfrom
DVProjects:main
Open

Update build system + minor .gitignore changes#6
DVProjects wants to merge 1 commit into
turrnutorg:mainfrom
DVProjects:main

Conversation

@DVProjects
Copy link
Copy Markdown

@DVProjects DVProjects commented May 31, 2026

Implemented advanced build system.
Removed previous static rules and replaced them with dynamic rule generation.

This system makes sure that only the files dependent on the changes are actually recompiled.

Instead of recreating the directories for objects at each compilation, we keep them empty with .gitignore files.

Summary by CodeRabbit

Release Notes

  • Chores
    • Refactored build system to use centralized configuration for toolchain and paths, improving maintainability and consistency.
    • Enhanced build process with dynamic dependency generation and streamlined artifact directory management.
    • Cleaned up repository ignore patterns for better version control practices.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The build system is refactored from hardcoded toolchain invocations into a config-driven architecture. A new config.mk centralizes toolchain commands, directories, and flags. The Makefile is restructured to auto-generate per-C-file compilation rules, use variable-based linking and assembly patterns, and relies on config.mk for all paths and commands.

Changes

Build System Refactoring

Layer / File(s) Summary
Build configuration setup
config.mk
Introduces centralized toolchain variables (CC, AS, LD), compilation/linking flags, source/output directory paths, and auto-derives object file lists from wildcard source discovery with assembly-to-object naming workaround.
Makefile core flow and C rule generation
Makefile
Imports config.mk, redefines compile target to build $(OS_ISO), and introduces dynamic per-C-file compilation rule generation via build_c.mk that emits dependency and compile commands when C sources/headers change.
Linking and assembly compilation rules
Makefile
Replaces hardcoded linking with config-based rule that builds $(OS_BIN) from $(OBJ_DIR)/blob.o and $(ASM_OBJS), and converts assembly compilation to a pattern rule generating $(OBJ_DIR)/%_asm.o from %.asm sources.
Clean and run targets
Makefile
Updates clean to remove $(OBJ_DIR), $(OUT_DIR), and generated build_c.mk instead of hardcoded paths, and updates run to depend on $(OS_ISO) with QEMU invocation using -cdrom $(OS_ISO).
Gitignore patterns for build artifacts
.gitignore, obj/.gitignore, out/.gitignore
Root .gitignore ignores generated build_c.mk, and obj/ and out/ directories gain .gitignore files that ignore all contents while preserving .gitignore itself for directory structure tracking.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A makefile once hardcoded and fixed,
Now dances with config in template mix,
Auto-rules bloom where wildcards play,
Build artifacts drift in directories away,
The refactor hops forward with grace! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: refactoring the build system from static to dynamic rules and updating .gitignore files accordingly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
config.mk (1)

17-19: ⚡ Quick win

Consider using patsubst for more robust ASM object naming.

The current approach using $(subst .,_,...) replaces all dots with underscores, which works for simple filenames but could produce unexpected results if assembly files contain dots in their base names (e.g., my.boot.asm becomes my_boot_asm.o).

A more precise alternative:

ASM_OBJS := $(patsubst $(SRC_DIR)/%.asm,$(OBJ_DIR)/%_asm.o,$(ASM_SRC))

This transforms only the .asm extension while preserving any dots in the filename itself.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config.mk` around lines 17 - 19, The ASM object naming currently uses
ASM_OBJS := $(addsuffix .o,$(subst .,_,$(subst
$(SRC_DIR),$(OBJ_DIR),$(ASM_SRC)))) which replaces all dots in paths; replace
this with a pattern substitution that only strips the .asm extension by mapping
$(ASM_SRC) from $(SRC_DIR)/%.asm to $(OBJ_DIR)/%_asm.o (use patsubst) so
filenames with dots (e.g., my.boot.asm) keep their dots and only the extension
is transformed; update the ASM_OBJS assignment and keep references to ASM_SRC,
SRC_DIR and OBJ_DIR.
Makefile (2)

5-7: ⚡ Quick win

Consider using variables for build paths.

The paths build/boot/os.bin and build are hardcoded. For consistency with the config-driven approach, consider defining these in config.mk:

# In config.mk
GRUB_DIR := build
GRUB_BOOT_DIR := $(GRUB_DIR)/boot

# In Makefile
$(OS_ISO): $(OS_BIN)
	cp $< $(GRUB_BOOT_DIR)/os.bin
	grub-mkrescue --output=$@ $(GRUB_DIR)

This improves maintainability and follows the established pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 5 - 7, Define configurable build path variables (e.g.,
GRUB_DIR and GRUB_BOOT_DIR) in config.mk and use them in the Makefile instead of
hardcoded paths; update the $(OS_ISO) rule that currently references
build/boot/os.bin and build so that the cp command copies $< to
$(GRUB_BOOT_DIR)/os.bin and the grub-mkrescue invocation uses $(GRUB_DIR),
keeping the existing targets $(OS_ISO) and $(OS_BIN) unchanged and ensuring the
Makefile reads the variables from config.mk.

32-40: ⚡ Quick win

Add .PHONY declarations for non-file targets.

The targets compile, clean, and run don't produce files with those names and should be declared as .PHONY to prevent conflicts if files named compile, clean, or run are accidentally created.

📝 Proposed addition

Add this line near the top of the Makefile (after the include statement):

 include config.mk
 
+.PHONY: compile clean run
+
 compile: $(OS_ISO)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 32 - 40, Declare the non-file Makefile targets as
phony to avoid name conflicts: add a .PHONY declaration listing compile, clean,
and run (for example ".PHONY: compile clean run") near the top of the Makefile
(immediately after the include statement) so make treats those targets as always
out-of-date rather than as files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@config.mk`:
- Around line 17-19: The ASM object naming currently uses ASM_OBJS :=
$(addsuffix .o,$(subst .,_,$(subst $(SRC_DIR),$(OBJ_DIR),$(ASM_SRC)))) which
replaces all dots in paths; replace this with a pattern substitution that only
strips the .asm extension by mapping $(ASM_SRC) from $(SRC_DIR)/%.asm to
$(OBJ_DIR)/%_asm.o (use patsubst) so filenames with dots (e.g., my.boot.asm)
keep their dots and only the extension is transformed; update the ASM_OBJS
assignment and keep references to ASM_SRC, SRC_DIR and OBJ_DIR.

In `@Makefile`:
- Around line 5-7: Define configurable build path variables (e.g., GRUB_DIR and
GRUB_BOOT_DIR) in config.mk and use them in the Makefile instead of hardcoded
paths; update the $(OS_ISO) rule that currently references build/boot/os.bin and
build so that the cp command copies $< to $(GRUB_BOOT_DIR)/os.bin and the
grub-mkrescue invocation uses $(GRUB_DIR), keeping the existing targets
$(OS_ISO) and $(OS_BIN) unchanged and ensuring the Makefile reads the variables
from config.mk.
- Around line 32-40: Declare the non-file Makefile targets as phony to avoid
name conflicts: add a .PHONY declaration listing compile, clean, and run (for
example ".PHONY: compile clean run") near the top of the Makefile (immediately
after the include statement) so make treats those targets as always out-of-date
rather than as files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a141e15-0e98-41d4-9419-efe0a36aed2f

📥 Commits

Reviewing files that changed from the base of the PR and between 2dbfa09 and 4221df5.

📒 Files selected for processing (6)
  • .GITIGNORE
  • .gitignore
  • Makefile
  • config.mk
  • obj/.gitignore
  • out/.gitignore
💤 Files with no reviewable changes (1)
  • .GITIGNORE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant