VirtualBox

source: vbox/trunk/tools/bin/gen-vscode-workspace.sh@ 94773

Last change on this file since 94773 was 94572, checked in by vboxsync, 3 years ago

bin/gen-vscode-workspace.sh: Add a softfloat project to the workspace. ​bugref:9898

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 39.0 KB
Line 
1# !kmk_ash
2# $Id: gen-vscode-workspace.sh 94572 2022-04-12 10:51:58Z vboxsync $
3## @file
4# Script for generating a Visual Studio Code (vscode) workspace.
5#
6
7#
8# Copyright (C) 2022 Oracle Corporation
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18
19#
20# Some constants.
21#
22MY_CAT="kmk_cat"
23MY_CP="kmk_cp"
24MY_MKDIR="kmk_mkdir"
25MY_MV="kmk_mv"
26MY_SED="kmk_sed"
27MY_RM="kmk_rm"
28MY_SLEEP="kmk_sleep"
29MY_EXPR="kmk_expr"
30MY_SVN="svn"
31
32#MY_SORT="kmk_cat"
33MY_SORT="sort"
34
35#
36# Globals.
37#
38MY_PROJECT_FILES=""
39MY_OUT_DIRS="\
40out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/${KBUILD_TYPE} \
41out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/debug \
42out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/release \
43out/linux.amd64/debug \
44out/linux.x86/debug \
45out/win.amd64/debug \
46out/win.x86/debug \
47out/darwin.amd64/debug \
48out/darwin.x86/debug \
49out/haiku.amd64/debug \
50out/haiku.x86/debug \
51out/solaris.amd64/debug \
52out/solaris.x86/debug";
53
54
55#
56# Parameters w/ defaults.
57#
58MY_ROOT_DIR=".."
59MY_VSCODE_DIR=".vscode"
60MY_VSCODE_FILE_DOT_EXT=".json"
61MY_OUT_DIR=${MY_VSCODE_DIR}
62MY_PRJ_PRF="VBox-"
63MY_WS_NAME="virtualbox.code-workspace"
64MY_DBG=""
65MY_WINDOWS_HOST=""
66MY_OPT_MINIMAL=""
67MY_OPT_USE_WILDCARDS="yes"
68
69
70##
71# Gets the absolute path to an existing directory.
72#
73# @param $1 The path.
74my_abs_dir()
75{
76 if test -n "${PWD}"; then
77 MY_ABS_DIR=`cd ${MY_ROOT_DIR}/${1} && echo ${PWD}`
78
79 else
80 # old cygwin shell has no PWD and need adjusting.
81 MY_ABS_DIR=`cd ${MY_ROOT_DIR}/${1} && pwd | ${MY_SED} -e 's,^/cygdrive/\(.\)/,\1:/,'`
82 fi
83 if test -z "${MY_ABS_DIR}"; then
84 MY_ABS_DIR="${1}"
85 fi
86}
87
88##
89# Gets the file name part of a path.
90#
91# @param $1 The path.
92my_get_name()
93{
94 SAVED_IFS=$IFS
95 IFS=":/ "
96 set $1
97 while test $# -gt 1 -a -n "${2}";
98 do
99 shift;
100 done
101
102 IFS=$SAVED_IFS
103 #echo "$1"
104 export MY_GET_NAME=$1
105}
106
107##
108# Gets the newest version of a library (like openssl).
109#
110# @param $1 The library base path relative to root.
111my_get_newest_ver()
112{
113 cd "${MY_ROOT_DIR}" > /dev/null
114 latest=
115 for ver in "$1"*;
116 do
117 if test -z "${latest}" || "${MY_EXPR}" "${ver}" ">" "${latest}" > /dev/null; then
118 latest="${ver}"
119 fi
120 done
121 if test -z "${latest}"; then
122 echo "error: could not find any version of: $1" >&2;
123 exit 1;
124 fi
125 echo "${latest}"
126 return 0;
127}
128
129
130##
131# Generate file entry for the specified file if it was found to be of interest.
132#
133# @param $1 The output file name base.
134# @param $2 The file name.
135# @param $3 Optional folder override.
136my_file()
137{
138 # sort and filter by file type.
139 case "$2" in
140 # drop these.
141 *.kup|*~|*.pyc|*.exe|*.sys|*.dll|*.o|*.obj|*.lib|*.a|*.ko)
142 return 0
143 ;;
144
145 # by prefix or directory component.
146 tst*|*/testcase/*)
147 MY_FOLDER="$1-Testcases.lst"
148 ;;
149
150 # by extension.
151 *.c|*.cpp|*.m|*.mm|*.pl|*.py|*.as|*.c.h|*.cpp.h|*.java)
152 MY_FOLDER="$1-Sources.lst"
153 ;;
154
155 *.h|*.hpp|*.mm)
156 MY_FOLDER="$1-Headers.lst"
157 ;;
158
159 *.asm|*.s|*.S|*.inc|*.mac)
160 MY_FOLDER="$1-Assembly.lst"
161 ;;
162
163 *)
164 MY_FOLDER="$1-Others.lst"
165 ;;
166 esac
167 if test -n "$3";
168 then
169 MY_FOLDER="$1-$3.lst"
170 fi
171
172 ## @todo only files which are in subversion.
173# if ${MY_SVN} info "${2}" > /dev/null 2>&1; then
174 my_get_name "${2}"
175 echo ' <!-- sortkey: '"${MY_GET_NAME}"' --> <F N="'"${2}"'"/>' >> "${MY_FOLDER}"
176# fi
177}
178
179##
180# Generate file entry for the specified file if it was found to be of interest.
181#
182# @param $1 The output file name base.
183# @param $2 The wildcard spec.
184# @param $3 Optional folder override.
185my_wildcard()
186{
187 if test -n "$3"; then
188 MY_FOLDER="$1-$3.lst"
189 else
190 MY_FOLDER="$1-All.lst"
191 fi
192 EXCLUDES="*.log;*.kup;*~;*.bak;*.bak?;*.pyc;*.exe;*.sys;*.dll;*.o;*.obj;*.lib;*.a;*.ko;*.class;*.cvsignore;*.done;*.project;*.actionScriptProperties;*.scm-settings;*.svnpatch.rej;*.svn-base;.svn/*;*.gitignore;*.gitattributes;*.gitmodules;*.swagger-codegen-ignore;*.png;*.bmp;*.jpg"
193 echo ' <F N="'"${2}"'/*" Recurse="1" Excludes="'"${EXCLUDES}"'"/>' >> "${MY_FOLDER}"
194}
195
196##
197# Generate file entries for the specified sub-directory tree.
198#
199# @param $1 The output filename.
200# @param $2 The sub-directory.
201# @param $3 Optional folder override.
202my_sub_tree()
203{
204 if test -n "$MY_DBG"; then echo "dbg: my_sub_tree: ${2}"; fi
205
206 # Skip .svn directories.
207 case "$2" in
208 */.svn|*/.svn)
209 return 0
210 ;;
211 esac
212
213 # Process the files in the directory.
214 for f in $2/*;
215 do
216 if test -d "${f}";
217 then
218 my_sub_tree "${1}" "${f}" "${3}"
219 else
220 my_file "${1}" "${f}" "${3}"
221 fi
222 done
223 return 0;
224}
225
226##
227# Function generating an (intermediate) project task.
228#
229# @param $1 The project file name.
230# @param $2 Build config name.
231# @param $3 Task group to assign task to.
232# @param $4 kBuild extra args.
233# @param $5 kBuild working directory to set.
234# If empty, the file's directory will be used.
235# @param $6 kBuild per-task options.
236# Leave empty if not being used.
237my_generate_project_task()
238{
239 MY_FILE="${1}";
240 MY_CFG_NAME="${2}";
241 MY_TASK_GROUP="${3}";
242 MY_KMK_EXTRAS="${4}";
243 MY_KMK_CWD="${5}";
244 MY_KMK_TASK_ARGS="${6}";
245 shift; shift; shift; shift; shift; shift;
246
247 if [ -z "$MY_KMK_CWD" ]; then
248 MY_KMK_CWD='${fileDirname}'
249 fi
250
251 MY_TASK_LABEL="${MY_TASK_GROUP}: ${MY_CFG_NAME}"
252
253 echo ' {' >> "${MY_FILE}"
254 echo ' "type": "shell",' >> "${MY_FILE}"
255 echo ' "label": "'${MY_TASK_LABEL}'",' >> "${MY_FILE}"
256 echo ' "command": "'${MY_KMK_CMD}'",' >> "${MY_FILE}"
257 echo ' "args": [' >> "${MY_FILE}"
258 echo ' ' ${MY_KMK_ARGS} ',' >> "${MY_FILE}"
259 if [ -n "${MY_KMK_EXTRAS}" ]; then
260 echo ' '${MY_KMK_EXTRAS}' ,' >> "${MY_FILE}"
261 fi
262 echo ' "-C",' >> "${MY_FILE}"
263 echo ' "'${MY_KMK_CWD}'"' >> "${MY_FILE}"
264 if [ -n "${MY_KMK_TASK_ARGS}" ]; then
265 echo ' ', ${MY_KMK_TASK_ARGS} >> "${MY_FILE}"
266 fi
267 echo ' ],' >> "${MY_FILE}"
268 echo ' "options": {' >> "${MY_FILE}"
269 echo ' "cwd": "'${MY_KMK_CWD}'"' >> "${MY_FILE}"
270 echo ' },' >> "${MY_FILE}"
271 echo ' "problemMatcher": [' >> "${MY_FILE}"
272 echo ' "$gcc"' >> "${MY_FILE}"
273 echo ' ],' >> "${MY_FILE}"
274 echo ' "presentation": {' >> "${MY_FILE}"
275 echo ' "reveal": "always",' >> "${MY_FILE}"
276 echo ' "clear": true,' >> "${MY_FILE}"
277 echo ' "panel": "dedicated"' >> "${MY_FILE}"
278 echo ' },' >> "${MY_FILE}"
279 echo ' "detail": "compiler: /bin/clang++-9"' >> "${MY_FILE}"
280 echo ' },' >> "${MY_FILE}"
281}
282
283##
284# Function generating a project build config.
285#
286# @param $1 The project file name.
287# @param $2 Build config name.
288# @param $3 Extra kBuild command line options, variant 1.
289# @param $4 Extra kBuild command line options, variant 2.
290# @param $4+ Include directories.
291# @param $N --end-includes
292my_generate_project_config()
293{
294 MY_FILE="${1}";
295 MY_CFG_NAME="${2}";
296 MY_KMK_EXTRAS1="${3}";
297 MY_KMK_EXTRAS2="${4}";
298 MY_KMK_EXTRAS3="${5}";
299 MY_KMK_EXTRAS4="${6}";
300 shift; shift; shift; shift; shift; shift;
301
302 ## @todo Process includes.
303 while test $# -ge 1 -a "${1}" != "--end-includes";
304 do
305 for f in $1;
306 do
307 my_abs_dir ${f}
308 #echo "Includes: ${MY_ABS_DIR}/"
309 done
310 shift
311 done
312 shift
313
314 #
315 # Build tasks.
316 #
317 MY_TASK_CWD='${fileDirname}'
318 MY_TASK_ARGS='"-o", "${file}"'
319 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile1" "${MY_KMK_EXTRAS1}" \
320 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
321 if test -n "${MY_KMK_EXTRAS2}"; then
322 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile2" "${MY_KMK_EXTRAS2}" \
323 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
324 fi
325 if test -n "${MY_KMK_EXTRAS3}"; then
326 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile3" "${MY_KMK_EXTRAS3}" \
327 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
328 fi
329 if test -n "${MY_KMK_EXTRAS4}"; then
330 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Compile4" "${MY_KMK_EXTRAS4}" \
331 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
332 fi
333 MY_TASK_CWD='${workspaceFolder}'
334 MY_TASK_ARGS=""
335 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build1" "${MY_KMK_EXTRAS1}" \
336 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
337 if test -n "${MY_KMK_EXTRAS2}"; then
338 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build2" "${MY_KMK_EXTRAS2}" \
339 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
340 fi
341 if test -n "${MY_KMK_EXTRAS3}"; then
342 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build3" "${MY_KMK_EXTRAS3}" \
343 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
344 fi
345 if test -n "${MY_KMK_EXTRAS4}"; then
346 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Build4" "${MY_KMK_EXTRAS4}" \
347 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
348 fi
349
350 MY_TASK_CWD='${workspaceFolder}'
351 MY_TASK_ARGS='"rebuild"'
352 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild1" "${MY_KMK_EXTRAS1}" \
353 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
354 if test -n "${MY_KMK_EXTRAS2}"; then
355 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild2" "${MY_KMK_EXTRAS2}" \
356 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
357 fi
358 if test -n "${MY_KMK_EXTRAS3}"; then
359 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild3" "${MY_KMK_EXTRAS3}" \
360 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
361 fi
362 if test -n "${MY_KMK_EXTRAS4}"; then
363 my_generate_project_task "${MY_FILE}" "${MY_CFG_NAME}" "Rebuild4" "${MY_KMK_EXTRAS4}" \
364 "${MY_TASK_CWD}" "${MY_TASK_ARGS}"
365 fi
366
367 #
368 # Generate compound tasks that invokes all needed sub tasks.
369 #
370 # Note: We include "VBox" in the label so that the command is easier to find
371 # in the command pallette.
372 #
373 echo ' {' >> "${MY_FILE}"
374 echo ' "label": "VBox Compile: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
375 echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
376 echo ' "dependsOn": [ "Compile1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
377 if test -n "${MY_KMK_EXTRAS2}"; then
378 echo ' , "Compile2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
379 fi
380 if test -n "${MY_KMK_EXTRAS3}"; then
381 echo ' , "Compile3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
382 fi
383 if test -n "${MY_KMK_EXTRAS4}"; then
384 echo ' , "Compile4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
385 fi
386 echo ' ]' >> "${MY_FILE}"
387 echo ' },' >> "${MY_FILE}"
388 echo ' {' >> "${MY_FILE}"
389 echo ' "label": "VBox Build: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
390 echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
391 echo ' "dependsOn": [ "Build1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
392 if test -n "${MY_KMK_EXTRAS2}"; then
393 echo ' , "Build2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
394 fi
395 if test -n "${MY_KMK_EXTRAS3}"; then
396 echo ' , "Build3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
397 fi
398 if test -n "${MY_KMK_EXTRAS4}"; then
399 echo ' , "Build4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
400 fi
401 echo ' ],' >> "${MY_FILE}"
402 echo ' "group": {' >> "${MY_FILE}"
403 echo ' "kind": "build",' >> "${MY_FILE}"
404 echo ' "isDefault": true' >> "${MY_FILE}"
405 echo ' }' >> "${MY_FILE}"
406 echo ' },' >> "${MY_FILE}"
407 echo ' {' >> "${MY_FILE}"
408 echo ' "label": "VBox Rebuild: '${MY_CFG_NAME}'",' >> "${MY_FILE}"
409 echo ' "dependsOrder": "sequence",' >> "${MY_FILE}"
410 echo ' "dependsOn": [ "Rebuild1: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
411 if test -n "${MY_KMK_EXTRAS2}"; then
412 echo ' , "Rebuild2: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
413 fi
414 if test -n "${MY_KMK_EXTRAS3}"; then
415 echo ' , "Rebuild3: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
416 fi
417 if test -n "${MY_KMK_EXTRAS4}"; then
418 echo ' , "Rebuild4: '${MY_CFG_NAME}'"' >> "${MY_FILE}"
419 fi
420 echo ' ]' >> "${MY_FILE}"
421 echo ' },' >> "${MY_FILE}"
422}
423
424
425##
426# Function generating a project.
427#
428# @param $1 The project file name.
429# @param $2 The project working directory.
430# @param $3 Dummy separator.
431# @param $4+ Include directories.
432# @param $N --end-includes
433# @param $N+1 Directory sub-trees and files to include in the project.
434#
435my_generate_project()
436{
437 MY_PRJ_NAME=${1}
438 MY_WRK_DIR="${MY_FILE_ROOT_DIR}/${2}"
439 MY_FILE_PATH="${MY_WRK_DIR}/.vscode"
440 shift
441 shift
442 shift
443
444 # Make sure that the .vscode project dir exists.
445 mkdir -p "$MY_FILE_PATH"
446
447 MY_FILE="${MY_FILE_PATH}/c_cpp_properties${MY_VSCODE_FILE_DOT_EXT}";
448 echo "Generating ${MY_FILE}..."
449
450 # Add it to the project list for workspace construction later on.
451 MY_PROJECT_FILES="${MY_PROJECT_FILES} ${MY_PRJ_NAME}:${MY_WRK_DIR}"
452
453 #
454 # Generate the C/C++ bits.
455 ## @todo Might needs tweaking a bit more as stuff evolves.
456 #
457 echo '{' > "${MY_FILE}"
458 echo ' "configurations": [' >> "${MY_FILE}"
459 echo ' {' >> "${MY_FILE}"
460 echo ' "name": "Linux",' >> "${MY_FILE}"
461 echo ' "includePath": [' >> "${MY_FILE}"
462 echo ' "${workspaceFolder}/**"' >> "${MY_FILE}"
463 echo ' ],' >> "${MY_FILE}"
464 echo ' "defines": [],' >> "${MY_FILE}"
465 echo ' "cStandard": "c17",' >> "${MY_FILE}"
466 echo ' "cppStandard": "c++14",' >> "${MY_FILE}"
467 echo ' "intelliSenseMode": "linux-gcc-x64",' >> "${MY_FILE}"
468 echo ' "compilerPath": "/usr/bin/gcc"' >> "${MY_FILE}"
469 echo ' }' >> "${MY_FILE}"
470 echo ' ],' >> "${MY_FILE}"
471 echo ' "version": 4' >> "${MY_FILE}"
472 echo '}' >> "${MY_FILE}"
473
474 MY_FILE="${MY_FILE_PATH}/tasks${MY_VSCODE_FILE_DOT_EXT}";
475 echo "Generating ${MY_FILE}..."
476
477 #
478 # Tasks header.
479 #
480 echo '{' > "${MY_FILE}"
481 echo ' "version": "2.0.0",' >> "${MY_FILE}"
482 echo ' "tasks": [' >> "${MY_FILE}"
483
484 my_generate_project_config "${MY_FILE}" "Default" "" "" "" "" $*
485 my_generate_project_config "${MY_FILE}" "Debug + hardening" \
486 '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
487 "" "" "" $*
488 my_generate_project_config "${MY_FILE}" "Release + hardening" \
489 '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
490 "" "" "" $*
491 my_generate_project_config "${MY_FILE}" "Debug+Release + hardening" \
492 '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
493 '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
494 "" "" $*
495 my_generate_project_config "${MY_FILE}" "Debug w/o hardening" \
496 '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
497 "" "" "" $*
498 my_generate_project_config "${MY_FILE}" "Release w/o hardening" \
499 '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
500 "" "" "" $*
501 my_generate_project_config "${MY_FILE}" "Debug+Release w/o hardening" \
502 '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
503 '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
504 "" "" $*
505 my_generate_project_config "${MY_FILE}" "Debug+Release with and without hardening" \
506 '"KBUILD_TYPE=debug", "VBOX_WITH_HARDENING=1"' \
507 '"KBUILD_TYPE=release", "VBOX_WITH_HARDENING=1"' \
508 '"KBUILD_TYPE=debug", "VBOX_WITHOUT_HARDENING=1"' \
509 '"KBUILD_TYPE=release", "VBOX_WITHOUT_HARDENING=1"' \
510 $*
511
512 #
513 # Tasks footer.
514 #
515 echo ' ]' >> "${MY_FILE}"
516 echo '}' >> "${MY_FILE}"
517
518 while test $# -ge 1 -a "${1}" != "--end-includes";
519 do
520 shift;
521 done;
522 shift;
523
524 return 0
525}
526
527
528##
529# Generate the workspace
530#
531my_generate_workspace()
532{
533 MY_FILE="${MY_FILE_ROOT_DIR}/${MY_WS_NAME}"
534 echo "Generating ${MY_FILE}..."
535 echo '{' > "${MY_FILE}"
536 echo ' "folders": [' >> "${MY_FILE}"
537 for i in ${MY_PROJECT_FILES};
538 do
539 MY_PRJ_NAME=$(echo $i | cut -d ":" -f 1)
540 MY_PRJ_PATH=$(echo $i | cut -d ":" -f 2)
541 echo ' {' >> "${MY_FILE}"
542 echo ' "name": "'"${MY_PRJ_NAME}"'",' >> "${MY_FILE}"
543 echo ' "path": "'"${MY_PRJ_PATH}"'",' >> "${MY_FILE}"
544 echo ' },' >> "${MY_FILE}"
545 done
546 echo ' ],' >> "${MY_FILE}"
547 echo ' "settings": {},' >> "${MY_FILE}"
548 echo ' "extensions": {' >> "${MY_FILE}"
549 echo ' "recommendations": ["ms-vscode.cpptools"]' >> "${MY_FILE}"
550 echo ' },' >> "${MY_FILE}"
551 echo '}' >> "${MY_FILE}"
552 return 0
553}
554
555
556#
557# Parse arguments.
558#
559while test $# -ge 1;
560do
561 ARG=$1
562 shift
563 case "$ARG" in
564
565 --rootdir)
566 if test $# -eq 0; then
567 echo "error: missing --rootdir argument." 1>&2
568 exit 1;
569 fi
570 MY_ROOT_DIR="$1"
571 shift
572 ;;
573
574 --outdir)
575 if test $# -eq 0; then
576 echo "error: missing --outdir argument." 1>&2
577 exit 1;
578 fi
579 MY_OUT_DIR="$1"
580 shift
581 ;;
582
583 --project-base)
584 if test $# -eq 0; then
585 echo "error: missing --project-base argument." 1>&2
586 exit 1;
587 fi
588 MY_PRJ_PRF="$1"
589 shift
590 ;;
591
592 --workspace)
593 if test $# -eq 0; then
594 echo "error: missing --workspace argument." 1>&2
595 exit 1;
596 fi
597 MY_WS_NAME="$1"
598 shift
599 ;;
600
601 --windows-host)
602 MY_WINDOWS_HOST=1
603 ;;
604
605 --minimal)
606 MY_OPT_MINIMAL=1
607 ;;
608
609 # usage
610 --h*|-h*|-?|--?)
611 echo "usage: $0 [--rootdir <rootdir>] [--outdir <outdir>] [--project-base <prefix>] [--workspace <name>] [--minimal]"
612 echo ""
613 echo "If --outdir is specified, you must specify a --rootdir relative to it as well."
614 exit 1;
615 ;;
616
617 # default
618 *)
619 echo "error: Invalid parameter '$ARG'" 1>&2
620 exit 1;
621
622 esac
623done
624
625
626#
627# From now on everything *MUST* succeed.
628#
629set -e
630
631
632#
633# Save the absolute path to the root directory.
634#
635cd "${MY_OUT_DIR}"
636my_abs_dir "."
637MY_FILE_ROOT_DIR=${MY_ABS_DIR}
638
639
640#
641# Make sure the output directory exists, is valid and clean.
642#
643${MY_RM} -f \
644 "${MY_OUT_DIR}"*.json \
645 "${MY_FILE_ROOT_DIR}/${MY_WS_NAME}"
646${MY_MKDIR} -p "${MY_OUT_DIR}"
647
648
649#
650# Determine the invocation to conjure up kmk.
651#
652my_abs_dir "tools"
653if test -n "${MY_WINDOWS_HOST}"; then
654 MY_KMK_CMD="cscript.exe"
655 MY_KMK_ARGS='"/Nologo", "'${MY_ABS_DIR}/envSub.vbs'", "--quiet", "--", "kmk.exe"'
656else
657 MY_KMK_CMD="/usr/bin/env"
658 MY_KMK_ARGS='"LANG=C", "'${MY_ABS_DIR}/env.sh'", "--quiet", "--no-wine", "kmk"'
659fi
660
661#
662# Generate the projects and workspace.
663#
664# Note! The configs aren't optimal yet, lots of adjustment wrt headers left to be done.
665#
666
667# src/VBox/Runtime
668my_generate_project "IPRT" "src/VBox/Runtime" --begin-incs "include" "src/VBox/Runtime/include" --end-includes "include/iprt" "src/VBox/Runtime"
669
670# src/VBox/VMM
671my_generate_project "VMM" "src/VBox/VMM" --begin-incs "include" "src/VBox/VMM" --end-includes "src/VBox/VMM" \
672 "include/VBox/vmm/cfgm.h" \
673 "include/VBox/vmm/cpum.*" \
674 "include/VBox/vmm/dbgf.h" \
675 "include/VBox/vmm/em.h" \
676 "include/VBox/vmm/gim.h" \
677 "include/VBox/vmm/apic.h" \
678 "include/VBox/vmm/gmm.*" \
679 "include/VBox/vmm/gvm.*" \
680 "include/VBox/vmm/hm*.*" \
681 "include/VBox/vmm/iom.h" \
682 "include/VBox/vmm/mm.h" \
683 "include/VBox/vmm/patm.*" \
684 "include/VBox/vmm/pdm*.h" \
685 "include/VBox/vmm/pgm.*" \
686 "include/VBox/vmm/selm.*" \
687 "include/VBox/vmm/ssm.h" \
688 "include/VBox/vmm/stam.*" \
689 "include/VBox/vmm/tm.h" \
690 "include/VBox/vmm/trpm.*" \
691 "include/VBox/vmm/vm.*" \
692 "include/VBox/vmm/vmm.*"
693
694# src/VBox/Additions
695my_generate_project "Add-darwin" "src/VBox/Additions/darwin" --begin-incs "include" "src/VBox/Additions/darwin" --end-includes "src/VBox/Additions/darwin"
696my_generate_project "Add-freebsd" "src/VBox/Additions/freebsd" --begin-incs "include" "src/VBox/Additions/freebsd" --end-includes "src/VBox/Additions/freebsd"
697my_generate_project "Add-haiku" "src/VBox/Additions/haiku" --begin-incs "include" "src/VBox/Additions/haiku" --end-includes "src/VBox/Additions/haiku"
698my_generate_project "Add-linux" "src/VBox/Additions/linux" --begin-incs "include" "src/VBox/Additions/linux" --end-includes "src/VBox/Additions/linux"
699my_generate_project "Add-os2" "src/VBox/Additions/os2" --begin-incs "include" "src/VBox/Additions/os2" --end-includes "src/VBox/Additions/os2"
700my_generate_project "Add-solaris" "src/VBox/Additions/solaris" --begin-incs "include" "src/VBox/Additions/solaris" --end-includes "src/VBox/Additions/solaris"
701my_generate_project "Add-win" "src/VBox/Additions/WINNT" --begin-incs "include" "src/VBox/Additions/WINNT" --end-includes "src/VBox/Additions/WINNT"
702if test -z "$MY_OPT_MINIMAL"; then
703 my_generate_project "Add-x11" "src/VBox/Additions/x11" --begin-incs "include" "src/VBox/Additions/x11" --end-includes "src/VBox/Additions/x11"
704fi
705my_generate_project "Add-Control" "src/VBox/Additions/common/VBoxControl" --begin-incs "include" "src/VBox/Additions/common/VBoxControl" --end-includes "src/VBox/Additions/common/VBoxControl"
706my_generate_project "Add-GuestDrv" "src/VBox/Additions/common/VBoxGuest" --begin-incs "include" "src/VBox/Additions/common/VBoxGuest" --end-includes "src/VBox/Additions/common/VBoxGuest" "include/VBox/VBoxGuest*.*"
707my_generate_project "Add-Lib" "src/VBox/Additions/common/VBoxGuest/lib" --begin-incs "include" "src/VBox/Additions/common/VBoxGuest/lib" --end-includes "src/VBox/Additions/common/VBoxGuest/lib" "include/VBox/VBoxGuest/lib/*.*"
708my_generate_project "Add-Service" "src/VBox/Additions/common/VBoxService" --begin-incs "include" "src/VBox/Additions/common/VBoxService" --end-includes "src/VBox/Additions/common/VBoxService"
709my_generate_project "Add-VBoxVideo" "src/VBox/Additions/common/VBoxVideo" --begin-incs "include" "src/VBox/Additions/common/VBoxVideo" --end-includes "src/VBox/Additions/common/VBoxVideo"
710if test -z "$MY_OPT_MINIMAL"; then
711 my_generate_project "Add-pam" "src/VBox/Additions/common/pam" --begin-incs "include" "src/VBox/Additions/common/pam" --end-includes "src/VBox/Additions/common/pam"
712 my_generate_project "Add-cmn-test" "src/VBox/Additions/common/testcase" --begin-incs "include" "src/VBox/Additions/common/testcase" --end-includes "src/VBox/Additions/common/testcase"
713 my_generate_project "Add-CredProv" "src/VBox/Additions/WINNT/VBoxCredProv" --begin-incs "include" "src/VBox/Additions/WINNT/VBoxCredProv" --end-includes "src/VBox/Additions/WINNT/VBoxCredProv"
714 my_generate_project "Add-GINA" "src/VBox/Additions/WINNT/VBoxGINA" --begin-incs "include" "src/VBox/Additions/WINNT/VBoxGINA" --end-includes "src/VBox/Additions/WINNT/VBoxGINA"
715fi
716
717# src/VBox/Debugger
718my_generate_project "Debugger" "src/VBox/Debugger" --begin-incs "include" "src/VBox/Debugger" --end-includes "src/VBox/Debugger" "include/VBox/dbggui.h" "include/VBox/dbg.h"
719
720# src/VBox/Devices
721my_generate_project "Devices" "src/VBox/Devices" --begin-incs "include" "src/VBox/Devices" --end-includes "src/VBox/Devices" "include/VBox/pci.h" "include/VBox/pdm*.h"
722## @todo split this up.
723
724# src/VBox/Disassembler
725my_generate_project "DIS" "src/VBox/Disassembler" --begin-incs "include" "src/VBox/Disassembler" --end-includes "src/VBox/Disassembler" "include/VBox/dis*.h"
726
727# src/VBox/Frontends
728if test -z "$MY_OPT_MINIMAL"; then
729 my_generate_project "FE-VBoxBalloonCtrl" "src/VBox/Frontends/VBoxBalloonCtrl" --begin-incs "include" "src/VBox/Frontends/VBoxBalloonCtrl" --end-includes "src/VBox/Frontends/VBoxBalloonCtrl"
730fi
731my_generate_project "FE-VBoxManage" "src/VBox/Frontends/VBoxManage" --begin-incs "include" "src/VBox/Frontends/VBoxManage" --end-includes "src/VBox/Frontends/VBoxManage"
732my_generate_project "FE-VBoxHeadless" "src/VBox/Frontends/VBoxHeadless" --begin-incs "include" "src/VBox/Frontends/VBoxHeadless" --end-includes "src/VBox/Frontends/VBoxHeadless"
733my_generate_project "FE-VBoxSDL" "src/VBox/Frontends/VBoxSDL" --begin-incs "include" "src/VBox/Frontends/VBoxSDL" --end-includes "src/VBox/Frontends/VBoxSDL"
734my_generate_project "FE-VBoxShell" "src/VBox/Frontends/VBoxShell" --begin-incs "include" "src/VBox/Frontends/VBoxShell" --end-includes "src/VBox/Frontends/VBoxShell"
735# noise - my_generate_project "FE-VBoxBFE" "src/VBox/Frontends/VBoxBFE" --begin-incs "include" "src/VBox/Frontends/VBoxBFE" --end-includes "src/VBox/Frontends/VBoxBFE"
736FE_VBOX_WRAPPERS=""
737for d in ${MY_OUT_DIRS};
738do
739 if test -d "${MY_ROOT_DIR}/${d}/obj/VirtualBox/include"; then
740 FE_VBOX_WRAPPERS="${d}/obj/VirtualBox/include"
741 break
742 fi
743done
744if test -n "${FE_VBOX_WRAPPERS}"; then
745 my_generate_project "FE-VirtualBox" "src/VBox/Frontends/VirtualBox" --begin-incs "include" "${FE_VBOX_WRAPPERS}" --end-includes "src/VBox/Frontends/VirtualBox" "${FE_VBOX_WRAPPERS}/COMWrappers.cpp" "${FE_VBOX_WRAPPERS}/COMWrappers.h"
746else
747 my_generate_project "FE-VirtualBox" "src/VBox/Frontends/VirtualBox" --begin-incs "include" --end-includes "src/VBox/Frontends/VirtualBox"
748fi
749
750# src/VBox/GuestHost
751my_generate_project "HGSMI-GH" "src/VBox/GuestHost/HGSMI" --begin-incs "include" --end-includes "src/VBox/GuestHost/HGSMI"
752if test -z "$MY_OPT_MINIMAL"; then
753 my_generate_project "DnD-GH" "src/VBox/GuestHost/DragAndDrop" --begin-incs "include" --end-includes "src/VBox/GuestHost/DragAndDrop"
754fi
755my_generate_project "ShClip-GH" "src/VBox/GuestHost/SharedClipboard" --begin-incs "include" --end-includes "src/VBox/GuestHost/SharedClipboard"
756
757# src/VBox/HostDrivers
758my_generate_project "SUP" "src/VBox/HostDrivers/Support" --begin-incs "include" "src/VBox/HostDrivers/Support" --end-includes "src/VBox/HostDrivers/Support" "include/VBox/sup.h" "include/VBox/sup.mac"
759my_generate_project "VBoxNetAdp" "src/VBox/HostDrivers/VBoxNetAdp" --begin-incs "include" "src/VBox/HostDrivers/VBoxNetAdp" --end-includes "src/VBox/HostDrivers/VBoxNetAdp" "include/VBox/intnet.h"
760my_generate_project "VBoxNetFlt" "src/VBox/HostDrivers/VBoxNetFlt" --begin-incs "include" "src/VBox/HostDrivers/VBoxNetFlt" --end-includes "src/VBox/HostDrivers/VBoxNetFlt" "include/VBox/intnet.h"
761my_generate_project "VBoxUSB" "src/VBox/HostDrivers/VBoxUSB" --begin-incs "include" "src/VBox/HostDrivers/VBoxUSB" --end-includes "src/VBox/HostDrivers/VBoxUSB" "include/VBox/usblib*.h" "include/VBox/usbfilter.h"
762my_generate_project "AdpCtl" "src/VBox/HostDrivers/adpctl" --begin-incs "include" --end-includes "src/VBox/HostDrivers/adpctl"
763
764# src/VBox/HostServices
765my_generate_project "GuestCntl" "src/VBox/HostServices/GuestControl" --begin-incs "include" "src/VBox/HostServices/GuestControl" --end-includes "src/VBox/HostServices/GuestControl"
766my_generate_project "DragAndDrop" "src/VBox/HostServices/DragAndDrop" --begin-incs "include" "src/VBox/HostServices/DragAndDrop" --end-includes "src/VBox/HostServices/DragAndDrop"
767my_generate_project "GuestProps" "src/VBox/HostServices/GuestProperties" --begin-incs "include" "src/VBox/HostServices/GuestProperties" --end-includes "src/VBox/HostServices/GuestProperties"
768my_generate_project "ShClip-HS" "src/VBox/HostServices/SharedClipboard" --begin-incs "include" "src/VBox/HostServices/SharedClipboard" --end-includes "src/VBox/HostServices/SharedClipboard"
769my_generate_project "SharedFolders" "src/VBox/HostServices/SharedFolders" --begin-incs "include" "src/VBox/HostServices/SharedFolders" --end-includes "src/VBox/HostServices/SharedFolders" "include/VBox/shflsvc.h"
770
771# src/VBox/ImageMounter
772my_generate_project "ImageMounter" "src/VBox/ImageMounter" --begin-incs "include" "src/VBox/ImageMounter" --end-includes "src/VBox/ImageMounter"
773
774# src/VBox/Installer
775my_generate_project "Installers" "src/VBox/Installer" --begin-incs "include" --end-includes "src/VBox/Installer"
776
777# src/VBox/Main
778my_generate_project "Main" "src/VBox/Main" --begin-incs "include" "src/VBox/Main/include" --end-includes "src/VBox/Main" "include/VBox/com" "include/VBox/settings.h"
779## @todo seperate webservices and Main. pick the right headers. added generated headers.
780
781# src/VBox/Network
782my_generate_project "Net-DHCP" "src/VBox/NetworkServices/Dhcpd" --begin-incs "include" "src/VBox/NetworkServices/NetLib" --end-includes "src/VBox/NetworkServices/Dhcpd"
783my_generate_project "Net-NAT" "src/VBox/NetworkServices/NAT" --begin-incs "include" "src/VBox/NetworkServices/NAT" --end-includes "src/VBox/NetworkServices/NAT" "src/VBox/Devices/Network/slirp"
784my_generate_project "Net-NetLib" "src/VBox/NetworkServices/NetLib" --begin-incs "include" "src/VBox/NetworkServices/NetLib" --end-includes "src/VBox/NetworkServices/NetLib"
785
786# src/VBox/RDP
787my_generate_project "RDP-Client" "src/VBox/RDP/client-1.8.4" --begin-incs "include" "src/VBox/RDP/client-1.8.4" --end-includes "src/VBox/RDP/client-1.8.4"
788my_generate_project "RDP-Server" "src/VBox/RDP/server" --begin-incs "include" "src/VBox/RDP/server" --end-includes "src/VBox/RDP/server"
789my_generate_project "RDP-WebClient" "src/VBox/RDP/webclient" --begin-incs "include" "src/VBox/RDP/webclient" --end-includes "src/VBox/RDP/webclient"
790my_generate_project "RDP-Misc" "src/VBox/RDP" --begin-incs "include" --end-includes "src/VBox/RDP/auth" "src/VBox/RDP/tscpasswd" "src/VBox/RDP/x11server"
791
792# src/VBox/Storage
793my_generate_project "Storage" "src/VBox/Storage" --begin-incs "include" "src/VBox/Storage" --end-includes "src/VBox/Storage"
794
795# src/VBox/ValidationKit
796my_generate_project "ValidationKit" "src/VBox/ValidationKit" --begin-incs "include" --end-includes "src/VBox/ValidationKit"
797
798# src/VBox/ExtPacks
799my_generate_project "ExtPacks" "src/VBox/ExtPacks" --begin-incs "include" --end-includes "src/VBox/ExtPacks"
800
801# src/bldprogs
802my_generate_project "bldprogs" "src/bldprogs" --begin-incs "include" --end-includes "src/bldprogs"
803
804# A few things from src/lib
805lib=$(my_get_newest_ver src/libs/zlib)
806my_generate_project "zlib" "${lib}" --begin-incs "include" --end-includes "${lib}/*.c" "${lib}/*.h"
807lib=$(my_get_newest_ver src/libs/liblzf)
808my_generate_project "liblzf" "${lib}" --begin-incs "include" --end-includes "${lib}"
809lib=$(my_get_newest_ver src/libs/libpng)
810my_generate_project "libpng" "${lib}" --begin-incs "include" --end-includes "${lib}/*.c" "${lib}/*.h"
811lib=$(my_get_newest_ver src/libs/openssl)
812my_generate_project "openssl" "${lib}" --begin-incs "include" "${lib}/crypto" --end-includes "${lib}"
813lib=$(my_get_newest_ver src/libs/curl)
814my_generate_project "curl" "${lib}" --begin-incs "include" "${lib}/include" --end-includes "${lib}"
815lib=$(my_get_newest_ver src/libs/softfloat)
816my_generate_project "softfloat" "${lib}" --begin-incs "include" "${lib}/source/include" --end-includes "${lib}"
817
818# webtools
819my_generate_project "webtools" "webtools" --begin-incs "include" "webtools/tinderbox/server/Tinderbox3" --end-includes "webtools"
820
821# include/VBox
822my_generate_project "VBoxHeaders" "include" --begin-incs "include" --end-includes "include/VBox"
823
824# Misc
825my_generate_project "misc" "." --begin-incs "include" --end-includes \
826 "configure" \
827 "configure.vbs" \
828 "Config.kmk" \
829 "Makefile.kmk" \
830 "src/Makefile.kmk" \
831 "src/VBox/Makefile.kmk" \
832 "tools/env.sh" \
833 "tools/env.cmd" \
834 "tools/envSub.vbs" \
835 "tools/envSub.cmd" \
836 "tools/win/vbscript"
837
838
839# out/x.y/z/bin/sdk/bindings/xpcom
840XPCOM_INCS="src/libs/xpcom18a4"
841for d in \
842 "out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/${KBUILD_TYPE}/dist/sdk/bindings/xpcom" \
843 "out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/${KBUILD_TYPE}/bin/sdk/bindings/xpcom" \
844 "out/linux.amd64/debug/bin/sdk/bindings/xpcom" \
845 "out/linux.x86/debug/bin/sdk/bindings/xpcom" \
846 "out/darwin.amd64/debug/dist/sdk/bindings/xpcom" \
847 "out/darwin.x86/debug/bin/dist/bindings/xpcom" \
848 "out/haiku.amd64/debug/bin/sdk/bindings/xpcom" \
849 "out/haiku.x86/debug/bin/sdk/bindings/xpcom" \
850 "out/solaris.amd64/debug/bin/sdk/bindings/xpcom" \
851 "out/solaris.x86/debug/bin/sdk/bindings/xpcom";
852do
853 if test -d "${MY_ROOT_DIR}/${d}"; then
854 my_generate_project "SDK-xpcom" "${d}" --begin-incs "include" "${d}/include" --end-includes "${d}"
855 XPCOM_INCS="${d}/include"
856 break
857 fi
858done
859
860# lib/xpcom
861my_generate_project "xpcom" "src/libs/xpcom18a4" --begin-incs "include" "${XPCOM_INCS}" --end-includes "src/libs/xpcom18a4"
862
863my_generate_workspace
864
865
866
867
868echo "done"
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette