Opened 9 years ago

Last modified 4 years ago

#839 new enhancement

shell.Compile should invoke platform-specific compilation method

Reported by: tfogal Owned by:
Priority: patches-accepted Milestone: 0.9.+
Version: 0.8.0 Keywords: sprint
Cc: kovarththanan.rajaratnam@…

Description (last modified by sa2ajj)

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/"],
               linux=["sh", "Scripts/"],
               windows=["iscc", "Scripts/installer/64.iss"],

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/"],
                  linux=["sh", "Scripts/"],
                  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:
    elif self.getProperty("os") == "Linux" and self._linux is not None:
    elif self._windows is not None:

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.

Change History (5)

comment:1 Changed 9 years ago by dustin

I think that Compile is pretty well specialized to its current structure. However, this is an excellent use of a custom build step. Even in your case, I think this is fairly specific to your use-case: others would want a different notion of OS, for example.

It might be interesting to see some more generic form, perhaps with a collection of sub-steps, and some way of deciding which step the parent should delegate to.

comment:2 Changed 8 years ago by krajaratnam

  • Cc kovarththanan.rajaratnam@… added

comment:3 Changed 7 years ago by dustin

  • Keywords sprint added

Now that we have more info about the slave available master-side, it may be interesting to re-visit this in a more generic form.

comment:4 Changed 5 years ago by dustin

  • Milestone changed from 0.8.+ to 0.9.+

Ticket retargeted after milestone closed

comment:5 Changed 4 years ago by sa2ajj

  • Description modified (diff)
  • Priority changed from minor to patches-accepted
Note: See TracTickets for help on using tickets.