Project Address:
https://github.com/microsoft/vscode
Compilation Notes:
https://github.com/microsoft/vscode/wiki/How-to-Contribute
Reference:
https://github.com/fzxa/VSCode-sourcecode-analysis/blob/master/chapter-1.md
https://blog.csdn.net/zhugangsong/category_12600296.html
Compilation
Install the environment
My computer is window
Install the environment first:
Note that native modules are installed when installing node
- if you install Node on your system using the Node installer from the Node.JS page then ensure that you have installed the 'Tools for Native Modules'. Everything should work out of the box then.
Build
cd vscode
yarn
There is an error
build error "MSB8040: Spectre-mitigated libraries are required
It is written
Install it
### Build scriptRun the following command and ts will be compiled to js
yarn watch
Launch
.\scripts\code.bat
.\scripts\code-cli.bat #这一步不知道干啥的
Debugging
Open the Chrome debugging panel
## Compile to start the analysisThe startup of the program is mainly two commands
yarn watch
code.bat
Let's analyze them in turn
Yarn watch
"watch": "npm-run-all -lp watch-client watch-extensions",
npm-run-all
-l, --print-label - - - - Set the flag to print the task name as a prefix
on each line of output. Tools in tasks may s
-p, --parallel <tasks> - Run a group of tasks in parallel.
e.g. 'npm-run-all -p foo bar' is similar to
It's all about doing it at the same time
--max-old-space-size specifies the maximum memory unit M available for the node
"watch-client": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js watch-client",
and
"watch-extensions": "node --max-old-space-size=4095 ./node_modules/gulp/bin/gulp.js watch-extensions watch-extension-media",
Then execute [gulp] (https://gulpjs.com/)
After a quick look, watch-client is mainly compiled
src/\*\* to the out/ directory
Because our project doesn't have plugins, it doesn't matter.
The specific compilation details will not be studied, and the current mainstream no longer uses the original TS compilation tool such as Glup. There is no learning value.
We just need to know that after yarn watch, we can write TS scripts in the src directory with peace of mind.
code.bat
Executed first
node build/lib/preLaunch.js
The main thing is to execute
yarn electron
Then find the product name
Looking for the nameShort field in the product.json is the binary program that was compiled earlier
Then execute
%CODE% . %* //%* indicates a command-line parameter. We execute without parameters, so it's empty
Equivalent
Summary:yarn electron
.build\electron\Code - OSS.exe
yarn electron
node build/lib/electron
This command is to package electron
The generated resources are in .build/electron