瀏覽代碼

🔨 Add 'opt_find' to find matching options

Scott Lahteine 3 年之前
父節點
當前提交
f5b085157a
共有 1 個文件被更改,包括 33 次插入0 次删除
  1. 33
    0
      buildroot/bin/opt_find

+ 33
- 0
buildroot/bin/opt_find 查看文件

@@ -0,0 +1,33 @@
1
+#!/usr/bin/env bash
2
+#
3
+# opt_find
4
+# Find one or more Marlin options - Configuration lines starting with #define
5
+#
6
+
7
+MYNAME=$(basename $0)
8
+
9
+[[ $# == 0 ]] && ONE="-h" || ONE=$1
10
+
11
+COMM="(//\\s*)?" ; TYPE=""
12
+case "$ONE" in
13
+  -d|--disabled )
14
+      shift ; COMM="(//\\s*)" ; TYPE="disabled " ;;
15
+  -e|--enabled )
16
+      shift ; COMM="" ; TYPE="enabled " ;;
17
+  -h|--help )
18
+      echo "$MYNAME [-d|--disabled|-e|--enabled] STRING ... Find matching Marlin configuration options."
19
+      echo ; shift ;;
20
+  -* )
21
+      echo "Unknown option $ONE" ; shift ;;
22
+esac
23
+
24
+while [[ $# > 0 ]]; do
25
+  DID=0
26
+  for FN in Configuration Configuration_adv; do
27
+    FOUND=$( grep -HEn "^\s*${COMM}#define\s+[A-Z0-9_]*${1}" "Marlin/$FN.h" 2>/dev/null )
28
+    [[ -n "$FOUND" ]] && { echo "$FOUND" ; DID=1 ; }
29
+  done
30
+  ((DID)) || { echo "ERROR: ${MYNAME} - No ${TYPE}match for ${1}" ; exit 9; }
31
+  shift
32
+  echo
33
+done

Loading…
取消
儲存