Skip to content

Instantly share code, notes, and snippets.

@iczero
Last active April 14, 2022 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iczero/48d16000a3524154706920b350fb49ea to your computer and use it in GitHub Desktop.
Save iczero/48d16000a3524154706920b350fb49ea to your computer and use it in GitHub Desktop.
Compile linux builds of VSCode from source
#!/bin/bash
# note: certain directory names have been changed to the original to
# preserve compatibility with certain extensions that do not expect
# changed directory names
export NVM_DIR="$(realpath nvm)" && (
git clone https://github.com/creationix/nvm.git "$NVM_DIR" || true
cd "$NVM_DIR"
git fetch --all
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"
nvm install 10
set -xe
mkdir -p out/linux/deb out/linux/rpm out/linux/generic
rm -rf latest
git clone https://github.com/Microsoft/vscode -b master --depth 1000 || true
cd vscode
git fetch --all --tags
export VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
if [ -f ../out/linux/generic/vscode-linux-x64-$VERSION.tar.gz ]; then
echo "Build already exists."
exit 0
fi
git checkout -f $VERSION
which node
yarn install
# NOTE: when updating product.json, don't forget to double-escape backslashes
# and remove darwin credits key and remove prebuilt electron repo
cat <<EOF >product.json
{
"nameShort": "Code",
"nameLong": "Code",
"applicationName": "code-oss",
"win32AppId": "{{F8A2A208-72B3-4D61-95FC-8A65D340689B}",
"win32x64AppId": "{{EA457B21-F73E-494C-ACAB-524FDE069978}",
"win32UserAppId": "{{D628A17A-9713-46BF-8D57-E671B46A741E}",
"win32x64UserAppId": "{{771FD6B0-FA20-440A-A002-3B3BAC16DC50}",
"win32NameVersion": "Code",
"win32DirName": "Microsoft VS Code",
"win32SetupExeBasename": "VSCodeSetup",
"win32AppUserModelId": "Microsoft.VisualStudioCode",
"win32ShellNameShort": "Code",
"win32MutexName": "vscode",
"win32RegValueName": "VSCode",
"darwinBundleIdentifier": "com.microsoft.VSCode",
"darwinExecutable": "VSCode",
"linuxIconName": "com.visualstudio.code.oss",
"licenseFileName": "LICENSE.txt",
"licenseName": "MIT",
"urlProtocol": "vscode",
"dataFolderName": ".vscode",
"serverDataFolderName": ".vscode-server",
"downloadUrl": "https://example.com/",
"welcomePage": "https://go.microsoft.com/fwlink/?LinkId=723048",
"updateUrl": "https://update.code.visualstudio.com",
"quality": "stable",
"extensionsGallery": {
"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
"itemUrl": "https://marketplace.visualstudio.com/items",
"controlUrl": "https://az764295.vo.msecnd.net/extensions/marketplace.json",
"recommendationsUrl": "https://az764295.vo.msecnd.net/extensions/workspaceRecommendations.json.gz"
},
"extensionTips": {
"ms-vscode.csharp": "{**/*.cs,**/project.json,**/global.json,**/*.csproj,**/*.cshtml,**/*.sln,**/appsettings.json}",
"msjsdiag.debugger-for-chrome": "{**/*.ts,**/*.tsx**/*.js,**/*.jsx,**/*.es6,**/.babelrc}",
"ms-vscode.Go": "**/*.go",
"ms-vscode.PowerShell": "{**/*.ps,**/*.ps1,**/*.ps.config,**/*.ps1.config}",
"austin.code-gnu-global": "{**/*.c,**/*.cpp,**/*.h}",
"Ionide.Ionide-fsharp": "{**/*.fsx,**/*.fsi,**/*.fs,**/*.ml,**/*.mli}",
"dbaeumer.vscode-eslint": "{**/*.js,**/*.jsx,**/*.es6,**/.eslintrc.*,**/.eslintrc,**/.babelrc,**/jsconfig.json}",
"dbaeumer.jshint": "{**/*.js,**/*.jsx,**/*.es6,**/.babelrc,**/jsconfig.json,**/.jshintrc,**/.jshintignore}",
"ms-vscode.vscode-typescript-tslint-plugin": "{**/*.ts,**/*.tsx,**/tslint.json,**/tsconfig.json}",
"bmewburn.vscode-intelephense-client": "{**/*.php,**/php.ini}",
"felixfbecker.php-intellisense": "{**/*.php,**/php.ini}",
"felixfbecker.php-debug": "{**/*.php,**/php.ini}",
"ikappas.phpcs": "{**/*.php,**/php.ini}",
"rust-lang.rust": "{**/*.rs,**/*.rslib}",
"ms-vscode.cpptools": "{**/*.c,**/*.cpp,**/*.cc,**/.cxx,**/*.hh,**/*.hpp,**/*.hxx,**/*.h}",
"DavidAnson.vscode-markdownlint": "{**/*.md}",
"ms-azuretools.vscode-docker": "{**/dockerfile,**/Dockerfile,**/docker-compose.yml,**/docker-compose.*.yml}",
"EditorConfig.EditorConfig": "{**/.editorconfig}",
"HookyQR.beautify": "{**/.jsbeautifyrc,**/*.js,**/*.jsx,**/*.es6,**/.eslintrc.*,**/.babelrc,**/jsconfig.json}",
"donjayamanne.githistory": "{**/.gitignore,**/.git}",
"felipecaputo.git-project-manager": "{**/.gitignore,**/.git}",
"eamodio.gitlens": "{**/.gitignore,**/.git}",
"rebornix.Ruby": "{**/*.rb,**/*.erb,**/*.reek,**/.fasterer.yml,**/ruby-lint.yml,**/.rubocop.yml}",
"DotJoshJohnson.xml": "{**/*.xml}",
"shinnn.stylelint": "{**/.stylelintrc,**/stylelint.config.js}",
"eg2.vscode-npm-script": "{**/package.json}",
"ms-mssql.mssql": "{**/*.sql}",
"usqlextpublisher.usql-vscode-ext": "{**/*.usql}",
"ms-vscode.sublime-keybindings": "{**/.sublime-project,**/.sublime-workspace}",
"k--kato.intellij-idea-keybindings": "{**/.idea}",
"christian-kohler.npm-intellisense": "{**/package.json}",
"octref.vetur": "{**/*.vue}",
"ms-python.python": "{**/*.py}",
"cake-build.cake-vscode": "{**/build.cake}",
"Angular.ng-template": "{**/.angular-cli.json,**/*.ng.html,**/*.ng,**/*.ngml}",
"vscjava.vscode-maven": "**/pom.xml",
"ms-azuretools.vscode-azureterraform": "**/*.tf",
"mauve.terraform": "**/*.tf",
"vsciot-vscode.vscode-arduino": "**/*.ino",
"ms-kubernetes-tools.vscode-kubernetes-tools ": "{**/Chart.yaml}"
},
"extensionImportantTips": {
"ms-vscode.csharp": {
"name": "C#",
"pattern": "{**/*.cs,**/project.json,**/global.json,**/*.csproj,**/*.cshtml,**/*.sln}"
},
"ms-python.python": {
"name": "Python",
"pattern": "{**/*.py}"
},
"ms-vscode.Go": {
"name": "Go",
"pattern": "**/*.go"
},
"vscjava.vscode-java-pack": {
"name": "Java",
"pattern": "{**/*.java}"
},
"ms-vscode.PowerShell": {
"name": "PowerShell",
"pattern": "{**/*.ps,**/*.ps1}"
},
"ms-vscode.cpptools": {
"name": "C/C++",
"pattern": "{**/*.c,**/*.cpp,**/*.cc,**/.cxx,**/*.hh,**/*.hpp,**/*.hxx,**/*.h}"
},
"ms-azuretools.vscode-docker": {
"name": "Docker",
"pattern": "{**/dockerfile,**/Dockerfile,**/docker-compose.yml,**/docker-compose.*.yml}"
},
"ms-mssql.mssql": {
"name": "mssql",
"pattern": "{**/*.sql}"
},
"octref.vetur": {
"name": "Vetur",
"pattern": "{**/*.vue}"
},
"vsciot-vscode.vscode-arduino": {
"name": "Arduino",
"pattern": "{**/*.ino}"
}
},
"keymapExtensionTips": ["vscodevim.vim", "ms-vscode.sublime-keybindings", "ms-vscode.atom-keybindings", "ms-vscode.vs-keybindings", "ms-vscode.notepadplusplus-keybindings", "k--kato.intellij-idea-keybindings", "hiro-sun.vscode-emacs", "alphabotsec.vscode-eclipse-keybindings", "alefragnani.delphi-keybindings"],
"exeBasedExtensionTips": {
"az": {
"friendlyName": "Azure CLI",
"windowsPath": "%ProgramFiles(x86)%\\\\Microsoft SDKs\\\\Azure\\\\CLI2\\\\wbin\\\\az.cmd",
"recommendations": ["ms-vscode.azurecli"]
},
"heroku": {
"friendlyName": "Heroku CLI",
"windowsPath": "%ProgramFiles%\\\\Heroku\\\\bin\\\\heroku.cmd",
"recommendations": ["ms-azuretools.vscode-azureappservice", "pkosta2005.heroku-command"]
},
"mongo": {
"friendlyName": "Mongo",
"windowsPath": "%ProgramFiles%\\\\MongoDB\\\\Server\\\\3.6\\\\bin\\\\mongod.exe",
"recommendations": ["ms-azuretools.vscode-cosmosdb"]
},
"serverless": {
"friendlyName": "Serverless framework",
"windowsPath": "%APPDATA%\\\\npm\\\\serverless.cmd",
"recommendations": ["ms-azuretools.vscode-azurefunctions"]
},
"func": {
"friendlyName": "Azure Function SDK",
"windowsPath": "%APPDATA%\\\\npm\\\\func.cmd",
"recommendations": ["ms-azuretools.vscode-azurefunctions"]
},
"mysql": {
"friendlyName": "MySQL",
"windowsPath": "%ProgramFiles%\\\\MySQL\\\\MySQL Server 5.7\\\\bin\\\\mysqld.exe",
"recommendations": ["ms-mssql.mssql", "bajdzis.vscode-database"]
},
"postgres": {
"friendlyName": "PostgreSQL",
"windowsPath": "%ProgramFiles%\\\\PostgreSQL\\\\9.6\\\\bin\\\\psql.exe",
"recommendations": ["ms-mssql.mssql", "bajdzis.vscode-database"]
},
"sqlcmd": {
"friendlyName": "SQL CLI",
"recommendations": ["ms-mssql.mssql"]
},
"now": {
"friendlyName": "Now CLI",
"windowsPath": "%APPDATA%\\\\npm\\\\now.cmd",
"recommendations": ["ms-azuretools.vscode-azureappservice", "ms-azuretools.vscode-docker"]
},
"docker": {
"friendlyName": "Docker",
"windowsPath": "%ProgramFiles%\\\\Docker\\\\Docker\\\\Resources\\\\bin\\\\docker.exe",
"recommendations": ["ms-azuretools.vscode-docker", "ms-kubernetes-tools.vscode-kubernetes-tools", "azuredevspaces.azds"]
},
"kubectl": {
"friendlyName": "Kubernetes",
"windowsPath": "%ProgramFiles%\\\\Docker\\\\Docker\\\\Resources\\\\bin\\\\kubectl.exe",
"recommendations": ["ms-azuretools.vscode-docker", "ms-kubernetes-tools.vscode-kubernetes-tools", "azuredevspaces.azds"]
},
"ng": {
"friendlyName": "Angular CLI",
"windowsPath": "%APPDATA%\\\\npmexit\\\\ng.cmd",
"recommendations": ["johnpapa.Angular2"]
},
"create-react-app": {
"friendlyName": "Create React App",
"windowsPath": "%APPDATA%\\\\npm\\\\create-react-app.cmd",
"recommendations": ["vsmobile.vscode-react-native"]
},
"git": {
"friendlyName": "Git",
"windowsPath": "%ProgramFiles%\\\\Git\\\\cmd\\\\git.exe",
"recommendations": ["ms-vsts.team"]
},
"tfx": {
"friendlyName": "Team Foundation Server",
"recommendations": ["ms-vsts.team"]
},
"p4": {
"friendlyName": "Perforce",
"recommendations": ["slevesque.perforce"]
},
"hg": {
"friendlyName": "Mercurial",
"recommendations": ["mrcrowl.hg"]
},
"subl": {
"friendlyName": "Sublime",
"windowsPath": "%ProgramFiles%\\\\Sublime Text3\\\\sublime_text.exe",
"recommendations": ["ms-vscode.sublime-keybindings"]
},
"atom": {
"friendlyName": "Atom",
"windowsPath": "%USERPROFILE%\\\\AppData\\\\Local\\\\atom\\\\bin\\\\atom.cmd",
"recommendations": ["ms-vscode.atom-keybindings"]
},
"notepadplusplus": {
"friendlyName": "Notepad++",
"windowsPath": "%ProgramFiles%\\\\Notepad++\\\\Notepad++.exe",
"recommendations": ["ms-vscode.notepadplusplus-keybindings"]
},
"vi": {
"friendlyName": "VIM",
"windowsPath": "%ProgramFiles(x86)\\\\Vim\\\\vim80\\\\gvim.exe",
"recommendations": ["vscodevim.vim"]
},
"mvn": {
"friendlyName": "Maven",
"recommendations": ["vscjava.vscode-maven"]
},
"Microsoft Edge": {
"friendlyName": "Microsoft Edge",
"windowsPath": "%USERPROFILE%\\\\AppData\\\\Local\\\\Microsoft\\\\Edge\\\\Application\\\\msedge.exe",
"recommendations": ["msjsdiag.debugger-for-edge"]
},
"Microsoft Edge Dev": {
"friendlyName": "Microsoft Edge Dev",
"windowsPath": "%USERPROFILE%\\\\AppData\\\\Local\\\\Microsoft\\\\Edge Dev\\\\Application\\\\msedge.exe",
"recommendations": ["msjsdiag.debugger-for-edge"]
},
"Microsoft Edge Beta": {
"friendlyName": "Microsoft Edge Beta",
"windowsPath": "%USERPROFILE%\\\\AppData\\\\Local\\\\Microsoft\\\\Edge Beta\\\\Application\\\\msedge.exe",
"recommendations": ["msjsdiag.debugger-for-edge"]
},
"Microsoft Edge Canary": {
"friendlyName": "Microsoft Edge Canary",
"windowsPath": "%USERPROFILE%\\\\AppData\\\\Local\\\\Microsoft\\\\Edge SxS\\\\Application\\\\msedge.exe",
"recommendations": ["msjsdiag.debugger-for-edge"]
},
"react-native": {
"friendlyName": "React Native",
"windowsPath": "%APPDATA%\\\\npm\\\\react-native-cli",
"recommendations": ["vsmobile.vscode-react-native"]
},
"cordova": {
"friendlyName": "Cordova",
"windowsPath": "%APPDATA%\\\\npm\\\\cordova",
"recommendations": ["vsmobile.cordova-tools"]
}
},
"extensionKeywords": {
"md": ["Markdown"],
"js": ["JavaScript"],
"jsx": ["JavaScript"],
"es6": ["JavaScript"],
"html": ["Html"],
"ts": ["TypeScript"],
"tsx": ["TypeScript"],
"css": ["CSS"],
"scss": ["SASS"],
"txt": ["Text"],
"php": ["PHP"],
"php3": ["PHP"],
"php4": ["PHP"],
"ph3": ["PHP"],
"ph4": ["PHP"],
"xml": ["XML"],
"py": ["Python"],
"pyc": ["Python"],
"pyd": ["Python"],
"pyo": ["Python"],
"pyw": ["Python"],
"pyz": ["Python"],
"java": ["Java"],
"class": ["Java"],
"jar": ["Java"],
"c": ["c", "objective c", "objective-c"],
"m": ["objective c", "objective-c"],
"mm": ["objective c", "objective-c"],
"cpp": ["cpp", "c plus plus", "c", "c++"],
"cc": ["cpp", "c plus plus", "c", "c++"],
"cxx": ["cpp", "c plus plus", "c++"],
"hh": ["cpp", "c plus plus", "c++"],
"hpp": ["cpp", "c++"],
"h": ["cpp", "c plus plus", "c++", "c", "objective c", "objective-c"],
"sql": ["sql"],
"sh": ["bash"],
"bash": ["bash"],
"zsh": ["bash", "zshell"],
"cs": ["c#", "csharp"],
"csproj": ["c#", "csharp"],
"sln": ["c#", "csharp"],
"go": ["go"],
"sty": ["latex"],
"tex": ["latex"],
"ps": ["powershell"],
"ps1": ["powershell"],
"rs": ["rust"],
"rslib": ["rust"],
"hs": ["haskell"],
"lhs": ["haskell"],
"scm": ["scheme"],
"ss": ["scheme"],
"clj": ["clojure"],
"cljs": ["clojure"],
"cljc": ["clojure"],
"edn": ["clojure"],
"erl": ["erlang"],
"hrl": ["erlang"],
"scala": ["scala"],
"sc": ["scala"],
"pl": ["perl"],
"pm": ["perl"],
"t": ["perl"],
"pod": ["perl"],
"groovy": ["groovy"],
"swift": ["swift"],
"rb": ["ruby"],
"rbw": ["ruby"],
"jl": ["julia"],
"f": ["fortran"],
"for": ["fortran"],
"f90": ["fortran"],
"f95": ["fortran"],
"coffee": ["CoffeeScript"],
"litcoffee": ["CoffeeScript"],
"yaml": ["yaml"],
"yml": ["yaml"],
"dart": ["dart"],
"json": ["json"]
},
"extensionAllowedBadgeProviders": ["api.bintray.com", "api.travis-ci.com", "api.travis-ci.org", "app.fossa.io", "badge.buildkite.com", "badge.fury.io", "badge.waffle.io", "badgen.net", "badges.frapsoft.com", "badges.gitter.im", "badges.greenkeeper.io", "cdn.travis-ci.com", "cdn.travis-ci.org", "ci.appveyor.com", "circleci.com", "cla.opensource.microsoft.com", "codacy.com", "codeclimate.com", "codecov.io", "coveralls.io", "david-dm.org", "deepscan.io", "dev.azure.com", "docs.rs", "flat.badgen.net", "gemnasium.com", "githost.io", "gitlab.com", "godoc.org", "goreportcard.com", "img.shields.io", "isitmaintained.com", "marketplace.visualstudio.com", "nodesecurity.io", "opencollective.com", "snyk.io", "travis-ci.com", "travis-ci.org", "visualstudio.com", "vsmarketplacebadge.apphb.com", "www.bithound.io", "www.versioneye.com"],
"documentationUrl": "https://go.microsoft.com/fwlink/?LinkID=533484#vscode",
"releaseNotesUrl": "https://go.microsoft.com/fwlink/?LinkID=533483#vscode",
"keyboardShortcutsUrlMac": "https://go.microsoft.com/fwlink/?linkid=832143",
"keyboardShortcutsUrlLinux": "https://go.microsoft.com/fwlink/?linkid=832144",
"keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145",
"introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146",
"tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118",
"newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter",
"twitterUrl": "https://go.microsoft.com/fwlink/?LinkID=533687",
"requestFeatureUrl": "https://go.microsoft.com/fwlink/?LinkID=533482",
"reportIssueUrl": "https://github.com/Microsoft/vscode/issues/new",
"licenseUrl": "https://go.microsoft.com/fwlink/?LinkID=533485",
"privacyStatementUrl": "https://go.microsoft.com/fwlink/?LinkId=786907",
"telemetryOptOutUrl": "https://go.microsoft.com/fwlink/?linkid=870136",
"checksumFailMoreInfoUrl": "https://go.microsoft.com/fwlink/?LinkId=828886",
"extensionAllowedProposedApi": ["ms-vscode.references-view", "ms-vsliveshare.vsliveshare", "ms-vsliveshare.cloudenv", "ms-vsliveshare.cloudenv-explorer", "GitHub.vscode-pull-request-github", "Microsoft.vscode-nmake-tools", "atlassian.atlascode", "ms-vscode-remote.remote-containers", "ms-vscode-remote.remote-containers-nightly", "ms-vscode-remote.remote-ssh", "ms-vscode-remote.remote-ssh-nightly", "ms-vscode-remote.remote-ssh-edit", "ms-vscode-remote.remote-ssh-edit-nightly", "ms-vscode-remote.remote-ssh-explorer", "ms-vscode-remote.remote-ssh-explorer-nightly", "ms-vscode-remote.remote-wsl", "ms-vscode-remote.remote-wsl-nightly", "ms-vscode-remote.vscode-remote-extensionpack", "ms-vscode-remote.vscode-remote-extensionpack-nightly"],
"uiExtensions": ["atlassian.atlascode", "CoenraadS.bracket-pair-colorizer", "formulahendry.auto-close-tag", "hiro-sun.vscode-emacs", "hnw.vscode-auto-open-markdown-preview", "monokai.theme-monokai-pro-vscode", "shalldie.background", "techer.open-in-browser", "vincaslt.highlight-matching-tag", "wayou.vscode-todo-highlight", "ms-azuretools.vscode-docker"],
"commit": "$(git rev-parse HEAD)",
"date": "$(node -e 'console.log(new Date())')",
"builtInExtensions": $(jq .builtInExtensions product.json)
}
EOF
export NODE_ENV=production
npx gulp vscode-linux-x64-min --max_old_space_size=16384
npx gulp vscode-linux-x64-build-deb --max_old_space_size=16384
npx gulp vscode-linux-x64-build-rpm --max_old_space_size=16384
cd ../VSCode-linux-x64
tar czf ../out/linux/generic/vscode-linux-x64-$VERSION.tar.gz .
cd ..
rm -rf VSCode-linux-x64
DEB_PATH=$(realpath vscode/.build/linux/deb/amd64/deb/*.deb)
RPM_PATH=$(realpath vscode/.build/linux/rpm/x86_64/*.rpm)
cp $DEB_PATH out/linux/deb
cp $RPM_PATH out/linux/rpm
mkdir -p latest
cp out/linux/generic/vscode-linux-x64-$VERSION.tar.gz latest/vscode-linux-x64.tar.gz
cp $DEB_PATH latest/vscode-linux-x64.deb
cp $RPM_PATH latest/vscode-linux-x64.rpm
echo $VERSION > latest/version.txt
rm -rf vscode/.build/linux
# this isn't cleaned up properly
rm -rf /tmp/gulp-electron-cache || echo "Unable to clean up /tmp/gulp-electron-cache"
@kcinnu
Copy link

kcinnu commented Apr 14, 2022

based

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment