mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
— use upstream rules_swift and tulsi
— update tulsi, apple_support, rules_apple, rules_swift — bump bazel version to 5.0.0 — bump Xcode version to 13.2.1 — automatically download bazel binaries
This commit is contained in:
parent
14d07cf947
commit
c69a9b4e24
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -7,7 +7,7 @@
|
|||||||
url=https://github.com/bazelbuild/rules_apple.git
|
url=https://github.com/bazelbuild/rules_apple.git
|
||||||
[submodule "build-system/bazel-rules/rules_swift"]
|
[submodule "build-system/bazel-rules/rules_swift"]
|
||||||
path = build-system/bazel-rules/rules_swift
|
path = build-system/bazel-rules/rules_swift
|
||||||
url=https://github.com/ali-fareed/rules_swift.git
|
url=https://github.com/bazelbuild/rules_swift.git
|
||||||
[submodule "build-system/bazel-rules/apple_support"]
|
[submodule "build-system/bazel-rules/apple_support"]
|
||||||
path = build-system/bazel-rules/apple_support
|
path = build-system/bazel-rules/apple_support
|
||||||
url = https://github.com/bazelbuild/apple_support.git
|
url = https://github.com/bazelbuild/apple_support.git
|
||||||
@ -16,7 +16,7 @@ url=https://github.com/ali-fareed/rules_swift.git
|
|||||||
url = https://github.com/telegramdesktop/libtgvoip.git
|
url = https://github.com/telegramdesktop/libtgvoip.git
|
||||||
[submodule "build-system/tulsi"]
|
[submodule "build-system/tulsi"]
|
||||||
path = build-system/tulsi
|
path = build-system/tulsi
|
||||||
url=https://github.com/ali-fareed/tulsi.git
|
url=https://github.com/bazelbuild/tulsi.git
|
||||||
[submodule "submodules/TgVoipWebrtc/tgcalls"]
|
[submodule "submodules/TgVoipWebrtc/tgcalls"]
|
||||||
path = submodules/TgVoipWebrtc/tgcalls
|
path = submodules/TgVoipWebrtc/tgcalls
|
||||||
url=../tgcalls.git
|
url=../tgcalls.git
|
||||||
|
25
README.md
25
README.md
@ -20,23 +20,7 @@ There are several things we require from **all developers** for the moment.
|
|||||||
git clone --recursive -j8 https://github.com/TelegramMessenger/Telegram-iOS.git
|
git clone --recursive -j8 https://github.com/TelegramMessenger/Telegram-iOS.git
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Download Bazel 4.0.0
|
3. Adjust configuration parameters
|
||||||
|
|
||||||
```
|
|
||||||
mkdir -p $HOME/bazel-dist
|
|
||||||
cd $HOME/bazel-dist
|
|
||||||
curl -O -L https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-darwin-x86_64
|
|
||||||
mv bazel-* bazel
|
|
||||||
```
|
|
||||||
|
|
||||||
Verify that it's working
|
|
||||||
|
|
||||||
```
|
|
||||||
chmod +x bazel
|
|
||||||
./bazel --version
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Adjust configuration parameters
|
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir -p $HOME/telegram-configuration
|
mkdir -p $HOME/telegram-configuration
|
||||||
@ -46,7 +30,7 @@ cp -R build-system/example-configuration/* $HOME/telegram-configuration/
|
|||||||
- Modify the values in `variables.bzl`
|
- Modify the values in `variables.bzl`
|
||||||
- Replace the provisioning profiles in `provisioning` with valid files
|
- Replace the provisioning profiles in `provisioning` with valid files
|
||||||
|
|
||||||
5. (Optional) Create a build cache directory to speed up rebuilds
|
4. (Optional) Create a build cache directory to speed up rebuilds
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir -p "$HOME/telegram-bazel-cache"
|
mkdir -p "$HOME/telegram-bazel-cache"
|
||||||
@ -56,7 +40,6 @@ mkdir -p "$HOME/telegram-bazel-cache"
|
|||||||
|
|
||||||
```
|
```
|
||||||
python3 build-system/Make/Make.py \
|
python3 build-system/Make/Make.py \
|
||||||
--bazel="$HOME/bazel-dist/bazel" \
|
|
||||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||||
build \
|
build \
|
||||||
--configurationPath="$HOME/telegram-configuration" \
|
--configurationPath="$HOME/telegram-configuration" \
|
||||||
@ -68,7 +51,6 @@ python3 build-system/Make/Make.py \
|
|||||||
|
|
||||||
```
|
```
|
||||||
python3 build-system/Make/Make.py \
|
python3 build-system/Make/Make.py \
|
||||||
--bazel="$HOME/bazel-dist/bazel" \
|
|
||||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||||
generateProject \
|
generateProject \
|
||||||
--configurationPath="$HOME/telegram-configuration" \
|
--configurationPath="$HOME/telegram-configuration" \
|
||||||
@ -78,7 +60,6 @@ python3 build-system/Make/Make.py \
|
|||||||
It is possible to generate a project that does not require any codesigning certificates to be installed: add `--disableProvisioningProfiles` flag:
|
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 \
|
python3 build-system/Make/Make.py \
|
||||||
--bazel="$HOME/bazel-dist/bazel" \
|
|
||||||
--cacheDir="$HOME/telegram-bazel-cache" \
|
--cacheDir="$HOME/telegram-bazel-cache" \
|
||||||
generateProject \
|
generateProject \
|
||||||
--configurationPath="$HOME/telegram-configuration" \
|
--configurationPath="$HOME/telegram-configuration" \
|
||||||
@ -100,6 +81,8 @@ python3 build-system/Make/Make.py build --help
|
|||||||
python3 build-system/Make/Make.py generateProject --help
|
python3 build-system/Make/Make.py generateProject --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Bazel is automatically downloaded when running Make.py for the first time. If you wish to use your own build of Bazel, pass `--bazel=path-to-bazel`. If your Bazel version differs from that in `versions.json`, you may use `--overrideBazelVersion` to skip the version check.
|
||||||
|
|
||||||
Each release is built using specific Xcode and Bazel versions (see `versions.json`). The helper script checks the versions of installed software and reports an error if they don't match the ones specified in `versions.json`. There are flags that allow to bypass these checks:
|
Each release is built using specific Xcode and Bazel versions (see `versions.json`). The helper script checks the versions of installed software and reports an error if they don't match the ones specified in `versions.json`. There are flags that allow to bypass these checks:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
32
build-system/Make/BazelLocation.py
Normal file
32
build-system/Make/BazelLocation.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from BuildEnvironment import is_apple_silicon, resolve_executable, call_executable, BuildEnvironmentVersions
|
||||||
|
|
||||||
|
def locate_bazel(base_path):
|
||||||
|
versions = BuildEnvironmentVersions(base_path=os.getcwd())
|
||||||
|
if is_apple_silicon():
|
||||||
|
arch = 'darwin-arm64'
|
||||||
|
else:
|
||||||
|
arch = 'x86_64'
|
||||||
|
bazel_name = 'bazel-{version}-{arch}'.format(version=versions.bazel_version, arch=arch)
|
||||||
|
bazel_path = '{}/build-input/{}'.format(base_path, bazel_name)
|
||||||
|
|
||||||
|
if not os.path.isfile(bazel_path):
|
||||||
|
call_executable([
|
||||||
|
'curl',
|
||||||
|
'-L',
|
||||||
|
'https://github.com/bazelbuild/bazel/releases/download/{version}/{name}'.format(
|
||||||
|
version=versions.bazel_version,
|
||||||
|
name=bazel_name
|
||||||
|
),
|
||||||
|
'--output',
|
||||||
|
bazel_path
|
||||||
|
])
|
||||||
|
|
||||||
|
if not os.access(bazel_path, os.X_OK):
|
||||||
|
st = os.stat(bazel_path)
|
||||||
|
os.chmod(bazel_path, st.st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
|
return bazel_path
|
@ -93,18 +93,12 @@ def get_xcode_version():
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
class BuildEnvironment:
|
class BuildEnvironmentVersions:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
base_path,
|
base_path
|
||||||
bazel_path,
|
|
||||||
override_bazel_version,
|
|
||||||
override_xcode_version
|
|
||||||
):
|
):
|
||||||
self.base_path = os.path.expanduser(base_path)
|
configuration_path = os.path.join(base_path, 'versions.json')
|
||||||
self.bazel_path = os.path.expanduser(bazel_path)
|
|
||||||
|
|
||||||
configuration_path = os.path.join(self.base_path, 'versions.json')
|
|
||||||
with open(configuration_path) as file:
|
with open(configuration_path) as file:
|
||||||
configuration_dict = json.load(file)
|
configuration_dict = json.load(file)
|
||||||
if configuration_dict['app'] is None:
|
if configuration_dict['app'] is None:
|
||||||
@ -120,24 +114,41 @@ class BuildEnvironment:
|
|||||||
else:
|
else:
|
||||||
self.xcode_version = configuration_dict['xcode']
|
self.xcode_version = configuration_dict['xcode']
|
||||||
|
|
||||||
|
class BuildEnvironment:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
base_path,
|
||||||
|
bazel_path,
|
||||||
|
override_bazel_version,
|
||||||
|
override_xcode_version
|
||||||
|
):
|
||||||
|
self.base_path = os.path.expanduser(base_path)
|
||||||
|
self.bazel_path = os.path.expanduser(bazel_path)
|
||||||
|
|
||||||
|
versions = BuildEnvironmentVersions(base_path=self.base_path)
|
||||||
|
|
||||||
actual_bazel_version = get_bazel_version(self.bazel_path)
|
actual_bazel_version = get_bazel_version(self.bazel_path)
|
||||||
if actual_bazel_version != self.bazel_version:
|
if actual_bazel_version != versions.bazel_version:
|
||||||
if override_bazel_version:
|
if override_bazel_version:
|
||||||
print('Overriding the required bazel version {} with {} as reported by {}'.format(
|
print('Overriding the required bazel version {} with {} as reported by {}'.format(
|
||||||
self.bazel_version, actual_bazel_version, self.bazel_path))
|
versions.bazel_version, actual_bazel_version, self.bazel_path))
|
||||||
self.bazel_version = actual_bazel_version
|
self.bazel_version = actual_bazel_version
|
||||||
else:
|
else:
|
||||||
print('Required bazel version is "{}", but "{}"" is reported by {}'.format(
|
print('Required bazel version is "{}", but "{}"" is reported by {}'.format(
|
||||||
self.bazel_version, actual_bazel_version, self.bazel_path))
|
versions.bazel_version, actual_bazel_version, self.bazel_path))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
actual_xcode_version = get_xcode_version()
|
actual_xcode_version = get_xcode_version()
|
||||||
if actual_xcode_version != self.xcode_version:
|
if actual_xcode_version != versions.xcode_version:
|
||||||
if override_xcode_version:
|
if override_xcode_version:
|
||||||
print('Overriding the required Xcode version {} with {} as reported by \'xcode-select -p\''.format(
|
print('Overriding the required Xcode version {} with {} as reported by \'xcode-select -p\''.format(
|
||||||
self.xcode_version, actual_xcode_version, self.bazel_path))
|
versions.xcode_version, actual_xcode_version, self.bazel_path))
|
||||||
self.xcode_version = actual_xcode_version
|
versions.xcode_version = actual_xcode_version
|
||||||
else:
|
else:
|
||||||
print('Required Xcode version is {}, but {} is reported by \'xcode-select -p\''.format(
|
print('Required Xcode version is {}, but {} is reported by \'xcode-select -p\''.format(
|
||||||
self.xcode_version, actual_xcode_version, self.bazel_path))
|
versions.xcode_version, actual_xcode_version, self.bazel_path))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
self.app_version = versions.app_version
|
||||||
|
self.xcode_version = versions.xcode_version
|
||||||
|
self.bazel_version = versions.bazel_version
|
||||||
|
@ -7,15 +7,15 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from BuildEnvironment import is_apple_silicon, resolve_executable, call_executable, BuildEnvironment
|
from BuildEnvironment import resolve_executable, call_executable, BuildEnvironment
|
||||||
from ProjectGeneration import generate
|
from ProjectGeneration import generate
|
||||||
|
from BazelLocation import locate_bazel
|
||||||
|
|
||||||
class BazelCommandLine:
|
class BazelCommandLine:
|
||||||
def __init__(self, bazel_path, override_bazel_version, override_xcode_version, bazel_user_root):
|
def __init__(self, bazel, override_bazel_version, override_xcode_version, bazel_user_root):
|
||||||
self.build_environment = BuildEnvironment(
|
self.build_environment = BuildEnvironment(
|
||||||
base_path=os.getcwd(),
|
base_path=os.getcwd(),
|
||||||
bazel_path=bazel_path,
|
bazel_path=bazel,
|
||||||
override_bazel_version=override_bazel_version,
|
override_bazel_version=override_bazel_version,
|
||||||
override_xcode_version=override_xcode_version
|
override_xcode_version=override_xcode_version
|
||||||
)
|
)
|
||||||
@ -27,6 +27,9 @@ class BazelCommandLine:
|
|||||||
self.configuration_args = None
|
self.configuration_args = None
|
||||||
self.configuration_path = None
|
self.configuration_path = None
|
||||||
self.split_submodules = False
|
self.split_submodules = False
|
||||||
|
self.custom_target = None
|
||||||
|
self.continue_on_error = False
|
||||||
|
self.enable_sandbox = False
|
||||||
|
|
||||||
self.common_args = [
|
self.common_args = [
|
||||||
# https://docs.bazel.build/versions/master/command-line-reference.html
|
# https://docs.bazel.build/versions/master/command-line-reference.html
|
||||||
@ -314,9 +317,9 @@ class BazelCommandLine:
|
|||||||
call_executable(combined_arguments)
|
call_executable(combined_arguments)
|
||||||
|
|
||||||
|
|
||||||
def clean(arguments):
|
def clean(bazel, arguments):
|
||||||
bazel_command_line = BazelCommandLine(
|
bazel_command_line = BazelCommandLine(
|
||||||
bazel_path=arguments.bazel,
|
bazel=bazel,
|
||||||
override_bazel_version=arguments.overrideBazelVersion,
|
override_bazel_version=arguments.overrideBazelVersion,
|
||||||
override_xcode_version=arguments.overrideXcodeVersion,
|
override_xcode_version=arguments.overrideXcodeVersion,
|
||||||
bazel_user_root=arguments.bazelUserRoot
|
bazel_user_root=arguments.bazelUserRoot
|
||||||
@ -355,9 +358,9 @@ def resolve_configuration(bazel_command_line: BazelCommandLine, arguments):
|
|||||||
raise Exception('Neither configurationPath nor configurationGenerator are set')
|
raise Exception('Neither configurationPath nor configurationGenerator are set')
|
||||||
|
|
||||||
|
|
||||||
def generate_project(arguments):
|
def generate_project(bazel, arguments):
|
||||||
bazel_command_line = BazelCommandLine(
|
bazel_command_line = BazelCommandLine(
|
||||||
bazel_path=arguments.bazel,
|
bazel=bazel,
|
||||||
override_bazel_version=arguments.overrideBazelVersion,
|
override_bazel_version=arguments.overrideBazelVersion,
|
||||||
override_xcode_version=arguments.overrideXcodeVersion,
|
override_xcode_version=arguments.overrideXcodeVersion,
|
||||||
bazel_user_root=arguments.bazelUserRoot
|
bazel_user_root=arguments.bazelUserRoot
|
||||||
@ -401,9 +404,9 @@ def generate_project(arguments):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def build(arguments):
|
def build(bazel, arguments):
|
||||||
bazel_command_line = BazelCommandLine(
|
bazel_command_line = BazelCommandLine(
|
||||||
bazel_path=arguments.bazel,
|
bazel=bazel,
|
||||||
override_bazel_version=arguments.overrideBazelVersion,
|
override_bazel_version=arguments.overrideBazelVersion,
|
||||||
override_xcode_version=arguments.overrideXcodeVersion,
|
override_xcode_version=arguments.overrideXcodeVersion,
|
||||||
bazel_user_root=arguments.bazelUserRoot
|
bazel_user_root=arguments.bazelUserRoot
|
||||||
@ -463,7 +466,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--bazel',
|
'--bazel',
|
||||||
required=True,
|
required=False,
|
||||||
help='Use custom bazel binary',
|
help='Use custom bazel binary',
|
||||||
metavar='path'
|
metavar='path'
|
||||||
)
|
)
|
||||||
@ -596,7 +599,8 @@ if __name__ == '__main__':
|
|||||||
'--disableParallelSwiftmoduleGeneration',
|
'--disableParallelSwiftmoduleGeneration',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help='Generate .swiftmodule files in parallel to building modules, can speed up compilation on multi-core systems.'
|
help='Generate .swiftmodule files in parallel to building modules, can speed up compilation on multi-core '
|
||||||
|
'systems. '
|
||||||
)
|
)
|
||||||
buildParser.add_argument(
|
buildParser.add_argument(
|
||||||
'--target',
|
'--target',
|
||||||
@ -629,13 +633,19 @@ if __name__ == '__main__':
|
|||||||
if args.commandName is None:
|
if args.commandName is None:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
bazel_path = None
|
||||||
|
if args.bazel is None:
|
||||||
|
bazel_path = locate_bazel(base_path=os.getcwd())
|
||||||
|
else:
|
||||||
|
bazel_path = args.bazel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if args.commandName == 'clean':
|
if args.commandName == 'clean':
|
||||||
clean(arguments=args)
|
clean(bazel=bazel_path, arguments=args)
|
||||||
elif args.commandName == 'generateProject':
|
elif args.commandName == 'generateProject':
|
||||||
generate_project(arguments=args)
|
generate_project(bazel=bazel_path, arguments=args)
|
||||||
elif args.commandName == 'build':
|
elif args.commandName == 'build':
|
||||||
build(arguments=args)
|
build(bazel=bazel_path, arguments=args)
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown command')
|
raise Exception('Unknown command')
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c1f83903e864d753477e51d66d3ada6c2c6d096f
|
Subproject commit a448644dce247e59268864fd66b6578195412b59
|
@ -1 +1 @@
|
|||||||
Subproject commit fcbfcfad2d633b6c8be85954975db88bee3fa26c
|
Subproject commit 4ebd7cc45edfe6c525c1553a0f5294895653c9df
|
@ -1 +1 @@
|
|||||||
Subproject commit 03c89782e9a15d467c7e036ee36f9adb6bdda910
|
Subproject commit e850484071d2b8dc41685a62d3567c312173f3c3
|
@ -1 +1 @@
|
|||||||
Subproject commit ec7dd9ddf4b73dedb02df827b7ab3b2cbb1f2ac0
|
Subproject commit 4eb4edc06eef85d0a4593f36e8fe34e33f718018
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"app": "8.4.1",
|
"app": "8.4.1",
|
||||||
"bazel": "4.0.0",
|
"bazel": "5.0.0",
|
||||||
"xcode": "13.1"
|
"xcode": "13.2.1"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user