godotengine / godotengine/godot

VS projects have wrong module defines in all build configurations except the most recently built one

Open
#112,162 0 comments 0 reactions 0 assignees View on GitHub
bug platform:windows topic:buildsystem
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

All versions.

### System information

All systems

### Issue description

The modules header has different content that is dependent on the build target and build type. This means that its contents only reflect the last build target+type that the user did, because the location of the generated header is the same regardless of build configuration. This creates two problems:

- Even when nothing has changed in the source, the header is always regenerated if the last build was different than the current build. This adds extra time to the build.

- When loading the Visual Studio solution, the defines coming from the generated header will be wrong for all build configurations except for the most recently built one. This can cause code to resolve incorrectly in the IDE, potentially causing confusion. We're recording the module defines in a custom VS-only property, so VS ignores the header in favor of what's defined in the project, but code navigation from the define is then broken because it resolved to the harcoded define in the project, not the generated header. Including the module defines in the project was my local way to get around this generated header issue, and I would prefer having the header control the defines rather than having local patches to tell VS what's defined.

### Steps to reproduce

- Build the editor and then a template and then the editor again, and note the modules header being regenerated every time.

1. Build the editor with some module enabled - `scons target=editor module_ogg_enabled=yes vsproj=yes vsproj_gen_only=no`
1. Build a template with that module disabled - `scons target=template_debug module_ogg_enabled=yes vsproj=yes vsproj_gen_only=no`
1. Open the VS solution, select the editor build configuration
1. Open the `register_module_types.gen.cpp` file
1. Note that the `#ifdef MODULE_OGG_ENABLED` define is incorrectly resolved as not being defined.

### Minimal reproduction project (MRP)

N/A

### Linked PRs

- #112154
- #112153

Contributor guide

Open the contributing guide

Research direction

Start with the Visual Studio solution generation invoked by the listed SCons commands and inspect how the generated modules header and register_module_types.gen.cpp are handled per build configuration. Reproduce the editor/template/editor sequence, then verify that each Visual Studio configuration resolves its own module defines without regenerating a shared header unnecessarily.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.