Skip to content

Top module#30

Open
OldDev78 wants to merge 2 commits into
Redot-Engine:masterfrom
OldDev78:top-module
Open

Top module#30
OldDev78 wants to merge 2 commits into
Redot-Engine:masterfrom
OldDev78:top-module

Conversation

@OldDev78
Copy link
Copy Markdown
Contributor

@OldDev78 OldDev78 commented May 30, 2026

import draconic; can now import everything under engine/native (we can already rename that directory, tbd).

Also, move platform implementation details to an internal static library.

Summary by CodeRabbit

  • Chores
    • Reorganized internal build system and module dependency structure
    • Refactored platform abstraction layer architecture to separate interface from implementation details
    • Simplified module imports in core initialization

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

This PR refactors the platform abstraction layer from C++20 module-based to traditional header-based implementation. It introduces a new platform_impl static library for platform-specific code, reorganizes the build system to add an intermediate native aggregation target, and consolidates module imports through a new draconic facade module.

Changes

Platform Layer Refactoring

Layer / File(s) Summary
Build System Restructuring
CMakeLists.txt, engine/CMakeLists.txt, engine/native/CMakeLists.txt, engine/native/platform/CMakeLists.txt
Root CMakeLists adds engine subdirectory instead of engine/native. New native module target aggregates platform, core, input, scene, rendering dependencies. draconic target's link list simplified to depend on native. engine/native/platform/CMakeLists.txt reduced to add only the impl subdirectory.
Platform Implementation Layer Extraction and Module Interface
engine/native/platform/impl/CMakeLists.txt, engine/native/platform/impl/platform_impl.h, engine/native/platform/impl/win32/win32.cpp, engine/native/platform/impl/mac/mac.mm, engine/native/platform/impl/linux/linux.cpp, engine/native/platform/platform.cppm
New platform_impl static library selects platform source conditionally and discovers Linux dependencies (X11/Wayland) via PkgConfig. New header platform_impl.h defines NativeWindowType enum, NativeWindowFrame struct, and get_native_handles function. Platform-specific implementations refactored from C++20 module syntax to traditional includes, moved to draco::platform::impl namespace. Public platform.cppm module now re-exports impl types as aliases and provides inline forwarding wrapper for get_native_handles.
Module Aggregation and Entry Point Simplification
engine/native/draconic.cppm, engine/native/main/main.cpp
New draconic.cppm module re-exports platform, core, input, scene, rendering. main.cpp simplified to import single draconic module instead of five individual engine modules.

Sequence Diagram

sequenceDiagram
  participant main as main.cpp
  participant draconic as draconic module
  participant platform as platform.cppm
  participant impl_header as platform_impl.h
  participant win32 as win32.cpp<br/>(impl namespace)
  participant mac as mac.mm<br/>(impl namespace)
  participant linux as linux.cpp<br/>(impl namespace)
  
  main->>draconic: import draconic
  draconic->>platform: export import platform
  platform->>impl_header: `#include` impl/platform_impl.h
  platform->>platform: using NativeWindowType<br/>using NativeWindowFrame
  main->>platform: call get_native_handles()
  platform->>impl_header: call impl::get_native_handles()
  impl_header->>win32: conditional compile (WIN32)
  impl_header->>mac: conditional compile (APPLE)
  impl_header->>linux: conditional compile (Linux)
  win32-->>impl_header: return NativeWindowFrame
  mac-->>impl_header: return NativeWindowFrame
  linux-->>impl_header: return NativeWindowFrame
  impl_header-->>platform: NativeWindowFrame
  platform-->>main: NativeWindowFrame
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • Redot-Engine/DraconicEngine#16: Both PRs touch the cross-platform native window handle code (the get_native_handles API in engine/native/platform/*), with the main PR refactoring its implementation into a new platform_impl and updating module/CMake wiring accordingly.

Suggested Reviewers

  • Arctis-Fireblight
  • mcdubhghlas

Poem

🐰 Hops through the platform maze with glee,
Extracting impl so all can see—
Module facades now forward the way,
Headers and CMake work in play,
Native calls spring to life each day!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Top module' is vague and generic, using non-descriptive terminology that doesn't clearly convey the main architectural change of creating a unified top-level draconic module for importing engine components. Consider a more descriptive title like 'Add top-level draconic module for unified engine imports' to better communicate the main objective.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

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

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.

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.

2 participants