MSBuild of Delphi project for RELEASE still sets D+ option - delphi

We're trying to build our Delphi 2007 projects using MSBuild. In the IDE we set all Buidl configurations to Debug with (among others) the D+ option on.
The Release build configuration, of course has the debug options off.
We build the project with the following command line:
Msbuild /target:Build /property:configuration=Release /clp:NoItemAndPropertyList
the resulting DCC command contains the correct command parameters (-$D-):
C:\Program Files (x86)\CodeGear\RAD Studio\5.0\bin\dcc32.exe
-B
-GD
-H-
-I <removed for clarity>
-LE<removed for clarity>
-LN <removed for clarity>
-O <removed for clarity>
-R <removed for clarity>
-U <removed for clarity>
--no-config
-$C-
-$D-
-$L-
-$Y-
-W- projectname.dpk
But when i run the project, the D+ option is on because my code shows a warning dialog after an {$ifopt D+}. If i change the active Buidl configuration in the IDE it works correcty. So it seems that dcc32 is still reading the options from the IDE in stead of the command line overrides.
Can anybody help me to fix this?
Edit: Realizing now that a .dpk has its compile options explicitly included ({DEBUGINFO ON}). Obviously this overrides the commandline parameters of the dcc32 command. Could this be the cause of my problems? ... and how to override them?

Found the answer myself :-)
The explicit settings in the .dpk are the problem, but they can be overriden without loss of IDE functionality by changing the {$ into {<space> changed.
See the following link: Compile DPK files using DCC32

Related

How to make gcov and gcovr pick up source and header files

I am trying to generate coverage report for project using .bat file as detailed below.
I see very few .gcov files. Also, when I click on link on generated html output, I am not able to see file details (file not found error). How do I fix it?
After I execute .bat file, I see output like ‘parsing coverage data for QString.h’ (QT library files). Is it expected?
I have seen many related questions but I am not able to figure out
(in report_coverage.bat)
set GCovrpath= C:\python37\script\lib\
set GCovpath= C:\abc\ghj\bin\
set datafiles= C:\source\mywork\root\testing\unittests\rose\build\debug\
set gcovr_src= C:\source\mywork\root\
%GCovpath%gcov.exe %datafiles% >> output.log
gcovr %datafiles% -s -p --html --html-details --gcov-executable %GCovpath%gcov.exe -o Test.html –verbose
Here are details….
Compile and execute code using
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS += --coverage
.GCNO and .GCDA files are generated as expected
It seems simple directory structure
Root
Header
Rose
Marigold
Jasmin
Source
Rose
Marigold
Jasmin
Testing
UnitTests
Rose
build
debug
Marigold
build
debug
Jasmin
build
debug
Thank you.
Update:
See answer below
I can not emphasis enough "\" for windows.
run this command from debug folder(because test.exe is here)
gcov -b -l -s C:\source\mywork\root\ debug\*.gcno
run this command from Unit tests folder (this will exclude .h files and files containing test)
gcovr -g -k -v --root C:\source\mywork\root\ -e ".*\.h" -e ".*test[_-|A-Z|a-z|0-9]*\.cpp" --html --html-details -o report.html
If you invoke gcov yourself, you need to run it from the same directory where the compiler was executed, and you need to give it either the path to the gcno, gcda, or source file. Gcov can only handle one input file at a time.
When gcov runs in the correct place, it can look at compilation metadata to find the correct source file. If there are errors about missing source files, that indicates that you didn't use the correct directory.
Gcovr runs gcov automatically, and has heuristics to figure out the correct directory. However, you should still run it from the directory where you started the compilation (typically, a build directory).
And gcovr will exclude coverage data if it doesn't belong to your project. If you have a separate build directory, you will need to set the --root argument to the directory containing your source code. Gcov processes coverage data for all files that were compiled, which makes this post-processing by gcovr necessary.
In verbose mode, gcovr will output “Parsing coverage data for <file>” when opening a gcov report. It will then use data within the file to decide whether it belongs to your project, and output “Filtering coverage data” if the source code is part of your project, “Excluding coverage data” otherwise.
There are multiple reasons why the coverage report might not be complete:
There is a problem with filtering.
Gcovr's heuristics can get confused when multiple files have the same name, e.g. two files called util.h in different directories.
Gcovr's --html-details report consists of multiple .html files, so make sure that they are all available.
In your BAT file, this invocation might work better:
gcovr --root ../src --print-summary --sort-percentage --html-details --gcov-executable %GCovpath%gcov.exe --output Test.html --verbose
assuming the following directory structure, and that you run gcovr from within build/:
your-project/
src/
Header/
...
Source/
...
Testing/
...
build/
...
If there are problems with a root path like ../src, consider using an absolute path like C:/path/to/the/src.

DCC32 compiler configuration file and command line parameter precedence

I am trying to build first time my Delphi application through command line using DCC32. I have few doubts regarding the configuration file of my project. There are some search paths I have to add to project when compiling through IDE. When I remove them, the compilation fails.
Now if I compile it through command line is it need to specify configuration file details or the search path parameters?
without any parameters:
dcc32.exe project1.dpr
with some parameters:
dcc32.exe -u%Shared% -ND:\out project1.dpr
I have following doubts:
if the config file details are not mentioned then it will take settings automtically from project.cfg (created by IDE)??
if yes then if i mentioned the -U,-N options in command line then it will override All the settings which are in .cfg ile?
This question sounds foolish but want to know What is use of compiling through command line over IDE?
Please provide some help to resolve my doubts. Any information related to dcc32 compilation options will be appreciated.
1. - If the project config file is not specified in the command line options, will the settings be taken from the project's cfg file generated by IDE ?
Yes.
2. - When I use the -U, -N options in command line will that override all the settings from a project cfg file ?
No. Command line options takes precedence though, but only those options you specify will override the settings from the project's *.cfg file, not the whole configuration
3. Is there a difference between compilation from command line and compilation from IDE ?
No. There is no difference speaking about Delphi 5. From my view, the command line way just brings you the possibility to automate a build process through command line batch without need of opening IDE.
It's been a while, but I believe you are correct in your assumptions about the command-line vs the .cfg file. You can verify this yourself by having one path in the .cfg and specifying a different one on the command line and, say, have an error in the file that the .cfg would reference and see if the compiler hits the error.
Compiling from the command-line is convenient for automated build systems but is otherwise the same as compiling through the IDE.

How to do a command line build using Delphi 7?

I am trying to build a delphi project from the command line compiler
Example: C:\dcc32 -B C:\BD\Delphi7\work\MyProject.dpr
Aside from the the standard evironment pathing:
$(DELPHI)\Bin;
$(DELPHI)\Lib;
$(DELPHI)\Imports;
$(DELPHI)\Projects\Bpl;
$(DELPHI)\Rave5\Lib;
there is nearly 50 other paths to other libraries, components, etc...
How do i package this all up and point to these to use in the commanline parameters to make my build?
When i run the example above
C:\dcc32 -B C:\BD\Delphi7\work\MyProject.dpr
i get a FATAL: File not found : 'file name here'
thanks
Under Delphi 7 you need to edit you dcc32.cfg file (in you Delphi bin folder). You need to copy the library path from the IDE and put in the dcc32.cfg file. You have to add it 4 times for the different command line parameters, eg:
-u=path
-i=path
-r=path
-o=path
There are 4, I believe. I haven't done this in a few years so I hope that the info is correct. Certainly, the command line compiler does not use the same place to store the paths as the IDE does.
I don't think dcc32.exe is stored under C:\, if it is you're installation of Delphi is really out of order, or you have moved only the dcc32.exe file.
It's advised to use the dcc32.exe from the directory where the Delphi install has stored it. The Delphi directory depends strongly on the Delphi version, but for Delphi versions op to 7, this looked something like this:
C:\Program Files\Borland\Delphi7\bin\dcc32.exe
For later versions of Delphi, this should be changed to:
"C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\DCC32.exe" -h

Delphi 6 command line compile: NO DCU’s

When using dcc32 against the .dpr file it produces a dll but no dcu’s.
The project level .cfg is using the –N switch to set the path but nothing is in the directory specified. It must see the .cfg as the –E switch is working.
I tried to use brcc32/brc32 against the .dpr file before a call dcc32 but either one gives me the Error projectName.dpr 3 1: Expecting END?
I need the dcu’s from project1 for project2 which when I run the dcc32 against the .dpr it errors stating it can’t find the missing dcu’s from project1 for project2.
What steps, clc/utility need to be run to produce the dcu files?
Running on XP with Delphi 6 installed.
DCC32 v14
BRC32 v5.4
Perhaps it is ignoring the -N switch because it doesn't have one? As far as I know the switch to specify where the dcu's should go is the -N0 switch. (Letter N, digit zero).
dcc32 --help is your friend here. In particular:
-N0<path> = unit .dcu output directory
(Note that D6 does not show this switch. D7 and more recent versions do.)
You do have to make sure that you include all necessary unit dependencies through the -U flag, resource dependencies through the -R flag, and so on. For instance:
dcc32 -B -CC -Q -E.\bin -IC:\home\work\Indy;C:\home\work\dUnit\src -LE.\bin -N0.\build -O"C:\home\work\Indy;C:\home\work\dUnit\src" -U"C:\home\work\Indy;C:\home\work\dUnit\src" -R"C:\Program Files\Borland\Delphi6\source\Indy;C:\Program Files\Borland\Delphi6\lib" SIP.dpr
EDIT: It doesn't help that dcc32 --help does NOT tell you about the -N0 switch. I found this out the hard way, and it was only on the advice of my boss (Guido Gybels) that I managed to get things working.

Delphi 2009 command line compiler using dcc32.cfg?

In Delphi 2009, how can I build a project using command line. I tried using the command line compiler and supplying -a -u -i -r in dcc32.cfg file. But compiler is not recognizing the paths and throwing the error required package xyzPack is not found.
-aWinTypes=Windows;WinProcs=Windows;DbiProcs=BDE;DbiTypes=BDE;DbiErrs=BDE
-u"C:\MyProj\Output\DCP"
-i"C:\MyProj\Output\DCP"
-r"C:\MyProj\Output\DCP"
and on command line i execute the command :
dcc32 "C:\MyProj\MyProject.dpr" -B -E"c:\MyProj\Output\EXE"
What am I doing wrong here?
Thanks & Regards,
Pavan.
Instead of invoking the compiler directly, consider using MSBuild on your .dproj, since that's what the IDE uses. Delphi MSBuild Build Configurations From Command Line might help you with that.
From the related answer (as shown below) ie:
Compiling with Delphi 2009 from a command line under Windows Vista 64-bit
I notice that you should be able to build a single package from the command line this way. I have used batch files (buildall.cmd) to launch dcc32, and have not yet used msbuild.
I have ultimately found both approaches frustrating, and have instead decided to opt for building a little GUI shell (a lite version of Final Builder, if you like) that basically works as a semi-graphical semi-command-line way of automating my builds and filtering the compiler output to produce results. I would be highly interested in anyone else's experiences with "tinder box" (daily or even continuous build) operations with Delphi.
You may end up where I'm heading... just buy Final Builder. :-)

Resources