diff --git a/situs.drush.inc b/situs.drush.inc index 27cbad2..2ad5079 100644 --- a/situs.drush.inc +++ b/situs.drush.inc @@ -13,6 +13,7 @@ function situs_drush_command() { $options = array( 'root' => 'The root of the site to build.', 'make-file' => 'The make file to use for building.', + 'make-*' => 'Settings to pass on to drush make, "make-" will be strippe off. Eg make-concurrency will set the concurrency flag.', 'save-files' => 'Comma-separated list of files to save when rebuilding.', ); foreach (situs_plugins() as $info) { @@ -109,10 +110,14 @@ function drush_situs_build($alias = '') { return FALSE; } - $settings = array( + $make_options = array( 'working-copy' => TRUE, ); - $res = drush_invoke_process('@self', 'make', array($makefile, $build_path), $settings, TRUE); + + // Add in custom settings. + $make_options += _situs_get_custom_make_options(); + + $res = drush_invoke_process('@self', 'make', array($makefile, $build_path), $make_options, TRUE); if (!$res || $res['error_status'] != 0) { return drush_set_error('BUILD_FAILED', dt('Drush Make failed.')); @@ -403,6 +408,39 @@ function situs_git_pre_build() { } /** + * Returns an array of options supplied via make-* options. + * + * "make-file" is a special case and is excluded. + */ +function _situs_get_custom_make_options() { + // We are not checking a specific context, so check them in a predefined order + // of precedence. + $contexts = drush_context_names(); + $make_options = array(); + foreach ($contexts as $context_name) { + $context = drush_get_context($context_name); + + foreach ($context as $key => $value) { + // We're looking for variables prefixed with "make-" (except for + // make-file). + if ($key != 'make-file' && strpos($key, 'make-') === 0) { + + // Strip off the prefix. + $option_key = substr($key, strlen('make-')); + + // We're going through the contexts in prioritized order, so first in + // wins. + if (!isset($make_options[$option_key])) { + $make_options[$option_key] = $value; + } + } + } + } + + return $make_options; +} + +/** * */ function situs_drush_pre_build() {