Unverified Commit 0ad0dc25 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] fix missing cmake (#103761)

parent 90a592bf
...@@ -124,34 +124,33 @@ Future<void> _runCmake(String buildModeName, Directory sourceDir, Directory buil ...@@ -124,34 +124,33 @@ Future<void> _runCmake(String buildModeName, Directory sourceDir, Directory buil
final bool needCrossBuildOptionsForArm64 = needCrossBuild final bool needCrossBuildOptionsForArm64 = needCrossBuild
&& targetPlatform == TargetPlatform.linux_arm64; && targetPlatform == TargetPlatform.linux_arm64;
int result; int result;
try { if (!globals.processManager.canRun('cmake')) {
result = await globals.processUtils.stream( throwToolExit(globals.userMessages.cmakeMissing);
<String>[
'cmake',
'-G',
'Ninja',
'-DCMAKE_BUILD_TYPE=$buildFlag',
'-DFLUTTER_TARGET_PLATFORM=${getNameForTargetPlatform(targetPlatform)}',
// Support cross-building for arm64 targets on x64 hosts.
// (Cross-building for x64 on arm64 hosts isn't supported now.)
if (needCrossBuild)
'-DFLUTTER_TARGET_PLATFORM_SYSROOT=$targetSysroot',
if (needCrossBuildOptionsForArm64)
'-DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu',
if (needCrossBuildOptionsForArm64)
'-DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu',
sourceDir.path,
],
workingDirectory: buildDir.path,
environment: <String, String>{
'CC': 'clang',
'CXX': 'clang++',
},
trace: true,
);
} on ArgumentError {
throwToolExit("cmake not found. Run 'flutter doctor' for more information.");
} }
result = await globals.processUtils.stream(
<String>[
'cmake',
'-G',
'Ninja',
'-DCMAKE_BUILD_TYPE=$buildFlag',
'-DFLUTTER_TARGET_PLATFORM=${getNameForTargetPlatform(targetPlatform)}',
// Support cross-building for arm64 targets on x64 hosts.
// (Cross-building for x64 on arm64 hosts isn't supported now.)
if (needCrossBuild)
'-DFLUTTER_TARGET_PLATFORM_SYSROOT=$targetSysroot',
if (needCrossBuildOptionsForArm64)
'-DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu',
if (needCrossBuildOptionsForArm64)
'-DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu',
sourceDir.path,
],
workingDirectory: buildDir.path,
environment: <String, String>{
'CC': 'clang',
'CXX': 'clang++',
},
trace: true,
);
if (result != 0) { if (result != 0) {
throwToolExit('Unable to generate build files'); throwToolExit('Unable to generate build files');
} }
......
...@@ -172,18 +172,15 @@ void main() { ...@@ -172,18 +172,15 @@ void main() {
OperatingSystemUtils: () => FakeOperatingSystemUtils(), OperatingSystemUtils: () => FakeOperatingSystemUtils(),
}); });
testUsingContext('Handles argument error from missing cmake', () async { testUsingContext('Handles missing cmake', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
setUpMockProjectFilesForBuild(); setUpMockProjectFilesForBuild();
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.empty()
cmakeCommand('release', onRun: () { ..excludedExecutables.add('cmake');
throw ArgumentError();
}),
]);
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'linux', '--no-pub'] const <String>['build', 'linux', '--no-pub']
), throwsToolExit(message: "cmake not found. Run 'flutter doctor' for more information.")); ), throwsToolExit(message: 'CMake is required for Linux development.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => processManager, ProcessManager: () => processManager,
......
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