Summary: [patch] Adding support for fast and reliable build
tools to the frontend
Created an attachment (id=410)
DMD frontend patch
Creating a reliable and fast build tool for D is a tricky business currently.
Bu[il]d gets away with partial parsing of D files and is reasonably fast, but
may miss some imports and doesn't guarantee proper incremental builds. ReBuild
parses the project's modules by using the DMD frontend on them, then figures
out which files to pass to the compiler. This approach may provide proper full
and partial builds, but is slow because of duplicating a lot of work.
Leonard Dahlmann and myself have been working on a build tool that achieves
both of these merits through a reasonable compromise. It requires a special
patch to the compiler so it emits dependencies between modules to a file during
the semantic analysis. This way it can track module dependencies and build
projects by usually only running the compiler once (twice in special cases).
Tracking module dependencies is critical, because when A imports B and its code
is conditionally generated upon some declarations in B, they both have to be
recompiled whenever B is changed.
The patch has already been included in LDC 0.9.1 and works great with the first
tool that can exploit the extra info the compiler provides thanks to it -
xfBuild ( http://wiki.team0xf.com/index.php?n=Tools.XfBuild ). Several people
have been testing it for more than a month with DMD as well on Linux and
Windows, using a custom-patched version of DMD. It's proving to be consistently
faster and more reliable than other build tools.
Summary of the diff:
The mars.c file is modified as to accept an additional switch "-deps=filename".
This is to specify the file to which module dependencies are written in the
following format ( the real work is done in import.c ):
::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
ModuleAliasIdentifier ] "\n"
::= ModuleFullyQualifiedName " (" FilePath ") : " Protection " [ " static"
] : " ModuleFullyQualifiedName " (" FilePath ")"
- any string with '(', ')' and '\' escaped with the '\' character
The ImportBindList, ModuleAliasIdentifier, ModuleFullyQualifiedName
non-terminals are borrowed from
http://digitalmars.com/d/1.0/module.html#ImportDeclaration with the exception
of not allowing whitespace between substitution symbols
mod.ModA (mod\\ModA.d) : public : object
mod.ModCommon (mod\\ModCommon.d) : public : object
mod.ModA (mod\\ModA.d) : public : mod.ModCommon (mod\\ModCommon.d)
aliasedSelectiveImport (aliasedSelectiveImport.d) : public :
parse,toString32 -> Integer
The patch I've attached is Public Domain. It can be applied to DMD's source by
> patch -p0 -ui dmdDiff.patch
in the dmd/src directory, assuming DMD sources are in dmd/src/dmd. It's created
against DMD 1.045. It might be necessary to run 'dos2unix' on the files to be
patched (import.c, mars.c, mars.h) if doing it on a *nix.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------