Update build system

This commit is contained in:
Ali 2023-03-31 00:19:15 +04:00
parent 0e3fbeb08b
commit 1de7bae929
14 changed files with 87 additions and 77 deletions

View File

@ -35,6 +35,3 @@ build --spawn_strategy=standalone
build --strategy=SwiftCompile=standalone
build --define RULES_SWIFT_BUILD_DUMMY_WORKER=1
#build --linkopt=-fuse-ld=/Users/ali/Downloads/ld64.lld
#build --linkopt=-fuse-ld=/Users/ali/build/zld/build/Build/Products/Release/zld
#build --linkopt=-Wl,-zld_original_ld_path,__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

1
.gitignore vendored
View File

@ -59,6 +59,7 @@ bazel-telegram-ios
bazel-telegram-ios/*
bazel-testlogs
bazel-testlogs/*
xcodeproj.bazelrc
*/*.swp
*.swp
build-input/*

3
.gitmodules vendored
View File

@ -29,3 +29,6 @@ url=../tgcalls.git
[submodule "third-party/libx264/x264"]
path = third-party/libx264/x264
url = https://github.com/mirror/x264.git
[submodule "build-system/bazel-rules/rules_xcodeproj"]
path = build-system/bazel-rules/rules_xcodeproj
url = https://github.com/MobileNativeFoundation/rules_xcodeproj.git

View File

@ -25,12 +25,19 @@ load("@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load(
"@rules_xcodeproj//xcodeproj:defs.bzl",
"top_level_target",
"xcodeproj",
)
load("//build-system/bazel-utils:plist_fragment.bzl",
"plist_fragment",
)
load(
"@build_configuration//:variables.bzl",
"telegram_bazel_path",
"telegram_bundle_id",
"telegram_aps_environment",
"telegram_team_id",
@ -1010,29 +1017,6 @@ plist_fragment(
)
)
ios_framework(
name = "AsyncDisplayKitFramework",
bundle_id = "{telegram_bundle_id}.AsyncDisplayKit".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":AsyncDisplayKitInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
":RequiredDeviceCapabilitiesPlist",
],
minimum_os_version = minimum_os_version,
extension_safe = True,
ipa_post_processor = strip_framework,
deps = [
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
],
)
plist_fragment(
name = "DisplayInfoPlist",
extension = "plist",
@ -1094,33 +1078,6 @@ sh_binary(
srcs = [":GenerateAddAlternateIcons"],
)
ios_framework(
name = "DisplayFramework",
bundle_id = "{telegram_bundle_id}.Display".format(
telegram_bundle_id = telegram_bundle_id,
),
families = [
"iphone",
"ipad",
],
infoplists = [
":DisplayInfoPlist",
":BuildNumberInfoPlist",
":VersionInfoPlist",
":RequiredDeviceCapabilitiesPlist",
],
frameworks = [
":SwiftSignalKitFramework",
":AsyncDisplayKitFramework",
],
minimum_os_version = minimum_os_version,
extension_safe = True,
ipa_post_processor = strip_framework,
deps = [
"//submodules/Display:Display",
],
)
plist_fragment(
name = "TelegramUIInfoPlist",
extension = "plist",
@ -1159,8 +1116,6 @@ ios_framework(
":SwiftSignalKitFramework",
":PostboxFramework",
":TelegramCoreFramework",
":AsyncDisplayKitFramework",
":DisplayFramework",
],
minimum_os_version = minimum_os_version,
extension_safe = True,
@ -1997,8 +1952,6 @@ ios_application(
":SwiftSignalKitFramework",
":PostboxFramework",
":TelegramCoreFramework",
":AsyncDisplayKitFramework",
":DisplayFramework",
":TelegramUIFramework",
],
strings = [
@ -2023,6 +1976,18 @@ ios_application(
":Main",
":Lib",
],
visibility = ["//visibility:public"],
)
xcodeproj(
name = "Telegram_xcodeproj",
build_mode = "bazel",
bazel_path = telegram_bazel_path,
project_name = "Telegram",
tags = ["manual"],
top_level_targets = [
":Telegram",
],
)
# Temporary targets used to simplify webrtc build tests

View File

@ -1,15 +1,15 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
http_archive(
'''http_archive(
name = "com_google_protobuf",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.14.0.zip"],
sha256 = "bf0e5070b4b99240183b29df78155eee335885e53a8af8683964579c214ad301",
strip_prefix = "protobuf-3.14.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protobuf-22.2.zip"],
sha256 = "bf1f92aebd619651220711e97b3d560cdc2484718cd56d95161bfb2fadb8628e",
strip_prefix = "protobuf-22.2",
type = "zip",
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
protobuf_deps()'''
local_repository(
name = "build_bazel_rules_apple",
@ -26,6 +26,11 @@ local_repository(
path = "build-system/bazel-rules/apple_support",
)
local_repository(
name = "rules_xcodeproj",
path = "build-system/bazel-rules/rules_xcodeproj",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
@ -47,6 +52,13 @@ load(
apple_support_dependencies()
load(
"@rules_xcodeproj//xcodeproj:repositories.bzl",
"xcodeproj_rules_dependencies",
)
xcodeproj_rules_dependencies()
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

View File

@ -35,8 +35,9 @@ class BuildConfiguration:
self.enable_siri = enable_siri
self.enable_icloud = enable_icloud
def write_to_variables_file(self, aps_environment, path):
def write_to_variables_file(self, bazel_path, aps_environment, path):
string = ''
string += 'telegram_bazel_path = "{}"\n'.format(bazel_path)
string += 'telegram_bundle_id = "{}"\n'.format(self.bundle_id)
string += 'telegram_api_id = "{}"\n'.format(self.api_id)
string += 'telegram_api_hash = "{}"\n'.format(self.api_hash)

View File

@ -30,6 +30,7 @@ class BazelCommandLine:
override_bazel_version=override_bazel_version,
override_xcode_version=override_xcode_version
)
self.bazel = bazel
self.bazel_user_root = bazel_user_root
self.remote_cache = None
self.cache_dir = None
@ -497,7 +498,7 @@ def resolve_configuration(base_path, bazel_command_line: BazelCommandLine, argum
print('Could not find a valid aps-environment entitlement in the provided provisioning profiles')
sys.exit(1)
build_configuration.write_to_variables_file(aps_environment=codesigning_data.aps_environment, path=configuration_repository_path + '/variables.bzl')
build_configuration.write_to_variables_file(bazel_path=bazel_command_line.bazel, aps_environment=codesigning_data.aps_environment, path=configuration_repository_path + '/variables.bzl')
provisioning_profile_files = []
for file_name in os.listdir(provisioning_path):

View File

@ -9,8 +9,41 @@ def remove_directory(path):
if os.path.isdir(path):
shutil.rmtree(path)
def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name):
bazel_generate_arguments = [build_environment.bazel_path]
bazel_generate_arguments += ['run', '//Telegram:Telegram_xcodeproj']
bazel_generate_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
#if disable_extensions:
# bazel_generate_arguments += ['--//{}:disableExtensions'.format(app_target)]
#if disable_provisioning_profiles:
# bazel_generate_arguments += ['--//{}:disableProvisioningProfiles'.format(app_target)]
#if generate_dsym:
# bazel_generate_arguments += ['--apple_generate_dsym']
#bazel_generate_arguments += ['--//{}:disableStripping'.format('Telegram')]
project_bazel_arguments = []
for argument in bazel_app_arguments:
project_bazel_arguments.append(argument)
project_bazel_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
xcodeproj_bazelrc = os.path.join(build_environment.base_path, 'xcodeproj.bazelrc')
if os.path.isfile(xcodeproj_bazelrc):
os.unlink(xcodeproj_bazelrc)
with open(xcodeproj_bazelrc, 'w') as file:
for argument in project_bazel_arguments:
file.write('build ' + argument + '\n')
call_executable(bazel_generate_arguments)
xcodeproj_path = 'Telegram/Telegram.xcodeproj'
call_executable(['open', xcodeproj_path])
def generate(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name):
generate_xcodeproj(build_environment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name)
def generate_tulsi(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name):
project_path = os.path.join(build_environment.base_path, 'build-input/gen/project')
if '/' in target_name:

@ -1 +1 @@
Subproject commit 2659bae1f561e34b89fcc230df26aaf6dada2646
Subproject commit 7cecc126925fef811c274b10b99329179574f9cb

@ -1 +1 @@
Subproject commit 782fa6bb135b5a9a31ab7884e9ebfaac29ef71d9
Subproject commit 34939e5b8d4be5ea8f9323414702f3230c0642a8

@ -1 +1 @@
Subproject commit 371ab0507ab2318f0936adde3bcebbb1ccacf3a8
Subproject commit e01b8f76e7666ac254f1780b00de33c1296da8ff

@ -0,0 +1 @@
Subproject commit dc226d129aca2237982b98a95c80ed1ccc74f0c5

View File

@ -22,15 +22,11 @@ def _plist_fragment(ctx):
fail("Expected value for --define={} was not found".format(key))
resolved_values[key] = value
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>
""" + template.format(**resolved_values) + """
</dict>
</plist>
"""
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>""" + template.format(**resolved_values) + """</dict>
</plist>"""
ctx.actions.write(
output = output,

View File

@ -1,5 +1,5 @@
{
"app": "9.5.4",
"bazel": "5.3.1",
"bazel": "6.1.1",
"xcode": "14.2"
}