From 72633df91f3f28c70185790efc52f4788bba81dd Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sun, 17 Jan 2021 19:01:25 +0400 Subject: [PATCH] Update build scripts --- README.md | 16 ++++++- Telegram/BUILD | 58 ++++++++++++++++++++++---- build-system/Make/Make.py | 15 ++++++- build-system/Make/ProjectGeneration.py | 6 +-- 4 files changed, 80 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 344a62325c6..7cd8b3146d7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ There are several things we require from **all developers** for the moment. 2. Clone the project from GitHub: ``` -git clone --recursive https://github.com/TelegramMessenger/Telegram-iOS.git +git clone --recursive -j8 https://github.com/TelegramMessenger/Telegram-iOS.git ``` 3. Download Bazel 3.7.0 @@ -75,7 +75,19 @@ python3 build-system/Make/Make.py \ --disableExtensions ``` -Tip: use `--disableExtensions` when developing to speed up development by not building application extensions. +It is possible to generate a project that does not require any codesigning certificates to be installed: add `--disableProvisioningProfiles` flag: +``` +python3 build-system/Make/Make.py \ + --bazel="$HOME/bazel-dist/bazel" \ + --cacheDir="$HOME/telegram-bazel-cache" \ + generateProject \ + --configurationPath="$HOME/telegram-configuration" \ + --disableExtensions \ + --disableProvisioningProfiles +``` + + +Tip: use `--disableExtensions` when developing to speed up development by not building application extensions and the WatchOS app. # Tips diff --git a/Telegram/BUILD b/Telegram/BUILD index f3ad0c827a6..970ce9b5d5c 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -41,6 +41,12 @@ bool_flag( visibility = ["//visibility:public"], ) +bool_flag( + name = "disableProvisioningProfiles", + build_setting_default = False, + visibility = ["//visibility:public"], +) + config_setting( name = "disableExtensionsSetting", flag_values = { @@ -48,6 +54,13 @@ config_setting( }, ) +config_setting( + name = "disableProvisioningProfilesSetting", + flag_values = { + ":disableProvisioningProfiles": "True", + }, +) + genrule( name = "empty", outs = ["empty.swift"], @@ -486,7 +499,10 @@ watchos_extension( ":WatchExtensionNSExtensionInfoPlist", ], minimum_os_version = "5.0", - provisioning_profile = "@build_configuration//provisioning:WatchExtension.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:WatchExtension.mobileprovision", + }), resources = [ ":TelegramWatchExtensionResources", ], @@ -514,7 +530,10 @@ watchos_application( ":WatchAppCompanionInfoPlist", ], minimum_os_version = "5.0", - provisioning_profile = "@build_configuration//provisioning:WatchApp.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:WatchApp.mobileprovision", + }), resources = [ ":TelegramWatchAppResources", ":TelegramWatchAppAssets", @@ -1023,7 +1042,10 @@ ios_extension( ":AppNameInfoPlist", ], minimum_os_version = "9.0", - provisioning_profile = "@build_configuration//provisioning:Share.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:Share.mobileprovision", + }), deps = [":ShareExtensionLib"], frameworks = [ ":TelegramUIFramework" @@ -1092,7 +1114,10 @@ ios_extension( ":AppNameInfoPlist", ], minimum_os_version = "10.0", - provisioning_profile = "@build_configuration//provisioning:NotificationContent.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:NotificationContent.mobileprovision", + }), deps = [":NotificationContentExtensionLib"], frameworks = [ ":TelegramUIFramework" @@ -1156,7 +1181,10 @@ ios_extension( ], minimum_os_version = "14.0", provides_main = True, - provisioning_profile = "@build_configuration//provisioning:Widget.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:Widget.mobileprovision", + }), deps = [":WidgetExtensionLib"], frameworks = [], ) @@ -1235,7 +1263,10 @@ ios_extension( ":AppNameInfoPlist", ], minimum_os_version = "10.0", - provisioning_profile = "@build_configuration//provisioning:Intents.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:Intents.mobileprovision", + }), deps = [":IntentsExtensionLib"], frameworks = [ ":SwiftSignalKitFramework", @@ -1286,7 +1317,10 @@ ios_extension( ":AppNameInfoPlist", ], minimum_os_version = "10.0", - provisioning_profile = "@build_configuration//provisioning:NotificationService.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:NotificationService.mobileprovision", + }), deps = ["//Telegram/NotificationService:NotificationServiceExtensionLib"], frameworks = [ ":MtProtoKitFramework", @@ -1472,7 +1506,10 @@ ios_application( ), families = ["iphone", "ipad"], minimum_os_version = "9.0", - provisioning_profile = "@build_configuration//provisioning:Telegram.mobileprovision", + provisioning_profile = select({ + ":disableProvisioningProfilesSetting": None, + "//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision", + }), entitlements = ":TelegramEntitlements.entitlements", infoplists = [ ":TelegramInfoPlist", @@ -1509,7 +1546,10 @@ ios_application( ":WidgetExtension", ], }), - watch_application = ":TelegramWatchApp", + watch_application = select({ + ":disableExtensionsSetting": None, + "//conditions:default": ":TelegramWatchApp", + }), deps = [ ":Main", ":Lib", diff --git a/build-system/Make/Make.py b/build-system/Make/Make.py index 6ba61407655..0b94c0d876c 100644 --- a/build-system/Make/Make.py +++ b/build-system/Make/Make.py @@ -289,12 +289,15 @@ def generate_project(arguments): disable_extensions = False if arguments.disableExtensions is not None: disable_extensions = arguments.disableExtensions - + if arguments.disableProvisioningProfiles is not None: + disable_provisioning_profiles = arguments.disableProvisioningProfiles + call_executable(['killall', 'Xcode'], check_result=False) generate( build_environment=bazel_command_line.build_environment, disable_extensions=disable_extensions, + disable_provisioning_profiles=disable_provisioning_profiles, configuration_path=bazel_command_line.configuration_path, bazel_app_arguments=bazel_command_line.get_project_generation_arguments() ) @@ -431,6 +434,16 @@ def add_project_and_build_common_arguments(current_parser: argparse.ArgumentPars ''' ) + generateProjectParser.add_argument( + '--disableProvisioningProfiles', + action='store_true', + default=False, + help=''' + This allows to build the project for simulator without having any codesigning identities installed. + Building for an actual device will fail. + ''' + ) + buildParser = subparsers.add_parser('build', help='Build the app') buildParser.add_argument( '--buildNumber', diff --git a/build-system/Make/ProjectGeneration.py b/build-system/Make/ProjectGeneration.py index dab2520e342..8442fbf4fe6 100644 --- a/build-system/Make/ProjectGeneration.py +++ b/build-system/Make/ProjectGeneration.py @@ -10,7 +10,7 @@ def remove_directory(path): shutil.rmtree(path) -def generate(build_environment: BuildEnvironment, disable_extensions, configuration_path, bazel_app_arguments): +def generate(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, configuration_path, bazel_app_arguments): project_path = os.path.join(build_environment.base_path, 'build-input/gen/project') app_target = 'Telegram' @@ -51,8 +51,6 @@ def generate(build_environment: BuildEnvironment, disable_extensions, configurat bazel_wrapper_arguments = [] bazel_wrapper_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)] - if disable_extensions and False: - bazel_wrapper_arguments += ['--//Telegram:disableExtensions'] with open(bazel_wrapper_path, 'wb') as bazel_wrapper: bazel_wrapper.write('''#!/bin/sh @@ -90,6 +88,8 @@ def generate(build_environment: BuildEnvironment, disable_extensions, configurat bazel_build_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)] if disable_extensions: bazel_build_arguments += ['--//Telegram:disableExtensions'] + if disable_provisioning_profiles: + bazel_build_arguments += ['--//Telegram:disableProvisioningProfiles'] call_executable([ tulsi_path,