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",
20 "files.associations": {
26 die
"Could not write settings.json"
28 # Infer some setup-specific locations/names
30 GCCPATH
="$(which gcc)"
31 GDBPATH
="$(which gdb)"
32 MAKECOMMAND
="make -j5 DEVELOPER=1"
37 GCCPATH
="$(cygpath -am "$GCCPATH")"
38 GDBPATH
="$(cygpath -am "$GDBPATH")"
39 MAKE_BASH
="$(cygpath -am /git-cmd.exe) --command=usr\\\\bin\\\\bash.exe"
40 MAKECOMMAND
="$MAKE_BASH -lc \\\"$MAKECOMMAND\\\""
54 cat >.vscode
/tasks.json.new
<<EOF ||
56 // See https://go.microsoft.com/fwlink/?LinkId=733558
57 // for the documentation about the tasks.json format
63 "command": "$MAKECOMMAND",
72 die
"Could not install default build task"
76 cat >.vscode
/launch.json.new
<<EOF ||
78 // Use IntelliSense to learn about possible attributes.
79 // Hover to view descriptions of existing attributes.
80 // For more information, visit:
81 // https://go.microsoft.com/fwlink/?linkid=830387
85 "name": "(gdb) Launch",
88 "program": "\${workspaceFolder}/git$X",
91 "cwd": "\${workspaceFolder}",
93 "externalConsole": true,
95 "miDebuggerPath": "$GDBPATH",
98 "description": "Enable pretty-printing for gdb",
99 "text": "-enable-pretty-printing",
100 "ignoreFailures": true
107 die
"Could not write launch configuration"
109 # C/C++ extension settings
111 make -f - OSNAME
=$OSNAME GCCPATH
="$GCCPATH" vscode-init \
112 >.vscode
/c_cpp_properties.json
<<\EOF ||
116 @mkdir
-p .vscode
&& \
118 for e
in $
(ALL_CFLAGS
) \
119 '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
120 '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
121 '-DBINDIR="$(bindir_relative_SQ)"' \
122 '-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"' \
123 '-DDEFAULT_GIT_TEMPLATE_DIR="$(template_dir_SQ)"' \
124 '-DETC_GITCONFIG="$(ETC_GITCONFIG_SQ)"' \
125 '-DETC_GITATTRIBUTES="$(ETC_GITATTRIBUTES_SQ)"' \
126 '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
127 '-DCURL_DISABLE_TYPECHECK', \
128 '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
129 '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
130 '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'; do \
133 incs
="$$(printf '% 16s"$
${workspaceRoot}",\n%s' \
137 incs
="$$(printf '% 16s"%s
",\n%s' \
138 "" "$
${e#-I}" "$
$incs")" \
141 incs
="$$(printf '% 16s"$
${workspaceRoot}/%s
",\n%s' \
142 "" "$
${e#-I}" "$
$incs")" \
145 defs
="$$(printf '% 16s"%s
",\n%s' \
146 "" "$$
(echo "$${e#-D}" |
sed 's/"/\\&/g')" \
152 echo ' "configurations": [' && \
154 echo ' "name": "$(OSNAME)",' && \
155 echo ' "intelliSenseMode": "clang-x64",' && \
156 echo ' "includePath": [' && \
157 echo "$$incs" |
sort |
sed '$$s/,$$//' && \
159 echo ' "defines": [' && \
160 echo "$$defs" |
sort |
sed '$$s/,$$//' && \
162 echo ' "browse": {' && \
163 echo ' "limitSymbolsToIncludedHeaders": true,' && \
164 echo ' "databaseFilename": "",' && \
165 echo ' "path": [' && \
166 echo ' "$${workspaceRoot}"' && \
169 echo ' "cStandard": "c11",' && \
170 echo ' "cppStandard": "c++17",' && \
171 echo ' "compilerPath": "$(GCCPATH)"' && \
174 echo ' "version": 4' && \
177 die
"Could not write settings for the C/C++ extension"
179 for file in .vscode
/settings.json .vscode
/tasks.json .vscode
/launch.json
183 if git
diff --no-index --quiet --exit-code $file $file.new
187 printf "The file $file.new has these changes:\n\n"
188 git
--no-pager diff --no-index $file $file.new
189 printf "\n\nMaybe \`mv $file.new $file\`?\n\n"