1 | # !kmk_ash
|
---|
2 | # $Id: gen-vscode-workspace.sh 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Script for generating a Visual Studio Code (vscode) workspace.
|
---|
5 | #
|
---|
6 | # This is derived from gen-slickedit-workspace.sh, so fixes may apply to both.
|
---|
7 | #
|
---|
8 |
|
---|
9 | #
|
---|
10 | # Copyright (C) 2009-2022 Oracle and/or its affiliates.
|
---|
11 | #
|
---|
12 | # This file is part of VirtualBox base platform packages, as
|
---|
13 | # available from https://www.virtualbox.org.
|
---|
14 | #
|
---|
15 | # This program is free software; you can redistribute it and/or
|
---|
16 | # modify it under the terms of the GNU General Public License
|
---|
17 | # as published by the Free Software Foundation, in version 3 of the
|
---|
18 | # License.
|
---|
19 | #
|
---|
20 | # This program is distributed in the hope that it will be useful, but
|
---|
21 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
23 | # General Public License for more details.
|
---|
24 | #
|
---|
25 | # You should have received a copy of the GNU General Public License
|
---|
26 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
27 | #
|
---|
28 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
29 | #
|
---|
30 |
|
---|
31 | #
|
---|
32 | # Include code we share with gen-slickedit-workspace.sh
|
---|
33 | #
|
---|
34 | MY_SCRIPT_DIR=.
|
---|
35 | case "$0" in
|
---|
36 | */*|*\\*)
|
---|
37 | MY_SCRIPT_DIR=$(echo "$0" | kmk_sed -e 's,[/\][^/\][^/\]*$,,')
|
---|
38 | ;;
|
---|
39 | esac
|
---|
40 | . "${MY_SCRIPT_DIR}/common-gen-workspace.inc.sh"
|
---|
41 |
|
---|
42 |
|
---|
43 | #
|
---|
44 | # Globals.
|
---|
45 | #
|
---|
46 | MY_PROJECT_FILES=""
|
---|
47 |
|
---|
48 |
|
---|
49 | #
|
---|
50 | # Parameters w/ defaults.
|
---|
51 | #
|
---|
52 | MY_VSCODE_DIR=".vscode"
|
---|
53 | MY_VSCODE_FILE_DOT_EXT=".json"
|
---|
54 | MY_OUT_DIR=${MY_VSCODE_DIR}
|
---|
55 | MY_PRJ_PRF="VBox-"
|
---|
56 | MY_WS_NAME="virtualbox.code-workspace"
|
---|
57 | MY_DBG=""
|
---|
58 | MY_WINDOWS_HOST=""
|
---|
59 | MY_OPT_MINIMAL=""
|
---|
60 | MY_OPT_USE_WILDCARDS="yes"
|
---|
61 |
|
---|
62 |
|
---|
63 | ##
|
---|
64 | # Function generating an (intermediate) project task.
|
---|
65 | #
|
---|
66 | # @param $1 The project file name.
|
---|
67 | # @param $2 Build config name.
|
---|
68 | # @param $3 Task group to assign task to.
|
---|
69 | # @param $4 kBuild extra args.
|
---|
70 | # @param $5 kBuild working directory to set.
|
---|
71 | # If empty, the file's directory will be used.
|
---|
72 | # @param $6 kBuild per-task options.
|
---|
73 | # Leave empty if not being used.
|
---|
74 | my_generate_project_task()
|
---|
75 | {
|
---|
76 | MY_FILE="${1}";
|
---|
77 | MY_CFG_NAME="${2}";
|
---|
78 | MY_TASK_GROUP="${3}";
|
---|
79 | MY_KMK_EXTRAS="${4}";
|
---|
80 | MY_KMK_CWD="${5}";
|
---|
81 | MY_KMK_TASK_ARGS="${6}";
|
---|
82 | shift; shift; shift; shift; shift; shift;
|
---|
83 |
|
---|
84 | if [ -z "$MY_KMK_CWD" ]; then
|
---|
85 | MY_KMK_CWD='${fileDirname}'
|
---|
86 | fi
|
---|
87 |
|
---|
88 | MY_TASK_LABEL="${MY_TASK_GROUP}: ${MY_CFG_NAME}"
|
---|
89 |
|
---|
90 | echo ' {' >> "${MY_FILE}"
|
---|
91 | echo ' "type": "shell",' >> "${MY_FILE}"
|
---|
92 | echo ' "label": "'${MY_TASK_LABEL}'",' >> "${MY_FILE}"
|
---|
93 | echo ' "command": "'${MY_KMK_CMD}'",' >> "${MY_FILE}"
|
---|
94 | echo ' "args": [' >> "${MY_FILE}"
|
---|
95 | echo ' ' ${MY_KMK_ARGS} ',' >> "${MY_FILE}"
|
---|
96 | if [ -n "${MY_KMK_EXTRAS}" ]; then
|
---|
97 | echo ' '${MY_KMK_EXTRAS}' ,' >> "${MY_FILE}"
|
---|
98 | fi
|
---|
99 | echo ' "-C",' >> "${MY_FILE}"
|
---|
100 | echo ' "'${MY_KMK_CWD}'"' >> "${MY_FILE}"
|
---|
101 | if [ -n "${MY_KMK_TASK_ARGS}" ]; then
|
---|
102 | echo ' ', ${MY_KMK_TASK_ARGS} >> "${MY_FILE}"
|
---|
103 | fi
|
---|
104 | echo ' ],' >> "${MY_FILE}"
|
---|
105 | echo ' "options": {' >> "${MY_FILE}"
|
---|
106 | echo ' "cwd": "'${MY_KMK_CWD}'"' >> "${MY_FILE}"
|
---|
107 | echo ' },' >> "${MY_FILE}"
|
---|
108 | echo ' "problemMatcher": [' >> "${MY_FILE}"
|
---|
109 | echo ' "$gcc"' >> "${MY_FILE}"
|
---|
110 | echo ' ],' >> "${MY_FILE}"
|
---|
111 | echo ' "presentation": {' >> "${MY_FILE}"
|
---|
112 | echo ' "reveal": "always",' >> "${MY_FILE}"
|
---|
113 | echo ' "clear": true,' >> "${MY_FILE}"
|
---|
114 | echo ' "panel": "dedicated"' >> "${MY_FILE}"
|
---|
115 | echo ' },' >> "${MY_FILE}"
|
---|
116 | echo ' "detail": "compiler: /bin/clang++-9"' >> "${MY_FILE}"
|
---|
117 | echo ' },' >> "${MY_FILE}"
|
---|
118 | }
|
---|
119 |
|
---|
120 | ##
|
---|
121 | # Function generating a project build config.
|
---|
122 | #
|
---|
123 | # @param $1 The project file name.
|
---|
124 | # @param $2 Build config name.
|
---|
125 | # @param $3 Extra kBuild command line options, variant 1.
|
---|
126 | # @param $4 Extra kBuild command line options, variant 2.
|
---|
127 | # @param $4+ Include directories.
|
---|
128 | # @param $N --end-includes
|
---|
129 | my_generate_project_config()
|
---|
130 | {
|
---|
131 | MY_FILE="${1}";
|
---|
132 | MY_CFG_NAME="${2}";
|
---|
133 | MY_KMK_EXTRAS1="${3}";
|
---|
134 | MY_KMK_EXTRAS2="${4}";
|
---|
135 | MY_KMK_EXTRAS3="${5}";
|
---|
136 | MY_KMK_EXTRAS4="${6}";
|
---|
137 | shift; shift; shift; shift; shift; shift;
|
---|
138 |
|
---|
139 | ## @todo Process includes.
|
---|
140 | while test $# -ge 1 -a "${1}" != "--end-includes";
|
---|
141 | do
|
---|
142 | for f in $1;
|
---|
143 | do
|
---|
144 | my_abs_dir ${f}
|
---|
145 | #echo "Includes: ${MY_ABS_DIR}/"
|
---|
146 | done
|
---|
147 | shift
|
---|
148 | done
|
---|
149 | shift
|
---|
150 |
|
---|
151 | #
|
---|
152 | # Build tasks.
|
---|
153 | #
|
---|
154 | MY_TASK_CWD='${fileDirname}'
|
---|
155 | MY_TASK_ARGS='"-o", "${file}"'
|
---|
156 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile1" "${MY_KMK_EXTRAS1}" \
|
---|
157 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
158 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
159 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile2" "${MY_KMK_EXTRAS2}" \
|
---|
160 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
161 | fi
|
---|
162 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
163 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile3" "${MY_KMK_EXTRAS3}" \
|
---|
164 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
165 | fi
|
---|
166 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
167 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile4" "${MY_KMK_EXTRAS4}" \
|
---|
168 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
169 | fi
|
---|
170 | MY_TASK_CWD='${workspaceFolder}'
|
---|
171 | MY_TASK_ARGS=""
|
---|
172 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build1" "${MY_KMK_EXTRAS1}" \
|
---|
173 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
174 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
175 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build2" "${MY_KMK_EXTRAS2}" \
|
---|
176 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
177 | fi
|
---|
178 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
179 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build3" "${MY_KMK_EXTRAS3}" \
|
---|
180 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
181 | fi
|
---|
182 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
183 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build4" "${MY_KMK_EXTRAS4}" \
|
---|
184 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
185 | fi
|
---|
186 |
|
---|
187 | MY_TASK_CWD='${workspaceFolder}'
|
---|
188 | MY_TASK_ARGS='"rebuild"'
|
---|
189 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild1" "${MY_KMK_EXTRAS1}" \
|
---|
190 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
191 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
192 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild2" "${MY_KMK_EXTRAS2}" \
|
---|
193 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
194 | fi
|
---|
195 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
196 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild3" "${MY_KMK_EXTRAS3}" \
|
---|
197 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
198 | fi
|
---|
199 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
200 | my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild4" "${MY_KMK_EXTRAS4}" \
|
---|
201 | "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
|
---|
202 | fi
|
---|
203 |
|
---|
204 | #
|
---|
205 | # Generate compound tasks that invokes all needed sub tasks.
|
---|
206 | #
|
---|
207 | # Note: We include "VBox" in the label so that the command is easier to find
|
---|
208 | # in the command pallette.
|
---|
209 | #
|
---|
210 | echo ' {' >> "${MY_FILE}"
|
---|
211 | echo ' "label": "VBox Compile: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
|
---|
212 | echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
|
---|
213 | echo ' "dependsOn": [ "Compile1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
214 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
215 | echo ' , "Compile2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
216 | fi
|
---|
217 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
218 | echo ' , "Compile3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
219 | fi
|
---|
220 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
221 | echo ' , "Compile4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
222 | fi
|
---|
223 | echo ' ]' >> "${MY_FILE}"
|
---|
224 | echo ' },' >> "${MY_FILE}"
|
---|
225 | echo ' {' >> "${MY_FILE}"
|
---|
226 | echo ' "label": "VBox Build: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
|
---|
227 | echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
|
---|
228 | echo ' "dependsOn": [ "Build1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
229 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
230 | echo ' , "Build2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
231 | fi
|
---|
232 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
233 | echo ' , "Build3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
234 | fi
|
---|
235 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
236 | echo ' , "Build4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
237 | fi
|
---|
238 | echo ' ],' >> "${MY_FILE}"
|
---|
239 | echo ' "group": {' >> "${MY_FILE}"
|
---|
240 | echo ' "kind": "build",' >> "${MY_FILE}"
|
---|
241 | echo ' "isDefault": true' >> "${MY_FILE}"
|
---|
242 | echo ' }' >> "${MY_FILE}"
|
---|
243 | echo ' },' >> "${MY_FILE}"
|
---|
244 | echo ' {' >> "${MY_FILE}"
|
---|
245 | echo ' "label": "VBox Rebuild: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
|
---|
246 | echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
|
---|
247 | echo ' "dependsOn": [ "Rebuild1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
248 | if test -n "${MY_KMK_EXTRAS2}"; then
|
---|
249 | echo ' , "Rebuild2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
250 | fi
|
---|
251 | if test -n "${MY_KMK_EXTRAS3}"; then
|
---|
252 | echo ' , "Rebuild3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
253 | fi
|
---|
254 | if test -n "${MY_KMK_EXTRAS4}"; then
|
---|
255 | echo ' , "Rebuild4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
|
---|
256 | fi
|
---|
257 | echo ' ]' >> "${MY_FILE}"
|
---|
258 | echo ' },' >> "${MY_FILE}"
|
---|
259 | }
|
---|
260 |
|
---|
261 |
|
---|
262 | ##
|
---|
263 | # Function generating a project.
|
---|
264 | #
|
---|
265 | # @param $1 The project file name.
|
---|
266 | # @param $2 The project working directory.
|
---|
267 | # @param $3 Dummy separator.
|
---|
268 | # @param $4+ Include directories.
|
---|
269 | # @param $N --end-includes
|
---|
270 | # @param $N+1 Directory sub-trees and files to include in the project.
|
---|
271 | #
|
---|
272 | my_generate_project()
|
---|
273 | {
|
---|
274 | MY_PRJ_NAME=${1}
|
---|
275 | MY_WRK_DIR="${MY_FILE_ROOT_DIR}/${2}"
|
---|
276 | MY_FILE_PATH="${MY_WRK_DIR}/.vscode"
|
---|
277 | shift
|
---|
278 | shift
|
---|
279 | shift
|
---|
280 |
|
---|
281 | # Make sure that the .vscode project dir exists. But do *NOT* create the
|
---|
282 | # parent dir, it must already exist. Duh!
|
---|
283 | test -d "${MY_FILE_PATH}" || ${MY_MKDIR} "${MY_FILE_PATH}"
|
---|
284 |
|
---|
285 | MY_FILE="${MY_FILE_PATH}/c_cpp_properties${MY_VSCODE_FILE_DOT_EXT}";
|
---|
286 | echo "Generating ${MY_FILE}..."
|
---|
287 |
|
---|
288 | # Add it to the project list for workspace construction later on.
|
---|
289 | MY_PROJECT_FILES="${MY_PROJECT_FILES} ${MY_PRJ_NAME}:${MY_WRK_DIR}"
|
---|
290 |
|
---|
291 | #
|
---|
292 | # Generate the C/C++ bits.
|
---|
293 | ## @todo Might needs tweaking a bit more as stuff evolves.
|
---|
294 | #
|
---|
295 | echo '{' > "${MY_FILE}"
|
---|
296 | echo ' "configurations": [' >> "${MY_FILE}"
|
---|
297 | echo ' {' >> "${MY_FILE}"
|
---|
298 | echo ' "name": "Linux",' >> "${MY_FILE}"
|
---|
299 | echo ' "includePath": [' >> "${MY_FILE}"
|
---|
300 | echo ' "${workspaceFolder}/**"' >> "${MY_FILE}"
|
---|
301 | echo ' ],' >> "${MY_FILE}"
|
---|
302 | echo ' "defines": [],' >> "${MY_FILE}"
|
---|
303 | echo ' "cStandard": "c17",' >> "${MY_FILE}"
|
---|
304 | echo ' "cppStandard": "c++14",' >> "${MY_FILE}"
|
---|
305 | echo ' "intelliSenseMode": "linux-gcc-x64",' >> "${MY_FILE}"
|
---|
306 | echo ' "compilerPath": "/usr/bin/gcc"' >> "${MY_FILE}"
|
---|
307 | echo ' }' >> "${MY_FILE}"
|
---|
308 | echo ' ],' >> "${MY_FILE}"
|
---|
309 | echo ' "version": 4' >> "${MY_FILE}"
|
---|
310 | echo '}' >> "${MY_FILE}"
|
---|
311 |
|
---|
312 | MY_FILE="${MY_FILE_PATH}/tasks${MY_VSCODE_FILE_DOT_EXT}";
|
---|
313 | echo "Generating ${MY_FILE}..."
|
---|
314 |
|
---|
315 | #
|
---|
316 | # Tasks header.
|
---|
317 | #
|
---|
318 | echo '{' > "${MY_FILE}"
|
---|
319 | echo ' "version": "2.0.0",' >> "${MY_FILE}"
|
---|
320 | echo ' "tasks": [' >> "${MY_FILE}"
|
---|
321 |
|
---|
322 | my_generate_project_config "${MY_FILE}" "Default" "" "" "" "" $*
|
---|
323 | my_generate_project_config "${MY_FILE}" "Debug + hardening" \
|
---|
324 | '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
|
---|
325 | "" "" "" $*
|
---|
326 | my_generate_project_config "${MY_FILE}" "Release + hardening" \
|
---|
327 | '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
|
---|
328 | "" "" "" $*
|
---|
329 | my_generate_project_config "${MY_FILE}" "Debug+Release + hardening" \
|
---|
330 | '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
|
---|
331 | '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
|
---|
332 | "" "" $*
|
---|
333 | my_generate_project_config "${MY_FILE}" "Debug w/o hardening" \
|
---|
334 | '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
335 | "" "" "" $*
|
---|
336 | my_generate_project_config "${MY_FILE}" "Release w/o hardening" \
|
---|
337 | '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
338 | "" "" "" $*
|
---|
339 | my_generate_project_config "${MY_FILE}" "Debug+Release w/o hardening" \
|
---|
340 | '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
341 | '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
342 | "" "" $*
|
---|
343 | my_generate_project_config "${MY_FILE}" "Debug+Release with and without hardening" \
|
---|
344 | '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
|
---|
345 | '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
|
---|
346 | '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
347 | '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
|
---|
348 | $*
|
---|
349 |
|
---|
350 | #
|
---|
351 | # Tasks footer.
|
---|
352 | #
|
---|
353 | echo ' ]' >> "${MY_FILE}"
|
---|
354 | echo '}' >> "${MY_FILE}"
|
---|
355 |
|
---|
356 | while test $# -ge 1 -a "${1}" != "--end-includes";
|
---|
357 | do
|
---|
358 | shift;
|
---|
359 | done;
|
---|
360 | shift;
|
---|
361 |
|
---|
362 | return 0
|
---|
363 | }
|
---|
364 |
|
---|
365 |
|
---|
366 | ##
|
---|
367 | # Generate the workspace
|
---|
368 | #
|
---|
369 | my_generate_workspace()
|
---|
370 | {
|
---|
371 | MY_FILE="${MY_FILE_ROOT_DIR}/${MY_WS_NAME}"
|
---|
372 | echo "Generating ${MY_FILE}..."
|
---|
373 | echo '{' > "${MY_FILE}"
|
---|
374 | echo ' "folders": [' >> "${MY_FILE}"
|
---|
375 | for i in ${MY_PROJECT_FILES};
|
---|
376 | do
|
---|
377 | MY_PRJ_NAME=$(echo $i | ${MY_SED} -e 's/:.*$//')
|
---|
378 | MY_PRJ_PATH=$(echo $i | ${MY_SED} -e 's/^.*://')
|
---|
379 | echo ' {' >> "${MY_FILE}"
|
---|
380 | echo ' "name": "'"${MY_PRJ_NAME}"'",' >> "${MY_FILE}"
|
---|
381 | echo ' "path": "'"${MY_PRJ_PATH}"'",' >> "${MY_FILE}"
|
---|
382 | echo ' },' >> "${MY_FILE}"
|
---|
383 | done
|
---|
384 | echo ' ],' >> "${MY_FILE}"
|
---|
385 | echo ' "settings": {' >> "${MY_FILE}"
|
---|
386 | echo ' "breadcrumbs.enabled": true,' >> "${MY_FILE}"
|
---|
387 | echo ' "diffEditor.renderSideBySide": false,' >> "${MY_FILE}"
|
---|
388 | echo ' "editor.renderWhitespace": "boundary",' >> "${MY_FILE}"
|
---|
389 | echo ' "editor.cursorStyle": "block-outline",' >> "${MY_FILE}"
|
---|
390 | echo ' "editor.minimap.showSlider": "always",' >> "${MY_FILE}"
|
---|
391 | echo ' "editor.wordWrapColumn": 130,' >> "${MY_FILE}"
|
---|
392 | echo ' "editor.rulers": [ 80, 130],' >> "${MY_FILE}"
|
---|
393 | echo ' "files.associations": {' >> "${MY_FILE}"
|
---|
394 | echo ' "*.kmk": "makefile",' >> "${MY_FILE}"
|
---|
395 | echo ' "*.wxi": "xml",' >> "${MY_FILE}"
|
---|
396 | echo ' "*.wxs": "xml"' >> "${MY_FILE}"
|
---|
397 | echo ' },' >> "${MY_FILE}"
|
---|
398 | echo ' "files.trimFinalNewlines": true,' >> "${MY_FILE}"
|
---|
399 | echo ' "files.trimTrailingWhitespace": true,' >> "${MY_FILE}"
|
---|
400 | echo ' "multiclip.bufferSize": 999,' >> "${MY_FILE}"
|
---|
401 | echo ' "telemetry.telemetryLevel": "off",' >> "${MY_FILE}"
|
---|
402 | echo ' "python.linting.pylintEnabled": true,' >> "${MY_FILE}"
|
---|
403 | echo ' "python.linting.enabled": false,' >> "${MY_FILE}"
|
---|
404 | echo ' "python.linting.pylintUseMinimalCheckers": false,' >> "${MY_FILE}"
|
---|
405 | echo ' "window.restoreWindows": "all",' >> "${MY_FILE}"
|
---|
406 | echo ' "workbench.editor.highlightModifiedTabs": true,' >> "${MY_FILE}"
|
---|
407 | echo ' "workbench.colorCustomizations": {' >> "${MY_FILE}"
|
---|
408 | echo ' "editorRuler.foreground": "#660000"' >> "${MY_FILE}"
|
---|
409 | echo ' },' >> "${MY_FILE}"
|
---|
410 | echo ' "xmlTools.enableXmlTreeViewCursorSync": true,' >> "${MY_FILE}"
|
---|
411 | echo ' },' >> "${MY_FILE}"
|
---|
412 | echo ' "extensions": {' >> "${MY_FILE}"
|
---|
413 | echo ' "recommendations": [' >> "${MY_FILE}"
|
---|
414 | echo ' "ms-vscode.cpptools",' >> "${MY_FILE}"
|
---|
415 | echo ' "ms-vscode.cpptools-extension-pack",' >> "${MY_FILE}"
|
---|
416 | echo ' "ms-python.python",' >> "${MY_FILE}"
|
---|
417 | echo ' "ms-python.vscode-pylance",' >> "${MY_FILE}"
|
---|
418 | echo ' "johnstoncode.svn-scm"' >> "${MY_FILE}"
|
---|
419 | echo ' ]' >> "${MY_FILE}"
|
---|
420 | echo ' }' >> "${MY_FILE}"
|
---|
421 | echo '}' >> "${MY_FILE}"
|
---|
422 | return 0
|
---|
423 | }
|
---|
424 |
|
---|
425 |
|
---|
426 | #
|
---|
427 | # Parse arguments.
|
---|
428 | #
|
---|
429 | while test $# -ge 1;
|
---|
430 | do
|
---|
431 | ARG=$1
|
---|
432 | shift
|
---|
433 | case "$ARG" in
|
---|
434 |
|
---|
435 | --rootdir)
|
---|
436 | if test $# -eq 0; then
|
---|
437 | echo "error: missing --rootdir argument." 1>&2
|
---|
438 | exit 1;
|
---|
439 | fi
|
---|
440 | MY_ROOT_DIR="$1"
|
---|
441 | shift
|
---|
442 | ;;
|
---|
443 |
|
---|
444 | --outdir)
|
---|
445 | if test $# -eq 0; then
|
---|
446 | echo "error: missing --outdir argument." 1>&2
|
---|
447 | exit 1;
|
---|
448 | fi
|
---|
449 | MY_OUT_DIR="$1"
|
---|
450 | shift
|
---|
451 | ;;
|
---|
452 |
|
---|
453 | --project-base)
|
---|
454 | if test $# -eq 0; then
|
---|
455 | echo "error: missing --project-base argument." 1>&2
|
---|
456 | exit 1;
|
---|
457 | fi
|
---|
458 | MY_PRJ_PRF="$1"
|
---|
459 | shift
|
---|
460 | ;;
|
---|
461 |
|
---|
462 | --workspace)
|
---|
463 | if test $# -eq 0; then
|
---|
464 | echo "error: missing --workspace argument." 1>&2
|
---|
465 | exit 1;
|
---|
466 | fi
|
---|
467 | MY_WS_NAME="$1"
|
---|
468 | shift
|
---|
469 | ;;
|
---|
470 |
|
---|
471 | --windows-host)
|
---|
472 | MY_WINDOWS_HOST=1
|
---|
473 | ;;
|
---|
474 |
|
---|
475 | --minimal)
|
---|
476 | MY_OPT_MINIMAL=1
|
---|
477 | ;;
|
---|
478 |
|
---|
479 | # usage
|
---|
480 | --h*|-h*|-?|--?)
|
---|
481 | echo "usage: $0 [--rootdir <rootdir>] [--outdir <outdir>] [--project-base <prefix>] [--workspace <name>] [--minimal]"
|
---|
482 | echo ""
|
---|
483 | echo "If --outdir is specified, you must specify a --rootdir relative to it as well."
|
---|
484 | exit 1;
|
---|
485 | ;;
|
---|
486 |
|
---|
487 | # default
|
---|
488 | *)
|
---|
489 | echo "error: Invalid parameter '$ARG'" 1>&2
|
---|
490 | exit 1;
|
---|
491 |
|
---|
492 | esac
|
---|
493 | done
|
---|
494 |
|
---|
495 |
|
---|
496 | #
|
---|
497 | # From now on everything *MUST* succeed.
|
---|
498 | #
|
---|
499 | set -e
|
---|
500 |
|
---|
501 |
|
---|
502 | #
|
---|
503 | # Make sure the output directory exists, is valid and clean.
|
---|
504 | #
|
---|
505 | ## @todo r=bird: The above statement is *extremely* misleading. This script will
|
---|
506 | # create .vscode subdirs all over the place, and the root one doesn't seem to
|
---|
507 | # have any special purpose compared to the rest. Guess this is just fluff
|
---|
508 | # inherited from gen-slickedit-workspace.sh.
|
---|
509 | ${MY_RM} -f \
|
---|
510 | "${MY_OUT_DIR}"*.json \
|
---|
511 | "${MY_OUT_DIR}/${MY_ROOT_DIR}/${MY_WS_NAME}"
|
---|
512 | ${MY_MKDIR} -p "${MY_OUT_DIR}"
|
---|
513 |
|
---|
514 | # Enter the directory (or ${MY_ROOT_DIR} + my_abs_dir won't work) and save the absolute root path.
|
---|
515 | cd "${MY_OUT_DIR}"
|
---|
516 | my_abs_dir "."
|
---|
517 | MY_FILE_ROOT_DIR=${MY_ABS_DIR} ## @todo r=bird: 'FILE' or 'DIR'? ;-)
|
---|
518 |
|
---|
519 |
|
---|
520 | #
|
---|
521 | # Determine the invocation to conjure up kmk.
|
---|
522 | #
|
---|
523 | my_abs_dir "tools"
|
---|
524 | if test -n "${MY_WINDOWS_HOST}"; then
|
---|
525 | MY_KMK_CMD="cscript.exe"
|
---|
526 | MY_KMK_ARGS='"/Nologo", "'${MY_ABS_DIR}/envSub.vbs'", "--quiet", "--", "kmk.exe"'
|
---|
527 | else
|
---|
528 | MY_KMK_CMD="/usr/bin/env"
|
---|
529 | MY_KMK_ARGS='"LANG=C", "'${MY_ABS_DIR}/env.sh'", "--quiet", "--no-wine", "kmk"'
|
---|
530 | fi
|
---|
531 |
|
---|
532 |
|
---|
533 | #
|
---|
534 | # Generate the projects (common code) and workspace.
|
---|
535 | #
|
---|
536 | my_generate_all_projects # in common-gen-workspace-projects.inc.sh
|
---|
537 | my_generate_workspace
|
---|
538 |
|
---|
539 |
|
---|
540 | echo "done"
|
---|