From 02dc0aff2d58dc7c658d467eb53bad0b45bbe054 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 17 Feb 2025 16:36:24 +0100 Subject: [PATCH] Add flat buffers generation script --- .../FlatSerialization/macOS/generate.sh | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 submodules/TelegramCore/FlatSerialization/macOS/generate.sh diff --git a/submodules/TelegramCore/FlatSerialization/macOS/generate.sh b/submodules/TelegramCore/FlatSerialization/macOS/generate.sh new file mode 100644 index 0000000000..cb0b4987fb --- /dev/null +++ b/submodules/TelegramCore/FlatSerialization/macOS/generate.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# Default directories +OUTPUT_DIR="" +INPUT_DIR="" + +# Parse command line arguments +while [ "$#" -gt 0 ]; do + case "$1" in + --output) + OUTPUT_DIR="$2" + shift 2 + ;; + --input) + INPUT_DIR="$2" + shift 2 + ;; + *) + echo "Unknown parameter: $1" + exit 1 + ;; + esac +done + +# Validate output directory +if [ -z "$OUTPUT_DIR" ]; then + echo "Error: --output argument is required" + exit 1 +fi + +if [ ! -d "$OUTPUT_DIR" ]; then + echo "Error: Output directory does not exist: $OUTPUT_DIR" + exit 1 +fi + +# Validate input directory +if [ -z "$INPUT_DIR" ]; then + echo "Error: --input argument is required" + exit 1 +fi + +if [ ! -d "$INPUT_DIR" ]; then + echo "Error: Input directory does not exist: $INPUT_DIR" + exit 1 +fi + +# Remove existing Swift files from output directory +rm -f "$OUTPUT_DIR"/*.swift + +# Get all .fbs files in Models directory +models=$(ls "$INPUT_DIR"/*.fbs) + +# Initialize empty flatc_input +flatc_input="" + +# Build space-separated list of model paths +for model in $models; do + flatc_input="$flatc_input $model" +done + +flatc --require-explicit-ids --swift -o "$OUTPUT_DIR" ${flatc_input}