Skip to content

Invalid cross includes that do not respect area encapsulation rules #53295

Open
@akien-mga

Description

Godot version

4.0.dev (06c1b40)

System information

Any

Issue description

The engine codebase is compartmentalized in areas/folders which have a defined dependency order to prevent both cyclic dependencies and general bad design patterns.

To ensure this encapsulation, we need to make sure that we don't include headers from high level areas in low level areas. For example core is the lowest level area, so it shouldn't include headers from any other folder (aside from thirdparty, which is independent from Godot code).

We should add CI checks to prevent adding such invalid includes, but first we need to fix the problems we already have in the codebase (#29730 is related, this issue is the same but for the whole codebase/dependency path).

The dependency order should follow the build order as defined here:

godot/SConstruct

Lines 724 to 737 in 06c1b40

# Build subdirs, the build order is dependent on link order.
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
SConscript("editor/SCsub")
SConscript("drivers/SCsub")
SConscript("platform/SCsub")
SConscript("modules/SCsub")
if env["tests"]:
SConscript("tests/SCsub")
SConscript("main/SCsub")
SConscript("platform/" + selected_platform + "/SCsub") # Build selected platform.

  • core
  • servers
  • scene
  • drivers (no issue)
  • editor
  • modules
  • tests (no issue)
  • main
  • platform (no issue since last)

I'll list invalid includes in comments for each folder/area.

Steps to reproduce

n/a

Minimal reproduction project

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions