diff --git a/.gitignore b/.gitignore index 3603100d4a..ee6e976d84 100644 --- a/.gitignore +++ b/.gitignore @@ -68,4 +68,4 @@ build-input/* submodules/OpusBinding/SharedHeaders/* submodules/FFMpegBinding/SharedHeaders/* submodules/OpenSSLEncryptionProvider/SharedHeaders/* - +submodules/TelegramCore/FlatSerialization/Sources/* diff --git a/submodules/TelegramCore/FlatBuffers/Package.swift b/submodules/TelegramCore/FlatBuffers/Package.swift new file mode 100644 index 0000000000..a5df82be59 --- /dev/null +++ b/submodules/TelegramCore/FlatBuffers/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "FlatBuffers", + platforms: [.macOS(.v10_13)], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "FlatBuffers", + targets: ["FlatBuffers"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "FlatBuffers", + dependencies: [], + path: "Sources"), + ] +) diff --git a/submodules/TelegramCore/FlatSerialization/Package.swift b/submodules/TelegramCore/FlatSerialization/Package.swift new file mode 100644 index 0000000000..0f6939f96d --- /dev/null +++ b/submodules/TelegramCore/FlatSerialization/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "FlatSerialization", + platforms: [.macOS(.v10_13)], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "FlatSerialization", + targets: ["FlatSerialization"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + .package(name: "FlatBuffers", path: "../FlatBuffers") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "FlatSerialization", + dependencies: [ + .product(name: "FlatBuffers", package: "FlatBuffers", condition: nil), + ], + path: "Sources"), + ] +) diff --git a/submodules/TelegramCore/FlatSerialization/macOS/generate.sh b/submodules/TelegramCore/FlatSerialization/macOS/generate.sh index cb0b4987fb..ef391b5afc 100644 --- a/submodules/TelegramCore/FlatSerialization/macOS/generate.sh +++ b/submodules/TelegramCore/FlatSerialization/macOS/generate.sh @@ -3,10 +3,15 @@ # Default directories OUTPUT_DIR="" INPUT_DIR="" +BINARY_PATH="" # Parse command line arguments while [ "$#" -gt 0 ]; do case "$1" in + --binary) + BINARY_PATH="$2" + shift 2 + ;; --output) OUTPUT_DIR="$2" shift 2 @@ -28,6 +33,12 @@ if [ -z "$OUTPUT_DIR" ]; then exit 1 fi +# Validate output directory +if [ -z "$BINARY_PATH" ]; then + echo "Error: --binary argument is required" + exit 1 +fi + if [ ! -d "$OUTPUT_DIR" ]; then echo "Error: Output directory does not exist: $OUTPUT_DIR" exit 1 @@ -58,4 +69,4 @@ for model in $models; do flatc_input="$flatc_input $model" done -flatc --require-explicit-ids --swift -o "$OUTPUT_DIR" ${flatc_input} +$BINARY_PATH --require-explicit-ids --swift -o "$OUTPUT_DIR" ${flatc_input} diff --git a/submodules/TelegramCore/Package.swift b/submodules/TelegramCore/Package.swift index bd86af416d..9060a52b3b 100644 --- a/submodules/TelegramCore/Package.swift +++ b/submodules/TelegramCore/Package.swift @@ -15,6 +15,8 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), + .package(name: "FlatBuffers", path: "./FlatBuffers"), + .package(name: "FlatSerialization", path: "./FlatSerialization"), .package(name: "Postbox", path: "../Postbox"), .package(name: "SSignalKit", path: "../SSignalKit"), .package(name: "MtProtoKit", path: "../MtProtoKit"), @@ -40,6 +42,8 @@ let package = Package( .product(name: "DarwinDirStat", package: "DarwinDirStat", condition: nil), .product(name: "Reachability", package: "Reachability", condition: nil), .product(name: "Emoji", package: "Emoji", condition: nil), + .product(name: "FlatBuffers", package: "FlatBuffers", condition: nil), + .product(name: "FlatSerialization", package: "FlatSerialization", condition: nil), .product(name: "EncryptionProvider", package: "EncryptionProvider", condition: nil)], path: "Sources"), ] diff --git a/third-party/flatc/Package.swift b/third-party/flatc/Package.swift new file mode 100644 index 0000000000..b4184bdbac --- /dev/null +++ b/third-party/flatc/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:5.5 +import PackageDescription + +let package = Package( + name: "FlatBuffersBuilder", + platforms: [ + .macOS(.v12) + ], + products: [ + .plugin( + name: "FlatBuffersPlugin", + targets: ["FlatBuffersPlugin"] + ) + ], + dependencies: [], + targets: [ + .binaryTarget( + name: "flatc", + url: "https://github.com/google/flatbuffers/releases/download/v23.5.26/Mac.flatc.binary.zip", + checksum: "d65628c225ef26e0386df003fe47d6b3ec8775c586d7dae1a9ef469a0a9906f1" + ), + .plugin( + name: "FlatBuffersPlugin", + capability: .buildTool(), + dependencies: ["flatc"] + ) + ] +)