mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Expose build-dir config option (#36773)
This commit is contained in:
parent
6e963b9985
commit
15e322c0e5
@ -6,6 +6,8 @@ import 'dart:async';
|
||||
|
||||
import '../android/android_sdk.dart';
|
||||
import '../android/android_studio.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../convert.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart';
|
||||
@ -24,6 +26,8 @@ class ConfigCommand extends FlutterCommand {
|
||||
argParser.addOption('gradle-dir', help: 'The gradle install directory.');
|
||||
argParser.addOption('android-sdk', help: 'The Android SDK directory.');
|
||||
argParser.addOption('android-studio-dir', help: 'The Android Studio install directory.');
|
||||
argParser.addOption('build-dir', help: 'The relative path to override a projects build directory',
|
||||
valueHelp: 'out/');
|
||||
argParser.addFlag('machine',
|
||||
negatable: false,
|
||||
hide: !verboseHelp,
|
||||
@ -128,6 +132,14 @@ class ConfigCommand extends FlutterCommand {
|
||||
if (argResults.wasParsed('clear-ios-signing-cert'))
|
||||
_updateConfig('ios-signing-cert', '');
|
||||
|
||||
if (argResults.wasParsed('build-dir')) {
|
||||
final String buildDir = argResults['build-dir'];
|
||||
if (fs.path.isAbsolute(buildDir)) {
|
||||
throwToolExit('build-dir should be a relative path');
|
||||
}
|
||||
_updateConfig('build-dir', buildDir);
|
||||
}
|
||||
|
||||
for (Feature feature in allFeatures) {
|
||||
if (feature.configSetting == null) {
|
||||
continue;
|
||||
|
@ -7,9 +7,11 @@ import 'dart:convert';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/config.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/config.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
@ -53,6 +55,28 @@ void main() {
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
});
|
||||
|
||||
testUsingContext('Can set build-dir', () async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
|
||||
|
||||
await commandRunner.run(<String>[
|
||||
'config',
|
||||
'--build-dir=foo'
|
||||
]);
|
||||
|
||||
expect(getBuildDirectory(), 'foo');
|
||||
});
|
||||
|
||||
testUsingContext('throws error on absolute path to build-dir', () async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
|
||||
|
||||
expect(() => commandRunner.run(<String>[
|
||||
'config',
|
||||
'--build-dir=/foo'
|
||||
]), throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
testUsingContext('allows setting and removing feature flags', () async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
|
||||
|
Loading…
Reference in New Issue
Block a user