From 8c00d4416c810af865c35c472e2c51d47533de7e Mon Sep 17 00:00:00 2001
From: Recolic Keghart <root@recolic.net>
Date: Tue, 4 Sep 2018 09:31:01 +0800
Subject: [PATCH] update c support

---
 gen_tcl.sh          | 12 ++++++++----
 template/Vivadofile |  3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gen_tcl.sh b/gen_tcl.sh
index b5f8caa..2738083 100755
--- a/gen_tcl.sh
+++ b/gen_tcl.sh
@@ -19,6 +19,12 @@ function burn_file () {
     "
 }
 
+function list_sources () {
+    find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;
+    find ${proj_dir}/*.srcs -regex '^.*\.o?cc?p?p?x?x?$' -exec echo add_files \{\} \;
+    find ${proj_dir}/*.srcs -regex '^.*\.hh?p?p?x?x?$' -exec echo add_files \{\} \;
+}
+
 if [[ $1 == build ]]; then
     xpr="$2"
     run_name_synth="$3"
@@ -32,8 +38,7 @@ if [[ $1 == build ]]; then
     echo "# Generated by Vivado wrapper, licensed under GPL 3.0
     # Copyright (C) Recolic Keghart <root@recolic.net>
     open_project ${xpr}
-    `find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;`
-    `find ${proj_dir}/*.srcs -regex '^.*\.o?cc?p?p?x?x?$' -exec echo add_files \{\} \;`
+    `list_sources`
     set_property top ${top_mod} [current_fileset]
     reset_run ${run_name_synth}
     reset_run ${run_name_impl}
@@ -59,8 +64,7 @@ elif [[ $1 == gui ]]; then
     xpr="$2"
     proj_dir=`dirname ${xpr}`
     echo "open_project ${xpr}
-    `find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;`
-    `find ${proj_dir}/*.srcs -regex '^.*\.o?cc?p?p?x?x?$' -exec echo add_files \{\} \;`
+    `list_sources`
     start_gui"
 elif [[ $1 == init-project ]]; then
     proj_name="$2"
diff --git a/template/Vivadofile b/template/Vivadofile
index e667528..d312c70 100644
--- a/template/Vivadofile
+++ b/template/Vivadofile
@@ -2,7 +2,8 @@
 # Required options
 #
 
-# You may use SystemVerilog, Verilog, or VHDL files as sources.
+# You may use SystemVerilog, Verilog, or VHDL files as sources. (.sv .v .vh)
+# You may also use C, C++, ObjectC or SystemC files as sources. (.c .cc .cxx .cpp .oc .h .hh .hpp .hxx)
 # sources=(test_main.sv lib/* ./mod?.v)
 sources=(src/*)
 
-- 
GitLab