Bug 21597 – Compiler flag should output a "normalized" file without unittests and comments

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-30T20:57:03Z
Last change time
2024-12-13T19:14:23Z
Assigned to
No Owner
Creator
Andrei Alexandrescu
Moved to GitHub: dmd#18020 →

Comments

Comment #0 by andrei — 2021-01-30T20:57:03Z
One D file is really four files in one: * The summary/header/".h"/interface file, with declarations and bodies of template functions and inline functions. * The documentation file, consisting of all declarations together with their documentation comments, and also documentation unittests. * The unittest file, consisting of the unittests. * The implementation file, containing the actual code. This conflation makes it difficult for build systems to distinguish changes: was the change to the interface, documentation, unittests, or implementation? Of course, all extant build systems assume "all of the above" and proceed with wasteful compilation of the normal build, the unittest build, the documentation build, and the rebuild of all dependencies. This needs addressing. The -H feature already extracts the interface file; it is currently broken and needs attention. There is no feature to extract the implementation file sans unittests. We need such.
Comment #1 by schveiguy — 2021-01-30T23:04:56Z
Note: if some comparison is to be done, it should remove all whitespace as well (spacing is actually something that does get changed)
Comment #2 by andrei — 2021-01-31T00:00:43Z
Yah, ideally normalization would be in some canonical format that is the same for all styles of coding.
Comment #3 by moonlightsentinel — 2021-01-31T00:47:25Z
Why should this be included in the compiler instead of being a seperate project using libdparse? See e.g. the test extractor used by the `publictests` target for druntime/phobos.
Comment #4 by andrei — 2021-01-31T00:59:05Z
(In reply to moonlightsentinel from comment #3) > Why should this be included in the compiler instead of being a seperate > project using libdparse? > > See e.g. the test extractor used by the `publictests` target for > druntime/phobos. A syntactic tool would be incomplete but probably still useful. It won't be able to do much with mixin-generated code. As with other tools (dependency detection/management) the conclusion is that only the compiler has access to all information needed.
Comment #5 by robert.schadek — 2024-12-13T19:14:23Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18020 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB