diff --git a/.gitignore b/.gitignore index 6878ff932f..c70c75cf64 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ bazel-telegram-ios/* bazel-testlogs bazel-testlogs/* */*.swp +build-input/data +build-input/data/* diff --git a/Telegram/BUILD b/Telegram/BUILD new file mode 100644 index 0000000000..4044f3d941 --- /dev/null +++ b/Telegram/BUILD @@ -0,0 +1,156 @@ +load("@build_bazel_rules_apple//apple:ios.bzl", + "ios_application", + "ios_framework", +) + +load("@build_bazel_rules_swift//swift:swift.bzl", + "swift_library", +) + +load("//build-system:defines.bzl", + "file_from_define", +) + +load(":telegram_info_plist.bzl", + "telegram_info_plist", +) + +filegroup( + name = "AppResources", + srcs = glob([ + "Telegram-iOS/Resources/**/*", + ], exclude = ["Telegram-iOS/Resources/**/.*"]), +) + +filegroup( + name = "AppStringResources", + srcs = glob([ + "Telegram-iOS/*.lproj/Localizable.strings", + ], exclude = ["Telegram-iOS/*.lproj/**/.*"]), +) + +filegroup( + name = "AppIntentVocabularyResources", + srcs = glob([ + "Telegram-iOS/*.lproj/AppIntentVocabulary.plist", + ], exclude = ["Telegram-iOS/*.lproj/**/.*"]), +) + +filegroup( + name = "InfoPlistStringResources", + srcs = glob([ + "Telegram-iOS/*.lproj/InfoPlist.strings", + ], exclude = ["Telegram-iOS/*.lproj/**/.*"]), +) + +filegroup( + name = "Icons", + srcs = glob([ + "Telegram-iOS/Icons.xcassets", + ]), +) + +filegroup( + name = "AppIcons", + srcs = glob([ + "Telegram-iOS/AppIcons.xcassets", + ]), +) + +filegroup( + name = "AdditionalIcons", + srcs = glob([ + "Telegram-iOS/*.png", + ]), +) + +filegroup( + name = "LaunchScreen", + srcs = glob([ + "Telegram-iOS/Base.lproj/LaunchScreen.xib", + ]), +) + +objc_library( + name = "Main", + srcs = [ + "Telegram-iOS/main.m" + ], +) + +swift_library( + name = "Lib", + srcs = glob([ + "Telegram-iOS/Application.swift", + ]), + data = [ + ":AppStringResources", + ], + deps = [ + "//submodules/GZip:GZip", + "//submodules/AsyncDisplayKit:AsyncDisplayKit", + "//submodules/SSignalKit/SSignalKit:SSignalKit", + "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", + "//submodules/ObjCRuntimeUtils:ObjCRuntimeUtils", + "//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils", + "//submodules/Display:Display", + "//submodules/AlertUI:AlertUI", + "//submodules/ActivityIndicator:ActivityIndicator", + "//submodules/OverlayStatusController:OverlayStatusController", + "//submodules/openssl:openssl", + "//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider", + "//submodules/WalletCore:WalletCore", + "//submodules/BuildConfig:BuildConfig", + "//submodules/AppBundle:AppBundle", + "//submodules/SolidRoundedButtonNode:SolidRoundedButtonNode", + "//submodules/Camera:Camera", + "//submodules/QrCode:QrCode", + "//submodules/MergeLists:MergeLists", + "//submodules/GlassButtonNode:GlassButtonNode", + "//submodules/UrlEscaping:UrlEscaping", + "//submodules/LocalAuth:LocalAuth", + "//submodules/ScreenCaptureDetection:ScreenCaptureDetection", + "//submodules/WalletUrl:WalletUrl", + "//submodules/ProgressNavigationButtonNode:ProgressNavigationButtonNode", + "//submodules/Markdown:Markdown", + "//submodules/StringPluralization:StringPluralization", + "//submodules/YuvConversion:YuvConversion", + "//submodules/rlottie:RLottieBinding", + "//submodules/AnimatedStickerNode:AnimatedStickerNode", + "//submodules/WalletUI:WalletUI", + ], +) + +additional_info_plist = telegram_info_plist( + name = "AdditionalInfo.plist", + app_name = "Telegram", + url_scheme = "tg", + bundle_id_define = "telegram_bundle_id", + app_version_define = "telegram_version", + build_number_define = "telegram_build_number", +) + +provisioning_profile = file_from_define( + name = "TelegramProvisioningProfile", + extension = "mobileprovision", + define_name = "telegram_provisioning_profile", +) + +ios_application( + name = "Telegram", + bundle_id = "{telegram_bundle_id}", + families = ["iphone", "ipad"], + minimum_os_version = "9.0", + provisioning_profile = ":TelegramProvisioningProfile", + infoplists = [ + "Info.plist", + ":AdditionalInfo.plist", + ], + frameworks = [ + #":AsyncDisplayKitFramework", + ], + deps = [ + ":Main", + ":Lib", + ], +) diff --git a/Telegram/Info.plist b/Telegram/Info.plist new file mode 100644 index 0000000000..140f3cf30d --- /dev/null +++ b/Telegram/Info.plist @@ -0,0 +1,335 @@ + + + + + BGTaskSchedulerPermittedIdentifiers + + $(PRODUCT_BUNDLE_IDENTIFIER).refresh + + CFBundleAllowMixedLocalizations + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIcons + + CFBundleAlternateIcons + + Black + + CFBundleIconFiles + + BlackIcon + BlackNotificationIcon + + UIPrerenderedIcon + + + BlackClassic + + CFBundleIconFiles + + BlackClassicIcon + BlackClassicNotificationIcon + + UIPrerenderedIcon + + + BlackFilled + + CFBundleIconFiles + + BlackFilledIcon + + UIPrerenderedIcon + + + Blue + + CFBundleIconFiles + + BlueIcon + BlueNotificationIcon + + UIPrerenderedIcon + + + BlueClassic + + CFBundleIconFiles + + BlueClassicIcon + BlueClassicNotificationIcon + + UIPrerenderedIcon + + + BlueFilled + + CFBundleIconFiles + + BlueFilledIcon + + UIPrerenderedIcon + + + WhiteFilled + + CFBundleIconFiles + + WhiteFilledIcon + + UIPrerenderedIcon + + + + CFBundlePrimaryIcon + + CFBundleIconName + AppIconLLC + UIPrerenderedIcon + + + + CFBundleIcons~ipad + + CFBundleAlternateIcons + + Black + + CFBundleIconFiles + + BlackIconIpad + BlackIconLargeIpad + BlackNotificationIcon + + UIPrerenderedIcon + + + BlackClassic + + CFBundleIconFiles + + BlackClassicIconIpad + BlackClassicIconLargeIpad + BlackClassicNotificationIcon + + UIPrerenderedIcon + + + BlackFilled + + CFBundleIconFiles + + BlackFilledIconIpad + BlackFilledIconLargeIpad + + UIPrerenderedIcon + + + Blue + + CFBundleIconFiles + + BlueIconIpad + BlueIconLargeIpad + BlueNotificationIcon + + UIPrerenderedIcon + + + BlueClassic + + CFBundleIconFiles + + BlueClassicIconIpad + BlueClassicIconLargeIpad + BlueClassicNotificationIcon + + UIPrerenderedIcon + + + BlueFilled + + CFBundleIconFiles + + BlueFilledIconIpad + BlueFilledIconLargeIpad + + UIPrerenderedIcon + + + WhiteFilled + + CFBundleIconFiles + + WhiteFilledIcon + + UIPrerenderedIcon + + + + CFBundlePrimaryIcon + + CFBundleIconName + AppIconLLC + UIPrerenderedIcon + + + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleSignature + ???? + ITSAppUsesNonExemptEncryption + + LSApplicationQueriesSchemes + + instagram + comgooglemaps-x-callback + foursquare + here-location + yandexmaps + yandexnavi + comgooglemaps + youtube + twitter + vk + waze + googlechrome + firefox + touch-http + yandexbrowser-open-url + vimeo + vine + coub + uber + citymapper + lyft + opera-http + firefox-focus + ddgQuickLink + moovit + alook + dgis + microsoft-edge-http + brave + onionhttp + ucbrowser + dolphin + + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSCameraUsageDescription + We need this so that you can take and share photos and videos. + NSContactsUsageDescription + Telegram stores your contacts heavily encrypted in the cloud to let you connect with your friends across all your devices. + NSFaceIDUsageDescription + You can use Face ID to unlock the app. + NSLocationAlwaysUsageDescription + When you send your location to your friends, Telegram needs access to show them a map. You also need this to send locations from an Apple Watch. + NSLocationWhenInUseUsageDescription + When you send your location to your friends, Telegram needs access to show them a map. + NSMicrophoneUsageDescription + We need this so that you can record and share voice messages and videos with sound. + NSMotionUsageDescription + When you send your location to your friends, Telegram needs access to show them a map. + NSPhotoLibraryAddUsageDescription + We need this so that you can share photos and videos from your photo library. + NSPhotoLibraryUsageDescription + We need this so that you can share photos and videos from your photo library. + NSSiriUsageDescription + You can use Siri to send messages. + NSUserActivityTypes + + INSendMessageIntent + RemindAboutChatIntent + + UIAppFonts + + SFCompactRounded-Semibold.otf + + UIBackgroundModes + + audio + fetch + location + remote-notification + voip + + UIDeviceFamily + + 1 + 2 + + UIFileSharingEnabled + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UIRequiresPersistentWiFi + + UIStatusBarStyle + UIStatusBarStyleDefault + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + UIViewEdgeAntialiasing + + UIViewGroupOpacity + + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + Telegram iOS Color Theme File + UTTypeIconFiles + + BlueIcon@3x.png + + UTTypeIdentifier + org.telegram.Telegram-iOS.theme + UTTypeTagSpecification + + public.filename-extension + + tgios-theme + + + + + + diff --git a/Telegram/telegram_info_plist.bzl b/Telegram/telegram_info_plist.bzl new file mode 100644 index 0000000000..11726ee17b --- /dev/null +++ b/Telegram/telegram_info_plist.bzl @@ -0,0 +1,78 @@ +load("//build-system:defines.bzl", + "string_value", +) + +def _telegram_info_plist(ctx): + output = ctx.outputs.out + + plist_string = """ + + + + + CFBundleShortVersionString + {app_version} + CFBundleVersion + {build_number} + CFBundleURLTypes + + + CFBundleTypeRole + Viewer + CFBundleURLName + {bundle_id} + CFBundleURLSchemes + + telegram + + + + CFBundleTypeRole + Viewer + CFBundleURLName + {bundle_id}.ton + CFBundleURLSchemes + + ton + + + + CFBundleTypeRole + Viewer + CFBundleURLName + {app_name}.compatibility + CFBundleURLSchemes + + tg + {url_scheme} + + + + + + """.format( + app_version = string_value(ctx, ctx.attr.app_version_define), + build_number = string_value(ctx, ctx.attr.build_number_define), + bundle_id = string_value(ctx, ctx.attr.bundle_id_define), + app_name = ctx.attr.app_name, + url_scheme = ctx.attr.url_scheme, + ) + + ctx.actions.write( + output = output, + content = plist_string, + ) + +telegram_info_plist = rule( + implementation = _telegram_info_plist, + attrs = { + "app_name": attr.string(mandatory = True), + "url_scheme": attr.string(mandatory = True), + "bundle_id_define": attr.string(mandatory = True), + "app_version_define": attr.string(mandatory = True), + "build_number_define": attr.string(mandatory = True), + }, + outputs = { + "out": "%{name}.plist" + }, +) diff --git a/Wallet/BUILD b/Wallet/BUILD index 5fcb61ea6e..cab7075b2d 100644 --- a/Wallet/BUILD +++ b/Wallet/BUILD @@ -1,6 +1,5 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_framework") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") version_info_plist_source = """ echo \ @@ -17,13 +16,6 @@ echo \ > "$@" """.format("1.0", "30") - -string_flag( - name = "wallet_bundle_id", - build_setting_default = "", - visibility = ["//visibility:public"], -) - genrule( name = "VersionInfoPlist", outs = ["VersionInfo.plist"], diff --git a/build-input/BUILD b/build-input/BUILD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/build-system/BUILD b/build-system/BUILD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/build-system/defines.bzl b/build-system/defines.bzl new file mode 100644 index 0000000000..d9e5ac9fdd --- /dev/null +++ b/build-system/defines.bzl @@ -0,0 +1,36 @@ +def string_value(ctx, define_name): + """Looks up a define on ctx for a string value. + + Will also report an error if the value is not defined. + + Args: + ctx: A skylark context. + define_name: The name of the define to look up. + + Returns: + The value of the define. + """ + value = ctx.var.get(define_name, None) + if value != None: + return value + fail("Expected value for --define={} was not found".format( + define_name, + )) + +def _file_from_define(ctx): + output = ctx.outputs.out + ctx.actions.write( + output = output, + content = "profile_data", + ) + +file_from_define = rule( + implementation = _file_from_define, + attrs = { + "define_name": attr.string(mandatory = True), + "extension": attr.string(mandatory = True), + }, + outputs = { + "out": "%{name}.%{extension}" + }, +) diff --git a/build-system/find-provisioning-profile.sh b/build-system/find-provisioning-profile.sh new file mode 100644 index 0000000000..aefeba9633 --- /dev/null +++ b/build-system/find-provisioning-profile.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +if [ "$PROVISIONING_PROFILE_SEARCH_PATH" = "" ]; then + >&2 echo "PROVISIONING_PROFILE_SEARCH_PATH not defined" + exit 1 +fi + +SEARCH_NAME="$1" + +if [ "$SEARCH_NAME" == "" ]; then + >&2 echo "Usage: sh find-provisioning-profile.sh name" + exit 1 +fi + +FOUND_PROFILE="" + +for PROFILE in `find "$PROVISIONING_PROFILE_SEARCH_PATH" -type f -name "*.mobileprovision"`; do + PROFILE_DATA=$(security cms -D -i "$PROFILE") + PROFILE_NAME=$(/usr/libexec/PlistBuddy -c "Print :Name" /dev/stdin <<< $(echo $PROFILE_DATA)) + if [ "$PROFILE_NAME" == "$SEARCH_NAME" ]; then + if [ "$FOUND_PROFILE" == "" ]; then + FOUND_PROFILE="$PROFILE" + else + >&2 echo "Found multiple profiles with name \"$SEARCH_NAME\"" + exit 1 + fi + fi +done + +if [ "$FOUND_PROFILE" == "" ]; then + >&2 echo "Profile \"$SEARCH_NAME\" not found" + exit 1 +fi + +cat "$FOUND_PROFILE" | gzip | zcat | base64 diff --git a/submodules/ActivityIndicator/BUILD b/submodules/ActivityIndicator/BUILD index 86e9f555e5..08c019b637 100644 --- a/submodules/ActivityIndicator/BUILD +++ b/submodules/ActivityIndicator/BUILD @@ -7,8 +7,8 @@ swift_library( "Sources/**/*.swift", ]), deps = [ - "//submodules/Display:Display#shared", - "//submodules/AsyncDisplayKit:AsyncDisplayKit#shared", + "//submodules/Display:Display", + "//submodules/AsyncDisplayKit:AsyncDisplayKit", ], visibility = [ "//visibility:public",