This commit is contained in:
Ali 2020-02-19 22:09:53 +04:00
parent 7417b994db
commit d8ff630d11
10 changed files with 644 additions and 10 deletions

2
.gitignore vendored
View File

@ -59,3 +59,5 @@ bazel-telegram-ios/*
bazel-testlogs
bazel-testlogs/*
*/*.swp
build-input/data
build-input/data/*

156
Telegram/BUILD Normal file
View File

@ -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",
],
)

335
Telegram/Info.plist Normal file
View File

@ -0,0 +1,335 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).refresh</string>
</array>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Black</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackIcon</string>
<string>BlackNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlackClassic</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackClassicIcon</string>
<string>BlackClassicNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlackFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackFilledIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>Blue</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueIcon</string>
<string>BlueNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlueClassic</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueClassicIcon</string>
<string>BlueClassicNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlueFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueFilledIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>WhiteFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>WhiteFilledIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconName</key>
<string>AppIconLLC</string>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Black</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackIconIpad</string>
<string>BlackIconLargeIpad</string>
<string>BlackNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlackClassic</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackClassicIconIpad</string>
<string>BlackClassicIconLargeIpad</string>
<string>BlackClassicNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlackFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlackFilledIconIpad</string>
<string>BlackFilledIconLargeIpad</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>Blue</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueIconIpad</string>
<string>BlueIconLargeIpad</string>
<string>BlueNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlueClassic</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueClassicIconIpad</string>
<string>BlueClassicIconLargeIpad</string>
<string>BlueClassicNotificationIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>BlueFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>BlueFilledIconIpad</string>
<string>BlueFilledIconLargeIpad</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
<key>WhiteFilled</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>WhiteFilledIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconName</key>
<string>AppIconLLC</string>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
<string>comgooglemaps-x-callback</string>
<string>foursquare</string>
<string>here-location</string>
<string>yandexmaps</string>
<string>yandexnavi</string>
<string>comgooglemaps</string>
<string>youtube</string>
<string>twitter</string>
<string>vk</string>
<string>waze</string>
<string>googlechrome</string>
<string>firefox</string>
<string>touch-http</string>
<string>yandexbrowser-open-url</string>
<string>vimeo</string>
<string>vine</string>
<string>coub</string>
<string>uber</string>
<string>citymapper</string>
<string>lyft</string>
<string>opera-http</string>
<string>firefox-focus</string>
<string>ddgQuickLink</string>
<string>moovit</string>
<string>alook</string>
<string>dgis</string>
<string>microsoft-edge-http</string>
<string>brave</string>
<string>onionhttp</string>
<string>ucbrowser</string>
<string>dolphin</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>We need this so that you can take and share photos and videos.</string>
<key>NSContactsUsageDescription</key>
<string>Telegram stores your contacts heavily encrypted in the cloud to let you connect with your friends across all your devices.</string>
<key>NSFaceIDUsageDescription</key>
<string>You can use Face ID to unlock the app.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>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.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>When you send your location to your friends, Telegram needs access to show them a map.</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need this so that you can record and share voice messages and videos with sound.</string>
<key>NSMotionUsageDescription</key>
<string>When you send your location to your friends, Telegram needs access to show them a map.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>We need this so that you can share photos and videos from your photo library.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need this so that you can share photos and videos from your photo library.</string>
<key>NSSiriUsageDescription</key>
<string>You can use Siri to send messages.</string>
<key>NSUserActivityTypes</key>
<array>
<string>INSendMessageIntent</string>
<string>RemindAboutChatIntent</string>
</array>
<key>UIAppFonts</key>
<array>
<string>SFCompactRounded-Semibold.otf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
<string>voip</string>
</array>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIFileSharingEnabled</key>
<false/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresPersistentWiFi</key>
<true/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIViewEdgeAntialiasing</key>
<false/>
<key>UIViewGroupOpacity</key>
<false/>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Telegram iOS Color Theme File</string>
<key>UTTypeIconFiles</key>
<array>
<string>BlueIcon@3x.png</string>
</array>
<key>UTTypeIdentifier</key>
<string>org.telegram.Telegram-iOS.theme</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>tgios-theme</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,78 @@
load("//build-system:defines.bzl",
"string_value",
)
def _telegram_info_plist(ctx):
output = ctx.outputs.out
plist_string = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>{app_version}</string>
<key>CFBundleVersion</key>
<string>{build_number}</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{bundle_id}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>telegram</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{bundle_id}.ton</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ton</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{app_name}.compatibility</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tg</string>
<string>{url_scheme}</string>
</array>
</dict>
</array>
</dict>
</plist>
""".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"
},
)

View File

@ -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"],

0
build-input/BUILD Normal file
View File

0
build-system/BUILD Normal file
View File

36
build-system/defines.bzl Normal file
View File

@ -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}"
},
)

View File

@ -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

View File

@ -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",