Eclipse code assistance is failing due to missing defines

RESOLVED FIXED in Firefox 65

Status

enhancement
RESOLVED FIXED
2 years ago
8 months ago

People

(Reporter: jwatt, Assigned: jwatt)

Tracking

unspecified
mozilla65
Dependency tree / graph

Firefox Tracking Flags

(firefox65 fixed)

Details

Attachments

(4 attachments)

https://dxr.mozilla.org/mozilla-central/source/python/mozbuild/mozbuild/backend/cpp_eclipse.py

'consume_object' processes Defines objects to create the defines for the directories in the Eclipse process. However, Defines objects are only created for directories that have a moz.build that sets DEFINES, and only for the defines that are set on that variable. That means, for example, that there is no Defines object created for layout/svg, and that the Defines object created for dom/svg only has OS_POSIX, OS_MACOSX and DEBUG set.

The result of this is that we're missing several defines that the source files are compiled with. For example, running:

./mach compileflags dom/svg/SVGRect.cpp 

Shows that when we compile files in dom/svg the compiler is passed the defines STATIC_EXPORTABLE_JS_API, MOZ_HAS_MOZGLUE, MOZILLA_INTERNAL_API and MOZILLA_CLIENT. The generated Eclipse project does not contain these defines anywhere, and the result is that Eclipse improperly processes the files in dom/svg (the same is true pretty much everywhere else).
It's unclear to me how best to fix this. consume_object appears to be called with a ComputedFlags object for each directory, and that object contains 'CXXFLAGS' and 'CFLAGS' variables that contain the missing defines. I guess consume_object could parse the needed information out from that, but this information is likely duplicated across the entire tree, or much of it. Processing it for each directory and setting duplicate defines on each directory in the Eclipse project doesn't seem ideal. I'd hope that we can figure out a way to set this once as a project-wide setting (assuming these extra defines are indeed always project-wide).
(The DirectoryTraversal object that's passed for the root of the source tree doesn't appear to contain the missing defines FWIW.)
glandium, can you provide some advice here?
Flags: needinfo?(mh+mozilla)
Depends on: 1362612
I talked to cmanchester about this a few days ago. Apparently the eclipse backend can now get the information it needs from ComputedFlags objects and should ignore the Defines objects.
Flags: needinfo?(mh+mozilla)
Assignee: nobody → jwatt
Flags: needinfo?(jwatt)
Product: Core → Firefox Build System
Flags: needinfo?(jwatt)
chmanchester, is there much that has changed in the last year that I should be aware of before trying to fix this?
Flags: needinfo?(cmanchester)
No, I don't think so. 'DEFINES' are still found as a key in ComputedFlags instances in the backend.
Flags: needinfo?(cmanchester)
(In reply to Jonathan Watt [:jwatt] from comment #0)
> However, Defines objects are only created for directories that have a
> moz.build that sets DEFINES, and only for the defines that are set on
> that variable. That means, for example, that there is no Defines object
> created for layout/svg, and that the Defines object created for dom/svg
> only has OS_POSIX, OS_MACOSX and DEBUG set.

Actually, our problems are deeper than this. The defines that we do set for individual directories are set as "CDT Managed Build Setting Entries" which are ignored(!) since we don't use the Eclipse managed build system (we use mach). We need to set the defines as "CDT User Setting Entries". In terms of the generated project files, that means that we need to set them in language.settings.xml instead of in .cproject.
We've been setting per-directory defines in the "CDT Managed Build Setting
Entries" which are ignored(!) during indexing since we don't use the Eclipse
managed build system (we use mach). We need to set the defines as "CDT User
Setting Entries".
consume_object() is only called with Defines objects for directories containing
a moz.build file that sets a DEFINES value, and those Defines objects only
contain the defines set in that moz.build (not defines that affect the
directory's files that are set elsewhere).  That's why we fail to set some
defines.

This commit changes consume_object to obtain defines from the ComputedFlags
objects that it is passed instead.  We get one of these objects for every
directory with a moz.build, and we can obtain all defines passed to the
compiler for the files in a given directory from these objects.

Depends on D12008
Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/mozilla-inbound/rev/58bb44b8cbba
p1. Set Eclipse CDT per-directory defines in the right place. r=botond
https://hg.mozilla.org/integration/mozilla-inbound/rev/ab9d9c4cd361
p2. Fix Eclipse CDT project missing defines. r=botond
https://hg.mozilla.org/integration/mozilla-inbound/rev/9797d26fd00e
p3. Have Eclipse CDT globally set MOZILLA_CLIENT and the NSS include path. r=botond
https://hg.mozilla.org/integration/mozilla-inbound/rev/300e5ba9c142
p4. Set per-directory include paths for Eclipse CDT. r=botond
You need to log in before you can comment on or make changes to this bug.