flutter/packages/flutter_tools/bin/tool_backend.dart
Ian Hickson 449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00

97 lines
3.6 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io'; // ignore: dart_io_import.
import 'package:path/path.dart' as path; // ignore: package_path_import.
/// Executes the required flutter tasks for a desktop build.
Future<void> main(List<String> arguments) async {
final String targetPlatform = arguments[0];
final String buildMode = arguments[1].toLowerCase();
final String projectDirectory = Platform.environment['PROJECT_DIR'];
final bool verbose = Platform.environment['VERBOSE_SCRIPT_LOGGING'] != null;
final bool trackWidgetCreation = Platform.environment['TRACK_WIDGET_CREATION'] != null;
final String flutterTarget = Platform.environment['FLUTTER_TARGET'] ?? path.join('lib', 'main.dart');
final String flutterEngine = Platform.environment['FLUTTER_ENGINE'];
final String localEngine = Platform.environment['LOCAL_ENGINE'];
final String flutterRoot = Platform.environment['FLUTTER_ROOT'];
Directory.current = projectDirectory;
if (localEngine != null && !localEngine.contains(buildMode)) {
stderr.write('''
ERROR: Requested build with Flutter local engine at '$localEngine'
This engine is not compatible with FLUTTER_BUILD_MODE: '$buildMode'.
You can fix this by updating the LOCAL_ENGINE environment variable, or
by running:
flutter build <platform> --local-engine=host_$buildMode
or
flutter build <platform> --local-engine=host_${buildMode}_unopt
========================================================================
''');
exit(1);
}
final String flutterExecutable = path.join(
flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
if (targetPlatform == 'linux-x64') {
// TODO(jonahwilliams): currently all builds are debug builds. Remove the
// hardcoded mode when profile and release support is added.
final ProcessResult unpackResult = await Process.run(
flutterExecutable,
<String>[
'--suppress-analytics',
'--verbose',
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
if (localEngine != null) '--local-engine=$localEngine',
'assemble',
'-dTargetPlatform=$targetPlatform',
'-dBuildMode=debug',
'-dTargetFile=$flutterTarget',
'--output=build',
'debug_bundle_linux_assets',
]);
if (unpackResult.exitCode != 0) {
stderr.write(unpackResult.stderr);
exit(1);
}
return;
}
const String cacheDirectory = 'windows/flutter/ephemeral';
final ProcessResult unpackResult = await Process.run(
flutterExecutable,
<String>[
'--suppress-analytics',
if (verbose) '--verbose',
'unpack',
'--target-platform=$targetPlatform',
'--cache-dir=$cacheDirectory',
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
if (localEngine != null) '--local-engine=$localEngine',
]);
if (unpackResult.exitCode != 0) {
stderr.write(unpackResult.stderr);
exit(1);
}
final ProcessResult buildResult = await Process.run(
flutterExecutable,
<String>[
'--suppress-analytics',
if (verbose) '--verbose',
'build',
'bundle',
'--target=$flutterTarget',
'--target-platform=$targetPlatform',
if (trackWidgetCreation) '--track-widget-creation',
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
if (localEngine != null) '--local-engine=$localEngine',
]);
if (buildResult.exitCode != 0) {
stderr.write(buildResult.stderr);
exit(1);
}
exit(0);
}