From 921c3e0e6d1252ac3bbf491ac8359dba67bdcb2d Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Mon, 2 Mar 2020 23:01:36 -0800 Subject: util/ide-config: Add basic eclipse support * It can only generate for a single board-image at a time. * It generates an XML that is importable from an existing CDT project. See https://gn.googlesource.com/gn/+/master/docs/reference.md#eclipse-ide-support for a better description about what is generated. BRANCH=none BUG=none TEST=./util/ide-config.sh eclipse nocturne_fp:RW >nocturne_fp-rw.xml Signed-off-by: Craig Hesling Change-Id: I891bce7fedf6cf10778618638f7bf5caffe57717 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2084413 Reviewed-by: Daisuke Nojiri --- util/ide-config.sh | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) (limited to 'util') diff --git a/util/ide-config.sh b/util/ide-config.sh index d71c43992b..001d36d2a1 100755 --- a/util/ide-config.sh +++ b/util/ide-config.sh @@ -36,7 +36,7 @@ deinit() { usage() { cat <<-HEREDOC - Usage: ide-config.sh [BOARD:IMAGE] [BOARD:IMAGE...] + Usage: ide-config.sh [BOARD:IMAGE] [BOARD:IMAGE...] Generate a C language configuration for a given IDE and EC board. Examples: @@ -45,6 +45,7 @@ usage() { ide-config.sh vscode nocturne_fp:RO ide-config.sh vscode nocturne:RO hatch:RW ide-config.sh vscode all # implicitly :RW + ide-config.sh eclipse nocturne_fp > ~/Downloads/nocturne_fp-RW.xml HEREDOC } @@ -253,6 +254,122 @@ vscode() { | encap '{\n' '}\n' } +# Usage: eclipse-cdt-import [cfg...] +# +# * Add odd EC "File Types" +# - *.tasklist *.mocklist *.testlist *.irqlist "C Header File" +# - *.inc "C Header File" +# - gpio.wrap "C Header File" +# * Enable the indexer to follow current build configuration +# - Enable "Index all header variants" +# - Enable "Use active build configuration" (ensure this options sticks) +# - Probably bump up the Cache Limit->"Absolute Limit" +# * Remove default system includes +# - Depending on your eclipse toolchain configuration, it may be possible +# to remove the standard C headers. +# This helps satisfy the EC's -nostdinc usage. +eclipse-cdt-import() { + if [[ $# -gt 1 ]]; then + echo "Error - eclipse generator can only process one board cfg" >&2 + return 1 + fi + + local cfg=$1 + local board image + + board=$(parse-cfg-board "${cfg}") + image=$(parse-cfg-image "${cfg}") + + local includes + # Grab workspace/project local paths + includes+="$(make-includes "${board}" "${image}" | grep -v "^\.\." \ + | join '' '' '\n\t\t\t')" + # Add separator manually + includes+="$(printf "\n\t\t\t")" + # Grab external paths (wil start with .. because forced relative) + # shellcheck disable=SC2016 + includes+="$(make-includes "${board}" "${image}" | grep "^\.\." \ + | join '${ProjDirPath}/' '' '\n\t\t\t')" + + local macros + macros="$( + while read -r name value; do + { + join '' '' '' <<<"${name}" + join '' '' '' <<<"${value}" + } | encap '\n' '\n' 3 + done < <(make-defines "${board}" "${image}" | tr '=' '\t') + )" + + cat < + + +
+ + + + + ${includes} + + + + ${includes} + + + + ${includes} + + + + + + ${includes} + + + + + + + ${includes} + + +
+ +
+ + + + +${macros} + + + +${macros} + + + +${macros} + + + + + +${macros} + + + + + + +${macros} + + +
+
+EOF +} + # Usage: main [cfgs...] main() { # Disaply help if no args @@ -339,6 +456,9 @@ main() { vscode) vscode "${cfgs[@]}" || exit $? ;; + eclipse) + eclipse-cdt-import "${cfgs[@]}" || exit $? + ;; *) echo "Error - IDE '${ide}' is an unsupported." >&2 exit 1 -- cgit v1.2.1