FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bug: build always return success

 
Post new topic   Reply to topic     Forum Index -> Build
View previous topic :: View next topic  
Author Message
barrett9h



Joined: 02 May 2005
Posts: 26
Location: Brazil

PostPosted: Wed Jun 08, 2005 9:13 pm    Post subject: bug: build always return success Reply with quote

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
View user's profile Send private message MSN Messenger
barrett9h



Joined: 02 May 2005
Posts: 26
Location: Brazil

PostPosted: Wed Jun 08, 2005 9:19 pm    Post subject: stdout, stderr Reply with quote

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
View user's profile Send private message MSN Messenger
barrett9h



Joined: 02 May 2005
Posts: 26
Location: Brazil

PostPosted: Wed Jun 08, 2005 9:22 pm    Post subject: Reply with quote

Sorry, that last one is actually dmd's fault.
Back to top
View user's profile Send private message MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Wed Jun 08, 2005 11:33 pm    Post subject: Re: bug: build always return success Reply with quote

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
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Wed Jun 08, 2005 11:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
barrett9h



Joined: 02 May 2005
Posts: 26
Location: Brazil

PostPosted: Thu Jun 09, 2005 6:25 am    Post subject: found the problem Reply with quote

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
View user's profile Send private message MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Thu Jun 09, 2005 6:56 am    Post subject: Re: found the problem Reply with quote

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
View user's profile Send private message
barrett9h



Joined: 02 May 2005
Posts: 26
Location: Brazil

PostPosted: Thu Jun 09, 2005 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Thu Jun 09, 2005 4:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Build All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group