8 cd "$(dirname "$0")"/../.. ||
9 die "Could not cd to top-level directory"
12 die "Could not create .vscode/"
16 cat >.vscode/settings.json.new <<\EOF ||
18 "C_Cpp.intelliSenseEngine": "Default",
19 "C_Cpp.intelliSenseEngineFallback": "Disabled",
21 "editor.wordWrap": "wordWrapColumn",
22 "editor.wordWrapColumn": 72
25 "editor.detectIndentation": false,
26 "editor.insertSpaces": false,
28 "editor.wordWrap": "wordWrapColumn",
29 "editor.wordWrapColumn": 80,
30 "files.trimTrailingWhitespace": true
32 "files.associations": {
36 "cSpell.ignorePaths": [
190 "cSpell.ignoreRegExpList": [
191 "\\\"(DIRC|FSMN|REUC|UNTR)\\\"",
192 "\\\\u[0-9a-fA-Fx]{4}\\b",
193 "\\b(filfre|frotz|xyzzy)\\b",
194 "\\bCMIT_FMT_DEFAULT\\b",
196 "\\bGET_OID_DISAMBIGUATORS\\b",
197 "\\bHASH_RENORMALIZE\\b",
198 "\\bTREESAMEness\\b",
200 "\\Wchar *\\*\\W*utfs\\W",
207 die "Could not write settings.json"
209 # Infer some setup-specific locations/names
211 GCCPATH="$(which gcc)"
212 GDBPATH="$(which gdb)"
213 MAKECOMMAND="make -j5 DEVELOPER=1"
216 case "$(uname -s)" in
218 GCCPATH="$(cygpath -am "$GCCPATH")"
219 GDBPATH="$(cygpath -am "$GDBPATH")"
220 MAKE_BASH="$(cygpath -am /git-cmd.exe) --command=usr\\\\bin\\\\bash.exe"
221 MAKECOMMAND="$MAKE_BASH -lc \\\"$MAKECOMMAND\\\""
235 cat >.vscode/tasks.json.new <<EOF ||
237 // See https://go.microsoft.com/fwlink/?LinkId=733558
238 // for the documentation about the tasks.json format
244 "command": "$MAKECOMMAND",
253 die "Could not install default build task"
257 cat >.vscode/launch.json.new <<EOF ||
259 // Use IntelliSense to learn about possible attributes.
260 // Hover to view descriptions of existing attributes.
261 // For more information, visit:
262 // https://go.microsoft.com/fwlink/?linkid=830387
266 "name": "(gdb) Launch",
269 "program": "\${workspaceFolder}/git$X",
271 "stopAtEntry": false,
272 "cwd": "\${workspaceFolder}",
274 "externalConsole": true,
276 "miDebuggerPath": "$GDBPATH",
279 "description": "Enable pretty-printing for gdb",
280 "text": "-enable-pretty-printing",
281 "ignoreFailures": true
288 die "Could not write launch configuration"
290 # C/C++ extension settings
292 make -f - OSNAME=$OSNAME GCCPATH="$GCCPATH" vscode-init \
293 >.vscode/c_cpp_properties.json <<\EOF ||
297 @mkdir -p .vscode && \
299 for e in $(ALL_CFLAGS) \
300 '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
301 '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
302 '-DBINDIR="$(bindir_relative_SQ)"' \
303 '-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"' \
304 '-DDEFAULT_GIT_TEMPLATE_DIR="$(template_dir_SQ)"' \
305 '-DETC_GITCONFIG="$(ETC_GITCONFIG_SQ)"' \
306 '-DETC_GITATTRIBUTES="$(ETC_GITATTRIBUTES_SQ)"' \
307 '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
308 '-DCURL_DISABLE_TYPECHECK', \
309 '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
310 '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
311 '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'; do \
314 incs="$$(printf '% 16s"$${workspaceRoot}",\n%s' \
318 incs="$$(printf '% 16s"%s",\n%s' \
319 "" "$${e#-I}" "$$incs")" \
322 incs="$$(printf '% 16s"$${workspaceRoot}/%s",\n%s' \
323 "" "$${e#-I}" "$$incs")" \
326 defs="$$(printf '% 16s"%s",\n%s' \
327 "" "$$(echo "$${e#-D}" | sed 's/"/\\&/g')" \
333 echo ' "configurations": [' && \
335 echo ' "name": "$(OSNAME)",' && \
336 echo ' "intelliSenseMode": "clang-x64",' && \
337 echo ' "includePath": [' && \
338 echo "$$incs" | sort | sed '$$s/,$$//' && \
340 echo ' "defines": [' && \
341 echo "$$defs" | sort | sed '$$s/,$$//' && \
343 echo ' "browse": {' && \
344 echo ' "limitSymbolsToIncludedHeaders": true,' && \
345 echo ' "databaseFilename": "",' && \
346 echo ' "path": [' && \
347 echo ' "$${workspaceRoot}"' && \
350 echo ' "cStandard": "c11",' && \
351 echo ' "cppStandard": "c++17",' && \
352 echo ' "compilerPath": "$(GCCPATH)"' && \
355 echo ' "version": 4' && \
358 die "Could not write settings for the C/C++ extension"
360 for file in .vscode/settings.json .vscode/tasks.json .vscode/launch.json
364 if git diff --no-index --quiet --exit-code $file $file.new
368 printf "The file $file.new has these changes:\n\n"
369 git --no-pager diff --no-index $file $file.new
370 printf "\n\nMaybe \`mv $file.new $file\`?\n\n"