Browse files

Adding script for generating ctags/cscope that's aware of the STRUCT(…

…) macros
  • Loading branch information...
1 parent f14c989 commit 4e3e84b2ec4374e6d77bd42e865f9edae4e3fc77 @superjer committed Feb 19, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 platforms/scripts/tags.sh
View
26 platforms/scripts/tags.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# This script calls ctags and cscope to build tags info for Vim.
+# Uses some sed/awk tricks to get tags where they would otherwise be obscured by macros.
+# Run at the root of the project.
+
+mv game/game_structs.h{,.bak}
+sed -e 's/#define *TYPE */TYPE(/' \
+ -e 's/^ *//' \
+ game/game_structs.h.bak \
+ | awk -F'(' \
+ ' { nom=1; }
+ $1 ~ "^TYPE" { nom=0; type=$2;
+ print "typedef struct " $2 "_t {"; }
+ $1 ~ "^STRUCT" ||
+ $1 ~ "^EXPOSE" ||
+ $1 ~ "^HIDE" ||
+ $1 ~ "^)" { nom=0; print "//" $0; }
+ $1 ~ "endstruct.h" { nom=0; print "}",type,";"; }
+ nom { print $0; }
+ ' >game/game_structs.h
+
+ctags {engine,game}/*.[ch]
+cscope -b -I engine -I game -s engine -s game
+
+mv game/game_structs.h{.bak,}

0 comments on commit 4e3e84b

Please sign in to comment.