Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/bash
  2. # Script to create prod version of project (concat all deps in one single file)
  3.  
  4. cd "$(dirname "$0")"
  5.  
  6. rm -f main_prod.c
  7.  
  8. tempfile=$(mktemp)
  9. tempmain=$(mktemp)
  10. cat main.c > "$tempmain"
  11.  
  12. IFS=$'\n'
  13. deps=($(sed -nE 's!#include *\"([a-zA-Z_]+)\.h\"!\1!p' < main.c))
  14. for dep in "${deps[@]}"; do
  15. echo "Found $dep"
  16. cat "$dep.h" >> "$tempfile"
  17. sed "s/#include \"$dep.h\"//" < "$dep.c" >> "$tempfile"
  18. sed -i "s/#include \"$dep.h\"//" "$tempmain"
  19. done
  20. sed -i "s/#define DEBUG//" "$tempmain"
  21. touch main_prod.c
  22. echo "//This file was created using create_prod_version.sh script" >> main_prod.c
  23. cat "$tempfile" >> main_prod.c
  24. cat "$tempmain" >> main_prod.c
  25. rm $tempfile
  26. rm $tempmain
Add Comment
Please, Sign In to add comment