Repository navigation
Expand file tree
/
Copy pathplatformData.ts
More file actions
71 lines (64 loc) · 2.36 KB
/
Copy pathplatformData.ts
File metadata and controls
71 lines (64 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { IFileSystem, IPlatformService } from '../common/platform/types';
import {
language_server_linux_x64_sha512,
language_server_osx_x64_sha512,
language_server_win_x64_sha512,
language_server_win_x86_sha512
} from './languageServerHashes';
export enum PlatformName {
Windows32Bit = 'win-x86',
Windows64Bit = 'win-x64',
Mac64Bit = 'osx-x64',
Linux64Bit = 'linux-x64'
}
export enum PlatformLSExecutables {
Windows = 'Microsoft.Python.LanguageServer.exe',
MacOS = 'Microsoft.Python.LanguageServer',
Linux = 'Microsoft.Python.LanguageServer'
}
export class PlatformData {
constructor(private platform: IPlatformService, fs: IFileSystem) { }
public getPlatformName(): PlatformName {
if (this.platform.isWindows) {
return this.platform.is64bit ? PlatformName.Windows64Bit : PlatformName.Windows32Bit;
}
if (this.platform.isMac) {
return PlatformName.Mac64Bit;
}
if (this.platform.isLinux) {
if (!this.platform.is64bit) {
throw new Error('Microsoft Python Language Server does not support 32-bit Linux.');
}
return PlatformName.Linux64Bit;
}
throw new Error('Unknown OS platform.');
}
public getEngineDllName(): string {
return 'Microsoft.Python.LanguageServer.dll';
}
public getEngineExecutableName(): string {
if (this.platform.isWindows) {
return PlatformLSExecutables.Windows;
} else if (this.platform.isLinux) {
return PlatformLSExecutables.Linux;
} else if (this.platform.isMac) {
return PlatformLSExecutables.MacOS;
} else {
return 'unknown-platform';
}
}
public async getExpectedHash(): Promise<string> {
if (this.platform.isWindows) {
return this.platform.is64bit ? language_server_win_x64_sha512 : language_server_win_x86_sha512;
}
if (this.platform.isMac) {
return language_server_osx_x64_sha512;
}
if (this.platform.isLinux && this.platform.is64bit) {
return language_server_linux_x64_sha512;
}
throw new Error('Unknown platform.');
}
}