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