Merge remote-tracking branch 'gst-plugins-good/tizen_gst_1.19.2' into tizen_gst_1...
[platform/upstream/gstreamer.git] / scripts / update-orc-dist-files.py
1 #!/usr/bin/env python3
2 #
3 # update-orc-dist-files.py ORC-FILE GENERATED-HEADER GENERATED-SOURCE
4 #
5 # Copies generated orc .c and .h files into source dir as -dist.[ch] backups,
6 # based on location of passed .orc file.
7 #
8 # Copyright (C) 2020 Tim-Philipp Müller <tim centricular com>
9 #
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
14 #
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 # Library General Public License for more details.
19 #
20 # You should have received a copy of the GNU Library General Public
21 # License along with this library; if not, write to the
22 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 # Boston, MA 02110-1301, USA.
24
25 import shutil
26 import subprocess
27 import sys
28
29 assert(len(sys.argv) == 4)
30
31 orc_file = sys.argv[1]
32 gen_header = sys.argv[2]
33 gen_source = sys.argv[3]
34
35 # split off .orc suffix
36 assert(orc_file.endswith('.orc'))
37 orc_src_base = sys.argv[1][:-4]
38
39 # figure out names of disted backup files
40 dist_h = orc_src_base + "-dist.h"
41 dist_c = orc_src_base + "-dist.c"
42
43 # copy generated files from build dir into source dir
44 shutil.copyfile(gen_header, dist_h)
45 shutil.copyfile(gen_source, dist_c)
46
47 # run gst-indent on the .c files (twice, because gnu indent)
48 subprocess.run(['gst-indent', dist_c])
49 subprocess.run(['gst-indent', dist_c])