diff --git a/build/lib/snapshotLoader.js b/build/lib/snapshotLoader.js new file mode 100644 index 00000000000..f89fbb2cd5c --- /dev/null +++ b/build/lib/snapshotLoader.js @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; +var snaps; +(function (snaps) { + var fs = require('fs'); + var path = require('path'); + var os = require('os'); + var cp = require('child_process'); + var mksnapshot = path.join(__dirname, "../../node_modules/.bin/" + (process.platform === 'win32' ? 'mksnapshot.cmd' : 'mksnapshot')); + var product = require('../../product.json'); + // + var loaderFilepath; + var startupBlobFilepath; + switch (process.platform) { + case 'darwin': + loaderFilepath = "VSCode-darwin/" + product.nameLong + ".app/Contents/Resources/app/out/vs/loader.js"; + startupBlobFilepath = "VSCode-darwin/" + product.nameLong + ".app/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin"; + break; + case 'win32': + case 'linux': + loaderFilepath = "VSCode-" + process.platform + "/loader.js"; + startupBlobFilepath = "VSCode-" + process.platform + "/snapshot_blob.bin"; + } + loaderFilepath = path.join(__dirname, '../../../', loaderFilepath); + startupBlobFilepath = path.join(__dirname, '../../../', startupBlobFilepath); + snapshotLoader(loaderFilepath, startupBlobFilepath); + function snapshotLoader(loaderFilepath, startupBlobFilepath) { + var inputFile = fs.readFileSync(loaderFilepath); + var wrappedInputFile = "\n\t\tvar Monaco_Loader_Init;\n\t\t(function() {\n\t\t\tvar doNotInitLoader = true;\n\t\t\t" + inputFile.toString() + ";\n\t\t\tMonaco_Loader_Init = function() {\n\t\t\t\tAMDLoader.init();\n\t\t\t\tCSSLoaderPlugin.init();\n\t\t\t\tNLSLoaderPlugin.init();\n\n\t\t\t\treturn define;\n\t\t\t}\n\t\t})();\n\t\t"; + var wrappedInputFilepath = path.join(os.tmpdir(), 'wrapped-loader.js'); + console.log(wrappedInputFilepath); + fs.writeFileSync(wrappedInputFilepath, wrappedInputFile); + cp.execFileSync(mksnapshot, [wrappedInputFilepath, "--startup_blob", startupBlobFilepath]); + } +})(snaps || (snaps = {})); diff --git a/build/lib/snapshotLoader.ts b/build/lib/snapshotLoader.ts new file mode 100644 index 00000000000..0562aec6754 --- /dev/null +++ b/build/lib/snapshotLoader.ts @@ -0,0 +1,62 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +namespace snaps { + + const fs = require('fs'); + const path = require('path'); + const os = require('os'); + const cp = require('child_process'); + + const mksnapshot = path.join(__dirname, `../../node_modules/.bin/${process.platform === 'win32' ? 'mksnapshot.cmd' : 'mksnapshot'}`); + const product = require('../../product.json'); + + // + let loaderFilepath: string; + let startupBlobFilepath: string; + + switch (process.platform) { + case 'darwin': + loaderFilepath = `VSCode-darwin/${product.nameLong}.app/Contents/Resources/app/out/vs/loader.js`; + startupBlobFilepath = `VSCode-darwin/${product.nameLong}.app/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin`; + break; + + case 'win32': + case 'linux': + loaderFilepath = `VSCode-${process.platform}/loader.js`; + startupBlobFilepath = `VSCode-${process.platform}/snapshot_blob.bin`; + } + + loaderFilepath = path.join(__dirname, '../../../', loaderFilepath); + startupBlobFilepath = path.join(__dirname, '../../../', startupBlobFilepath); + + snapshotLoader(loaderFilepath, startupBlobFilepath); + + function snapshotLoader(loaderFilepath: string, startupBlobFilepath: string): void { + + const inputFile = fs.readFileSync(loaderFilepath); + const wrappedInputFile = ` + var Monaco_Loader_Init; + (function() { + var doNotInitLoader = true; + ${inputFile.toString()}; + Monaco_Loader_Init = function() { + AMDLoader.init(); + CSSLoaderPlugin.init(); + NLSLoaderPlugin.init(); + + return define; + } + })(); + `; + const wrappedInputFilepath = path.join(os.tmpdir(), 'wrapped-loader.js'); + console.log(wrappedInputFilepath); + fs.writeFileSync(wrappedInputFilepath, wrappedInputFile); + + cp.execFileSync(mksnapshot, [wrappedInputFilepath, `--startup_blob`, startupBlobFilepath]); + } +} diff --git a/build/tfs/darwin/build.sh b/build/tfs/darwin/build.sh index bff74a7b49c..e342401b34e 100755 --- a/build/tfs/darwin/build.sh +++ b/build/tfs/darwin/build.sh @@ -23,7 +23,10 @@ step "Install distro dependencies" \ node build/tfs/common/installDistro.js step "Build minified & upload source maps" \ - npm run gulp -- --max_old_space_size=4096 vscode-darwin-snapshots upload-vscode-sourcemaps + npm run gulp -- --max_old_space_size=4096 vscode-darwin-min upload-vscode-sourcemaps + +step "Create loader snapshot" + node build/lib/snapshotLoader.js step "Run unit tests" \ ./scripts/test.sh --build --reporter dot