forked from dotnet/vscode-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
173 lines (144 loc) · 5.68 KB
/
gulpfile.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const fs = require('fs');
const path = require('path');
const del = require('del');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const tslint = require('gulp-tslint');
const vsce = require('vsce');
const debugUtil = require('./out/src/coreclr-debug/util');
const debugInstall = require('./out/src/coreclr-debug/install');
const packages = require('./out/src/packages');
const logger = require('./out/src/logger');
const platform = require('./out/src/platform');
const util = require('./out/src/common');
const child_process = require('child_process');
const optionsSchemaGenerator = require('./out/src/tools/GenerateOptionsSchema');
const Logger = logger.Logger;
const PackageManager = packages.PackageManager;
const LinuxDistribution = platform.LinuxDistribution;
const PlatformInformation = platform.PlatformInformation;
function cleanSync(deleteVsix) {
del.sync('install.*');
del.sync('.omnisharp-*');
del.sync('.debugger');
if (deleteVsix) {
del.sync('*.vsix');
}
}
gulp.task('clean', () => {
cleanSync(true);
});
gulp.task('generateOptionsSchema', () => {
optionsSchemaGenerator.GenerateOptionsSchema();
});
// Install Tasks
function install(platformInfo, packageJSON) {
const packageManager = new PackageManager(platformInfo, packageJSON);
const logger = new Logger(message => process.stdout.write(message));
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'), logger);
const debugInstaller = new debugInstall.DebugInstaller(debuggerUtil);
return packageManager.DownloadPackages(logger)
.then(() => {
return packageManager.InstallPackages(logger);
})
.then(() => {
return util.touchInstallFile(util.InstallFileType.Lock)
})
.then(() => {
return debugInstaller.finishInstall();
});
}
gulp.task('install', ['clean'], () => {
util.setExtensionPath(__dirname);
return PlatformInformation.GetCurrent()
.then(platformInfo => {
return install(platformInfo, getPackageJSON());
});
});
/// Packaging (VSIX) Tasks
function doPackageSync(packageName) {
var vsceArgs = [];
vsceArgs.push(path.join(__dirname, 'node_modules', 'vsce', 'out', 'vsce'))
vsceArgs.push('package'); // package command
if (packageName !== undefined) {
vsceArgs.push('-o');
vsceArgs.push(packageName);
}
var proc = child_process.spawnSync('node', vsceArgs);
if (proc.error) {
console.error(proc.error.toString());
}
}
function doOfflinePackage(platformInfo, packageName, packageJSON) {
if (process.platform === 'win32') {
throw new Error('Do not build offline packages on windows. Runtime executables will not be marked executable in *nix packages.');
}
cleanSync(false);
return install(platformInfo, packageJSON)
.then(() => {
doPackageSync(packageName + '-' + platformInfo.runtimeId + '.vsix');
});
}
function getPackageJSON() {
return JSON.parse(fs.readFileSync('package.json'));
}
gulp.task('package:clean', () => {
del.sync('*.vsix');
});
gulp.task('package:online', ['clean'], () => {
doPackageSync();
});
gulp.task('package:offline', ['clean'], () => {
util.setExtensionPath(__dirname);
var packageJSON = getPackageJSON();
var name = packageJSON.name;
var version = packageJSON.version;
var packageName = name + '.' + version;
var packages = [];
packages.push(new PlatformInformation('win32', 'x86_64'));
packages.push(new PlatformInformation('darwin', 'x86_64'));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('centos', '7')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('debian', '8')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('fedora', '23')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('opensuse', '13.2')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('rhel', '7.2')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('ubuntu', '14.04')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('ubuntu', '16.04')));
var promise = Promise.resolve();
packages.forEach(platformInfo => {
promise = promise
.then(() => {
return doOfflinePackage(platformInfo, packageName, packageJSON);
});
});
return promise;
});
/// Misc Tasks
const allTypeScript = [
'src/**/*.ts',
'!**/*.d.ts',
'!**/typings**'
];
const lintReporter = (output, file, options) => {
//emits: src/helloWorld.c:5:3: warning: implicit declaration of function ‘prinft’
var relativeBase = file.base.substring(file.cwd.length + 1).replace('\\', '/');
output.forEach(e => {
var message = relativeBase + e.name + ':' + (e.startPosition.line + 1) + ':' + (e.startPosition.character + 1) + ': ' + e.failure;
console.log('[tslint] ' + message);
});
};
gulp.task('tslint', () => {
gulp.src(allTypeScript)
.pipe(tslint({
rulesDirectory: "node_modules/tslint-microsoft-contrib"
}))
.pipe(tslint.report(lintReporter, {
summarizeFailureOutput: false,
emitError: false
}))
});