Skip to content

Commit 042ab2a

Browse files
Merge pull request #865 from DustinCampbell/fix-runtime-dependencies
Ensure OmniSharp binaries are executable on Unix
2 parents b8858b3 + 94bde36 commit 042ab2a

File tree

6 files changed

+59
-30
lines changed

6 files changed

+59
-30
lines changed

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
"installPath": ".omnisharp-coreclr",
7575
"runtimeIds": [
7676
"win7-x86"
77+
],
78+
"binaries": [
79+
"./.omnisharp-coreclr/OmniSharp"
7780
]
7881
},
7982
{
@@ -82,6 +85,9 @@
8285
"installPath": ".omnisharp-coreclr",
8386
"runtimeIds": [
8487
"win7-x64"
88+
],
89+
"binaries": [
90+
"./.omnisharp-coreclr/OmniSharp"
8591
]
8692
},
8793
{
@@ -90,6 +96,9 @@
9096
"installPath": ".omnisharp-coreclr",
9197
"runtimeIds": [
9298
"osx.10.11-x64"
99+
],
100+
"binaries": [
101+
"./.omnisharp-coreclr/OmniSharp"
93102
]
94103
},
95104
{
@@ -98,6 +107,9 @@
98107
"installPath": ".omnisharp-coreclr",
99108
"runtimeIds": [
100109
"centos.7-x64"
110+
],
111+
"binaries": [
112+
"./.omnisharp-coreclr/OmniSharp"
101113
]
102114
},
103115
{
@@ -106,6 +118,9 @@
106118
"installPath": ".omnisharp-coreclr",
107119
"runtimeIds": [
108120
"debian.8-x64"
121+
],
122+
"binaries": [
123+
"./.omnisharp-coreclr/OmniSharp"
109124
]
110125
},
111126
{
@@ -114,6 +129,9 @@
114129
"installPath": ".omnisharp-coreclr",
115130
"runtimeIds": [
116131
"fedora.23-x64"
132+
],
133+
"binaries": [
134+
"./.omnisharp-coreclr/OmniSharp"
117135
]
118136
},
119137
{
@@ -122,6 +140,9 @@
122140
"installPath": ".omnisharp-coreclr",
123141
"runtimeIds": [
124142
"opensuse.13.2-x64"
143+
],
144+
"binaries": [
145+
"./.omnisharp-coreclr/OmniSharp"
125146
]
126147
},
127148
{
@@ -130,6 +151,9 @@
130151
"installPath": ".omnisharp-coreclr",
131152
"runtimeIds": [
132153
"rhel.7-x64"
154+
],
155+
"binaries": [
156+
"./.omnisharp-coreclr/OmniSharp"
133157
]
134158
},
135159
{
@@ -138,6 +162,9 @@
138162
"installPath": ".omnisharp-coreclr",
139163
"runtimeIds": [
140164
"ubuntu.14.04-x64"
165+
],
166+
"binaries": [
167+
"./.omnisharp-coreclr/OmniSharp"
141168
]
142169
},
143170
{
@@ -146,6 +173,9 @@
146173
"installPath": ".omnisharp-coreclr",
147174
"runtimeIds": [
148175
"ubuntu.16.04-x64"
176+
],
177+
"binaries": [
178+
"./.omnisharp-coreclr/OmniSharp"
149179
]
150180
},
151181
{

src/main.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as OmniSharp from './omnisharp/extension';
1313
import * as util from './common';
1414
import { Logger } from './logger';
1515
import { PackageManager, Status } from './packages';
16-
import { PlatformInformation, OperatingSystem } from './platform';
16+
import { PlatformInformation } from './platform';
1717

1818
export function activate(context: vscode.ExtensionContext): any {
1919

@@ -88,10 +88,6 @@ function installRuntimeDependencies(extension: vscode.Extension<any>): Promise<v
8888
installationStage = 'installPackages';
8989
return packageManager.InstallPackages(logger, status);
9090
})
91-
.then(() => {
92-
installationStage = 'makeBinariesExecutable';
93-
return allowExecution(path.resolve(util.getBinPath(), 'run'), platformInfo, logger);
94-
})
9591
.then(() => {
9692
installationStage = 'touchLockFile';
9793
return util.touchLockFile();
@@ -114,7 +110,7 @@ function installRuntimeDependencies(extension: vscode.Extension<any>): Promise<v
114110

115111
function allowExecution(filePath: string, platformInfo: PlatformInformation, logger: Logger): Promise<void> {
116112
return new Promise<void>((resolve, reject) => {
117-
if (platformInfo.operatingSystem !== OperatingSystem.Windows) {
113+
if (!platformInfo.isWindows()) {
118114
util.fileExists(filePath)
119115
.then(exists => {
120116
if (exists) {

src/omnisharp/launcher.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
'use strict';
77

8-
import {spawn, ChildProcess} from 'child_process';
9-
import {satisfies} from 'semver';
10-
import {PlatformInformation, OperatingSystem} from '../platform';
8+
import { spawn, ChildProcess } from 'child_process';
9+
import { satisfies } from 'semver';
10+
import { PlatformInformation } from '../platform';
1111
import * as path from 'path';
1212
import * as vscode from 'vscode';
1313
import * as util from '../common';
@@ -165,7 +165,7 @@ function launch(cwd: string, args: string[], kind: LaunchTargetKind): Promise<La
165165

166166
const launchPath = options.path || getLaunchPath(platformInfo, kind);
167167

168-
if (platformInfo.operatingSystem === OperatingSystem.Windows) {
168+
if (platformInfo.isWindows()) {
169169
return launchWindows(launchPath, cwd, args);
170170
}
171171
else {
@@ -176,14 +176,20 @@ function launch(cwd: string, args: string[], kind: LaunchTargetKind): Promise<La
176176

177177
function getLaunchPath(platformInfo: PlatformInformation, kind: LaunchTargetKind): string {
178178
if (kind === LaunchTargetKind.Solution) {
179-
if (platformInfo.operatingSystem === OperatingSystem.Windows) {
179+
if (platformInfo.isWindows()) {
180180
return path.join(util.getExtensionPath(), '.omnisharp-desktop', 'OmniSharp.exe');
181181
}
182182

183-
return path.join(util.getExtensionPath(), '.omnisharp-mono', "OmniSharp.exe");
183+
return path.join(util.getExtensionPath(), '.omnisharp-mono', 'OmniSharp.exe');
184184
}
185185

186-
return path.join(util.getExtensionPath(), '.omnisharp-coreclr', "OmniSharp.exe");
186+
let basePath = path.join(util.getExtensionPath(), '.omnisharp-coreclr');
187+
if (platformInfo.isWindows()) {
188+
return path.join(basePath, 'OmniSharp.exe');
189+
}
190+
else {
191+
return path.join(basePath, 'OmniSharp');
192+
}
187193
}
188194

189195
function launchWindows(launchPath: string, cwd: string, args: string[]): LaunchResult {

src/omnisharp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {Options} from './options';
1515
import {Logger} from '../logger';
1616
import {DelayTracker} from './delayTracker';
1717
import {LaunchTarget, findLaunchTargets} from './launcher';
18-
import {PlatformInformation, OperatingSystem} from '../platform';
18+
import {PlatformInformation} from '../platform';
1919
import TelemetryReporter from 'vscode-extension-telemetry';
2020
import * as vscode from 'vscode';
2121

src/platform.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,13 @@ export enum OperatingSystem {
8787
}
8888

8989
export class PlatformInformation {
90-
public operatingSystem: OperatingSystem;
9190
public runtimeId: string;
9291

9392
public constructor(
9493
public platform: string,
9594
public architecture: string,
9695
public distribution: LinuxDistribution = null)
9796
{
98-
switch (platform) {
99-
case 'win32':
100-
this.operatingSystem = OperatingSystem.Windows;
101-
break;
102-
103-
case 'darwin':
104-
this.operatingSystem = OperatingSystem.MacOS;
105-
break;
106-
107-
case 'linux':
108-
this.operatingSystem = OperatingSystem.Linux;
109-
break;
110-
}
111-
11297
try {
11398
this.runtimeId = PlatformInformation.getRuntimeId(platform, architecture, distribution);
11499
}
@@ -117,6 +102,18 @@ export class PlatformInformation {
117102
}
118103
}
119104

105+
public isWindows(): boolean {
106+
return this.platform === 'win32';
107+
}
108+
109+
public isMacOS(): boolean {
110+
return this.platform === 'darwin';
111+
}
112+
113+
public isLinux(): boolean {
114+
return this.platform === 'linux';
115+
}
116+
120117
public toString(): string {
121118
let result = this.platform;
122119

test/platform.tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { should } from 'chai';
7-
import { LinuxDistribution, PlatformInformation, OperatingSystem } from '../src/platform';
7+
import { LinuxDistribution, PlatformInformation } from '../src/platform';
88

99
suite("Platform", () => {
1010
before(() => should());

0 commit comments

Comments
 (0)