User forums > Help
Running project pre-build steps executing twice
Orione:
Windows Vista, Code::Blocks 10.05
I have a workspace containing 2 projects: Ut (dll) and Test (Win32 console application).
I want to compile Ut project, copy it's target DLL to Test output directory, compile Test.
As I plan to add many more DLL and to use them in other worspaces as well I set in Test pre-build steps:
xcopy /d /y ..\Ut\bin\Debug\Ut.dll .\bin\Debug\.
Build Log follows. As you can see pre-build steps is executed twice and it also seems to be executed as part of Ut project build steps.
I found a similar message in this forum dated April 2008, last reply on April 2009 but no solution seems to have been found.
So does anyone have hints?
...omitted (Ut project file compiled) ...
Creating library file: bin\Debug\libUt.dll.a
Output size is 1.25 MB
Running project pre-build steps
xcopy /d /y ..\Ut\bin\Debug\Ut.dll .\bin\Debug\.
..\Ut\bin\Debug\Ut.dll
1 File copiati
Running project pre-build steps
xcopy /d /y ..\Ut\bin\Debug\Ut.dll .\bin\Debug\.
0 File copiati
-------------- Build: Debug in Test ---------------
...omitted (Test project file compiled) ...
Output size is 916.22 KB
Process terminated with status 0 (0 minutes, 12 seconds)
0 errors, 8 warnings
Jenna:
Thanks for reporting this.
Happens also here on linux, but seems to happen only if the second project (the one with the prebuild step depends on the first one).
It does not happen if you use per target prebuild steps, what makes sense in your case, because you copy a debug-dll to a debug-application.
I will look into it.
Pecan:
I ran across this also: the fix is to CompilerGCC::GetNextStateBasedOnJob as:
--- Code: --- case bsProjectDone:
{
// switch to next project in workspace
if (m_pBuildingProject)
m_pBuildingProject->SetCurrentlyCompilingTarget(0);
m_NextBuildState = bsProjectPreBuild;
//(ICC 2010/05/23) CB bug: bsProjectPreBuild being invoked twice
//return DoBuild(clean, build) >= 0 ? bsProjectPreBuild : bsNone;
return DoBuild(clean, build) >= 0 ? bsTargetPreBuild : bsNone;
}
default:
break;
}
return bsNone;
--- End code ---
It should be returning bsTargetPreBuild, not bsProjectPreBuild.
The return DoBuild() has already done the bsProjectPreBuild, so when it returns
it's time for the bsTargetPreBuild.
And while you're in there ;-)
--- Code: --- // create a new process
m_ProcessOutputFiles[procIndex] = (cmd->isLink && cmd->target) ? cmd->target->GetOutputFilename() : wxString();
Manager::Get()->GetMacrosManager()->ReplaceMacros(m_ProcessOutputFiles[procIndex]); //(ICC 2010/06/14)
--- End code ---
If the macros aren't replace in the output file name, OnJobEnd will get an open error trying to open such files as "bin/$(FILENAME).exe" etc. when it attempts to report the file size.
Jenna:
Thanks for the hint, it saves me a lot of time.
But I think it should be:
--- Code: --- case bsProjectDone:
{
// switch to next project in workspace
if (m_pBuildingProject)
m_pBuildingProject->SetCurrentlyCompilingTarget(0);
m_NextBuildState = bsProjectPreBuild;
// return DoBuild(clean, build) >= 0 ? bsProjectPreBuild : bsNone;
return DoBuild(clean, build) >= 0 ? (clean && !build?bsTargetClean:bsTargetPreBuild) : bsNone;
}
default:
break;
}
return bsNone;
--- End code ---
Otherwise it runs the target's prebuild-step on workspace cleaning.
What do you think ?
And it might make it more readable to use a "real" if-statement here.
Pecan:
--- Quote from: jens on June 20, 2010, 01:49:56 am ---<..snip...>
--- Code: --- return DoBuild(clean, build) >= 0 ? (clean && !build?bsTargetClean:bsTargetPreBuild) : bsNone;
--- End code ---
Otherwise it runs the target's prebuild-step on workspace cleaning.
What do you think ?
And it might make it more readable to use a "real" if-statement here.
--- End quote ---
Agreed !
And if you change it to a "real" if-statement, everyone will be better off for it.
Navigation
[0] Message Index
[#] Next page
Go to full version