瀏覽代碼

Meta: Add helper for generating a C++ string from a text file

Andreas Kling 4 年之前
父節點
當前提交
40892ac72e
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      Meta/text-to-cpp-string.sh

+ 11 - 0
Meta/text-to-cpp-string.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+# $1 name of the variable
+# $2 input path
+
+echo "extern const char $1[];"
+echo -n "const char $1[] = R\"("
+grep -v '^ *#' < "$2" | while IFS= read -r line; do
+  echo "$line"
+done
+echo ")\";"
+