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 '
|
'This option is valid only '
|
||||||
'if the current host and target architectures are different.',
|
'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
|
@override
|
||||||
@@ -109,12 +114,15 @@ class BuildPackageCommand extends BuildSubCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BuildInfo buildInfo = await getBuildInfo();
|
final BuildInfo buildInfo = await getBuildInfo();
|
||||||
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(buildInfo,
|
final ELinuxBuildInfo eLinuxBuildInfo = ELinuxBuildInfo(
|
||||||
targetArch: targetArch,
|
buildInfo,
|
||||||
targetBackendType: stringArg('target-backend-type'),
|
targetArch: targetArch,
|
||||||
targetCompilerTriple: stringArg('target-compiler-triple'),
|
targetBackendType: stringArg('target-backend-type'),
|
||||||
targetSysroot: stringArg('target-sysroot'),
|
targetCompilerTriple: stringArg('target-compiler-triple'),
|
||||||
systemIncludeDirectories: stringArg('system-include-directories'));
|
targetSysroot: stringArg('target-sysroot'),
|
||||||
|
systemIncludeDirectories: stringArg('system-include-directories'),
|
||||||
|
targetCompilerFlags: stringArg('target-compiler-flags'),
|
||||||
|
);
|
||||||
validateBuild(eLinuxBuildInfo);
|
validateBuild(eLinuxBuildInfo);
|
||||||
displayNullSafetyMode(buildInfo);
|
displayNullSafetyMode(buildInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ class NativeBundle {
|
|||||||
final String hostArch = _getCurrentHostPlatformArchName();
|
final String hostArch = _getCurrentHostPlatformArchName();
|
||||||
final String targetCompilerTriple = buildInfo.targetCompilerTriple;
|
final String targetCompilerTriple = buildInfo.targetCompilerTriple;
|
||||||
final String targetSysroot = buildInfo.targetSysroot;
|
final String targetSysroot = buildInfo.targetSysroot;
|
||||||
|
final String targetCompilerFlags = buildInfo.targetCompilerFlags;
|
||||||
final String systemIncludeDirectories = buildInfo.systemIncludeDirectories;
|
final String systemIncludeDirectories = buildInfo.systemIncludeDirectories;
|
||||||
RunResult result = await _processUtils.run(
|
RunResult result = await _processUtils.run(
|
||||||
<String>[
|
<String>[
|
||||||
@@ -371,10 +372,14 @@ class NativeBundle {
|
|||||||
'-DCMAKE_C_COMPILER_TARGET=$targetCompilerTriple',
|
'-DCMAKE_C_COMPILER_TARGET=$targetCompilerTriple',
|
||||||
if (targetCompilerTriple != null)
|
if (targetCompilerTriple != null)
|
||||||
'-DCMAKE_CXX_COMPILER_TARGET=$targetCompilerTriple',
|
'-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,
|
eLinuxDir.path,
|
||||||
],
|
],
|
||||||
workingDirectory: outputDir.path,
|
workingDirectory: outputDir.path,
|
||||||
environment: <String, String>{'CC': 'clang', 'CXX': 'clang++'},
|
|
||||||
);
|
);
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
throwToolExit('Failed to cmake:\n$result');
|
throwToolExit('Failed to cmake:\n$result');
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class ELinuxBuildInfo {
|
|||||||
@required this.targetCompilerTriple,
|
@required this.targetCompilerTriple,
|
||||||
@required this.targetSysroot,
|
@required this.targetSysroot,
|
||||||
@required this.systemIncludeDirectories,
|
@required this.systemIncludeDirectories,
|
||||||
|
@required this.targetCompilerFlags,
|
||||||
}) : assert(targetArch != null),
|
}) : assert(targetArch != null),
|
||||||
assert(targetBackendType != null);
|
assert(targetBackendType != null);
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ class ELinuxBuildInfo {
|
|||||||
final String targetCompilerTriple;
|
final String targetCompilerTriple;
|
||||||
final String targetSysroot;
|
final String targetSysroot;
|
||||||
final String systemIncludeDirectories;
|
final String systemIncludeDirectories;
|
||||||
|
final String targetCompilerFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See:
|
/// See:
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ class ELinuxDevice extends Device {
|
|||||||
targetCompilerTriple: null,
|
targetCompilerTriple: null,
|
||||||
targetSysroot: '/',
|
targetSysroot: '/',
|
||||||
systemIncludeDirectories: null,
|
systemIncludeDirectories: null,
|
||||||
|
targetCompilerFlags: null,
|
||||||
);
|
);
|
||||||
await ELinuxBuilder.buildBundle(
|
await ELinuxBuilder.buildBundle(
|
||||||
project: project,
|
project: project,
|
||||||
|
|||||||
Reference in New Issue
Block a user