Add |set -o errexit| to *makefiles.sh to abort the build on errors rather than just hiding them

RESOLVED FIXED in mozilla11

Status

()

Core
Build Config
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: emorley, Assigned: emorley)

Tracking

Trunk
mozilla11
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
As suggested by Joey, to avoid typos such as that fixed by bug 698526 slipping through again, we should ensure the *makefiles.sh scripts bail with a non-zero exit code and thus abort the build, if something goes awry.

http://www.davidpashley.com/articles/writing-robust-shell-scripts.html says we can do this with |set -e| or |set -o errexit|. I prefer the latter since it's more readable.
(Assignee)

Comment 1

6 years ago
Created attachment 575716 [details] [diff] [review]
Patch v1

|set -o errexit| is set for all scripts from that point onwards, so has to be turned off at the end of allmakefiles.sh, otherwise multiple places in the rest of configure will error out (eg: the |mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null| line shortly after allmakefile.sh is executed, and many more).
Attachment #575716 - Flags: review?(khuey)
(Assignee)

Comment 2

6 years ago
Meant to say, deliberately making a typo in services/makefiles.sh with this patch applied, correctly gives:
{
../inbound/services/makefiles.sh: line 56: add_FOOmakefiles: command not found
*** Fix above errors and then restart with               "c:/mozilla-build/python/python.exe c:/mozilla/repos/inbound/build/pymake/pymake/../make.py -f client.mk build"
c:\mozilla\repos\inbound\client.mk:315:0: command 'cd . &&   ../inbound/configure  \
  || ( echo "*** Fix above errors and then restart with\
               \"c:/mozilla-build/python/python.exe c:/mozilla/repos/inbound/build/pymake/pymake/../make.py -f client.mk build\"" && exit 1 )' failed, return code 1
c:\mozilla\repos\inbound\client.mk:327:0: command 'c:/mozilla-build/python/python.exe c:/mozilla/repos/inbound/build/pymake/pymake/../make.py -f ../inbound/client.mk configure' failed, return code 2
c:\mozilla\repos\inbound\client.mk:174:0: command 'c:/mozilla-build/python/python.exe c:/mozilla/repos/inbound/build/pymake/pymake/../make.py -f ../inbound/client.mk realbuild' failed, return code 2
}
Comment on attachment 575716 [details] [diff] [review]
Patch v1

Review of attachment 575716 [details] [diff] [review]:
-----------------------------------------------------------------

Is this going to make the "people remove a directory from tree but leave it in *-makefiles.sh" case error out?
Attachment #575716 - Flags: review?(khuey) → review+
(Assignee)

Comment 4

6 years ago
It shouldn't, since errexit will be turned off at the end of allmakefiles.sh, before configure calls http://mxr.mozilla.org/mozilla-central/source/build/autoconf/acoutput-fast.pl#174

Do you want it to?
I don't really care either way, I was just curious.
(Assignee)

Comment 6

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/0f4282490c81
Flags: in-testsuite-
Target Milestone: --- → mozilla11
https://hg.mozilla.org/mozilla-central/rev/0f4282490c81
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.