Steps to reproduce: (WinXP)
1, open a clean Codeblocks.cbp in a recent debugger branch nightly build.
2, change the command argument for src, like adding "-p=debugCC".
3, close this project.
Now, I can see that:
1, The EOL changing from CRLF to LF
2, There are many other changes like:
Index: E:/code/cb/cb_trunk/src/CodeBlocks.cbp
===================================================================
--- E:/code/cb/cb_trunk/src/CodeBlocks.cbp (revision 7781)
+++ E:/code/cb/cb_trunk/src/CodeBlocks.cbp (working copy)
@@ -24,7 +24,7 @@
</Linker>
</Target>
<Target title="tinyXML">
- <Option output="base\tinyxml\txml" prefix_auto="1" extension_auto="1" />
+ <Option output="base\tinyxml\libtxml" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option type="2" />
<Option compiler="gcc" />
@@ -60,7 +60,7 @@
</Compiler>
</Target>
<Target title="Squirrel">
- <Option output="sdk\scripting\lib\squirrel" prefix_auto="1" extension_auto="1" />
+ <Option output="sdk\scripting\lib\libsquirrel" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option type="2" />
<Option compiler="gcc" />
@@ -74,7 +74,7 @@
</Linker>
</Target>
<Target title="Squirrel std lib">
- <Option output="sdk\scripting\lib\sqstdlib" prefix_auto="1" extension_auto="1" />
+ <Option output="sdk\scripting\lib\libsqstdlib" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option external_deps="sdk\scripting\lib\libsquirrel.a;" />
<Option type="2" />
@@ -89,7 +89,7 @@
</Linker>
</Target>
<Target title="SqPlus">
- <Option output="sdk\scripting\lib\sqplus" prefix_auto="1" extension_auto="1" />
+ <Option output="sdk\scripting\lib\libsqplus" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option external_deps="sdk\scripting\lib\libsquirrel.a;sdk\scripting\lib\libsqstdlib.a;" />
<Option type="2" />
@@ -104,7 +104,7 @@
</Linker>
</Target>
<Target title="scintilla">
- <Option output="devel\wxscintilla_cb" prefix_auto="1" extension_auto="1" />
+ <Option output="devel\libwxscintilla_cb" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option type="2" />
<Option compiler="gcc" />
@@ -205,7 +205,7 @@
<Option external_deps="devel\libcodeblocks.a;" />
<Option type="0" />
<Option compiler="gcc" />
- <Option parameters="--debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen" />
+ <Option parameters="--debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen -p=debugCC" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="-DBUILDING_PLUGIN" />
@@ -316,7 +316,7 @@
</Linker>
</Target>
<Target title="Compiler depslib">
- <Option output="plugins\compilergcc\depslib\depslib" prefix_auto="1" extension_auto="1" />
+ <Option output="plugins\compilergcc\depslib\libdepslib" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option type="2" />
<Option compiler="gcc" />
So, Can I have some methods to solve this?
Thank you.
Can you please give a better explanation, because I don't think I understood the reason for the bug?
Have a look at:
ProjectLoader::ExportTargetAsProject(const wxString& filename, const wxString& onlyTarget, TiXmlElement* pExtensions)
While you do know the extension of the output file by its type, for the prefix you would need access to the compiler to query if and what prefix to apply to dynamic / static libraries.
It's simply not done, have a look at the code starting here:
if (target->GetTargetType() != ttCommandsOnly)
What's missing i something like:
if (prefixPolicy == tgfpPlatformDefault)
{
if (outputFileName.StartsWith(LIB_PREFIX_BY_COMPILER))
outputFileName = OUTPUT_FILE_NAME_WO_PREFIX;
}
if (prefixPolicy == tgfpPlatformDefault)
{
if (outputFileName.StartsWith(LIB_PREFIX_BY_COMPILER))
outputFileName = OUTPUT_FILE_NAME_WO_PREFIX;
}
...a better quick hack:
if ( prefixPolicy == tgfpPlatformDefault
&& ( (!platform::windows && target->GetTargetType() == ttDynamicLib)
|| (target->GetTargetType() == ttStaticLib) ) )
{
wxString compilerId = target->GetCompilerID();
Compiler* compiler = CompilerFactory::GetCompiler(compilerId);
if (compiler)
{
wxString compilerLibPrefix(compiler->GetSwitches()->libPrefix);
wxString outputFileNameWOPrefix;
if (outputFileName.StartsWith(compilerLibPrefix))
outputFileNameWOPrefix = outputFileName.Mid(compilerLibPrefix.Len());
if (!outputFileNameWOPrefix.IsEmpty())
outputFileName = outputFileNameWOPrefix;
}
}
NOT TESTED, NOT EVEN COMPILED!
...but something like this is needed.
EDIT: Fixed an obvious error, even in pseudo-code ;-)
...OK - another trial. Who will try this:
if ( (prefixPolicy == tgfpPlatformDefault)
&& ( (!platform::windows && target->GetTargetType() == ttDynamicLib)
|| (target->GetTargetType() == ttStaticLib) ) )
{
wxString compilerId = target->GetCompilerID();
Compiler* compiler = CompilerFactory::GetCompiler(compilerId);
if (compiler)
{
wxFileName fname(outputFileName);
wxString outputFileNameFile(fname.GetFullName());
wxString compilerLibPrefix(compiler->GetSwitches().libPrefix);
wxString outputFileNameWOPrefix;
if (outputFileNameFile.StartsWith(compilerLibPrefix))
{
outputFileNameWOPrefix = outputFileNameFile.Mid(compilerLibPrefix.Len());
if (!outputFileNameWOPrefix.IsEmpty())
{
fname.SetFullName(outputFileNameWOPrefix);
outputFileName = fname.GetFullPath();
}
}
}
}
?
;D
...OK - another trial. Who will try this:
if ( (prefixPolicy == tgfpPlatformDefault)
&& ( (!platform::windows && target->GetTargetType() == ttDynamicLib)
|| (target->GetTargetType() == ttStaticLib) ) )
{
wxString compilerId = target->GetCompilerID();
Compiler* compiler = CompilerFactory::GetCompiler(compilerId);
if (compiler)
{
wxFileName fname(outputFileName);
wxString outputFileNameFile(fname.GetFullName());
wxString compilerLibPrefix(compiler->GetSwitches().libPrefix);
wxString outputFileNameWOPrefix;
if (outputFileNameFile.StartsWith(compilerLibPrefix))
{
outputFileNameWOPrefix = outputFileNameFile.Mid(compilerLibPrefix.Len());
if (!outputFileNameWOPrefix.IsEmpty())
{
fname.SetFullName(outputFileNameWOPrefix);
outputFileName = fname.GetFullPath();
}
}
}
}
?
;D
I test it and the result looks like:
<Build>
<Target title="exchndl">
<Option platforms="Windows;" />
- <Option output="devel\exchndl" prefix_auto="1" extension_auto="1" />
+ <Option output="devel\exchndl.dll" prefix_auto="1" extension_auto="1" />
<Option working_dir="devel" />
<Option type="3" />
<Option compiler="gcc" />
@@ -24,7 +24,7 @@
</Linker>
</Target>
<Target title="tinyXML">
- <Option output="base\tinyxml\txml" prefix_auto="1" extension_auto="1" />
+ <Option output="base\tinyxml\txml.a" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option type="2" />
<Option compiler="gcc" />
I test it and the result looks like:
- <Option output="devel\exchndl" prefix_auto="1" extension_auto="1" />
+ <Option output="devel\exchndl.dll" prefix_auto="1" extension_auto="1" />
Hmmm... that is weird. Did you remove the extension policy? The code snippet was intended to be added and not to replace something.
Oh, I removed the original code snippets in the if statement. I'm adding them and test again.
Do you mean like below:
Index: E:/code/cb/cb_trunk/src/sdk/projectloader.cpp
===================================================================
--- E:/code/cb/cb_trunk/src/sdk/projectloader.cpp (revision 7781)
+++ E:/code/cb/cb_trunk/src/sdk/projectloader.cpp (working copy)
@@ -1163,8 +1163,29 @@
target->GetTargetFilenameGenerationPolicy(prefixPolicy, extensionPolicy);
wxString outputFileName = target->GetOutputFilename();
- if (extensionPolicy == tgfpPlatformDefault)
+ if ( (prefixPolicy == tgfpPlatformDefault)
+ && ( (!platform::windows && target->GetTargetType() == ttDynamicLib)
+ || (target->GetTargetType() == ttStaticLib) ) )
{
+ wxString compilerId = target->GetCompilerID();
+ Compiler* compiler = CompilerFactory::GetCompiler(compilerId);
+ if (compiler)
+ {
+ wxFileName fname(outputFileName);
+ wxString outputFileNameFile(fname.GetFullName());
+
+ wxString compilerLibPrefix(compiler->GetSwitches().libPrefix);
+ wxString outputFileNameWOPrefix;
+ if (outputFileNameFile.StartsWith(compilerLibPrefix))
+ {
+ outputFileNameWOPrefix = outputFileNameFile.Mid(compilerLibPrefix.Len());
+ if (!outputFileNameWOPrefix.IsEmpty())
+ {
+ fname.SetFullName(outputFileNameWOPrefix);
+ outputFileName = fname.GetFullPath();
+ }
+ }
+ }
wxFileName fname(outputFileName);
fname.ClearExt();
outputFileName = fname.GetFullPath();
I tested but it still give the same diff files.
EDIT
Oh, I made a mistake:
- if (extensionPolicy == tgfpPlatformDefault)
+ if ( (prefixPolicy == tgfpPlatformDefault)
I should preserve a old policy (if statement).
Ok, it works OK now, with this patch:
Index: E:/code/cb/cb_trunk/src/sdk/projectloader.cpp
===================================================================
--- E:/code/cb/cb_trunk/src/sdk/projectloader.cpp (revision 7781)
+++ E:/code/cb/cb_trunk/src/sdk/projectloader.cpp (working copy)
@@ -1169,7 +1169,31 @@
fname.ClearExt();
outputFileName = fname.GetFullPath();
}
+ if ( (prefixPolicy == tgfpPlatformDefault)
+ && ( (!platform::windows && target->GetTargetType() == ttDynamicLib)
+ || (target->GetTargetType() == ttStaticLib) ) )
+ {
+ wxString compilerId = target->GetCompilerID();
+ Compiler* compiler = CompilerFactory::GetCompiler(compilerId);
+ if (compiler)
+ {
+ wxFileName fname(outputFileName);
+ wxString outputFileNameFile(fname.GetFullName());
+ wxString compilerLibPrefix(compiler->GetSwitches().libPrefix);
+ wxString outputFileNameWOPrefix;
+ if (outputFileNameFile.StartsWith(compilerLibPrefix))
+ {
+ outputFileNameWOPrefix = outputFileNameFile.Mid(compilerLibPrefix.Len());
+ if (!outputFileNameWOPrefix.IsEmpty())
+ {
+ fname.SetFullName(outputFileNameWOPrefix);
+ outputFileName = fname.GetFullPath();
+ }
+ }
+ }
+ }
+
TiXmlElement* outnode = AddElement(tgtnode, "Option", "output", outputFileName);
outnode->SetAttribute("prefix_auto", prefixPolicy == tgfpPlatformDefault ? "1" : "0");
outnode->SetAttribute("extension_auto", extensionPolicy == tgfpPlatformDefault ? "1" : "0");
Hi, Morten, I need to bump this thread again, as I nowadays still find annoying issue about this:
Steps to reproduce: (WinXP)
1, open a clean Codeblocks.cbp in a recent debugger branch nightly build.
2, change the command argument for src, like adding "-p=debugCC".
3, close this project.
Now, I can see that:
1, The EOL changing from CRLF to LF
See, the cbp file was saved from CRLF to LF always. This always give me a warning if I commit to the git local repo. (git would say that: warning: LF will be replaced by CRLF in such cbp files in the repo.....)
I trace down and found that in the last stage of saving cbp file, we have such code:
bool TinyXML::SaveDocument(const wxString& filename, TiXmlDocument* doc)
{
if (!doc)
return false;
TiXmlPrinter printer;
printer.SetIndent("\t");
doc->Accept(&printer);
return Manager::Get()->GetFileManager()->SaveUTF8(filename, printer.CStr(), printer.Size());
}
Here, we create a printer object, which has:
class TiXmlPrinter : public TiXmlVisitor
{
public:
TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
buffer(), indent( " " ), lineBreak( "\n" ) {}
Look, it always use lineBreak( "\n" ).
Can we fix it by setting the lineBreak by platform?
Thanks.