• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
22input="$1"
23output="$2"
24
25name=$(basename "$input" | sed 's/.cl$//')
26
27cat >$output <<EOF
28// Generated from $input
29const char *ff_opencl_source_$name =
30"#line 1 \"$input\"\n"
31EOF
32
33# Convert \ to \\ and " to \", then add " to the start and end of the line.
34cat "$input" | sed 's/\\/\\\\/g;s/\"/\\\"/g;s/^/\"/;s/$/\\n\"/' >>$output
35
36echo ";" >>$output
37