This commit is contained in:
Ali 2021-01-08 02:23:18 +04:00
parent 9ebb5b0a9f
commit fdc850e011
5 changed files with 78 additions and 91 deletions

View File

@ -1,5 +1,5 @@
load("@bazel_skylib//rules:common_settings.bzl",
"bool_flag"
"bool_flag",
)
load("@build_bazel_rules_apple//apple:ios.bzl",
@ -23,8 +23,6 @@ load("//build-system/bazel-utils:plist_fragment.bzl",
load(
"@build_configuration//:variables.bzl",
"telegram_build_number",
"telegram_version",
"telegram_bundle_id",
"telegram_aps_environment",
"telegram_team_id",
@ -43,6 +41,12 @@ bool_flag(
visibility = ["//visibility:public"],
)
string_flag(
name = "buildNumber",
build_setting_default = "10000",
visibility = ["//visibility:public"],
)
config_setting(
name = "disableExtensionsSetting",
flag_values = {
@ -206,14 +210,20 @@ swift_library(
)
plist_fragment(
name = "AdditionalInfoPlist",
name = "BuildNumberInfoPlist",
extension = "plist",
template =
"""
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<string>{buildNumber}</string>
"""
)
plist_fragment(
name = "UrlTypesInfoPlist",
extension = "plist",
template =
"""
<key>CFBundleURLTypes</key>
<array>
<dict>
@ -226,16 +236,6 @@ plist_fragment(
<string>telegram</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>{telegram_bundle_id}.ton</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ton</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
@ -248,8 +248,6 @@ plist_fragment(
</dict>
</array>
""".format(
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
telegram_bundle_id = telegram_bundle_id,
)
)
@ -387,13 +385,8 @@ plist_fragment(
template =
"""
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
""".format(
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
<string>{telegramVersion}</string>
"""
)
plist_fragment(
@ -494,6 +487,7 @@ watchos_extension(
infoplists = [
":WatchExtensionInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
":WatchExtensionNSExtensionInfoPlist",
],
@ -521,6 +515,7 @@ watchos_application(
infoplists = [
":WatchAppInfoPlist",
":VersionInfoPlist",
"BuildNumberInfoPlist",
":AppNameInfoPlist",
":WatchAppCompanionInfoPlist",
],
@ -544,20 +539,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.MtProtoKit</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>MtProtoKit</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -572,6 +561,8 @@ ios_framework(
],
infoplists = [
":MtProtoKitInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
minimum_os_version = "9.0",
ipa_post_processor = strip_framework,
@ -587,20 +578,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.SwiftSignalKit</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>SwiftSignalKit</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -615,6 +600,8 @@ ios_framework(
],
infoplists = [
":SwiftSignalKitInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
minimum_os_version = "9.0",
ipa_post_processor = strip_framework,
@ -630,20 +617,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.Postbox</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>Postbox</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -658,6 +639,8 @@ ios_framework(
],
infoplists = [
":PostboxInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
frameworks = [
":SwiftSignalKitFramework",
@ -676,20 +659,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.TelegramApi</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>TelegramApi</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -704,6 +681,8 @@ ios_framework(
],
infoplists = [
":TelegramApiInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
minimum_os_version = "9.0",
ipa_post_processor = strip_framework,
@ -719,20 +698,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.SyncCore</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>SyncCore</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -747,6 +720,8 @@ ios_framework(
],
infoplists = [
":SyncCoreInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
frameworks = [
":SwiftSignalKitFramework",
@ -766,20 +741,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.TelegramCore</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>TelegramCore</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -794,13 +763,14 @@ ios_framework(
],
infoplists = [
":TelegramCoreInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
frameworks = [
":MtProtoKitFramework",
":SwiftSignalKitFramework",
":PostboxFramework",
":SyncCoreFramework",
#":TelegramApiFramework",
],
minimum_os_version = "9.0",
ipa_post_processor = strip_framework,
@ -816,20 +786,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.AsyncDisplayKit</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>AsyncDisplayKit</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -844,6 +808,8 @@ ios_framework(
],
infoplists = [
":AsyncDisplayKitInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
minimum_os_version = "9.0",
ipa_post_processor = strip_framework,
@ -859,20 +825,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.Display</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>Display</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -930,6 +890,8 @@ ios_framework(
],
infoplists = [
":DisplayInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
frameworks = [
":SwiftSignalKitFramework",
@ -949,20 +911,14 @@ plist_fragment(
"""
<key>CFBundleIdentifier</key>
<string>{telegram_bundle_id}.TelegramUI</string>
<key>CFBundleVersion</key>
<string>{telegram_build_number}</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleName</key>
<string>TelegramUI</string>
<key>CFBundleShortVersionString</key>
<string>{telegram_version}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
""".format(
telegram_bundle_id = telegram_bundle_id,
telegram_version = telegram_version,
telegram_build_number = telegram_build_number,
)
)
@ -977,12 +933,13 @@ ios_framework(
],
infoplists = [
":TelegramUIInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
],
frameworks = [
":MtProtoKitFramework",
":SwiftSignalKitFramework",
":PostboxFramework",
#":TelegramApiFramework",
":SyncCoreFramework",
":TelegramCoreFramework",
":AsyncDisplayKitFramework",
@ -1068,6 +1025,7 @@ ios_extension(
infoplists = [
":ShareInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "9.0",
@ -1136,6 +1094,7 @@ ios_extension(
infoplists = [
":NotificationContentInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
@ -1207,6 +1166,7 @@ ios_extension(
infoplists = [
":WidgetInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "14.0",
@ -1296,6 +1256,7 @@ ios_extension(
infoplists = [
":IntentsInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
@ -1305,7 +1266,6 @@ ios_extension(
":SwiftSignalKitFramework",
":PostboxFramework",
":TelegramCoreFramework",
#":TelegramApiFramework",
":SyncCoreFramework",
],
)
@ -1347,6 +1307,7 @@ ios_extension(
infoplists = [
":NotificationServiceInfoPlist",
":VersionInfoPlist",
":BuildNumberInfoPlist",
":AppNameInfoPlist",
],
minimum_os_version = "10.0",
@ -1356,8 +1317,6 @@ ios_extension(
":MtProtoKitFramework",
":SwiftSignalKitFramework",
":PostboxFramework",
#":TelegramApiFramework",
#":SyncCoreFramework",
],
)
@ -1542,7 +1501,9 @@ ios_application(
entitlements = ":TelegramEntitlements.entitlements",
infoplists = [
":TelegramInfoPlist",
":AdditionalInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
":UrlTypesInfoPlist",
],
ipa_post_processor = ":AddAlternateIcons",
resources = [

View File

@ -44,7 +44,7 @@ def run_executable_with_output(path, arguments):
return output_string
def call_executable(arguments, use_clean_environment=True):
def call_executable(arguments, use_clean_environment=True, check_result=True):
executable_path = resolve_executable(arguments[0])
if executable_path is None:
raise Exception('Could not resolve {} to a valid executable file'.format(arguments[0]))
@ -53,7 +53,13 @@ def call_executable(arguments, use_clean_environment=True):
resolved_env = get_clean_env()
else:
resolved_env = os.environ
subprocess.check_call([executable_path] + arguments[1:], env=resolved_env)
resolved_arguments = [executable_path] + arguments[1:]
if check_result:
subprocess.check_call(resolved_arguments, env=resolved_env)
else:
subprocess.call(resolved_arguments, env=resolved_env)
def get_bazel_version(bazel_path):
@ -106,6 +112,10 @@ class BuildEnvironment:
configuration_path = os.path.join(self.base_path, 'versions.json')
with open(configuration_path) as file:
configuration_dict = json.load(file)
if configuration_dict['app'] is None:
raise Exception('Missing app version in {}'.format(configuration_path))
else:
self.app_version = configuration_dict['app']
if configuration_dict['bazel'] is None:
raise Exception('Missing bazel version in {}'.format(configuration_path))
else:

View File

@ -22,6 +22,7 @@ class BazelCommandLine:
self.remote_cache = None
self.cache_dir = None
self.additional_args = None
self.build_number = None
self.configuration_args = None
self.configuration_path = None
@ -106,6 +107,9 @@ class BazelCommandLine:
def add_additional_args(self, additional_args):
self.additional_args = additional_args
def set_build_number(self, build_number):
self.build_number = build_number
def set_configuration_path(self, path):
self.configuration_path = path
@ -162,10 +166,17 @@ class BazelCommandLine:
print('TelegramBuild: running {}'.format(combined_arguments))
call_executable(combined_arguments)
def get_define_arguments(self):
return [
'--define=buildNumber={}'.format(self.build_number),
'--define=telegramVersion={}'.format(self.build_environment.app_version)
]
def get_project_generation_arguments(self):
combined_arguments = []
combined_arguments += self.common_args
combined_arguments += self.common_debug_args
combined_arguments += self.get_define_arguments()
if self.remote_cache is not None:
combined_arguments += [
@ -195,6 +206,7 @@ class BazelCommandLine:
combined_arguments += self.common_args
combined_arguments += self.common_build_args
combined_arguments += self.get_define_arguments()
if self.remote_cache is not None:
combined_arguments += [
@ -268,10 +280,14 @@ def generate_project(arguments):
resolve_configuration(bazel_command_line, arguments)
bazel_command_line.set_build_number(arguments.buildNumber)
disable_extensions = False
if arguments.disableExtensions is not None:
disable_extensions = arguments.disableExtensions
call_executable(['killall', 'Xcode'], check_result=False)
generate(
build_environment=bazel_command_line.build_environment,
disable_extensions=disable_extensions,
@ -296,6 +312,7 @@ def build(arguments):
resolve_configuration(bazel_command_line, arguments)
bazel_command_line.set_configuration(arguments.configuration)
bazel_command_line.set_build_number(arguments.buildNumber)
bazel_command_line.invoke_build()

View File

@ -1,9 +1,7 @@
telegram_build_number = "10000"
telegram_version = "7.3"
telegram_bundle_id = "ph.telegra.Telegraph"
telegram_api_id = "8"
telegram_team_id = "C67CF9S4VU"
telegram_api_hash = "7245de8e747a0d6fbe11f7cc14fcc0bb"
telegram_team_id = "C67CF9S4VU"
telegram_app_center_id = "0"
telegram_is_internal_build = "false"
telegram_is_appstore_build = "true"

View File

@ -1,4 +1,5 @@
{
"app": "7.3",
"bazel": "3.7.0",
"xcode": "12.3"
}