Notice

The forum is in read only mode.

  • Page:
  • 1

TOPIC: C++Builder: Premature Post-Build event execution

C++Builder: Premature Post-Build event execution 6 years 9 months ago #1617

(For the original version of the question, please, see below.)

I've found out, that following was the reason for the strange behavior:

The project has post-build event, which copies the output of the build (executable) to some additional directory.

Also one of the files of the project has some "local" options defined (it was required to disable some warning for this specific file).

The problem, that in the project file post-build event is duplicated for this specific file. And as a result it is triggered after this specific file is build (but before the executable is created). So, there were nothing to copy and this step failed. When I called "Make" once again, this file was already compiled and post-build event for it was not triggered, - it was triggered after the whole build completes (this time successfully).


So, the new question is: how to avoid triggering of global post-build event for the files, which have local options defined?

Note: for now as a workaround I just unchecked "stop on failure of post-build event" for this specific file, but I don't like this approach, as it contradicts the logic of the build. What I'd like to have is to avoid triggering of post-build event before it is really meant to be executed.

Thanks in advance,
Dmitrii.

- - - - - - - - - - - - - - - - -
Original version of the question:

Hi,

I use C++Builder XE6.

And I've got strange behavior: if I do "Clean" and then "Make" or "Build" with my project, then on first run build process is stopped before all the files are compiled and linked. If I run "Make" once again, then several more files are compiled and the executable is linked.

I would highly appreciate if some one can give any idea, what may be the reason of such strange behavior.

Thanks in advance.

C++Builder: Premature Post-Build event execution 6 years 9 months ago #1676

I've updated the question with new information, so, please, consider answering it, if you know the answer.

Thanks.

C++Builder: Premature Post-Build event execution 6 years 8 months ago #1773

Hi Dmitrii,

You don’t need to duplicate the post-build event that you've already configured in the project.
If the goal is to copy the .exe file, the post-build event in the project is the correct approach.

Regarding:

"How to avoid triggering of global post-build event for the files, which have local options defined?"
>> You should remove the duplicated post-build event from any source file and keep the global of the project.

Hope that helps.

Regards,
Sarina

C++Builder: Premature Post-Build event execution 6 years 8 months ago #1786

Hi Sarina,

Thanks for your answer. But probably I explained the problem not clear enough...

Of course, I don't duplicate post-build event in the local options of specific file. I only need it to be done after the whole build process is finished.

The problem is that the post-build event (if it exists) is duplicated automatically in the local properties of the file, when we create those local properties. And I don't know how to remove/disable it then.

Consider the following workflow:

1. Create C++ project with several source files (aka units).
2. Create global post-build event (all configurations, all platforms), which does something like

copy $(OUTPUTPATH) C:\some_other_dir

3. Right-click some source file (unit) -> "Edit local options". Let's call it "MySpecialSource.cpp"
4. Change some local options (in my case I disable some specific warning).
5. Save everything.
6. Try to compile.

=> I'd expect that it will fail on first run. And if you examine output, you'll see, that after MySpecialSource.cpp is compiled the post-build event is executed. But output executable (or dll) is not linked yet, so there is nothing to copy, which triggers the error).


To make things more obvious you may replace "copy" command with "echo". Something like "echo This is post-build event". And then check the output of the build (in the "Output" tab of "Messages" window). You'll see, that post-build event is triggered twice: once after compilation of "MySpecialSource.cpp" and second time after the build is completed.


Below you can find the output of the build of sample project created as described above. You can see, that "echo Hi there" is called twice: first time after "Unit1.cpp" is compiled and the second time after the build is completed.

So, the question is how to disable first occasion, while keeping local options of the file.

The build output:





Build started 30.04.2015 08:10:12.
__________________________________________________
Project "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" (Make target(s)):
Target MakeObjs:
Target _CppDepCheck:
Modified: File1.cpp;Unit1.cpp
Target CppCompile:
Target _CppCoreCompile:
Target _BCC32CoreCompile:
c:\program files (x86)\embarcadero\studio\14.0\bin\bcc32.exe -D_DEBUG -n.\Win32\Debug -ITestPostBuildEvents;"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39\boost\tr1\tr1";"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39";"c:\program files (x86)\embarcadero\studio\14.0\include";"c:\program files (x86)\embarcadero\studio\14.0\include\dinkumware";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\crtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\sdk";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\rtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\vcl";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -y -Q -k -r- -c -tC -C8 -o.\Win32\Debug\File1.obj -w-par -Od -v -vi- -H=.\Win32\Debug\Project1.pch -H File1.cpp
Build started 30.04.2015 08:10:13.
Target _BCC32CoreCompile:
__________________________________________________
Project "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" is building "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" (MakeOne target(s)):
Target _MakeOne:
Target _CppCoreCompile:
Target _BCC32CoreCompile:
c:\program files (x86)\embarcadero\studio\14.0\bin\bcc32.exe -D_DEBUG -n.\Win32\Debug -ITestPostBuildEvents;"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39\boost\tr1\tr1";"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39";"c:\program files (x86)\embarcadero\studio\14.0\include";"c:\program files (x86)\embarcadero\studio\14.0\include\dinkumware";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\crtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\sdk";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\rtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\vcl";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -y -Q -k -r- -c -tC -C8 -o.\Win32\Debug\Unit1.obj -w-par -Od -v -vi- -H=.\Win32\Debug\Project1.pch -H Unit1.cpp
Target PostBuildEvent:
echo Hi there
Hi there
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.27
Target RcCompile:
Target BuildVersionResource:
c:\program files (x86)\embarcadero\studio\14.0\bin\cgrc.exe -c65001 Project1.vrc -foProject1.res
CodeGear Resource Compiler/Binder
Version 1.2.2 Copyright (c) 2008-2012 Embarcadero Technologies Inc.

Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0

Copyright (C) Microsoft Corporation. All rights reserved.


Deleting file "Project1.vrc".
Target _PerformLink:
Target _PerformBCCILink:
c:\program files (x86)\embarcadero\studio\14.0\bin\ilink32.exe -G8 -L.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";TestPostBuildEvents;"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release";"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release\psdk";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32";C:\Users\Public\Documents\Embarcadero\Studio\14.0\DCP -j.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";TestPostBuildEvents;"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release";"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release\psdk";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32";C:\Users\Public\Documents\Embarcadero\Studio\14.0\DCP -l.\Win32\Debug -v -Tpe c0x32 .\Win32\Debug\File1.obj .\Win32\Debug\Unit1.obj , .\Win32\Debug\Project1.exe , .\Win32\Debug\Project1.map , import32.lib cw32.lib , , Project1.res
Target PostBuildEvent:
echo Hi there
Hi there
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.23
  • Page:
  • 1
Moderators: April Anne