Author Topic: Improvement of custom makefiles - patch to test  (Read 15948 times)

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Improvement of custom makefiles - patch to test
« on: January 21, 2009, 09:58:54 pm »
As announced in this thread I post a patch for the C::B build system, that improves the using of custom makefiles.

I attach two patches, one for linux and one for windows.

The contents are identical, but the windows patch is created with tortoise-svn and can easily applied with it, while the linux patch is created with standard diff.
Before use you have to unpack the patch with 7-zip.

To apply the linux version, change directory to the root directory of the C::B sources (the one that contains configure.in) and type
Code
patch -p1 < [path/to/the/patchfile/use_make_20090121-3.patch]
without square brackets and with the correct path of course.
To make sure it applies correctly you can first try it with the --dry-run option set, so nothing will be really changed.

The windows version can be applied from within with tortoise's context menu.


After patching the CodeBlocks[-unix].cbp and the ContripPlugins[-unix].workspace have to be build.
A rebuild or make clean should not be necessary, but some sdk-files are changed and without a new build C::B might crash.

After running [./]update[.bat] the new version should be usable.
If you compile it from within C::B and want to start it from inside the IDE, you also have to run [./]update[.bat], because I changed two .xrc-files, that would otherwise not be copied to the right place.

Cleaning, building and rebuilding of workspaces with and without custom makefiles should work as expected.
They can also be mixed or depend on each other.
Pre- and post-build steps for custom makefiles are also available.

The makefile has to be in the projects root dir and has to be set in the projects properties.
You still have to setup the parameters for the makefiles in Build options -> "Make" commands correctly. In most cases (on linux) it is enough to remove the $target, or use a targetname that is also used inside the makefile.

The last (new) command on the "Make" commands tab is used to test whether the project needs to be a rebuild.
The -q (question) parameter works for gnu make, I don't know the parameter for the make executables of other compilers. You have to figure it out yourself.

I normally do not use custm makefiles, so I only tested it with some of the wxWidgets samples and a simple wizard-generated .cbp-project.

Any questions, suggestions or whatever is not only welcome, but needed to make sure it works without breaking the standard build-system.

EDIT:
removed the patches, see next post, sorry for the inconvenience.
« Last Edit: March 29, 2009, 02:42:29 pm by jens »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #1 on: January 21, 2009, 11:45:08 pm »
The original patches lead to a crash if "Settings -> Compiler and debugger..." is called.

I forgot a null-pointer check.

Sorry.

Here are the corrected patches.

EDIT:
Attachments removed, please use the one in this post: http://forums.codeblocks.org/index.php/topic,9966.msg69440.html#msg69440
« Last Edit: January 22, 2009, 10:47:23 pm by jens »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9614
Re: Improvement of custom makefiles - patch to test
« Reply #2 on: January 22, 2009, 09:06:51 am »
Here are the corrected patches.
Hi Jens,
are you aware of this patch:
https://developer.berlios.de/patch/?func=detailpatch&patch_id=2583&group_id=5358
This I am testing for several weeks now and it looks quite good. It harmonises the build process quite nicely, including and especially the handling of custom makefiles. In addition its a kind of code cleanup for the build framework. Pretty nice, too. I could post an updated patch as the original one is based on a quite old revision. Any thoughts?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #3 on: January 22, 2009, 09:34:51 am »
No.

It looks good so far and I will test it and merge the patches and post a new one (hopefully this evening).

I like the test if a makefile-based project needs a rebuild to make the behaviour more consistent (only call the compiler if needed and if not just print a message).

I'm at work now, so I will not have the time to do so before this evening.


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9614
Re: Improvement of custom makefiles - patch to test
« Reply #4 on: January 22, 2009, 11:18:14 am »
I'm at work now, so I will not have the time to do so before this evening.
I am posting a patch here which you can take as a first step. I have merged your changes (the ones I think are required) and the onces of #2583 into compilergcc{.h/.cpp}. I am not sure if you really need DoCleanWithMake at all...?! And hopefully I didn't miss anything...

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #5 on: January 22, 2009, 11:32:32 am »
I just downloaded it, maybe I find some time during lunch  :wink:

New (merged) patch for tortoise attached.
I hope it works, but there might be problems with line-endings.

DoCleanWithMake is used, to make the clean process with "normal" projects and makefile-projects look the same.

EDIT:
Attachment removed, please use the one in this post: http://forums.codeblocks.org/index.php/topic,9966.msg69440.html#msg69440
« Last Edit: January 22, 2009, 10:47:42 pm by jens »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #6 on: January 22, 2009, 10:45:09 pm »
Here's the (hopefully) last version of the patch.

BAsed on the patch of gryphon, with some changes to make the two types of build-processes more consistent (check if makefile-based project needs arebuild and some small changes to clean).

Pre- and post-build steps can be used now, and of course also dependencies between projects.

I will remove all other attached patches.

EDIT:
Again an update to the patch:
http://forums.codeblocks.org/index.php/topic,9966.msg69472.html#msg69472
« Last Edit: January 24, 2009, 06:10:51 pm by jens »

Offline grischka

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Improvement of custom makefiles - patch to test
« Reply #7 on: January 23, 2009, 12:00:01 am »
BAsed on the patch of gryphon, with some changes to make the two types of build-processes more consistent ...
I think less consistency would be more actually, as there is information in the difference.  For instance for makefile builds I'd like to see the actual make commandline in the log.  Otherwise it's difficult to follow what is going on, esp. with mixed workspaces. 

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #8 on: January 23, 2009, 12:12:56 am »
BAsed on the patch of gryphon, with some changes to make the two types of build-processes more consistent ...
I think less consistency would be more actually, as there is information in the difference.  For instance for makefile builds I'd like to see the actual make commandline in the log.  Otherwise it's difficult to follow what is going on, esp. with mixed workspaces. 


That's not what I meant.
I don't like to have:
Quote
Process terminated with status 0 (0 minutes, 10 seconds)
0 errors, 0 warnings
after a makefilebased clean, when "normally" there is just a:
Quote
Cleaned "test - Debug"
Done.

To show the output of the make command should be possible, but I think it should only happen when full commandline logging is turned on.

And when normally only a task description is logged, this should also happen for makefile-based projects.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9614
Re: Improvement of custom makefiles - patch to test
« Reply #9 on: January 23, 2009, 03:58:40 pm »
Here's the (hopefully) last version of the patch.
I have compiled several projects now with the patch applied - no issues. This includes a custom makefile project and build/rebuild (thus, clean) processes.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #10 on: January 23, 2009, 08:00:04 pm »
Another day, another patch.

This one takes care of compile logging settings (Full commandline etc.) as good as possible.

Therefore I added another command on the build options "Make" commands tab.

I also hide the distclean command, because it is not used as far as I see.

[attachment deleted by admin]

Offline grischka

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Improvement of custom makefiles - patch to test
« Reply #11 on: January 23, 2009, 10:21:34 pm »
Nice.  Two notes:
- Clean doesn't print the make command.
- The code below is maybe not what you want:
Code
		case bsProjectPreBuild: return bsTargetPreBuild;
{
if (clean && !build)
{
return bsTargetClean;
}
return bsTargetPreBuild;
}

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #12 on: January 27, 2009, 12:11:33 am »
Nice.  Two notes:
- Clean doesn't print the make command.
- The code below is maybe not what you want:
Code
		case bsProjectPreBuild: return bsTargetPreBuild;
{
if (clean && !build)
{
return bsTargetClean;
}
return bsTargetPreBuild;
}


You are right, the code inside the curly braces is never reached, and is not needed at all.

Thanks for pointing it out.

If there are no objections from the other devs, I will apply the patch the next days, most likely tomorrow.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9614
Re: Improvement of custom makefiles - patch to test
« Reply #13 on: January 27, 2009, 07:22:04 am »
If there are no objections from the other devs, I will apply the patch the next days, most likely tomorrow.
As I said: No issues here - looks fine. I'd close the patch in the patch tracker afterwards...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Improvement of custom makefiles - patch to test
« Reply #14 on: January 27, 2009, 09:48:49 pm »
Committed !

SVN revision 5421