From 023a26bd0e5cca8b16af2defff559dff00005d5b Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 18 May 2025 22:46:27 +0800 Subject: [PATCH] Add gen_ag_interface_template.sh --- Scripts/gen_ag_interface_template.sh | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 Scripts/gen_ag_interface_template.sh diff --git a/Scripts/gen_ag_interface_template.sh b/Scripts/gen_ag_interface_template.sh new file mode 100755 index 00000000..9932f192 --- /dev/null +++ b/Scripts/gen_ag_interface_template.sh @@ -0,0 +1,29 @@ +#!/bin/zsh + +# A `realpath` alternative using the default C implementation. +filepath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" + +cd $OPENGRAPH_ROOT + +# Build the swiftinterface file +./Scripts/build_swiftinterface.sh + +# Copy to template file +cp .build/debug/OpenGraph.build/OpenGraph.swiftinterface ./template.swiftinterface + +# Process the template file +# 1. Remove the first 5 lines +# 2. Remove all references of "OpenGraph_SPI." +# 3. Replace all references of "OpenGraph" to "AttributeGraph" +# 4. Replace all references of "OG" to "AG" +sed -i '' '1,5d' ./template.swiftinterface +sed -i '' 's/OpenGraph_SPI\.//g' ./template.swiftinterface +sed -i '' 's/OpenGraph/AttributeGraph/g' ./template.swiftinterface +sed -i '' 's/OG/AG/g' ./template.swiftinterface + +echo "Generated template.swiftinterface successfully" +