cl2c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # Convert an OpenCL source file into a C source file containing the
  3. # OpenCL source as a C string. Also adds a #line directive so that
  4. # compiler messages are useful.
  5. # This file is part of FFmpeg.
  6. #
  7. # FFmpeg is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2.1 of the License, or (at your option) any later version.
  11. #
  12. # FFmpeg is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. # See the GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. input="$1"
  21. output="$2"
  22. name=$(basename "$input" | sed 's/.cl$//')
  23. cat >$output <<EOF
  24. // Generated from $input
  25. const char *ff_opencl_source_$name =
  26. "#line 1 \"$input\"\n"
  27. EOF
  28. # Convert \ to \\ and " to \", then add " to the start and end of the line.
  29. cat "$input" | sed 's/\\/\\\\/g;s/\"/\\\"/g;s/^/\"/;s/$/\\n\"/' >>$output
  30. echo ";" >>$output