View previous topic :: View next topic |
Author |
Message |
barrett9h
Joined: 02 May 2005 Posts: 26 Location: Brazil
|
Posted: Wed Jun 08, 2005 9:13 pm Post subject: bug: build always return success |
|
|
The build tool does not return with an error if the target could not be built.
It makes it harder to integrate in other environments: make, shell scripts, command line, etc.
For example, the following (shell command) does not work:
$ build program && ./program |
|
Back to top |
|
|
barrett9h
Joined: 02 May 2005 Posts: 26 Location: Brazil
|
Posted: Wed Jun 08, 2005 9:19 pm Post subject: stdout, stderr |
|
|
Also, errors should go to stderr.
They are currently going to stdout, along with the normal output.
(I learned that when trying to workaround the previous mentioned bug..) |
|
Back to top |
|
|
barrett9h
Joined: 02 May 2005 Posts: 26 Location: Brazil
|
Posted: Wed Jun 08, 2005 9:22 pm Post subject: |
|
|
Sorry, that last one is actually dmd's fault. |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Wed Jun 08, 2005 11:33 pm Post subject: Re: bug: build always return success |
|
|
barrett9h wrote: | The build tool does not return with an error if the target could not be built.
It makes it harder to integrate in other environments: make, shell scripts, command line, etc.
For example, the following (shell command) does not work:
$ build program && ./program |
It works in Windows. It returns zero if it succeeds, otherwise a non-zero value.
Can you give me an example where it returned zero on a failure? _________________ --
Derek
skype name: derek.j.parnell
Last edited by Derek Parnell on Wed Jun 08, 2005 11:50 pm; edited 1 time in total |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Wed Jun 08, 2005 11:36 pm Post subject: |
|
|
barrett9h wrote: | Sorry, that last one is actually dmd's fault. |
No problems.
All the 'error' messages are being sent out by throwing an exception. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
barrett9h
Joined: 02 May 2005 Posts: 26 Location: Brazil
|
Posted: Thu Jun 09, 2005 6:25 am Post subject: found the problem |
|
|
The problem was that (in unix?) only the lowest byte of the return code is accounted for.
Build was returning 256, so it was interpreted (rc & 0xff) as zero.
I changed the end of main() from
Code: | return lBuildResult; |
to
Code: | return (lBuildResult != 0); |
and it worked.
It's not the ideal solution, as it looses the (maybe useful) distiction between different kinds of errors on the return code.
Can all the errors code be kept under 256? |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Thu Jun 09, 2005 6:56 am Post subject: Re: found the problem |
|
|
barrett9h wrote: | The problem was that (in unix?) only the lowest byte of the return code is accounted for.
Build was returning 256, so it was interpreted (rc & 0xff) as zero.
I changed the end of main() from
Code: | return lBuildResult; |
to
Code: | return (lBuildResult != 0); |
and it worked.
It's not the ideal solution, as it looses the (maybe useful) distiction between different kinds of errors on the return code.
Can all the errors code be kept under 256? |
There are no error return codes generated by Build itself. It only returns whatever is returned by the system() call.
Can you try changing the return code to
Code: |
return (lBuildResult & 255);
|
That should remove values above 255.
And can you run it with the -V switch. I'm curious to see the verbose message line that starts "Failed. Return code: "
If this works for you, I'll make it permanent. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
barrett9h
Joined: 02 May 2005 Posts: 26 Location: Brazil
|
Posted: Thu Jun 09, 2005 9:05 am Post subject: |
|
|
The system() call return the return code on the second byte. The correct way is to right shift it eight bits.
(I remembered it while riding my bike to the work place now..) |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Thu Jun 09, 2005 4:06 pm Post subject: |
|
|
barrett9h wrote: | The system() call return the return code on the second byte. The correct way is to right shift it eight bits.
(I remembered it while riding my bike to the work place now..) |
Well that complicates it a bit;-)
Ok, rather than change the lBuildResult in main(), go to the function called "RunCommand" and after the line ...
Code: |
lRC = system(std.string.toStringz(pCommand));
|
add this line ...
Code: |
version(Posix) lRC = ((lRC & 0xFF00) >> 8); // Pluck out the real return value.
|
and let me know how it goes. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
|