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
target_path="${FLUTTER_TARGET}"
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
flutter_engine_flag="--local-engine-src-path=${FLUTTER_ENGINE}"
fi
......@@ -63,22 +51,29 @@ if [[ -n "$LOCAL_ENGINE" ]]; then
exit -1
fi
local_engine_flag="--local-engine=${LOCAL_ENGINE}"
flutter_framework="${FLUTTER_ENGINE}/out/${LOCAL_ENGINE}/${framework_name}"
fi
RunCommand mkdir -p -- "$ephemeral_dir"
RunCommand rm -rf -- "${ephemeral_dir}/${framework_name}"
RunCommand cp -Rp -- "${flutter_framework}" "${ephemeral_dir}"
# Set the build mode
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 \
${verbose_flag} \
build bundle \
--target-platform=darwin-x64 \
--target="${target_path}" \
--${build_mode} \
${track_widget_creation_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 {
// timestamps to track files, this leads to unecessary rebuilds if they
// are included. Once all the places that write these files have been
// 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) {
return path.contains('pubspec.yaml') ||
path.contains('.flutter-plugins') ||
path.contains('xcconfig');
return path.contains('.flutter-plugins') ||
path.contains('xcconfig') ||
path.contains('.dart_tool');
});
buildInstance.outputFiles.removeWhere((String path, File file) {
return path.contains('pubspec.yaml') ||
path.contains('.flutter-plugins') ||
path.contains('xcconfig');
return path.contains('.flutter-plugins') ||
path.contains('xcconfig') ||
path.contains('.dart_tool');
});
}
return BuildResult(
......@@ -509,6 +511,7 @@ class BuildSystem {
}
}
/// An active instance of a build.
class _BuildInstance {
_BuildInstance(this.environment, this.fileCache, this.buildSystemConfig)
......
......@@ -64,6 +64,7 @@ class KernelSnapshot extends Target {
@override
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.function(listDartSources), // <- every dart file under {PROJECT_DIR}/lib and in .packages
Source.artifact(Artifact.platformKernelDill),
......
......@@ -32,9 +32,8 @@ const List<Target> _kDefaultTargets = <Target>[
AotElfRelease(),
AotAssemblyProfile(),
AotAssemblyRelease(),
DebugMacOSApplication(),
ProfileMacOSApplication(),
ReleaseMacOSApplication(),
DebugMacOSFramework(),
DebugBundleFlutterAssets(),
];
/// Assemble provides a low level API to interact with the flutter tool build
......
......@@ -11,6 +11,9 @@ import 'device.dart';
/// Kills a process on linux or macOS.
Future<bool> killProcess(String executable) async {
if (executable == null) {
return false;
}
final RegExp whitespace = RegExp(r'\s+');
bool succeeded = true;
try {
......
......@@ -141,7 +141,7 @@ class BuildableMacOSApp extends MacOSApp {
return null;
}
final _ExecutableAndId executableAndId = MacOSApp._executableFromBundle(fs.directory(directory));
return executableAndId.executable;
return executableAndId?.executable;
}
}
......
......@@ -36,6 +36,13 @@ Future<void> buildMacOS({
setSymroot: false,
);
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.
String config = 'Debug';
......
......@@ -73,7 +73,7 @@ void main() {
return BuildResult(
success: true,
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']);
......
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