Skip to content

Commit

Permalink
Update build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali committed Mar 30, 2023
1 parent 0e3fbeb commit 1de7bae
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 77 deletions.
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bazel-telegram-ios
bazel-telegram-ios/*
bazel-testlogs
bazel-testlogs/*
xcodeproj.bazelrc
*/*.swp
*.swp
build-input/*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
73 changes: 19 additions & 54 deletions Telegram/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1159,8 +1116,6 @@ ios_framework(
":SwiftSignalKitFramework",
":PostboxFramework",
":TelegramCoreFramework",
":AsyncDisplayKitFramework",
":DisplayFramework",
],
minimum_os_version = minimum_os_version,
extension_safe = True,
Expand Down Expand Up @@ -1997,8 +1952,6 @@ ios_application(
":SwiftSignalKitFramework",
":PostboxFramework",
":TelegramCoreFramework",
":AsyncDisplayKitFramework",
":DisplayFramework",
":TelegramUIFramework",
],
strings = [
Expand All @@ -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
Expand Down
22 changes: 17 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion build-system/Make/BuildConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def __init__(self,
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)
Expand Down
3 changes: 2 additions & 1 deletion build-system/Make/Make.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, bazel, override_bazel_version, override_xcode_version, bazel_
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
Expand Down Expand Up @@ -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):
Expand Down
33 changes: 33 additions & 0 deletions build-system/Make/ProjectGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build-system/bazel-rules/apple_support
Submodule apple_support updated 67 files
+46 −5 .bazelci/presubmit.yml
+3 −0 .bazelrc
+3 −0 .bcr/config.yml
+20 −0 .bcr/metadata.template.json
+19 −0 .bcr/presubmit.yml
+5 −0 .bcr/source.template.json
+41 −0 .github/generate-notes.sh
+20 −0 .github/update-module-version.sh
+38 −0 .github/workflows/create-release.yml
+1 −1 .pre-commit-config.yaml
+4 −0 BUILD
+1 −0 CODEOWNERS
+0 −24 CONTRIBUTING.md
+14 −3 MODULE.bazel
+78 −21 README.md
+0 −0 WORKSPACE.bzlmod
+46 −0 configs/BUILD
+89 −0 configs/platforms.bzl
+8 −0 constraints/BUILD
+23 −0 crosstool/BUILD
+23 −0 crosstool/BUILD.toolchains
+89 −0 crosstool/BUILD.tpl
+2,676 −0 crosstool/cc_toolchain_config.bzl
+141 −0 crosstool/libtool.sh
+109 −0 crosstool/libtool_check_unique.cc
+58 −0 crosstool/make_hashed_objlist.py
+192 −0 crosstool/osx_cc_configure.bzl
+70 −0 crosstool/setup.bzl
+472 −0 crosstool/wrapped_clang.cc
+44 −0 crosstool/xcrunwrapper.sh
+1 −0 doc/BUILD
+4 −0 doc/README.md
+49 −2 doc/rules.md
+21 −0 lib/BUILD
+128 −23 lib/apple_support.bzl
+90 −8 lib/lipo.bzl
+7 −3 lib/repositories.bzl
+55 −0 lib/swizzle_absolute_xcttestsourcelocation.m
+21 −0 platforms/BUILD
+7 −0 rules/BUILD
+3 −1 rules/private/BUILD
+5 −1 rules/private/apple_genrule.bzl
+3 −1 rules/rules.doc.bzl
+52 −0 rules/toolchain_substitution.bzl
+8 −0 rules/universal_binary.bzl
+32 −0 test/BUILD
+1 −4 test/apple_support_test.bzl
+0 −0 test/fixtures/linking/BUILD
+45 −0 test/linking_tests.bzl
+3 −0 test/main.c
+3 −0 test/main.cc
+3 −0 test/main.m
+0 −0 test/rules/BUILD
+149 −0 test/rules/action_command_line_test.bzl
+60 −0 test/shell/BUILD
+115 −0 test/shell/apple_common.sh
+395 −0 test/shell/apple_test.sh
+27 −0 test/shell/integration_test_setup.sh
+177 −0 test/shell/objc_test.sh
+23 −0 test/shell/testenv.sh
+846 −0 test/shell/unittest.bash
+181 −0 test/shell/unittest_utils.sh
+106 −0 test/shell/wrapped_clang_test.sh
+83 −0 test/starlark_apple_binary.bzl
+13 −0 test/test_data/BUILD
+0 −7 tools/BUILD
+0 −137 tools/xcode_path_wrapper.sh
2 changes: 1 addition & 1 deletion build-system/bazel-rules/rules_apple
Submodule rules_apple updated 299 files
2 changes: 1 addition & 1 deletion build-system/bazel-rules/rules_swift
Submodule rules_swift updated 150 files
1 change: 1 addition & 0 deletions build-system/bazel-rules/rules_xcodeproj
Submodule rules_xcodeproj added at dc226d
14 changes: 5 additions & 9 deletions build-system/bazel-utils/plist_fragment.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "9.5.4",
"bazel": "5.3.1",
"bazel": "6.1.1",
"xcode": "14.2"
}

0 comments on commit 1de7bae

Please sign in to comment.