Skip to content

Commit

Permalink
Update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali committed Jan 17, 2021
1 parent 4b34a66 commit 72633df
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 15 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
58 changes: 49 additions & 9 deletions Telegram/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,26 @@ bool_flag(
visibility = ["//visibility:public"],
)

bool_flag(
name = "disableProvisioningProfiles",
build_setting_default = False,
visibility = ["//visibility:public"],
)

config_setting(
name = "disableExtensionsSetting",
flag_values = {
":disableExtensions": "True",
},
)

config_setting(
name = "disableProvisioningProfilesSetting",
flag_values = {
":disableProvisioningProfiles": "True",
},
)

genrule(
name = "empty",
outs = ["empty.swift"],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 = [],
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1509,7 +1546,10 @@ ios_application(
":WidgetExtension",
],
}),
watch_application = ":TelegramWatchApp",
watch_application = select({
":disableExtensionsSetting": None,
"//conditions:default": ":TelegramWatchApp",
}),
deps = [
":Main",
":Lib",
Expand Down
15 changes: 14 additions & 1 deletion build-system/Make/Make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions build-system/Make/ProjectGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 72633df

Please sign in to comment.