5770 has lost build dependencies functionality

Discussion about CodeLite development process and patches
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

Okay ... I have narrowed down the problem.

Make does not like having the embedded quotes in the name.

If I manually went in and changed WorkspacePath in the makefile

old definition:

WorkspacePath := "/home/user/Sample Folder"

new definition:

WorkspacePath :=/home/user/Sample\ Folder
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

Here are some changes that I made that fixes the problem:

First I added a new function BuilderGnuMake::EscapeSpecialChars then I massaged createConfigsVariables to call it.

Code: Select all

wxString BuilderGnuMake::EscapeSpecialChars(const wxString& sx) const
{
	char*		sStart = new char[sx.Length() * 2];
	char*		s = sStart;

	const wxChar*		p = sx.c_str();
	const wxChar*		pEnd = p + sx.Length();
	while ( p < pEnd )
	{
		if ( '$' == *p )
		{
			*s++ = *p;		// make it $$
			*s++ = *p++;
		}
		else if ( 0 < strchr("%?*[~#\\\"", *p ))
		{
			*s++ = wxChar('\\');
			*s++ = *p++;
		}
		else
		{
			*s++ = *p++;
		}
	}
	*s = '\0';
	return wxString::From8BitData( sStart );
}
modified

Code: Select all

void BuilderGnuMake::CreateConfigsVariables(ProjectPtr proj, BuildConfigPtr bldConf, wxString &text)
{
    wxString name = bldConf->GetName();
    name = NormalizeConfigName(name);

    wxString cmpType = bldConf->GetCompilerType();
    CompilerPtr cmp = BuildSettingsConfigST::Get()->GetCompiler(cmpType);

    wxString objectsFileName(wxT("$(IntermediateDirectory)"));
    objectsFileName << PATH_SEP << proj->GetName() << wxT(".txt");

	wxString	tmp;
	tmp = WorkspaceST::Get()->GetWorkspaceFileName().GetPath();
	wxString workspacePath = EscapeSpecialChars( tmp );

	tmp = proj->GetFileName().GetPath();
	wxString projectPath = EscapeSpecialChars( tmp );

    text << wxT("## ") << name << wxT("\n");

    wxString outputFile = bldConf->GetOutputFileName();
    if(OS_WINDOWS && (bldConf->GetProjectType() == Project::EXECUTABLE || bldConf->GetProjectType().IsEmpty())) {
        outputFile.Trim().Trim(false);
        //if(outputFile.EndsWith(wxT(".exe")) == false) {
        //	outputFile.Append(wxT(".exe"));
        //}
    }

    // Expand the build macros into the generated makefile
    text << wxT("ProjectName            :=") << proj->GetName() << wxT("\n");
    text << wxT("ConfigurationName      :=") << name << wxT("\n");
    text << wxT("WorkspacePath          := ") << workspacePath << wxT("\n");
    text << wxT("ProjectPath            := ") << projectPath << wxT("\n");
    text << wxT("IntermediateDirectory  :=") << bldConf->GetIntermediateDirectory() << wxT("\n");
    text << wxT("OutDir                 := $(IntermediateDirectory)\n");
    text << wxT("CurrentFileName        :=\n"); // TODO:: Need implementation
    text << wxT("CurrentFilePath        :=\n"); // TODO:: Need implementation
    text << wxT("CurrentFileFullPath    :=\n"); // TODO:: Need implementation
    text << wxT("User                   :=") << wxGetUserName() << wxT("\n");
    text << wxT("Date                   :=") << wxDateTime::Now().FormatDate() << wxT("\n");
    text << wxT("CodeLitePath           :=\"") << WorkspaceST::Get()->GetStartupDir() << wxT("\"\n");
    text << wxT("LinkerName             :=") << cmp->GetTool(wxT("LinkerName")) << wxT("\n");
    text << wxT("SharedObjectLinkerName :=") << cmp->GetTool(wxT("SharedObjectLinkerName")) << wxT("\n");
    text << wxT("ObjectSuffix           :=") << cmp->GetObjectSuffix() << wxT("\n");
    text << wxT("DependSuffix           :=") << cmp->GetDependSuffix() << wxT("\n");
    text << wxT("PreprocessSuffix       :=") << cmp->GetPreprocessSuffix() << wxT("\n");
    text << wxT("DebugSwitch            :=") << cmp->GetSwitch(wxT("Debug")) << wxT("\n");
    text << wxT("IncludeSwitch          :=") << cmp->GetSwitch(wxT("Include")) << wxT("\n");
    text << wxT("LibrarySwitch          :=") << cmp->GetSwitch(wxT("Library")) << wxT("\n");
    text << wxT("OutputSwitch           :=") << cmp->GetSwitch(wxT("Output")) << wxT("\n");
    text << wxT("LibraryPathSwitch      :=") << cmp->GetSwitch(wxT("LibraryPath")) << wxT("\n");
    text << wxT("PreprocessorSwitch     :=") << cmp->GetSwitch(wxT("Preprocessor")) << wxT("\n");
    text << wxT("SourceSwitch           :=") << cmp->GetSwitch(wxT("Source")) << wxT("\n");
    text << wxT("OutputFile             :=") << outputFile << wxT("\n");
    text << wxT("Preprocessors          :=") << ParsePreprocessor(bldConf->GetPreprocessor()) << wxT("\n");
    text << wxT("ObjectSwitch           :=") << cmp->GetSwitch(wxT("Object")) << wxT("\n");
    text << wxT("ArchiveOutputSwitch    :=") << cmp->GetSwitch(wxT("ArchiveOutput")) << wxT("\n");
    text << wxT("PreprocessOnlySwitch   :=") << cmp->GetSwitch(wxT("PreprocessOnly")) << wxT("\n");
    text << wxT("ObjectsFileList        :=\"") << objectsFileName << wxT("\"\n");
    text << wxT("PCHCompileFlags        :=") << bldConf->GetPchCompileFlags() << wxT("\n");

    if (OS_WINDOWS) {
        text << wxT("MakeDirCommand         :=") << wxT("makedir") << wxT("\n");
    } else {
        text << wxT("MakeDirCommand         :=") << wxT("mkdir -p") << wxT("\n");
    }

    wxString buildOpts = bldConf->GetCompileOptions();
    buildOpts.Replace(wxT(";"), wxT(" "));

    wxString cBuildOpts = bldConf->GetCCompileOptions();
    cBuildOpts.Replace(wxT(";"), wxT(" "));

    // Let the plugins add their content here
    wxCommandEvent e(wxEVT_GET_ADDITIONAL_COMPILEFLAGS);
    EventNotifier::Get()->ProcessEvent(e);

    wxString additionalCompileFlags = e.GetString();
    if(additionalCompileFlags.IsEmpty() == false) {
        buildOpts << wxT(" ") << additionalCompileFlags;
        cBuildOpts << wxT(" ") << additionalCompileFlags;
    }

    //only if resource compiler required, evaluate the resource variables
    if (bldConf->IsResCompilerRequired()) {
        wxString rcBuildOpts = bldConf->GetResCompileOptions();
        rcBuildOpts.Replace(wxT(";"), wxT(" "));
        text << wxT("RcCmpOptions           :=") << rcBuildOpts << wxT("\n");
        text << wxT("RcCompilerName         :=") << cmp->GetTool(wxT("ResourceCompiler")) << wxT("\n");
    }

    wxString linkOpt = bldConf->GetLinkOptions();
    linkOpt.Replace(wxT(";"), wxT(" "));

    //link options are kept with semi-colons, strip them
    text << wxT("LinkOptions            := ") << linkOpt << wxT("\n");

    // add the global include path followed by the project include path
    wxString pchFile;

    // If the PCH is required to be in the command line, add it here
    // otherwise, we just make sure it is generated and the compiler will pick it by itself
    if(bldConf->GetPchInCommandLine()) {
        pchFile = bldConf->GetPrecompiledHeader();
        pchFile.Trim().Trim(false);
        if(pchFile.IsEmpty() == false) {
            pchFile.Prepend(wxT(" -include ")).Append(wxT(" "));
        }
    }

    wxString libraries = bldConf->GetLibraries();
    wxArrayString libsArr = ::wxStringTokenize(libraries, wxT(";"), wxTOKEN_STRTOK);
    libraries.Clear();
    libraries << wxT(" ");
    for(size_t i=0; i<libsArr.GetCount(); i++) {
        libsArr.Item(i).Trim().Trim(false);
        libraries << wxT("\"") << libsArr.Item(i) << wxT("\" ");
    }

    text << wxT("IncludePath            := ") << ParseIncludePath(cmp->GetGlobalIncludePath(), proj->GetName(), bldConf->GetName()) << wxT(" ") << ParseIncludePath(bldConf->GetIncludePath(), proj->GetName(), bldConf->GetName()) << wxT("\n");
    text << wxT("IncludePCH             := ") << pchFile << wxT("\n");
    text << wxT("RcIncludePath          := ") << ParseIncludePath(bldConf->GetResCmpIncludePath(), proj->GetName(), bldConf->GetName()) << wxT("\n");
    text << wxT("Libs                   := ") << ParseLibs(bldConf->GetLibraries()) << wxT("\n");
    text << wxT("ArLibs                 := ") << libraries << wxT("\n");

    // add the global library path followed by the project library path
    text << wxT("LibPath                :=") << ParseLibPath(cmp->GetGlobalLibPath(), proj->GetName(), bldConf->GetName()) << wxT(" ") << ParseLibPath(bldConf->GetLibPath(), proj->GetName(), bldConf->GetName()) << wxT("\n");

    text << wxT("\n");
    text << wxT("##\n");
    text << wxT("## Common variables\n");
    text << wxT("## AR, CXX, CC, CXXFLAGS and CFLAGS can be overriden using an environment variables\n");
    text << wxT("##\n");
    text << wxT("AR       := ") << cmp->GetTool(wxT("AR"))  << wxT("\n");
    text << wxT("CXX      := ") << cmp->GetTool(wxT("CXX")) << wxT("\n");
    text << wxT("CC       := ") << cmp->GetTool(wxT("CC"))  << wxT("\n");
    text << wxT("CXXFLAGS := ") << buildOpts << wxT(" $(Preprocessors)") << wxT("\n");
    text << wxT("CFLAGS   := ") << cBuildOpts << wxT(" $(Preprocessors)") << wxT("\n");

    text << wxT("\n\n");
}
Oh ... I also changed the objectsFileName to be in the intermediate directory.
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

oops I had a leak in my new func

Code: Select all

wxString BuilderGnuMake::EscapeSpecialChars(const wxString& sx) const
{
	char*		sStart = new char[sx.Length() * 2];
	char*		s = sStart;

	const wxChar*		p = sx.c_str();
	const wxChar*		pEnd = p + sx.Length();
	while ( p < pEnd )
	{
		if ( '$' == *p )
		{
			*s++ = *p;		// make it $$
			*s++ = *p++;
		}
		else if ( 0 < strchr("%?*[~#\\\"", *p ))
		{
			*s++ = wxChar('\\');
			*s++ = *p++;
		}
		else
		{
			*s++ = *p++;
		}
	}
	*s = '\0';
	wxString	out = wxString::From8BitData( sStart );
	delete [] sStart;

	return out;
}
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by eranif »

Can you send it as patch?

It will be alot easier for me to apply it

Eran
Make sure you have read the HOW TO POST thread
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

Where do I read about how to post as patch?
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by eranif »

Basically, if you use SVN version of codelite:

From within codelite's root source directory:

Code: Select all

svn diff > my.patch
If you use stable tarball sources (remember to mention which revision did you use):

Use the 'diff' utility:

Code: Select all

diff -uNr path-orig path-mine > my.patch
Eran
Make sure you have read the HOW TO POST thread
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

I'm submitting a patch that is a significant change to the generated makefile. IMHO it is much cleaner and the makefile can be easily used outside of CodeLite (for those people that refuse to use IDEs). It also fixes the problems of dependencies not correctly updating. The one thing that I don't have working right now is Precompiled Headers. But I can't get them to work on my machine period! :-(

By the way, I couldn't figure out in the code how to invoke "Preprocess-Only". I have the makefile setup so it can generate the preprocess file but there is now way to trigger it.

Oh! its worth mentioning that this has only been tested on Linux. I don't have a Windows installation to try it on.

Give the new makefiles a spin and let me know if you want to add it.

-- humbly John
You do not have the required permissions to view the files attached to this post.
grizzie17
CodeLite Enthusiast
Posts: 15
Joined: Wed May 12, 2010 12:15 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by grizzie17 »

I have cleaned up a few things and gotten precompiled headers to work. :-)

This patch is against 4.1.5770

-- John
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: 5770 has lost build dependencies functionality

Post by eranif »

grizzie17 wrote:I have cleaned up a few things and gotten precompiled headers to work. :-)

This patch is against 4.1.5770

-- John
Thanks for the patch, I will give it a try tomorrow

Eran
Make sure you have read the HOW TO POST thread
Post Reply