diff --git a/.gitignore b/.gitignore index 736b3124ec5da..bf3d29ae67c65 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ out-editor/ out-editor-min/ out-editor-ossfree/ out-editor-ossfree-min/ +out-linux/ out-vscode/ out-vscode-min/ build/node_modules \ No newline at end of file diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 5addc93567cd7..f5dd30db8cf5d 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -32,6 +32,7 @@ var indentationFilter = [ '**', '!ThirdPartyNotices.txt', '!**/*.md', + '!**/*.template', '!**/*.yml', '!**/lib/**', '!**/*.d.ts', @@ -58,8 +59,10 @@ var indentationFilter = [ var copyrightFilter = [ '**', + '!**/*.desktop', '!**/*.json', '!**/*.html', + '!**/*.template', '!**/test/**', '!**/*.md', '!**/*.bat', diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 27123265c8b71..84fb6598cc8f9 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -13,10 +13,12 @@ var azure = require('gulp-azure-storage'); var electron = require('gulp-atom-electron'); var symdest = require('gulp-symdest'); var rename = require('gulp-rename'); +var replace = require('gulp-replace'); var filter = require('gulp-filter'); var json = require('gulp-json-editor'); var insert = require('gulp-insert'); var remote = require('gulp-remote-src'); +var shell = require("gulp-shell"); var File = require('vinyl'); var rimraf = require('rimraf'); var _ = require('underscore'); @@ -215,7 +217,7 @@ function packageTask(platform, arch, opts) { .pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], true)) .pipe(util.cleanNodeModule('weak', ['binding.gyp', 'build/**', 'src/**'], true)); - var resources = gulp.src('resources/*', { base: '.' }); + var resources = gulp.src(['resources/*','resources/common/**'], { base: '.' }); if (platform === 'win32') { resources = es.merge(resources, gulp.src('resources/win32/code_file.ico', { base: '.' })); @@ -257,11 +259,88 @@ function packageTask(platform, arch, opts) { }; } +function getFolderSize(root) { + var size = 0; + var paths = [root]; + while (paths.length > 0) { + var current = path.normalize(paths.pop()); + var stat = fs.statSync(current); + size += stat.size; + if (stat.isDirectory()) { + var newPaths = fs.readdirSync(current); + newPaths.forEach(function(newPath) { + paths.push(path.join(current, newPath)); + }); + } + } + return size; +} + +function getDebPackageArch(arch) { + if (arch === 'x64') + return 'amd64' + if (arch === 'ia32') + return 'i386'; + return undefined; +} + +function prepareDebPackage(arch) { + var binaryDir = '../VSCode-linux-' + arch; + var debArch = getDebPackageArch(arch); + var destination = './out-linux/vscode-' + debArch; + var packageRevision = '1'; + + return function () { + var shortcut = gulp.src('resources/common/bin/code.sh', { base: '.' }) + .pipe(rename(function (p) { + p.extname = '' + p.dirname = 'usr/bin'; + })); + + var desktop = gulp.src('resources/linux/debian/code.desktop', { base: '.' }) + .pipe(rename(function (p) { p.dirname = 'usr/share/applications'; })); + + var icon = gulp.src('resources/linux/code.png', { base: '.' }) + .pipe(rename(function (p) { p.dirname = 'usr/share/pixmaps'; })); + + var installedSize = Math.ceil(getFolderSize(root + '/' + binaryDir) / 1024); + + var control = gulp.src('resources/linux/debian/control.template', { base: '.' }) + .pipe(replace('@@VERSION@@', packageJson.version + '-' + packageRevision)) + .pipe(replace('@@ARCHITECTURE@@', debArch)) + .pipe(replace('@@INSTALLEDSIZE@@', installedSize)) + .pipe(rename(function (p) { + p.extname = ''; + p.dirname = 'DEBIAN'; + })); + + var all = es.merge( + control, + desktop, + icon, + shortcut); + + all.pipe(symdest(destination)); + + var binaryResult = gulp.src(binaryDir + '/**/*', { base: binaryDir }) + .pipe(gulp.dest(destination + '/usr/share/code')); + + return es.merge(all, binaryResult); + }; +} + +function buildDebPackage(arch) { + var debArch = getDebPackageArch(arch); + return shell.task(['fakeroot dpkg-deb -b ' + path.join(root, 'out-linux', 'vscode-' + debArch)]); +} + gulp.task('clean-vscode-win32', util.rimraf(path.join(path.dirname(root), 'VSCode-win32'))); gulp.task('clean-vscode-darwin', util.rimraf(path.join(path.dirname(root), 'VSCode-darwin'))); gulp.task('clean-vscode-linux-ia32', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-ia32'))); gulp.task('clean-vscode-linux-x64', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-x64'))); gulp.task('clean-vscode-linux-arm', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-arm'))); +gulp.task('clean-vscode-linux-ia32-deb', util.rimraf('out-linux/vscode-i386*')); +gulp.task('clean-vscode-linux-x64-deb', util.rimraf('out-linux/vscode-amd64*')); gulp.task('vscode-win32', ['optimize-vscode', 'clean-vscode-win32'], packageTask('win32')); gulp.task('vscode-darwin', ['optimize-vscode', 'clean-vscode-darwin'], packageTask('darwin')); @@ -275,6 +354,12 @@ gulp.task('vscode-linux-ia32-min', ['minify-vscode', 'clean-vscode-linux-ia32'], gulp.task('vscode-linux-x64-min', ['minify-vscode', 'clean-vscode-linux-x64'], packageTask('linux', 'x64', { minified: true })); gulp.task('vscode-linux-arm-min', ['minify-vscode', 'clean-vscode-linux-arm'], packageTask('linux', 'arm', { minified: true })); +gulp.task('vscode-linux-ia32-prepare-deb', ['clean-vscode-linux-ia32-deb', 'vscode-linux-ia32'], prepareDebPackage('ia32')); +gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb'/*, 'vscode-linux-x64'*/], prepareDebPackage('x64')); +gulp.task('vscode-linux-ia32-build-deb', ['vscode-linux-ia32-prepare-deb'], buildDebPackage('ia32')); +gulp.task('vscode-linux-x64-build-deb', ['vscode-linux-x64-prepare-deb'], buildDebPackage('x64')); +gulp.task('vscode-linux-packages', ['vscode-linux-ia32-build-deb', 'vscode-linux-x64-build-deb']); + // Sourcemaps gulp.task('vscode-sourcemaps', ['minify-vscode'], function () { @@ -285,4 +370,4 @@ gulp.task('vscode-sourcemaps', ['minify-vscode'], function () { container: 'sourcemaps', prefix: commit + '/' })); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 2ed9882f44270..872bd5ad51d43 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,8 @@ "gulp-mocha": "^2.1.3", "gulp-remote-src": "^0.4.0", "gulp-rename": "^1.2.0", + "gulp-replace": "^0.5.4", + "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^1.6.0", "gulp-symdest": "^1.0.0", "gulp-tsb": "^1.10.1", diff --git a/resources/common/bin/code.sh b/resources/common/bin/code.sh index 72ab09ff3fcf7..07d44ad05ea06 100755 --- a/resources/common/bin/code.sh +++ b/resources/common/bin/code.sh @@ -25,7 +25,7 @@ else fi fi -VSCODE_LAUNCHER="$VSCODE_DIR/launcher.js" +VSCODE_LAUNCHER="$VSCODE_DIR/resources/app/resources/common/bin/launcher.js" ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 VSCODE_PATH="$VSCODE_DIR/$ELECTRON_FILE" \ "$VSCODE_DIR/$ELECTRON_FILE" $VSCODE_LAUNCHER "$@" diff --git a/resources/linux/debian/code.desktop b/resources/linux/debian/code.desktop new file mode 100644 index 0000000000000..bc91a139cb8cc --- /dev/null +++ b/resources/linux/debian/code.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Visual Studio Code +Comment=Code Editing. Redefined. +GenericName=Text Editor +Exec=/usr/bin/code %U +Icon=code +Type=Application +StartupNotify=true +Categories=Utility;TextEditor;Development;IDE; +MimeType=text/plain; \ No newline at end of file diff --git a/resources/linux/debian/control.template b/resources/linux/debian/control.template new file mode 100644 index 0000000000000..35b6683e115a4 --- /dev/null +++ b/resources/linux/debian/control.template @@ -0,0 +1,10 @@ +Package: visual-studio-code +Version: @@VERSION@@ +Section: devel +Priority: optional +Architecture: @@ARCHITECTURE@@ +Maintainer: Microsoft Corporation +Homepage: https://github.com/Microsoft/vscode +Installed-Size: @@INSTALLEDSIZE@@ +Description: Code Editing. Redefined. + Build and debug modern web and cloud applications.