@@ -61,6 +61,8 @@ final class CommandHelper
6161 private const OPTION_SKIP_ENABLE_EXTENSION = 'skip-enable-extension ' ;
6262 private const OPTION_FORCE = 'force ' ;
6363 private const OPTION_NO_CACHE = 'no-cache ' ;
64+ private const OPTION_AUTO_INSTALL_BUILD_TOOLS = 'auto-install-build-tools ' ;
65+ private const OPTION_SUPPRESS_BUILD_TOOLS_CHECK = 'no-build-tools-check ' ;
6466
6567 private function __construct ()
6668 {
@@ -139,6 +141,19 @@ public static function configureDownloadBuildInstallOptions(Command $command, bo
139141 'When installing a PHP project, allow non-interactive project installations. Only used in certain contexts. ' ,
140142 );
141143
144+ $ command ->addOption (
145+ self ::OPTION_AUTO_INSTALL_BUILD_TOOLS ,
146+ null ,
147+ InputOption::VALUE_NONE ,
148+ 'If build tools are missing, automatically install them, instead of prompting. ' ,
149+ );
150+ $ command ->addOption (
151+ self ::OPTION_SUPPRESS_BUILD_TOOLS_CHECK ,
152+ null ,
153+ InputOption::VALUE_NONE ,
154+ 'Do not perform the check to see if build tools are present on the system. ' ,
155+ );
156+
142157 /**
143158 * Allows additional options for the `./configure` command to be passed here.
144159 * Note, this means you probably need to call {@see self::validateInput()} to validate the input manually...
@@ -233,6 +248,22 @@ public static function determineForceInstallingPackageVersion(InputInterface $in
233248 return $ input ->hasOption (self ::OPTION_FORCE ) && $ input ->getOption (self ::OPTION_FORCE );
234249 }
235250
251+ public static function autoInstallBuildTools (InputInterface $ input ): bool
252+ {
253+ return $ input ->hasOption (self ::OPTION_AUTO_INSTALL_BUILD_TOOLS )
254+ && $ input ->getOption (self ::OPTION_AUTO_INSTALL_BUILD_TOOLS );
255+ }
256+
257+ public static function shouldCheckForBuildTools (InputInterface $ input ): bool
258+ {
259+ if (Platform::isWindows ()) {
260+ return false ;
261+ }
262+
263+ return ! $ input ->hasOption (self ::OPTION_SUPPRESS_BUILD_TOOLS_CHECK )
264+ || ! $ input ->getOption (self ::OPTION_SUPPRESS_BUILD_TOOLS_CHECK );
265+ }
266+
236267 public static function determinePhpizePathFromInputs (InputInterface $ input ): PhpizePath |null
237268 {
238269 if ($ input ->hasOption (self ::OPTION_WITH_PHPIZE_PATH )) {
0 commit comments