]> git.sesse.net Git - ffmpeg/blob - tools/cl2c
avformat/avio: Add Metacube support
[ffmpeg] / tools / cl2c
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
6 # This file is part of FFmpeg.
7 #
8 # FFmpeg is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12 #
13 # FFmpeg is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the GNU Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22 input="$1"
23 output="$2"
24
25 name=$(basename "$input" | sed 's/.cl$//')
26
27 cat >$output <<EOF
28 // Generated from $input
29 const char *ff_opencl_source_$name =
30 "#line 1 \"$input\"\n"
31 EOF
32
33 # Convert \ to \\ and " to \", then add " to the start and end of the line.
34 cat "$input" | sed 's/\\/\\\\/g;s/\"/\\\"/g;s/^/\"/;s/$/\\n\"/' >>$output
35
36 echo ";" >>$output