Skip to content

Commit

Permalink
Merge pull request #1049 from drush-ops/make-pipe-buffer
Browse files Browse the repository at this point in the history
Reduces pipe buffer size for Drush Make
  • Loading branch information
jhedstrom committed Dec 23, 2014
2 parents 2a26a14 + a4e1e47 commit 763fad5
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions commands/make/make.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ function make_drush_command() {
'directory' => 'The temporary working directory to use',
),
'options' => array(
'projects' => 'An array of projects generated by make_projects()',
'manifest' => 'An array of projects already being processed',
'projects-location' => 'Name of a temporary file containing json-encoded output of make_projects().',
'manifest' => 'An array of projects already being processed.',
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'engines' => array('release_info'),
Expand Down Expand Up @@ -241,14 +241,19 @@ function drush_make($makefile = NULL, $build_path = NULL) {

/**
* Drush callback: hidden file to process an individual project.
*
* @param string $directory
* Directory where the project is being built.
*/
function drush_make_process($directory) {
$release_info = drush_get_engine('release_info');
drush_get_engine('release_info');

// Set the temporary directory.
make_tmp(TRUE, $directory);
$projects = drush_get_option('projects', array());

if (!$projects_location = drush_get_option('projects-location')) {
return drush_set_error('MAKE-PROCESS', dt('No projects passed to drush_make_process'));
}
$projects = json_decode(file_get_contents($projects_location), TRUE);
$manifest = drush_get_option('manifest', array());

foreach ($projects as $project) {
Expand Down Expand Up @@ -480,6 +485,10 @@ function make_projects($recursion, $contrib_destination, $info, $build_path, $ma
'method' => 'POST',
);

// Store projects in temporary files since passing this much data on the
// pipe buffer can break on certain systems.
_make_write_project_json($invocations);

$common_options = drush_redispatch_get_options();
// Merge in stdin options since we process makefiles recursively. See http://drupal.org/node/1510180.
$common_options = array_merge($common_options, drush_get_context('stdin'));
Expand All @@ -504,6 +513,22 @@ function make_projects($recursion, $contrib_destination, $info, $build_path, $ma
return TRUE;
}

/**
* Writes out project data to temporary files.
*
* @param array &$invocations
* An array containing projects sorted by thread.
*/
function _make_write_project_json(array &$invocations) {
foreach ($invocations as $thread => $info) {
$projects = $info['options']['projects'];
unset($invocations[$thread]['options']['projects']);
$temp_file = drush_tempnam('make_projects');
file_put_contents($temp_file, json_encode($projects));
$invocations[$thread]['options']['projects-location'] = $temp_file;
}
}

/**
* Gather additional data on all libraries specified in the make file.
*/
Expand Down

0 comments on commit 763fad5

Please sign in to comment.