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 25import shutil 26import subprocess 27import sys 28 29assert(len(sys.argv) == 4) 30 31orc_file = sys.argv[1] 32gen_header = sys.argv[2] 33gen_source = sys.argv[3] 34 35# split off .orc suffix 36assert(orc_file.endswith('.orc')) 37orc_src_base = sys.argv[1][:-4] 38 39# figure out names of disted backup files 40dist_h = orc_src_base + "-dist.h" 41dist_c = orc_src_base + "-dist.c" 42 43# copy generated files from build dir into source dir 44shutil.copyfile(gen_header, dist_h) 45shutil.copyfile(gen_source, dist_c) 46 47# run gst-indent on the .c files (twice, because gnu indent) 48subprocess.run(['gst-indent', dist_c]) 49subprocess.run(['gst-indent', dist_c]) 50