Unverified Commit 01feddbe authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Support for macOS release mode (1 of 3) (#37425)

parent 57f1508b
...@@ -33,18 +33,6 @@ if [[ -n "$FLUTTER_TARGET" ]]; then ...@@ -33,18 +33,6 @@ if [[ -n "$FLUTTER_TARGET" ]]; then
target_path="${FLUTTER_TARGET}" target_path="${FLUTTER_TARGET}"
fi fi
# Set the track widget creation flag.
track_widget_creation_flag=""
if [[ -n "$TRACK_WIDGET_CREATION" ]]; then
track_widget_creation_flag="--track-widget-creation"
fi
# Copy the framework and handle local engine builds.
framework_name="FlutterMacOS.framework"
ephemeral_dir="${SOURCE_ROOT}/Flutter/ephemeral"
framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/darwin-x64"
flutter_framework="${framework_path}/${framework_name}"
if [[ -n "$FLUTTER_ENGINE" ]]; then if [[ -n "$FLUTTER_ENGINE" ]]; then
flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}" flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}"
fi fi
...@@ -63,22 +51,29 @@ if [[ -n "$LOCAL_ENGINE" ]]; then ...@@ -63,22 +51,29 @@ if [[ -n "$LOCAL_ENGINE" ]]; then
exit -1 exit -1
fi fi
local_engine_flag="--local-engine=${LOCAL_ENGINE}" local_engine_flag="--local-engine=${LOCAL_ENGINE}"
flutter_framework="${FLUTTER_ENGINE}/out/${LOCAL_ENGINE}/${framework_name}"
fi fi
RunCommand mkdir -p -- "$ephemeral_dir"
RunCommand rm -rf -- "${ephemeral_dir}/${framework_name}"
RunCommand cp -Rp -- "${flutter_framework}" "${ephemeral_dir}"
# Set the build mode # Set the build mode
build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")" build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
# The path where the input/output xcfilelists are stored. These are used by xcode
# to conditionally skip this script phase if neither have changed.
ephemeral_dir="${SOURCE_ROOT}/Flutter/ephemeral"
build_inputs_path="${ephemeral_dir}/FlutterInputs.xcfilelist"
build_outputs_path="${ephemeral_dir}/FlutterOutputs.xcfilelist"
# TODO(jonahwilliams): connect AOT rules once engine artifacts are published.
# The build mode is currently hard-coded to debug only. Since this does not yet
# support AOT, we need to ensure that we compile the kernel file in debug so that
# the VM can load it.
RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \
${verbose_flag} \ ${verbose_flag} \
build bundle \
--target-platform=darwin-x64 \
--target="${target_path}" \
--${build_mode} \
${track_widget_creation_flag} \
${flutter_engine_flag} \ ${flutter_engine_flag} \
${local_engine_flag} ${local_engine_flag} \
assemble \
-dTargetPlatform=darwin-x64 \
-dTargetFile="${target_path}" \
-dBuildMode=debug \
--build-inputs="${build_inputs_path}" \
--build-outputs="${build_outputs_path}" \
debug_bundle_flutter_assets
...@@ -485,16 +485,18 @@ class BuildSystem { ...@@ -485,16 +485,18 @@ class BuildSystem {
// timestamps to track files, this leads to unecessary rebuilds if they // timestamps to track files, this leads to unecessary rebuilds if they
// are included. Once all the places that write these files have been // are included. Once all the places that write these files have been
// tracked down and moved into assemble, these checks should be removable. // tracked down and moved into assemble, these checks should be removable.
// We also remove files under .dart_tool, since these are intermediaries
// and don't need to be tracked by external systems.
{ {
buildInstance.inputFiles.removeWhere((String path, File file) { buildInstance.inputFiles.removeWhere((String path, File file) {
return path.contains('pubspec.yaml') || return path.contains('.flutter-plugins') ||
path.contains('.flutter-plugins') || path.contains('xcconfig') ||
path.contains('xcconfig'); path.contains('.dart_tool');
}); });
buildInstance.outputFiles.removeWhere((String path, File file) { buildInstance.outputFiles.removeWhere((String path, File file) {
return path.contains('pubspec.yaml') || return path.contains('.flutter-plugins') ||
path.contains('.flutter-plugins') || path.contains('xcconfig') ||
path.contains('xcconfig'); path.contains('.dart_tool');
}); });
} }
return BuildResult( return BuildResult(
...@@ -509,6 +511,7 @@ class BuildSystem { ...@@ -509,6 +511,7 @@ class BuildSystem {
} }
} }
/// An active instance of a build. /// An active instance of a build.
class _BuildInstance { class _BuildInstance {
_BuildInstance(this.environment, this.fileCache, this.buildSystemConfig) _BuildInstance(this.environment, this.fileCache, this.buildSystemConfig)
......
...@@ -64,6 +64,7 @@ class KernelSnapshot extends Target { ...@@ -64,6 +64,7 @@ class KernelSnapshot extends Target {
@override @override
List<Source> get inputs => const <Source>[ List<Source> get inputs => const <Source>[
Source.pattern('{PROJECT_DIR}/.packages'),
Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/dart.dart'), Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/dart.dart'),
Source.function(listDartSources), // <- every dart file under {PROJECT_DIR}/lib and in .packages Source.function(listDartSources), // <- every dart file under {PROJECT_DIR}/lib and in .packages
Source.artifact(Artifact.platformKernelDill), Source.artifact(Artifact.platformKernelDill),
......
...@@ -32,9 +32,8 @@ const List<Target> _kDefaultTargets = <Target>[ ...@@ -32,9 +32,8 @@ const List<Target> _kDefaultTargets = <Target>[
AotElfRelease(), AotElfRelease(),
AotAssemblyProfile(), AotAssemblyProfile(),
AotAssemblyRelease(), AotAssemblyRelease(),
DebugMacOSApplication(), DebugMacOSFramework(),
ProfileMacOSApplication(), DebugBundleFlutterAssets(),
ReleaseMacOSApplication(),
]; ];
/// Assemble provides a low level API to interact with the flutter tool build /// Assemble provides a low level API to interact with the flutter tool build
......
...@@ -11,6 +11,9 @@ import 'device.dart'; ...@@ -11,6 +11,9 @@ import 'device.dart';
/// Kills a process on linux or macOS. /// Kills a process on linux or macOS.
Future<bool> killProcess(String executable) async { Future<bool> killProcess(String executable) async {
if (executable == null) {
return false;
}
final RegExp whitespace = RegExp(r'\s+'); final RegExp whitespace = RegExp(r'\s+');
bool succeeded = true; bool succeeded = true;
try { try {
......
...@@ -141,7 +141,7 @@ class BuildableMacOSApp extends MacOSApp { ...@@ -141,7 +141,7 @@ class BuildableMacOSApp extends MacOSApp {
return null; return null;
} }
final _ExecutableAndId executableAndId = MacOSApp._executableFromBundle(fs.directory(directory)); final _ExecutableAndId executableAndId = MacOSApp._executableFromBundle(fs.directory(directory));
return executableAndId.executable; return executableAndId?.executable;
} }
} }
......
...@@ -36,6 +36,13 @@ Future<void> buildMacOS({ ...@@ -36,6 +36,13 @@ Future<void> buildMacOS({
setSymroot: false, setSymroot: false,
); );
await processPodsIfNeeded(flutterProject.macos, getMacOSBuildDirectory(), buildInfo.mode); await processPodsIfNeeded(flutterProject.macos, getMacOSBuildDirectory(), buildInfo.mode);
// If the xcfilelists do not exist, create empty version.
if (!flutterProject.macos.inputFileList.existsSync()) {
flutterProject.macos.inputFileList.createSync(recursive: true);
}
if (!flutterProject.macos.outputFileList.existsSync()) {
flutterProject.macos.outputFileList.createSync(recursive: true);
}
// Set debug or release mode. // Set debug or release mode.
String config = 'Debug'; String config = 'Debug';
......
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
return BuildResult( return BuildResult(
success: true, success: true,
inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()], inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()],
outputFiles: <File>[fs.file('bar')]); outputFiles: <File>[fs.file('bar'), fs.file(fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]);
}); });
await commandRunner.run(<String>['assemble', '--build-outputs=outputs', '--build-inputs=inputs', 'unpack_macos']); await commandRunner.run(<String>['assemble', '--build-outputs=outputs', '--build-inputs=inputs', 'unpack_macos']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment