From 0c7807d400e1af628b6e0e398b8173a34b6064e5 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 17 Apr 2019 16:59:52 +0200 Subject: [PATCH] added script to update SOURCES and HEADERS in chatternio.pro --- update_filelist.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 update_filelist.py diff --git a/update_filelist.py b/update_filelist.py new file mode 100644 index 00000000..411f28d2 --- /dev/null +++ b/update_filelist.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import re +import subprocess + +dir_path = os.path.dirname(os.path.realpath(__file__)) +filename = 'chatterino.pro' +data = "" + +with open(filename, 'r') as project: + data = project.read() + sources = subprocess.getoutput("find ./src -type f -regex '.*\.cpp' | sed 's_\./_ _g'") + sources = re.sub(r'$', r' \\\\', sources, flags=re.MULTILINE) + sources += "\n" + data = re.sub(r'^SOURCES(.|\r|\n)*?^$', 'SOURCES += \\\n' + sources, data, flags=re.MULTILINE) + + headers = subprocess.getoutput("find ./src -type f -regex '.*\.hpp' | sed 's_\./_ _g'") + headers = re.sub(r'$', r' \\\\', headers, flags=re.MULTILINE) + headers += "\n" + data = re.sub(r'^HEADERS(.|\r|\n)*?^$', 'HEADERS += \\\n' + headers, data, flags=re.MULTILINE) + +with open(filename, 'w') as project: + project.write(data) +