mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 01:14:16 +00:00
[pkgs/native] Windows support + CI
We use the MSVC from Depot Tools to build C files. When using clang from DEPS, we need to pass the right INCLUDE / LIB environment variables. So we might as well use the MSVC instead. Moves the `nativeCompilerEnvironmentVariables` to the `TestConfiguration` so that it's cached. Bug: https://github.com/dart-lang/sdk/issues/50565 Change-Id: I3576cd0ed07081afb9ae5ba737b8bfe1b21941e5 Cq-Include-Trybots: luci.dart.try:pkg-win-release-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try,pkg-linux-debug-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298580 Reviewed-by: William Hesse <whesse@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
parent
637dd76c7f
commit
6c3c7ae331
2
DEPS
2
DEPS
|
@ -151,7 +151,7 @@ vars = {
|
|||
"matcher_rev": "cb6b68c603d2c57a51bbddfff08fa211bba7dcd3",
|
||||
"mime_rev": "2d8496df6a6e851816610c3f99eae0d9663f54c4",
|
||||
"mockito_rev": "f851e1754f0af41b1731bd81803d05988482d61b",
|
||||
"native_rev": "9350cb71d44635f2ecb3a876f570045526e02543", # disable rev_sdk_deps.dart
|
||||
"native_rev": "5d5db9e1c019512752b5d4d222eb1ae572b8d33c", # disable rev_sdk_deps.dart
|
||||
"package_config_rev": "7e09db12e968482ef81e309de3ce233463b4cd7e",
|
||||
"path_rev": "23e33194c4073c0fdd818a70dd944afd5ad206e6",
|
||||
"pool_rev": "650e5d3eff10529c65ef45b5fcb4bca270c7ea8f",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:smith/configuration.dart';
|
||||
|
@ -278,6 +279,59 @@ class TestConfiguration {
|
|||
}
|
||||
}();
|
||||
|
||||
late final Map<String, String> nativeCompilerEnvironmentVariables = () {
|
||||
if (Platform.isWindows) {
|
||||
// Use MSVC from Depot Tools instead. When using clang from DEPS, we still
|
||||
// need to pass the right INCLUDE / LIB environment variables. So we might
|
||||
// as well use the MSVC instead.
|
||||
final windowsSdk = Uri.directory(windowsSdkPath!);
|
||||
final vsPath = windowsSdk.resolve('../../');
|
||||
final msvcPaths = vsPath.resolve('VC/Tools/MSVC/');
|
||||
final msvcPath = Directory.fromUri(msvcPaths)
|
||||
.listSync()
|
||||
.firstWhere((element) => element.path != '.' && element.path != '..')
|
||||
.uri;
|
||||
const targetFolderName = {
|
||||
Abi.windowsX64: 'x64',
|
||||
Abi.windowsIA32: 'ia32',
|
||||
};
|
||||
const envScriptArgument = {
|
||||
Abi.windowsX64: '/x64',
|
||||
Abi.windowsIA32: '/x86',
|
||||
};
|
||||
final binDir =
|
||||
msvcPath.resolve('bin/Hostx64/${targetFolderName[Abi.current()]!}/');
|
||||
final toolchainEnvScript = windowsSdk.resolve('bin/SetEnv.cmd');
|
||||
return {
|
||||
'AR': binDir.resolve('lib.exe').toFilePath(),
|
||||
'CC': binDir.resolve('cl.exe').toFilePath(),
|
||||
'LD': binDir.resolve('link.exe').toFilePath(),
|
||||
'ToolchainEnvScript': toolchainEnvScript.toFilePath(),
|
||||
'ToolchainEnvScriptArguments': envScriptArgument[Abi.current()]!,
|
||||
};
|
||||
}
|
||||
|
||||
if (Platform.isMacOS) {
|
||||
// Use XCode instead, it has the right sysroot by default.
|
||||
return <String, String>{};
|
||||
}
|
||||
|
||||
assert(Platform.isLinux);
|
||||
// Keep consistent with DEPS.
|
||||
const clangHostFolderName = {
|
||||
Abi.linuxArm64: 'linux-arm64',
|
||||
Abi.linuxX64: 'linux-x64',
|
||||
};
|
||||
final hostFolderName = clangHostFolderName[Abi.current()]!;
|
||||
final clangBin =
|
||||
Directory.current.uri.resolve('buildtools/$hostFolderName/clang/bin/');
|
||||
return {
|
||||
'AR': clangBin.resolve('llvm-ar').toFilePath(),
|
||||
'CC': clangBin.resolve('clang').toFilePath(),
|
||||
'LD': clangBin.resolve('ld.lld').toFilePath(),
|
||||
};
|
||||
}();
|
||||
|
||||
/// Gets the local file path to the browser executable for this configuration.
|
||||
late final String browserLocation = () {
|
||||
// If the user has explicitly configured a browser path, use it.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
|
@ -1037,28 +1036,3 @@ final Map<String, String> sanitizerEnvironmentVariables = (() {
|
|||
|
||||
return environment;
|
||||
})();
|
||||
|
||||
final Map<String, String> nativeCompilerEnvironmentVariables = (() {
|
||||
if (Platform.isMacOS) {
|
||||
// Use XCode instead, it has the right sysroot by default.
|
||||
return <String, String>{};
|
||||
}
|
||||
|
||||
// Keep consistent with DEPS.
|
||||
const clangHostFolderName = {
|
||||
Abi.linuxArm64: 'linux-arm64',
|
||||
Abi.linuxX64: 'linux-x64',
|
||||
Abi.macosArm64: 'mac-arm64',
|
||||
Abi.macosX64: 'mac-x64',
|
||||
Abi.windowsX64: 'win-x64',
|
||||
};
|
||||
|
||||
final hostFolderName = clangHostFolderName[Abi.current()]!;
|
||||
final clangBin =
|
||||
Directory.current.uri.resolve('buildtools/$hostFolderName/clang/bin/');
|
||||
return {
|
||||
'AR': clangBin.resolve('llvm-ar').toFilePath(),
|
||||
'CC': clangBin.resolve('clang').toFilePath(),
|
||||
'LD': clangBin.resolve('ld.lld').toFilePath(),
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -398,7 +398,7 @@ class RunningProcess {
|
|||
|
||||
Map<String, String> _createProcessEnvironment() {
|
||||
final environment = Map<String, String>.from(io.Platform.environment);
|
||||
environment.addAll(nativeCompilerEnvironmentVariables);
|
||||
environment.addAll(configuration.nativeCompilerEnvironmentVariables);
|
||||
environment.addAll(sanitizerEnvironmentVariables);
|
||||
for (var entry in command.environmentOverrides.entries) {
|
||||
environment[entry.key] = entry.value;
|
||||
|
|
7
third_party/pkg/c_compiler.status
vendored
7
third_party/pkg/c_compiler.status
vendored
|
@ -4,6 +4,7 @@
|
|||
|
||||
test/cbuilder/cbuilder_cross_android_test: SkipByDesign # Cross compilation is not tested on the Dart CI.
|
||||
test/cbuilder/cbuilder_cross_linux_host_test: SkipByDesign # Cross compilation is not tested on the Dart CI.
|
||||
test/cbuilder/cbuilder_cross_windows_host_test: SkipByDesign # Cross compilation is not tested on the Dart CI.
|
||||
test/native_toolchain/gcc_test: SkipByDesign # Cross compilation is not tested on the Dart CI.
|
||||
test/native_toolchain/ndk_test: SkipByDesign # Cross compilation is not tested on the Dart CI.
|
||||
|
||||
|
@ -19,5 +20,7 @@ test/tool/tool_resolver_test: SkipByDesign # Toolchains not installed in default
|
|||
test/cbuilder/cbuilder_cross_ios_test: SkipByDesign # XCode on Dart CI doesn't have the iphonesimulator SDK.
|
||||
test/native_toolchain/xcode_test: SkipByDesign # XCode on Dart CI doesn't have the iphonesimulator SDK.
|
||||
|
||||
[ $system != linux && $system != macos ]
|
||||
*: Skip # Non-Linux not yet implemented upstream.
|
||||
[ $system == windows ]
|
||||
test/cbuilder/compiler_resolver_test: SkipByDesign # Toolchains not installed in default locations on Dart CI.
|
||||
test/native_toolchain/msvc_test: SkipByDesign # Toolchains not installed in default locations on Dart CI.
|
||||
test/tool/tool_resolver_test: SkipByDesign # Toolchains not installed in default locations on Dart CI.
|
||||
|
|
3
third_party/pkg/native_assets_cli.status
vendored
3
third_party/pkg/native_assets_cli.status
vendored
|
@ -4,6 +4,3 @@
|
|||
|
||||
[ $runtime != vm ]
|
||||
*: SkipByDesign # Native assets is a VM-only feature.
|
||||
|
||||
[ $system != linux && $system != macos ]
|
||||
*: Skip # Non-Linux not yet implemented upstream.
|
||||
|
|
Loading…
Reference in a new issue