From 9ee1e741415e475d622e914b7d93b352e77984da Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 14 Jan 2025 15:16:23 +0100 Subject: [PATCH] tool: add simple replace string helper in python for cmake builds --- tool/replace_string.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tool/replace_string.py diff --git a/tool/replace_string.py b/tool/replace_string.py new file mode 100644 index 000000000..253842579 --- /dev/null +++ b/tool/replace_string.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# BlueKitchen GmbH (c) 2025 + +# This script replaces a string in a file with another string, introduced to create Ozone project files from CMakeLists.txt + +import sys + +def replace_string(input_file, output_file, search_string, replacement_string): + with open(input_file, 'r') as infile: + content = infile.read() + modified_content = content.replace(search_string, replacement_string) + with open(output_file, 'w') as outfile: + outfile.write(modified_content) + +if __name__ == "__main__": + if len(sys.argv) != 5: + print("Usage: python3 replace_string.py ") + sys.exit(1) + + replace_string(*sys.argv[1:])