Skip to content

Conversation

@ZiedYousfi
Copy link
Owner

@ZiedYousfi ZiedYousfi commented Nov 27, 2025

This pull request introduces significant improvements to the build system, project structure, and developer tooling for the cdirnuts project. The main focus is on modernizing CMake configuration, enhancing cross-platform CI workflows (including Windows, macOS, and Linux ARM64), and improving Lua and C++ integration. Additionally, developer experience is improved with better diagnostics and documentation updates.

Build system modernization and cross-platform CI:

  • Completely rewrites CMakeLists.txt to use modern CMake practices, modular targets, proper dependency management, and separate library/executable targets. Adds support for C++ standard 23, improved compiler flags, reproducible builds, and better installation/test configuration.
  • Updates CMakePresets.json with new presets for release/debug builds and vcpkg toolchain integration, aligning with the new CMake workflow.
  • Overhauls GitHub Actions workflows:
    • build-release.yml: Adds Windows MSVC setup, environment configuration, and switches to new CMake/Ninja/vcpkg presets for consistent cross-platform builds. [1] [2]
    • cmake-single-platform.yml (renamed to "Test Release Platforms"): Expands to a build matrix covering Linux x64/ARM64, macOS x64/ARM64, and Windows x64. Adds workflow dispatch for targeted runs, and uses new CMake/vcpkg/Ninja setup.

Developer tooling and diagnostics:

  • Adds .luarc.json and updates .vscode/settings.json to recognize cdirnuts as a global for Lua diagnostics, reducing false positives in editor linting. [1] [2]

Documentation improvements:

  • Updates LUA_API.md to reflect the C++ rewrite, new API naming conventions, and improved descriptions of the Lua integration and usage patterns.

Build System and CI Modernization

  • Major rewrite of CMakeLists.txt for modern CMake, modular targets, C++23, improved dependency management, and robust installation/testing.
  • GitHub Actions workflows now support full cross-platform builds (Windows, macOS, Linux x64/ARM64), use vcpkg toolchain, and leverage new CMake presets for consistency and maintainability. [1] [2] [3]
  • CMakePresets.json updated with new build and configure presets for release/debug/test scenarios, matching the new workflow.

Developer Experience

  • Adds .luarc.json and updates VS Code settings to recognize cdirnuts as a global in Lua, improving linting and diagnostics for contributors. [1] [2]

Documentation

  • Updates LUA_API.md for new C++-based Lua API, revised function names, and clearer usage instructions.

Summary by CodeRabbit

  • New Features

    • Lua API redesigned with virtual directory and file creation functions for in-memory project structures
    • Preset management system added to save and manage configuration presets
    • CLI enhanced with config execution and preset management commands (list, add, remove, use)
    • Default initialization script now creates projects using virtual abstractions
  • Documentation

    • Lua API documentation updated with new function names and examples
    • README updated with new CLI usage and API reference
    • Test coverage documentation added
  • Tests

    • Comprehensive test suite implemented with GoogleTest framework
    • Coverage includes filesystem, Lua engine, and preset management
  • Chores

    • Version bumped to 0.2.0
    • Build system modernized with CMake 3.23+; C++23 requirement enforced
    • Dependencies updated: CLI11, Sol2, GoogleTest added

✏️ Tip: You can customize this high-level summary in your review settings.

…ject metadata

- Updated CMakeLists.txt to include project description, homepage, and improved build configuration.
- Added CLI11 dependency and structured main.cpp to handle command-line options for configuration and preset management.
…ance and throw an exception on file read errors
…e registerAPI with error handling for directory and file creation
…ed performance and memory management; update Lua bindings for shared ownership.
… main function to set error result for missing presets
…t cases to use std::string for path initialization
…ce matrix configuration and streamline build steps
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request performs a comprehensive architectural migration from C to modern C++. It removes legacy C implementations (directory/file management, path parsing, logging, presets) and replaces them with C++ abstractions (fs::Path/Dir/File, Lua::LuaEngine, Presets::PresetManager). The build system is modernized with a rewritten CMakeLists.txt and updated CMakePresets, CI workflows gain Windows/MSVC support, and a comprehensive GoogleTest-based test suite is introduced.

Changes

Cohort / File(s) Summary
Build System Modernization
CMakeLists.txt, CMakePresets.json
Rewrote CMakeLists.txt with modern project settings (C++23 standard, metadata, external dependencies via find_package for Lua, CLI11, sol2). Introduced embedded Lua script generation, unified library/executable targets, installation rules, and optional GoogleTest-based testing. Added new configurePreset "vcpkg-release" and buildPresets ("vcpkg", "debug", "release").
CI/Workflow Enhancement
.github/workflows/build-release.yml, .github/workflows/cmake-single-platform.yml
Added Windows-specific setup steps for MSVC toolchain and compiler environment configuration; updated CMake presets to use vcpkg-release and release configurations.
C API Removals
include/config.h, include/dir.h, include/init.h, include/log.h, include/path.h, include/preset.h
src/config.c, src/dir.c, src/init.c, src/log.c, src/path.c, src/preset.c
Removed legacy C implementations: command execution (config), directory/file structs and management (dir), initialization (init), logging framework (log), path parsing utilities (path), and preset file I/O (preset).
C++ Filesystem Abstraction
include/fs.h, src/fs.cpp
Introduced new fs namespace with Path, File, and Dir classes providing modern C++ abstractions for filesystem operations with move semantics and error handling via exceptions.
Lua Integration (C++ Rewrite)
include/lua.h, src/lua.cpp, include/default_lua_script.h
Replaced C-based Lua embedding (lua_embed.h/c) with C++ LuaEngine class using sol2, featuring register_api() for bindings, execute_file/execute_string methods, and updated virtual directory/file API (create_virtual_dir, append_file, write_virtual_dir, etc.). Updated default_lua_script.h with C++ linkage guards.
Presets Management (C to C++)
include/presets.h, src/presets.cpp
Replaced C preset module with C++ Presets namespace containing Preset and PresetManager classes supporting add/remove/list operations, file persistence, and Lua script execution via use().
CLI Entry Point (C to C++)
src/main.c (removed), src/main.cpp (added)
Removed C-based CLI with preset management. Added C++ main.cpp using CLI11 for argument parsing, integrating PresetManager and LuaEngine with config file and preset subcommands (list, add, remove, use).
Configuration & Tooling
.gitignore, .luarc.json, .vscode/settings.json, vcpkg.json
Added test output directories to .gitignore; added .luarc.json and .vscode/settings.json for Lua diagnostics (cdirnuts global); bumped vcpkg.json version to 0.2.0 and added cli11, sol2, gtest dependencies.
Lua Script Updates
default_init.lua
Updated embedded Lua initialization script to use new virtual API: create_virtual_dir, create_virtual_file, append_subdir, append_file, write_virtual_dir, execute_shell_command; removed old allocDir/createDir/addFileToDir patterns.
Documentation & Tests
README.md, LUA_API.md, tests/README.md, tests/test_fs.cpp, tests/test_lua.cpp, tests/test_presets.cpp, tests/test.c (removed)
Updated documentation to reflect new C++ API and virtual abstractions. Removed C test suite (test.c); added comprehensive GoogleTest-based test suites for fs, lua, and presets modules with fixtures for filesystem cleanup and detailed coverage of new functionality.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Scope & heterogeneity: ~40 files affected with mixed removal, addition, and rewrite patterns (C→C++ migration with build/CI updates)
  • Logic density: New C++ implementations (fs abstraction, LuaEngine bindings, PresetManager) require careful review of move semantics, error handling, and Lua interop
  • Architecture shift: Complete refactor from C to modern C++ with dependency on sol2 and filesystem abstractions
  • Key areas requiring attention:
    • src/lua.cpp — Sol2 bindings and Lua API registration; verify usertype conversions and error propagation
    • CMakeLists.txt — Modern CMake patterns, external dependency management, and test discovery logic
    • src/fs.cpp — Move semantics, error handling in write_to_disk, recursive directory creation
    • src/presets.cpp — CSV parsing/serialization and PresetManager lifecycle; Windows CRLF handling
    • Test suite organization (tests/test_*.cpp) — Ensure fixture setup/teardown, file I/O cleanup, and error cases are adequate

Possibly related PRs

  • PR #8: Implements the same comprehensive C++ rewrite (fs abstraction, LuaEngine, PresetManager, CMake modernization, tests) — directly related code-level migration.
  • PR #7: Implements C-based presets module that this PR replaces with C++ Presets/PresetManager — related in preset management functionality.
  • PR #4: Adds C-based Lua embedding that this PR supersedes with C++ LuaEngine — related in Lua integration approach.

Poem

🐰 From C we hop to C++ so bright,
With sol2 bindings and move semantics right,
Virtual dirs and files dance in place,
While presets sing in the modern space,
GoogleTest hops through tests galore—
This rabbit's refactor opens the door! 🚀

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9f0bed and ea0a555.

📒 Files selected for processing (40)
  • .github/workflows/build-release.yml (2 hunks)
  • .github/workflows/cmake-single-platform.yml (1 hunks)
  • .gitignore (1 hunks)
  • .luarc.json (1 hunks)
  • .vscode/settings.json (1 hunks)
  • CMakeLists.txt (1 hunks)
  • CMakePresets.json (1 hunks)
  • LUA_API.md (3 hunks)
  • README.md (4 hunks)
  • cmake/embed_lua.cmake (1 hunks)
  • default_init.lua (4 hunks)
  • include/config.h (0 hunks)
  • include/default_lua_script.h (1 hunks)
  • include/dir.h (0 hunks)
  • include/fs.h (1 hunks)
  • include/init.h (0 hunks)
  • include/log.h (0 hunks)
  • include/lua.h (1 hunks)
  • include/lua_embed.h (0 hunks)
  • include/path.h (0 hunks)
  • include/preset.h (0 hunks)
  • include/presets.h (1 hunks)
  • src/config.c (0 hunks)
  • src/dir.c (0 hunks)
  • src/fs.cpp (1 hunks)
  • src/init.c (0 hunks)
  • src/log.c (0 hunks)
  • src/lua.cpp (1 hunks)
  • src/lua_embed.c (0 hunks)
  • src/main.c (0 hunks)
  • src/main.cpp (1 hunks)
  • src/path.c (0 hunks)
  • src/preset.c (0 hunks)
  • src/presets.cpp (1 hunks)
  • tests/README.md (1 hunks)
  • tests/test.c (0 hunks)
  • tests/test_fs.cpp (1 hunks)
  • tests/test_lua.cpp (1 hunks)
  • tests/test_presets.cpp (1 hunks)
  • vcpkg.json (1 hunks)

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.

@ZiedYousfi ZiedYousfi merged commit 5bcaf5f into main Nov 27, 2025
5 checks passed
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