Merge branch 'beta'

This commit is contained in:
Ali 2021-02-17 23:49:31 +04:00
commit 7c808530d2
9 changed files with 250 additions and 44 deletions

View File

@ -84,6 +84,7 @@ jobs:
--bazel="$HOME/bazel-dist/bazel" \
--bazelUserRoot="$BAZEL_USER_ROOT" \
build \
--disableParallelSwiftmoduleGeneration \
--configurationPath="$HOME/telegram-configuration" \
--buildNumber=$BUILD_NUMBER \
--configuration=release_universal

View File

@ -30,6 +30,9 @@ load(
"telegram_bundle_id",
"telegram_aps_environment",
"telegram_team_id",
"telegram_enable_icloud",
"telegram_enable_siri",
"telegram_enable_watch",
)
load("@build_bazel_rules_apple//apple:resources.bzl",
@ -287,7 +290,7 @@ apple_pay_merchants_fragment = "" if apple_pay_merchants == [] else """
<key>com.apple.developer.in-app-payments</key>
<array>
""" + "\n".join([
" <string>{}</string>".format(merchant_id) for merchant_id in apple_pay_merchants
" <string>{merchant_id}</string>".format(merchant_id=merchant_id) for merchant_id in apple_pay_merchants
]) + "\n" + """
</array>
"""
@ -304,44 +307,65 @@ official_carplay_fragment = """
"""
carplay_fragment = official_carplay_fragment if telegram_bundle_id in official_bundle_ids else ""
telegram_entitlements_template = """
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
<string>CloudDocuments</string>
</array>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.{telegram_bundle_id}</string>
</array>
<key>aps-environment</key>
<string>{telegram_aps_environment}</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:telegram.me</string>
<string>applinks:t.me</string>
</array>
<key>com.apple.developer.siri</key>
<true/>
icloud_fragment = "" if not telegram_enable_icloud else """
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
<string>CloudDocuments</string>
</array>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.{telegram_bundle_id}</string>
</array>
<key>com.apple.developer.icloud-container-environment</key>
<string>{telegram_icloud_environment}</string>
""".format(
telegram_bundle_id=telegram_bundle_id,
telegram_icloud_environment="Production" if telegram_aps_environment == "production" else "Development"
)
associated_domains_fragment = "" if telegram_bundle_id not in official_bundle_ids else """
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:telegram.me</string>
<string>applinks:t.me</string>
</array>
"""
siri_fragment = "" if not telegram_enable_siri else """
<key>com.apple.developer.siri</key>
<true/>
"""
aps_fragment = "" if telegram_aps_environment == "" else """
<key>aps-environment</key>
<string>{telegram_aps_environment}</string>
""".format(telegram_aps_environment=telegram_aps_environment)
app_groups_fragment = """
<key>com.apple.security.application-groups</key>
<array>
<string>group.{telegram_bundle_id}</string>
</array>
<key>application-identifier</key>
<string>{telegram_team_id}.{telegram_bundle_id}</string>
<key>com.apple.developer.icloud-container-environment</key>
<string>{telegram_icloud_environment}</string>
""" + apple_pay_merchants_fragment + unrestricted_voip_fragment + carplay_fragment
""".format(
telegram_team_id=telegram_team_id,
telegram_bundle_id=telegram_bundle_id
)
plist_fragment(
name = "TelegramEntitlements",
extension = "entitlements",
template = telegram_entitlements_template.format(
telegram_bundle_id = telegram_bundle_id,
telegram_team_id = telegram_team_id,
telegram_aps_environment = telegram_aps_environment,
telegram_icloud_environment = "Production" if telegram_aps_environment == "production" else "Development",
)
template = "".join([
app_groups_fragment,
siri_fragment,
associated_domains_fragment,
icloud_fragment,
apple_pay_merchants_fragment,
unrestricted_voip_fragment,
carplay_fragment
])
)
filegroup(
@ -530,7 +554,6 @@ watchos_extension(
watchos_application(
name = "TelegramWatchApp",
#app_icons = ,
bundle_id = "{telegram_bundle_id}.watchkitapp".format(
telegram_bundle_id = telegram_bundle_id,
),
@ -1112,6 +1135,25 @@ swift_library(
],
)
genrule(
name = "SetMinOsVersionNotificationContentExtension",
cmd_bash =
"""
name=NotificationContentExtension.appex
cat $(location PatchMinOSVersion.source.sh) | sed -e "s/<<<MIN_OS_VERSION>>>/10\\.0/g" | sed -e "s/<<<NAME>>>/$$name/g" > $(location SetMinOsVersionNotificationContentExtension.sh)
""",
srcs = [
"PatchMinOSVersion.source.sh",
],
outs = [
"SetMinOsVersionNotificationContentExtension.sh",
],
executable = True,
visibility = [
"//visibility:public",
]
)
ios_extension(
name = "NotificationContentExtension",
bundle_id = "{telegram_bundle_id}.NotificationContent".format(
@ -1127,7 +1169,8 @@ ios_extension(
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionNotificationContentExtension",
provisioning_profile = select({
":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:NotificationContent.mobileprovision",
@ -1194,6 +1237,25 @@ swift_library(
],
)
genrule(
name = "SetMinOsVersionWidgetExtension",
cmd_bash =
"""
name=WidgetExtension.appex
cat $(location PatchMinOSVersion.source.sh) | sed -e "s/<<<MIN_OS_VERSION>>>/14\\.0/g" | sed -e "s/<<<NAME>>>/$$name/g" > $(location SetMinOsVersionWidgetExtension.sh)
""",
srcs = [
"PatchMinOSVersion.source.sh",
],
outs = [
"SetMinOsVersionWidgetExtension.sh",
],
executable = True,
visibility = [
"//visibility:public",
]
)
ios_extension(
name = "WidgetExtension",
bundle_id = "{telegram_bundle_id}.Widget".format(
@ -1209,7 +1271,8 @@ ios_extension(
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "14.0",
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionWidgetExtension",
provides_main = True,
provisioning_profile = select({
":disableProvisioningProfilesSetting": None,
@ -1296,6 +1359,25 @@ swift_library(
],
)
genrule(
name = "SetMinOsVersionIntentsExtension",
cmd_bash =
"""
name=IntentsExtension.appex
cat $(location PatchMinOSVersion.source.sh) | sed -e "s/<<<MIN_OS_VERSION>>>/10\\.0/g" | sed -e "s/<<<NAME>>>/$$name/g" > $(location SetMinOsVersionIntentsExtension.sh)
""",
srcs = [
"PatchMinOSVersion.source.sh",
],
outs = [
"SetMinOsVersionIntentsExtension.sh",
],
executable = True,
visibility = [
"//visibility:public",
]
)
ios_extension(
name = "IntentsExtension",
bundle_id = "{telegram_bundle_id}.SiriIntents".format(
@ -1311,7 +1393,8 @@ ios_extension(
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionIntentsExtension",
provisioning_profile = select({
":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Intents.mobileprovision",
@ -1350,6 +1433,25 @@ plist_fragment(
)
)
genrule(
name = "SetMinOsVersionNotificationServiceExtension",
cmd_bash =
"""
name=NotificationServiceExtension.appex
cat $(location PatchMinOSVersion.source.sh) | sed -e "s/<<<MIN_OS_VERSION>>>/10\\.0/g" | sed -e "s/<<<NAME>>>/$$name/g" > $(location SetMinOsVersionNotificationServiceExtension.sh)
""",
srcs = [
"PatchMinOSVersion.source.sh",
],
outs = [
"SetMinOsVersionNotificationServiceExtension.sh",
],
executable = True,
visibility = [
"//visibility:public",
]
)
ios_extension(
name = "NotificationServiceExtension",
bundle_id = "{telegram_bundle_id}.NotificationService".format(
@ -1365,7 +1467,8 @@ ios_extension(
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionNotificationServiceExtension",
provisioning_profile = select({
":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:NotificationService.mobileprovision",
@ -1598,7 +1701,7 @@ ios_application(
watch_application = select({
":disableExtensionsSetting": None,
"//conditions:default": ":TelegramWatchApp",
}),
}) if telegram_enable_watch else None,
deps = [
":Main",
":Lib",

View File

@ -5,7 +5,7 @@ import NotificationServiceObjC
private let queue = Queue()
@available(iOSApplicationExtension 10.0, *)
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
@objc(NotificationService)
final class NotificationService: UNNotificationServiceExtension {
private let impl: QueueLocalObject<NotificationServiceImpl>

View File

@ -0,0 +1,15 @@
#!/bin/sh
set -e
name=<<<NAME>>>
version=<<<MIN_OS_VERSION>>>
f="$1/$name"
plist_path="$f/Info.plist"
plutil -replace MinimumOSVersion -string $version "$plist_path"
if [ "$version" == "14.0" ]; then
binary_path="$f/$(basename $f | sed -e s/\.appex//g)"
xcrun lipo "$binary_path" -remove armv7 -o "$binary_path" 2>/dev/null || true
fi

View File

@ -1,3 +1,5 @@
#if arch(arm64) || arch(x86_64)
import UIKit
import NotificationCenter
import BuildConfig
@ -63,6 +65,7 @@ private func rootPathForBasePath(_ appGroupPath: String) -> String {
return appGroupPath + "/telegram-data"
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct Provider: IntentTimelineProvider {
public typealias Entry = SimpleEntry
@ -221,6 +224,7 @@ struct Provider: IntentTimelineProvider {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct AvatarsProvider: IntentTimelineProvider {
public typealias Entry = SimpleEntry
@ -379,6 +383,7 @@ struct AvatarsProvider: IntentTimelineProvider {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct SimpleEntry: TimelineEntry {
enum Contents {
case recent
@ -396,6 +401,7 @@ enum PeersWidgetData {
case peers(ParsedPeers)
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct AvatarItemView: View {
var peer: ParsedPeer?
var itemSize: CGFloat
@ -415,6 +421,7 @@ struct AvatarItemView: View {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct WidgetView: View {
@Environment(\.widgetFamily) private var widgetFamily
@Environment(\.colorScheme) private var colorScheme
@ -853,6 +860,7 @@ struct WidgetView: View {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct AvatarsWidgetView: View {
@Environment(\.widgetFamily) private var widgetFamily
@Environment(\.colorScheme) private var colorScheme
@ -952,6 +960,7 @@ private let buildConfig: BuildConfig = {
return buildConfig
}()
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
func getWidgetData(contents: SimpleEntry.Contents) -> PeersWidgetData {
switch contents {
case .recent:
@ -963,6 +972,7 @@ func getWidgetData(contents: SimpleEntry.Contents) -> PeersWidgetData {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct Static_Widget: Widget {
private let kind: String = "Static_Widget"
@ -978,6 +988,7 @@ struct Static_Widget: Widget {
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct Static_AvatarsWidget: Widget {
private let kind: String = "Static_AvatarsWidget"
@ -994,9 +1005,31 @@ struct Static_AvatarsWidget: Widget {
}
@main
struct AllWidgetsEntryPoint {
static func main() {
if #available(iOS 14.0, *) {
AllWidgets.main()
} else {
preconditionFailure()
}
}
}
@available(iOSApplicationExtension 14.0, iOS 14.0, *)
struct AllWidgets: WidgetBundle {
var body: some Widget {
Static_Widget()
Static_AvatarsWidget()
}
}
#else
@main
class MyApp {
static func main() {
preconditionFailure("Not supported")
}
}
#endif

View File

@ -27,6 +27,7 @@ class BazelCommandLine:
self.build_number = None
self.configuration_args = None
self.configuration_path = None
self.split_submodules = False
self.common_args = [
# https://docs.bazel.build/versions/master/command-line-reference.html
@ -49,12 +50,6 @@ class BazelCommandLine:
]
self.common_build_args = [
# https://github.com/bazelbuild/rules_swift
# If enabled and whole module optimisation is being used, the `*.swiftdoc`,
# `*.swiftmodule` and `*-Swift.h` are generated with a separate action
# rather than as part of the compilation.
'--features=swift.split_derived_files_generation',
# https://github.com/bazelbuild/rules_swift
# If enabled the skip function bodies frontend flag is passed when using derived
# files generation.
@ -112,11 +107,25 @@ class BazelCommandLine:
def set_build_number(self, build_number):
self.build_number = build_number
def set_split_swiftmodules(self, value):
self.split_submodules = value
def set_configuration_path(self, path):
self.configuration_path = path
def set_configuration(self, configuration):
if configuration == 'debug_arm64':
if configuration == 'debug_universal':
self.configuration_args = [
# bazel debug build configuration
'-c', 'dbg',
# Build universal binaries.
'--ios_multi_cpus=armv7,arm64',
# Always build universal Watch binaries.
'--watchos_cpus=armv7k,arm64_32'
] + self.common_debug_args
elif configuration == 'debug_arm64':
self.configuration_args = [
# bazel debug build configuration
'-c', 'dbg',
@ -151,6 +160,23 @@ class BazelCommandLine:
# Generate DSYM files when building.
'--apple_generate_dsym',
# Require DSYM files as build output.
'--output_groups=+dsyms'
] + self.common_release_args
elif configuration == 'release_armv7':
self.configuration_args = [
# bazel optimized build configuration
'-c', 'opt',
# Build single-architecture binaries. It is almost 2 times faster is 32-bit support is not required.
'--ios_multi_cpus=armv7',
# Always build universal Watch binaries.
'--watchos_cpus=armv7k,arm64_32',
# Generate DSYM files when building.
'--apple_generate_dsym',
# Require DSYM files as build output.
'--output_groups=+dsyms'
] + self.common_release_args
@ -217,6 +243,19 @@ class BazelCommandLine:
return combined_arguments
def get_additional_build_arguments(self):
combined_arguments = []
if self.split_submodules:
combined_arguments += [
# https://github.com/bazelbuild/rules_swift
# If enabled and whole module optimisation is being used, the `*.swiftdoc`,
# `*.swiftmodule` and `*-Swift.h` are generated with a separate action
# rather than as part of the compilation.
'--features=swift.split_derived_files_generation',
]
return combined_arguments
def invoke_build(self):
combined_arguments = [
self.build_environment.bazel_path
@ -237,6 +276,7 @@ class BazelCommandLine:
combined_arguments += self.common_args
combined_arguments += self.common_build_args
combined_arguments += self.get_define_arguments()
combined_arguments += self.get_additional_build_arguments()
if self.remote_cache is not None:
combined_arguments += [
@ -355,6 +395,8 @@ def build(arguments):
bazel_command_line.set_configuration(arguments.configuration)
bazel_command_line.set_build_number(arguments.buildNumber)
bazel_command_line.set_split_swiftmodules(not arguments.disableParallelSwiftmoduleGeneration)
bazel_command_line.invoke_build()
@ -497,14 +539,22 @@ if __name__ == '__main__':
buildParser.add_argument(
'--configuration',
choices=[
'debug_universal',
'debug_arm64',
'debug_armv7',
'release_arm64',
'release_armv7',
'release_universal'
],
required=True,
help='Build configuration'
)
buildParser.add_argument(
'--disableParallelSwiftmoduleGeneration',
action='store_true',
default=False,
help='Generate .swiftmodule files in parallel to building modules, can speed up compilation on multi-core systems.'
)
if len(sys.argv) < 2:
parser.print_help()

View File

@ -9,3 +9,6 @@ telegram_is_appstore_build = "true"
telegram_appstore_id = "686449807"
telegram_app_specific_url_scheme = "tg"
telegram_aps_environment = "production"
telegram_enable_siri = True
telegram_enable_icloud = True
telegram_enable_watch = True

View File

@ -104,7 +104,7 @@ final class WidgetDataContext {
let queue = Queue()
let updatedAdditionalPeerIds: Signal<[AccountRecordId: Set<PeerId>], NoError> = Signal { subscriber in
if #available(iOSApplicationExtension 14.0, iOS 14.0, *) {
#if arch(arm64) || arch(i386) || arch(x86_64)
#if arch(arm64) || arch(x86_64)
WidgetCenter.shared.getCurrentConfigurations { result in
var peerIds: [AccountRecordId: Set<PeerId>] = [:]

View File

@ -3174,6 +3174,7 @@ common_arm_specific_sources = [webrtc_source_dir + "/" + path for path in [
armv7_specific_sources = [webrtc_source_dir + "/" + path for path in [
"common_audio/signal_processing/filter_ar_fast_q12.c",
"common_audio/signal_processing/complex_bit_reverse.c",
"common_audio/third_party/ooura/fft_size_128/ooura_fft_neon.cc",
]]
arm64_specific_sources = [webrtc_source_dir + "/" + path for path in [