Code::Blocks Forums

User forums => Help => Topic started by: colin on March 17, 2014, 04:36:16 pm

Title: Replacing compiler settings with a build script?
Post by: colin on March 17, 2014, 04:36:16 pm
Our company is using Python to check out files from svn and compile in a single step, which also provides arguments for selecting linux destop or a cross-compiler target.
I need to be able to disable Code::Blocks from trying to use GCC or any other compiler and just execute the company script to build the executable target.

I don't want Code::Blocks to use any compiler or makefile but just run the script, put the output into the Build log window and know where the target executable is for debugging, which does currently work when I run the script via a pre-step.
Everything I've tried from saying (*no compiler*) to clearing out makefile settings has failed.

Is there any way to do this?
Title: Re: Replacing compiler settings with a build script?
Post by: stahta01 on March 17, 2014, 05:35:04 pm
Have you tried setting the "Build Target" to command only?

Edit:
Project -> Properties
Tab "Build Target"
Type: "command only"

Tim S.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 17, 2014, 08:24:24 pm
Do
1. Project -> Properties -> This is a custom Makefile -> check it
2. Project -> Build options -> Make commands -> edit the commands for build/clean/rebuild
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 18, 2014, 09:01:32 am
Thanks for quick reply, I have tried both of these options but Code::Blocks still tries to use gcc to compile each file, even with a custom makefile.
It would seem the option (*no compiler*) is less than useless as it doesnt allow a build when set.

Also the Build log window no longer produces any output until the whole process is complete, and as a complete build could take 30 minutes that's not particularly helpful.

Is there any way to get the output window to produce anything with custom make so I can debug and see what is going on?
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 18, 2014, 09:07:57 am
Do you see your python script being executed in the log?
If not then you've not setup custom makefile!
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 18, 2014, 09:19:48 am
I've proven that the custom makefile is executing the script as it's producing a binary, and i can delete that binary and use Code::Blocks to generate it with the custom makefile.
I get no output in my build log window from the custom makefile execution, and it still tries to run a GCC compile after the custom makefile saying Target is up to date.

When I tried to do this before as a pre-step I could see output from my script in the Build log.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 18, 2014, 09:55:37 am
Can you show the log?
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 18, 2014, 10:17:19 am
This is all I see...

-------------- Build: Debug in proj.cb.linux_project (compiler: GNU GCC Compiler)---------------

Target is up to date.
Nothing to be done (all items are up-to-date).



When the Build line appears it sits there for a while running my script, then later the message Target is up to date appears.
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 21, 2014, 01:48:25 pm
Due to lack of activity we have abandonded code::blocks and switched to Eclipse for now.
I will keep an eye on this to see if anyone has anything to add.

Thanks so far for all your suggestions.


Colin.
Title: Re: Replacing compiler settings with a build script?
Post by: BlueHazzard on March 21, 2014, 05:11:35 pm
this seems as you didn't have configured your project right...
can you try to make a rebuild (the circle arrow or Build->Rebuild) and post the full build log (if the project is configured right this should not work ;) )?

greetings
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 22, 2014, 10:55:23 am
In fact there seems to be some kind of a problem with this.  :-\
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 22, 2014, 12:02:52 pm
OK, I've found it. You have to properly implement the "Ask rebuild" command to return 1 (or non-zero) value, in order to make build/rebuild work.

This is what make does:
Quote
       -q, --question
            ``Question mode''.  Do not run any commands, or print anything; just return an exit status that is zero if the specified targets are already up to date, nonzero otherwise.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 22, 2014, 03:37:57 pm
I've tried to improve the logging in the latest trunk version, so if you have time you can check it out.
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 24, 2014, 12:24:45 pm
Thanks everyone again, I will make some time this week to look into this further.
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 25, 2014, 10:22:17 am
Okay I just can't face dealing with nightly again, last time I had to hunt forums and try and find some reply somewhere for an ubuntu build.
We have even had other people here try and do the same and find exactly the same problems as I did.
"How to use Nightly" doesn't actually help to use nightly, so I think for now I will just have to abandon using Code::Blocks until I can face it again.

Thanks for help so far though, I just can't put myself through that again...
Title: Re: Replacing compiler settings with a build script?
Post by: BlueHazzard on March 25, 2014, 12:03:50 pm
it would be nice if you let us to help you. Some more detail about the problem?
There were also some ppa with nightlies, but they aren't updated since quite some time...
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 25, 2014, 08:15:26 pm
You don't need newer builds to make things work. I've just added more logging. 13.12 is perfectly fine and could do the job.
Title: Re: Replacing compiler settings with a build script?
Post by: stahta01 on March 25, 2014, 08:28:36 pm
You don't need newer builds to make things work. I've just added more logging. 13.12 is perfectly fine and could do the job.

I found a possible problem; setting compiler to "No Compiler" fails to work on my suggestion of command only.
It works great with the mingw gcc as the compiler; but, it does give the nothing to be done message.

Code
Running target pre-build steps
CMD /c dir
 Volume in drive E is Backup
 Volume Serial Number is 2A96-F81C
 Directory of E:\OpenSourceCode\Test\script_only
03/25/2014  03:23 PM    <DIR>          .
03/25/2014  03:23 PM    <DIR>          ..
03/25/2014  03:23 PM             1,019 script_only.cbp
               1 File(s)          1,019 bytes
               2 Dir(s)   1,312,088,064 bytes free

-------------- Build: script in script_only (compiler: GNU GCC Compiler)---------------

Target is up to date.
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Attached my cbp projects 7zipped.
custom Makefile also fails if "no compiler" is used.

All this tested on CB 13.12 running on Windows 7 32-bit

Tim S.


[attachment deleted by admin]
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 25, 2014, 08:47:23 pm
Hm, are you sure you've archived the correct project. I see simple gcc based project.
Title: Re: Replacing compiler settings with a build script?
Post by: stahta01 on March 25, 2014, 08:50:02 pm
Hm, are you sure you've archived the correct project. I see simple gcc based project.

I attached the one(s) that works; not the one(s) that fails.
Just change the compiler to no compiler and it fails to work under CB 13.12.

I attached a custom makefile using "no compile" to this message.

Code
"makefile_only_bad - make_only": The compiler's setup (*No Compiler*) is invalid, so Code::Blocks cannot find/run the compiler.
Probably the toolchain path within the compiler options is not setup correctly?! (Do you have a compiler installed?)
Goto "Settings->Compiler...->Global compiler settings->*No Compiler*->Toolchain executables" and fix the compiler's setup.
Skipping...
Nothing to be done (all items are up-to-date).

Tim S.
Title: Re: Replacing compiler settings with a build script?
Post by: stahta01 on March 25, 2014, 09:10:26 pm
Do you see your python script being executed in the log?
If not then you've not setup custom makefile!

Or his python script does NOT do output to stdout or stderr.

Does CB display both stdout and stderr?

My testing seem to implies that it does on Windows 7.

Tim S.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 25, 2014, 09:13:19 pm
Yes it does display both stdout and stderr.

But you've made the same mistake as colin - the ask for rebuild command is empty, it must be set and it must return proper value (0 or 1). C::B uses it to see if there is something to build or not.

edit: I've not looked at the reported error. It is invalid on my machine, too, but this is to be expected. Probably Alpha should comment when *No compiler* should be used. I think he has added it.
Title: Re: Replacing compiler settings with a build script?
Post by: stahta01 on March 25, 2014, 09:18:09 pm
Yes it does display both stdout and stderr.

But you've made the same mistake as colin - the ask for rebuild command is empty, it must be set and it must return proper value (0 or 1). C::B uses it to see if there is something to build or not.

edit: I've not looked at the reported error. It is invalid on my machine, too, but this is to be expected. Probably Alpha should comment when *No compiler* should be used. I think he has added it.

It works with the value empty on windows 7 32 bit.

Tim S.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on March 25, 2014, 09:27:24 pm
Hm, it works on linux, too.
Title: Re: Replacing compiler settings with a build script?
Post by: colin on March 27, 2014, 04:55:38 pm
The script always output to stdout and stderr, and works fine when as a pre-step.
I have finally reduced my backlog so I will make some time next week to look at this further as I personally prefer Code::Blocks to Eclipse.

Thanks again everyone so far for feedback, I should have more time from Monday to continue looking into this problem.


UPDATE:
I'm currently not able to look into this any further as the business is not allowing any extra time to proceed with solving this problem, so I will have to try and deal with this is my own time.

Colin.
Title: Re: Replacing compiler settings with a build script?
Post by: colin on April 15, 2014, 11:35:04 am
Okay I'm back on looking at this today and tomorrow, but I'm curious why the IDE should care about asking for rebuild?
I shouldn't care or want the IDE to check for this if all of that checking is done using an external script, I just want to IDE to assume it will build every time and let the script skip whatever it wants.

Anyway I will re-read the comments left behind since I looked at this last time and provide any new information.

Thanks,
Colin.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on April 15, 2014, 07:51:44 pm
Probably to print a user friendly message like "Program is up-to-date" or something similar.
Title: Re: Replacing compiler settings with a build script?
Post by: cartographer on April 21, 2014, 08:49:01 pm
I was having a similar issue and came up with a work-around, so I figured I would share.

In my case I did the following:
Compiler Settings -> Copy GCC -> Name it something
Select the new compiler -> Toolchain Executables and set the following (excluding quotes):

Compiler's Installation Directory: "/"
C, C++, Dynamic Linker, Static Linker, Make Program: "true" (aka "true(1): do nothing, successfully")

Then I just made a new build target set to "Commands only" and set it to use the new compiler. That is to say, all I really did was set the compiler to a program that does nothing, for my linux distribution it was the executable true located in my root bin directory. If you don't have such a program you can easily make one, just compile "int main() {return 0;}". Note that for some reason if I just changed the toolchain for the built-in "* No Compiler *" codeblocks would just crash when I tried to compile, I had to duplicate an existing compiler for some reason. Hope this helps.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on April 22, 2014, 09:02:09 pm
cartographer: Can you post the exact steps needed to make C::B crash?
Title: Re: Replacing compiler settings with a build script?
Post by: cartographer on April 24, 2014, 05:29:34 pm
cartographer: Can you post the exact steps needed to make C::B crash?
Sure, I've also attached the debug report generated when it crashes. Using Lubuntu 14.04 LTS and code::blocks 13.12.

Steps:
File->New->Project->Console application
Language: C++
Compiler: *No Compiler* (reset to default settings)

Settings->Compiler..->*No Compiler*->Toolchain executables
Options: See attached toolchain.png

Build->Build (crash here)


[attachment deleted by admin]
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on April 25, 2014, 11:33:03 pm
Reproduced.
The problem happens, because the code expects that there is at least on program in the m_Commands member variable of the compiler, but for options_null.xml there are none.

@Alpha: Any idea how to fix this problem?

This is the problematic method: const CompilerTool& Compiler::GetCompilerTool(CommandType ct, const wxString& fileExtension) const
Returning a reference here is pretty bad and most of the times it is used as a pointer.
Title: Re: Replacing compiler settings with a build script?
Post by: oBFusCATed on April 26, 2014, 04:23:37 pm
Should be fixed in trunk...