Drush Make and Module Dependencies

Drush make is a wonderful tool for constructing Drupal platforms. A lot of Drupal developers are used to adding a list of modules, a few libraries and theme or 2 then running drush make to build their platform. It all seems pretty easy. What if I told you module developers could make things even easier for site builders?

Some contrib modules depend on third party libraries, and due to various reasons they can't always be stored in git repositories on drupal.org and included in the module release. To solve this problem module developers can include a .make file for their module. Drush recursively processes make files, so the module make file would be processed once found by drush make.

A good example of where this could be useful is the SMTP module, which depends on the LGPL licensed PHPMailer library. The module also requires a patch to be applied to the library, which drush make can apply for us. The following .make file could be included in the SMTP module as smtp.make:

core = 6.x
api = 2

libraries[phpmailer][download][type] = "get"
libraries[phpmailer][download][url] = "http://downloads.sourceforge.net/project/phpmailer/phpmailer%20for%20php5_6/Previous%20Versions/2.2.1/phpMailer_v2.2.1_.tar.gz"
libraries[phpmailer][download][md5] = "0bf75c1bcef8bde6adbebcdc69f1a02d"
libraries[phpmailer][directory_name] = "phpmailer"
libraries[phpmailer][destination] = "modules/contrib/smtp"

libraries[phpmailer][patch][drupal-compatibility][url] = "http://drupalcode.org/project/smtp.git/blob_plain/2acaba97adcad7304c22624ceeb009d358b596e3:/class.phpmailer.php.2.2.1.patch"
libraries[phpmailer][patch][drupal-compatibility][md5] = "2d82de03b1a4b60f3b69cc20fae61b76"

Now when the SMTP module is included a normal drush make file it will be downloaded, the PHPMailer library will be downloaded and patched ready for use.

Unfortunately there are some limitations to this approach. Firstly it assumes that the SMTP module will be installed under the modules/contrib directory, which is accepted best practice, but may not suit everyone's needs. When I tested this with the current stable version of drush make (6.x-2.2) it failed, and drush make 6.x-3.x from git needed to be patched. Hopefully a fix for this can be backported to the 6.x-2.x branch and included in a future release.

Update: I have posted the make file for the SMTP module as patch in issue #1159080.

drush_make isn't quite ready for this yet.

adrinux wrote:

While adding make files to modules which drush_make automatically includes and runs is a cool feature, when it breaks, it breaks horribly, causing the entire platform build to fail.

Worse, there are currently no workarounds, no way to override the broken bundled make file. The only way to fix your platform build is fork the problem module and patch the make file.

The same applies if you need to use a different version of the third party code specified in the bundled make file.

I look forward to a day when we can recommend module authors do this, but for the moment I've been advising module developers to name make files as "modulename.make.example" - the platform builder is then able to add the example code to their own make file and retains full control.

Here's a couple of issues that give a taste of what can go wrong: http://drupal.org/node/839580 http://drupal.org/node/1103872

Added Tue, 2011-05-17 03:05

Seems the problem is simply the inability to override?

patcon wrote:

Could drush_make's "includes" declaration be repurposed to work on the *.make.example files?

Or how does drush_make build the whole data structure when it finds sub-makefiles? Does it build each separately, or could it build the whole array first, so that the master makefile could declare a key afterward, overriding the sub-make's settings? (or nullifying them?)

Added Wed, 2011-05-18 03:45

"directory not empty", destination and directory_name

grobot wrote:

Hey Dave - ran into something which brought me here this evg. Have been adding Archimedes to a set of makefiles and found that doing similarly for the required lib would cause the build to fail.

Pointing a lib at a module folder by using destination + directory_name failed on Drush 4.5 for me with Directory not empty

; Archimedes module
projects[archimedes][type] = "module"
projects[archimedes][download][type] = "git"
projects[archimedes][download][directory_name] = "archimedes"
projects[archimedes][download][url] =  "http://git.drupal.org/sandbox/fiasco/1116808.git"
; Archimedes lib class
libraries[archimedes-class][destination] = "modules"
libraries[archimedes-class][directory_name] = "archimedes"
libraries[archimedes-class][download][type] = "file"
libraries[archimedes-class][download][url] = https://github.com/GiantRobot/Archimedes-Library/raw/master/php/archimed...

while combining the directory_name into the destination like this worked -

; Archimedes module
projects[archimedes][type] = "module"
projects[archimedes][download][type] = "git"
projects[archimedes][download][directory_name] = "archimedes"
projects[archimedes][download][url] =  "http://git.drupal.org/sandbox/fiasco/1116808.git"
; Archimedes lib class
libraries[archimedes-class][destination] = "modules/archimedes"
libraries[archimedes-class][download][type] = "file"
libraries[archimedes-class][download][url] = https://github.com/GiantRobot/Archimedes-Library/raw/master/php/archimed...
Added Sat, 2012-05-12 23:51

The same applies in the event

lisacooper wrote:

The same applies in the event that you have to utilize an alternate rendition of the outsider code defined in the packaged make document. Buy Pinterest Followers

Added Tue, 2014-07-29 01:33

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <div> <blockquote> <pre>

More information about formatting options