Add --target-compiler-flags argument to specify flags for clang. (#106)
Also, avoid using environment variables to prevent interference to other commands run by CMake. Only CMAKE_C(XX)_COMPILER is sufficient to build flutter.
This commit is contained in:
+14
-6
@@ -68,6 +68,11 @@ class BuildPackageCommand extends BuildSubCommand
|
||||
'This option is valid only '
|
||||
'if the current host and target architectures are different.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'target-compiler-flags',
|
||||
defaultsTo: null,
|
||||
help: 'The extra compile flags to be applied to C and C++ compiler',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -109,12 +114,15 @@ class BuildPackageCommand extends BuildSubCommand
|
||||
}
|
||||
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(buildInfo,
|
||||
targetArch: targetArch,
|
||||
targetBackendType: stringArg('target-backend-type'),
|
||||
targetCompilerTriple: stringArg('target-compiler-triple'),
|
||||
targetSysroot: stringArg('target-sysroot'),
|
||||
systemIncludeDirectories: stringArg('system-include-directories'));
|
||||
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(
|
||||
buildInfo,
|
||||
targetArch: targetArch,
|
||||
targetBackendType: stringArg('target-backend-type'),
|
||||
targetCompilerTriple: stringArg('target-compiler-triple'),
|
||||
targetSysroot: stringArg('target-sysroot'),
|
||||
systemIncludeDirectories: stringArg('system-include-directories'),
|
||||
targetCompilerFlags: stringArg('target-compiler-flags'),
|
||||
);
|
||||
validateBuild(eLinuxBuildInfo);
|
||||
displayNullSafetyMode(buildInfo);
|
||||
|
||||
|
||||
@@ -356,6 +356,7 @@ class NativeBundle {
|
||||
final String hostArch = _getCurrentHostPlatformArchName();
|
||||
final String targetCompilerTriple = buildInfo.targetCompilerTriple;
|
||||
final String targetSysroot = buildInfo.targetSysroot;
|
||||
final String targetCompilerFlags = buildInfo.targetCompilerFlags;
|
||||
final String systemIncludeDirectories = buildInfo.systemIncludeDirectories;
|
||||
RunResult result = await _processUtils.run(
|
||||
<String>[
|
||||
@@ -371,10 +372,14 @@ class NativeBundle {
|
||||
'-DCMAKE_C_COMPILER_TARGET=$targetCompilerTriple',
|
||||
if (targetCompilerTriple != null)
|
||||
'-DCMAKE_CXX_COMPILER_TARGET=$targetCompilerTriple',
|
||||
if (targetCompilerFlags != null) '-DCMAKE_C_FLAGS=$targetCompilerFlags',
|
||||
if (targetCompilerFlags != null)
|
||||
'-DCMAKE_CXX_FLAGS=$targetCompilerFlags',
|
||||
'-DCMAKE_C_COMPILER=clang',
|
||||
'-DCMAKE_CXX_COMPILER=clang++',
|
||||
eLinuxDir.path,
|
||||
],
|
||||
workingDirectory: outputDir.path,
|
||||
environment: <String, String>{'CC': 'clang', 'CXX': 'clang++'},
|
||||
);
|
||||
if (result.exitCode != 0) {
|
||||
throwToolExit('Failed to cmake:\n$result');
|
||||
|
||||
@@ -38,6 +38,7 @@ class ELinuxBuildInfo {
|
||||
@required this.targetCompilerTriple,
|
||||
@required this.targetSysroot,
|
||||
@required this.systemIncludeDirectories,
|
||||
@required this.targetCompilerFlags,
|
||||
}) : assert(targetArch != null),
|
||||
assert(targetBackendType != null);
|
||||
|
||||
@@ -47,6 +48,7 @@ class ELinuxBuildInfo {
|
||||
final String targetCompilerTriple;
|
||||
final String targetSysroot;
|
||||
final String systemIncludeDirectories;
|
||||
final String targetCompilerFlags;
|
||||
}
|
||||
|
||||
/// See:
|
||||
|
||||
@@ -300,6 +300,7 @@ class ELinuxDevice extends Device {
|
||||
targetCompilerTriple: null,
|
||||
targetSysroot: '/',
|
||||
systemIncludeDirectories: null,
|
||||
targetCompilerFlags: null,
|
||||
);
|
||||
await ELinuxBuilder.buildBundle(
|
||||
project: project,
|
||||
|
||||
Reference in New Issue
Block a user