1

We use MSBuild to build our Delphi projects. Sometimes the DCC32 commandline gets too long (>32K characters) and fails. This is caused by our Search Path. We have already shorten this path using relative paths, combining sources, etc. This fixed it in the past.

Now we encounter this again and I am looking for a final solution for this. Restructuring the codebase is something I want to avoid, because we use a lot of third-party components which I don't want to mix (and keep in seperate directories).

I have read about response files for MSBuild, but I have no idea how I can get this working for DCC32. I have always mentioned that the same Search Path is passed several times to DCC32 with different flags (-U, -I, -R, -U). The -R (which is used for the resource compiler) does not have to use the exact same Search Path, but unfortunately it always inherits the Search Path from the compiler and I don't see options to ignore that.

Who has any idea how to solve this and find a solution to prevent these issues in the future?

Laurens
  • 325
  • 2
  • 12
  • Have you tried variables (for recurring parts in the path)? The can be defined in the IDE, used in project search paths, and also passed to MSBUILD as additional parameters. – mjn Jun 06 '23 at 16:43

3 Answers3

3

As it turns out, Embarcadero already had a fix inplace for this, but never documented it (I am not sure from which Delphi version this is supported). It is used when you enable the compiler option Use MSBuild externally to compile in your project. This enables the option/condition DCC_UseMSBuildExternally in the MSBuild script CodeGear.Delphi.Targets (locate in the Delphi-Bin directory). If this option is enabled, the MSBuild script will auto-generate a response file <your project>.cmds which is passed to dcc32. The comments in the Embarcadero MSBuild script are clear :-)

  <!--
  ========================================================================
               _GenerateCmdsFile
    Generate the .cmds file to pass to the compiler to avoid problems
    when the command line is too long and option "Use MSBuild externally
    to compile" is enabled.

  ========================================================================
  -->

So, to make a longer story short. Use the following MSBuild commandline to prevent these issues:

msbuild <your project>.drpoj /p:DCC_UseMSBuildExternally=true

Laurens
  • 325
  • 2
  • 12
2

You can place all the parameters in a commands file, each on a separate line, and give that file to the compiler prefixed with an @.

"c:\program files (x86)\embarcadero\studio\22.0\bin\dcc32.exe" @myProject.cmds myProject.dpr
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
  • To clarify: You don't need to put all parameters into the command file. Just a part of it (f.i. the path names) are fine, too. – Uwe Raabe Jun 06 '23 at 22:03
0

Could you please try to enable "Use MSBuild externally to compile" option in the IDE's project options page? The project will contain DCC_UseMSBuildExternally property. So your project will use a script file for compiling the source code instead of long-long command line options.

  • That is the solution I used, but more dedicated because I want to use the Delphi internal compiler in the IDE and MSBuild in VS Code (for the same destination and build type). – Laurens Jun 13 '23 at 18:23