Jump to content
David Schwartz

Running Tokyo 10.2.3 dcc32 from the command line

Recommended Posts

I have a situation where I'm running an app and I need to spawn off an EXE. If it's not there, I want to build it first with DCC32 by launching the compiler in a separate process first that runs the DPR -- instead of requiring the user to open Delphi and click Compile. Delphi builds the app and runs it just fine.

 

This is what I get just trying to run it in a git bash shell.

$ dcc32 bdm001_checks_imp.dpr
Embarcadero Delphi for Win32 compiler version 33.0
Copyright (c) 1983,2018 Embarcadero Technologies, Inc.
bdm001_checks_imp.dpr(8) Fatal: F2613 Unit 'Forms' not found.

 

Advice I've found says to add 'vcl' to the Unit Scope Names.

 

Like this? It doesn't seem to be helping. here.

 

Snag_2448576.png

Share this post


Link to post

Can you instead of .dpr compile .dproj? Something like this:
 

call "C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\rsvars.bat"

set Hlavni=C:\Delphi\Plantis
set Pomocna=R:\Plantis

"%FrameworkDir%\msbuild.exe" "%Hlavni%\Plantis.dproj" /target:build /p:DCC_BuildAllUnits=true /p:"Config=Release" /p:"Platform=Win32" /p:"DCC_DcuOutput=%Pomocna%\DCU" /l:FileLogger,Microsoft.Build.Engine;logfile="%Pomocna%\Logs.Win32.Release.MSBuildLog.txt"

 

Share this post


Link to post

Shouldn't you be using msbuild? That's how you make sure that you get all the project settings. Otherwise you have to manually convert all the project settings into the dcc32 arguments. The msbuild rules do all that for you. 

Share this post


Link to post

Well, all of the questions I found about this in SO talked about ancient versions of Delphi, like D7 and D2010. Nothing was very current. And I just followed what they said they were doing.

 

I could certainly use msbuild if that's what's needed.

 

This code we have started out in D6, and it has been very lightly touched since then. It does compile in Tokyo, and all of the files go to the current directory the same way they typically did in D7.

 

The IDE is set up to do a Debug build and run. I'm simply trying to create an EXE invisibly if it's not there so I can run it for the user. (Users don't care about Delphi in this case; they want to run the app.) 

 

Please don't over-think this ... at the moment, I'm the ONLY user who'll be using this in the near-term. I just don't want to have to fire up Delphi to build the EXE if it gets deleted for some reason. (It's not considered "essential" and we have processes that periodically go thru and flush out non-essential things. In this case, the process says to run it within the Delphi IDE, which rebuilds it every time anyway. I'm just wanting to bypass Delphi.)

Share this post


Link to post
2 hours ago, David Schwartz said:

Well, all of the questions I found about this in SO talked about ancient versions of Delphi, like D7 and D2010. Nothing was very current. And I just followed what they said they were doing.

https://delphi.fandom.com/wiki/Compile_from_Commandline

 

It doesn't explicitly mention anything newer than Delphi 2007, but since the process has not changed, why should it?

  • Thanks 1

Share this post


Link to post

Open cmd, type dcc32 it prints (almost) all parameters. You will find the -NS switch for namespace search path.

So what you do is pass -NSvcl (probably there are some more needed such as Winapi - just take those that a new project in Delphi usually gets)

  • Thanks 1

Share this post


Link to post
16 minutes ago, Stefan Glienke said:

Open cmd, type dcc32 it prints (almost) all parameters. You will find the -NS switch for namespace search path.

So what you do is pass -NSvcl (probably there are some more needed such as Winapi - just take those that a new project in Delphi usually gets)

That might make it compile, but you'll also need to specify any other options that are non-default.  And then update the code that invokes compilation any time you make a change to the project config being compiled. Why not let msbuild do it for you?

Edited by David Heffernan

Share this post


Link to post

Because msbuild opens an entirely different can of worms and actually requires a dproj - compiling some dpr with dcc is a no brainer

Share this post


Link to post
1 hour ago, Stefan Glienke said:

Because msbuild opens an entirely different can of worms and actually requires a dproj - compiling some dpr with dcc is a no brainer

What can of worms? It has always been easy enough for me. And clearly we do have a dproj in this instance.

Share this post


Link to post

I use msbuild for anything more than D7. dproj files contain tons of additional necessary stuff like lib subfolders, compiler options, defines etc. In fact, with preliminary configuring it allows generating f.ex. all combinations of platforms and build modes in several lines.

Share this post


Link to post
59 minutes ago, Fr0sT.Brutal said:

I use msbuild for anything more than D7.

I somehow doubt that, even assuming that you skipped or at least dropped Delphi 8 like every sane person. Delphi 2005 and 2006 didn't use msbuild.

 

[/smartass mode]

Edited by dummzeuch
  • Haha 1

Share this post


Link to post

So I guess I just put these two lines into a BAT file and run that?

 

call "%ProgramFiles%\CodeGear\RAD Studio\5.0\bin\rsvars.bat"

msbuild <project>.dproj


(This is for Delphi 2007, for later versions, adjust the path to rsvars.bat accordingly.)

Share this post


Link to post
56 minutes ago, David Schwartz said:

So I guess I just put these two lines into a BAT file and run that?

 

call "%ProgramFiles%\CodeGear\RAD Studio\5.0\bin\rsvars.bat"

msbuild <project>.dproj


(This is for Delphi 2007, for later versions, adjust the path to rsvars.bat accordingly.)

Yes. Or you copy the code from the rsvars.bat file and append the msbuild line. Note that you need to check where the user actually installed his Delphi. E.g. I didn't install to %ProgramFiles%. You can get that information from the registry:

HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0 -> RootDir

 

  • Thanks 1

Share this post


Link to post

I use MS Build this way  in batch file, Windows 10, Delphi 10.2.3.

Nice post is here:

http://www.delphifeeds.com/go/s/155085

 

@ECHO OFF
@SET BDS=C:\Program Files (x86)\Embarcadero\Studio\19.0
@SET BDSINCLUDE=C:\Program Files (x86)\Embarcadero\Studio\19.0\include
@SET BDSCOMMONDIR=C:\Users\Public\Documents\Embarcadero\Studio\19.0
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v3.5
@SET FrameworkVersion=v3.5
@SET FrameworkSDKDir=
@SET PATH=%FrameworkDir%;%FrameworkSDKDir%;C:\Program Files (x86)\Embarcadero\Studio\19.0\bin;C:\Program Files (x86)\Embarcadero\Studio\19.0\bin64;C:\Users\Public\Documents\Embarcadero\InterBase\redist\InterBase2017\IDE_spoof;%PATH%
@SET LANGDIR=EN
@SET BUILD_CONFIG=Release
@SET START_BUILD_STR=Start of building


REM LO_SintPro.dll

REM LO_Slos.dll
@SET LO_Slos="d:\Data Delphi\MyProjects\Dressler\LOCO_upgrade\Loco2\progr_dv_RAD102\DLLs\Lo_Slos\LO_Slos.dproj"
@ECHO %START_BUILD_STR% %LO_Slos%
DEL "d:\Data Delphi\MyProjects\Dressler\LOCO_upgrade\Loco2\progr_dv_RAD102\DLLs\Lo_Slos\LO_Slos.dll"
MSBuild %LO_Slos% -t:clean -p:config=%BUILD_CONFIG% -p:platform=Win32
MSBuild %LO_Slos% -t:Build -p:config=%BUILD_CONFIG% -p:platform=Win32


@ECHO Build %BUILD_CONFIG% done!

pause


 

  • Like 1

Share this post


Link to post
On 7/24/2020 at 9:03 PM, Stefan Glienke said:

Now that is clearly shorter than calling dcc32! /irony off

rsvars.bat && msbuild.exe /t:build /nologo %ProjFile%

beat it with call to dcc32 😜

  • Like 1
  • Thanks 1

Share this post


Link to post

To limit msbuild output, I use -clp:ErrorsOnly;WarningsOnly command line parameter. This allow to output warnings and errors only. However, in this case compiler hints are not visible. The question: is there exist any way to include compiler hints to the output, while keeping it clean and free of any other unneeded information?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×