简体   繁体   中英

Blank lines instead of a task console output in MSBuild

My product is being migrated from Delphi 6 to the newer Delphi XE3. The Delphi 6 compiler used to output list of files that were compiled to an executable:

Borland Delphi Version 14.0
Copyright (c) 1983,2002 Borland Software Corporation

ProjectName.dpr(X) 
...
PathToSomeUnit.pas(X) 
...
PathToSomeIncludedFile.inc(X)     
...
X lines, X.XX seconds, X bytes code, X bytes data.

where "X" mean some numbers

We have an internal software for analyzing dependencies between applications and particular files - units and included files. This software uses the dcc32 console output (like this one above) as its input.

With the new Delphi XE3 we no longer call dcc32 directly, but we use MSBuild. Unfortunately, the console output is not the same as with Delphi 6. When the "Quiet compile" option is disabled, the console output has multiple blank lines in place of the compiled file list.

Embarcadero Delphi for Win32 compiler version 24.0
Copyright (c) 1983,2012 Embarcadero Technologies, Inc.

[multiple blank lines]

X lines, X.X seconds, X bytes code, X bytes data. (TaskId:65) 

With the /verbosity:diagnostic parameter it looks as follows

Embarcadero Delphi for Win32 compiler version 24.0 (TaskId:65)
Copyright (c) 1983,2012 Embarcadero Technologies, Inc. (TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
...
X lines, X.X seconds, X bytes code, X bytes data. (TaskId:65)

When calling dcc32 directly, there was a similar problem, but it was resolved with the "-B" compiler switch (-B = Build all units). I tried a similar approach with MSBuild by adding /p:DCC_AdditionalSwitches=-B but still it outputs multiple blank lines.

Here's a possible solution:

  1. Back up your files, etc.
  2. Open a .NET Framework SDK v2.0 command prompt.
  3. Disassemble Borland.Build.Tasks.Delphi.dll (located in your $(BDS)\\bin directory):

    ildasm Borland.Build.Tasks.Delphi.dll /out=Borland.Build.Tasks.Delphi.il

  4. Edit Borland.Build.Tasks.Delphi.dcctask.xml (created by the previous step) and comment out the Ignore subnode of the OutputParsing node.

  5. Reassemble it:

    ilasm Borland.Build.Tasks.Delphi.il /dll

  6. Register a strong name exception for it:

    sn -Vr Borland.Build.Tasks.Delphi.dll

If you turned off the quiet mode as described in this answer , building your Delphi projects with MSBuild should now show the detailed compiler output.

Add --depends to DCC32 command line or /p:DCC_OutputDependencies=true to msbuild, it will output a .d file that can be easily parsed, like the example below:

C:\publico\BUILD\temp\YourDPR.exe: YourDPR.dpr \
        C:\blabla blabla\FrameWork\Base\biblioteca\dcus\unit15.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\dcus\unit13.dcu \
        C:\bla bla\bla\LIBD5\Units\unit12.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\rxlib\units\unit1.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\rxlib\units\unit13.dcu \
        C:\bla bla\bla\LIBD5\Units\unit1.dcu \
        C:\bla bla\bla\LIBD5\Units\unit12.dcu \

Ps. You can hide those blank msbuild lines with /p:DCC_Hints=false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM