[Buildbot] #839: shell.Compile should invoke platform-specific compilation method
Buildbot trac
trac at buildbot.net
Sat Nov 22 09:16:05 UTC 2014
#839: shell.Compile should invoke platform-specific compilation method
-----------------------------+--------------------
Reporter: tfogal | Owner:
Type: enhancement | Status: new
Priority: patches-accepted | Milestone: 0.9.+
Version: 0.8.0 | Resolution:
Keywords: sprint |
-----------------------------+--------------------
Changes (by sa2ajj):
* priority: minor => patches-accepted
Old description:
> It would be nice if shell.Compile would invoke a platform-specific build
> method. This is particularly relevant on win32, where `make all` is
> rarely the correct thing to do.
>
> That said, it is sometimes the correct thing to do, so I guess this needs
> to be configurable.
>
> I wrote something similar to handle the same problem at a higher level.
> I call it `Demux`; it is a `ShellCommand` which has kwargs for platform-
> specific behavior. This allows one to use a single step, and thus a
> single builder, even when there are minor platform differences. Here's
> an example use:
>
> {{{
> bundle = Demux(mac=["sh", "Scripts/mk_app.sh"],
> linux=["sh", "Scripts/mk_tarball.sh"],
> windows=["iscc", "Scripts/installer/64.iss"],
> description=["bundle"],
> descriptionDone=["bundling"])
> }}}
>
> You can then `fac.addStep(bundle)`, and it will do the correct per-
> platform behavior. You could also say `posix=...` and omit the `mac` and
> `linux` arguments.
>
> The class is pretty simple:
>
> {{{
> class Demux(shell.ShellCommand):
> """A Demux is a shell command that takes arguments for different
> platform
> types. For example:
> d = Demux(mac=["sh", "Scripts/bundle.sh"],
> linux=["sh", "Scripts/tarball.sh"],
> windows=["iscc", "Scripts/pkg.iss"])
> """
> def __init__(self, posix=None, mac=None, linux=None, windows=None,
> **kwargs):
> if posix is not None:
> mac = posix
> linux = posix
>
> # No checking. It's valid for any arguments to be None; this
> provides a
> # convenient mechanism to have a build step that is defined on all
> # platforms, but a no-op on some of them.
> if mac is None and linux is None and windows is None:
> raise TypeError("Demux is a no-op on all platforms. Just remove
> it.")
>
> shell.ShellCommand.__init__(self, **kwargs)
> self.addFactoryArguments(mac=mac, linux=linux, windows=windows)
> self._mac = mac
> self._linux = linux
> self._windows = windows
>
> def start(self):
> self.setCommand(["echo", "no-op"]) # default command is a no-op
>
> if self.getProperty("os") == "Darwin" and self._mac is not None:
> self.setCommand(self._mac)
> elif self.getProperty("os") == "Linux" and self._linux is not None:
> self.setCommand(self._linux)
> elif self._windows is not None:
> self.setCommand(self._windows)
> shell.ShellCommand.start(self)
> }}}
>
> As you can see, it relies on a property "os" which I set to the output of
> `uname` in earlier build steps. Well, except on windows:
>
> {{{shell.SetProperty(command="echo windows", property="os")}}}
>
> =)
>
> In the short term, I guess I can reuse this for compilation. It would be
> nice if a similar approach could be taken for `Compile`, though.
New description:
It would be nice if shell.Compile would invoke a platform-specific build
method. This is particularly relevant on win32, where `make all` is
rarely the correct thing to do.
That said, it is sometimes the correct thing to do, so I guess this needs
to be configurable.
I wrote something similar to handle the same problem at a higher level. I
call it `Demux`; it is a `ShellCommand` which has kwargs for platform-
specific behavior. This allows one to use a single step, and thus a
single builder, even when there are minor platform differences. Here's an
example use:
{{{
bundle = Demux(mac=["sh", "Scripts/mk_app.sh"],
linux=["sh", "Scripts/mk_tarball.sh"],
windows=["iscc", "Scripts/installer/64.iss"],
description=["bundle"],
descriptionDone=["bundling"])
}}}
You can then `fac.addStep(bundle)`, and it will do the correct per-
platform behavior. You could also say `posix=...` and omit the `mac` and
`linux` arguments.
The class is pretty simple:
{{{
class Demux(shell.ShellCommand):
"""A Demux is a shell command that takes arguments for different
platform
types. For example:
d = Demux(mac=["sh", "Scripts/bundle.sh"],
linux=["sh", "Scripts/tarball.sh"],
windows=["iscc", "Scripts/pkg.iss"])
"""
def __init__(self, posix=None, mac=None, linux=None, windows=None,
**kwargs):
if posix is not None:
mac = posix
linux = posix
# No checking. It's valid for any arguments to be None; this provides
a
# convenient mechanism to have a build step that is defined on all
# platforms, but a no-op on some of them.
if mac is None and linux is None and windows is None:
raise TypeError("Demux is a no-op on all platforms. Just remove
it.")
shell.ShellCommand.__init__(self, **kwargs)
self.addFactoryArguments(mac=mac, linux=linux, windows=windows)
self._mac = mac
self._linux = linux
self._windows = windows
def start(self):
self.setCommand(["echo", "no-op"]) # default command is a no-op
if self.getProperty("os") == "Darwin" and self._mac is not None:
self.setCommand(self._mac)
elif self.getProperty("os") == "Linux" and self._linux is not None:
self.setCommand(self._linux)
elif self._windows is not None:
self.setCommand(self._windows)
shell.ShellCommand.start(self)
}}}
As you can see, it relies on a property "os" which I set to the output of
`uname` in earlier build steps. Well, except on windows:
{{{shell.SetProperty(command="echo windows", property="os")}}}
=)
In the short term, I guess I can reuse this for compilation. It would be
nice if a similar approach could be taken for `Compile`, though.
--
--
Ticket URL: <http://trac.buildbot.net/ticket/839#comment:5>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation
More information about the bugs
mailing list