mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
[WIP] Settings experiment
This commit is contained in:
parent
5ca7082fbb
commit
3e0d9fd30c
@ -74,6 +74,12 @@ bool_flag(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
bool_flag(
|
||||
name = "projectIncludeRelease",
|
||||
build_setting_default = False,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "disableExtensionsSetting",
|
||||
flag_values = {
|
||||
@ -88,6 +94,13 @@ config_setting(
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "projectIncludeReleaseSetting",
|
||||
flag_values = {
|
||||
":projectIncludeRelease": "True",
|
||||
},
|
||||
)
|
||||
|
||||
bool_flag(
|
||||
name = "disableStripping",
|
||||
build_setting_default = False,
|
||||
@ -2015,9 +2028,9 @@ xcodeproj(
|
||||
"Debug": {
|
||||
"//command_line_option:compilation_mode": "dbg",
|
||||
},
|
||||
"Release": {
|
||||
"//command_line_option:compilation_mode": "opt",
|
||||
},
|
||||
#"Release": {
|
||||
# "//command_line_option:compilation_mode": "opt",
|
||||
#},
|
||||
},
|
||||
default_xcode_configuration = "Debug"
|
||||
|
||||
|
@ -546,6 +546,7 @@ def generate_project(bazel, arguments):
|
||||
|
||||
disable_extensions = False
|
||||
disable_provisioning_profiles = False
|
||||
project_include_release = False
|
||||
generate_dsym = False
|
||||
target_name = "Telegram"
|
||||
|
||||
@ -553,6 +554,8 @@ def generate_project(bazel, arguments):
|
||||
disable_extensions = arguments.disableExtensions
|
||||
if arguments.disableProvisioningProfiles is not None:
|
||||
disable_provisioning_profiles = arguments.disableProvisioningProfiles
|
||||
if arguments.projectIncludeRelease is not None:
|
||||
project_include_release = arguments.projectIncludeRelease
|
||||
if arguments.xcodeManagedCodesigning is not None and arguments.xcodeManagedCodesigning == True:
|
||||
disable_extensions = True
|
||||
if arguments.generateDsym is not None:
|
||||
@ -566,6 +569,7 @@ def generate_project(bazel, arguments):
|
||||
build_environment=bazel_command_line.build_environment,
|
||||
disable_extensions=disable_extensions,
|
||||
disable_provisioning_profiles=disable_provisioning_profiles,
|
||||
include_release=project_include_release,
|
||||
generate_dsym=generate_dsym,
|
||||
configuration_path=bazel_command_line.configuration_path,
|
||||
bazel_app_arguments=bazel_command_line.get_project_generation_arguments(),
|
||||
@ -839,6 +843,15 @@ if __name__ == '__main__':
|
||||
'''
|
||||
)
|
||||
|
||||
generateProjectParser.add_argument(
|
||||
'--projectIncludeRelease',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='''
|
||||
Generate the Xcode project with Debug and Release configurations.
|
||||
'''
|
||||
)
|
||||
|
||||
generateProjectParser.add_argument(
|
||||
'--generateDsym',
|
||||
action='store_true',
|
||||
|
@ -9,7 +9,7 @@ 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):
|
||||
def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name):
|
||||
if '/' in target_name:
|
||||
app_target_spec = target_name.split('/')[0] + '/' + target_name.split('/')[1] + ':' + target_name.split('/')[1]
|
||||
app_target = target_name
|
||||
@ -49,140 +49,5 @@ def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions,
|
||||
call_executable(['open', xcodeproj_path])
|
||||
|
||||
|
||||
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:
|
||||
app_target_spec = target_name.split('/')[0] + '/' + target_name.split('/')[1] + ':' + target_name.split('/')[1]
|
||||
app_target = target_name
|
||||
app_target_clean = app_target.replace('/', '_')
|
||||
else:
|
||||
app_target_spec = '{target}:{target}'.format(target=target_name)
|
||||
app_target = target_name
|
||||
app_target_clean = app_target.replace('/', '_')
|
||||
|
||||
os.makedirs(project_path, exist_ok=True)
|
||||
remove_directory('{}/Tulsi.app'.format(project_path))
|
||||
remove_directory('{project}/{target}.tulsiproj'.format(project=project_path, target=app_target_clean))
|
||||
|
||||
tulsi_path = os.path.join(project_path, 'Tulsi.app/Contents/MacOS/Tulsi')
|
||||
|
||||
tulsi_build_bazel_path = build_environment.bazel_path
|
||||
|
||||
current_dir = os.getcwd()
|
||||
os.chdir(os.path.join(build_environment.base_path, 'build-system/tulsi'))
|
||||
|
||||
tulsi_build_command = []
|
||||
tulsi_build_command += [tulsi_build_bazel_path]
|
||||
tulsi_build_command += ['build', '//:tulsi']
|
||||
if is_apple_silicon():
|
||||
tulsi_build_command += ['--macos_cpus=arm64']
|
||||
tulsi_build_command += ['--xcode_version={}'.format(build_environment.xcode_version)]
|
||||
tulsi_build_command += ['--use_top_level_targets_for_symlinks']
|
||||
tulsi_build_command += ['--verbose_failures']
|
||||
tulsi_build_command += ['--swiftcopt=-whole-module-optimization']
|
||||
|
||||
call_executable(tulsi_build_command)
|
||||
|
||||
os.chdir(current_dir)
|
||||
|
||||
bazel_wrapper_path = os.path.abspath('build-input/gen/project/bazel')
|
||||
|
||||
bazel_wrapper_arguments = []
|
||||
bazel_wrapper_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
|
||||
|
||||
with open(bazel_wrapper_path, 'wb') as bazel_wrapper:
|
||||
bazel_wrapper.write('''#!/bin/sh
|
||||
{bazel} "$@" {arguments}
|
||||
'''.format(
|
||||
bazel=build_environment.bazel_path,
|
||||
arguments=' '.join(bazel_wrapper_arguments)
|
||||
).encode('utf-8'))
|
||||
|
||||
call_executable(['chmod', '+x', bazel_wrapper_path])
|
||||
|
||||
call_executable([
|
||||
'unzip', '-oq',
|
||||
'build-system/tulsi/bazel-bin/tulsi.zip',
|
||||
'-d', project_path
|
||||
])
|
||||
|
||||
user_defaults_path = os.path.expanduser('~/Library/Preferences/com.google.Tulsi.plist')
|
||||
if os.path.isfile(user_defaults_path):
|
||||
os.unlink(user_defaults_path)
|
||||
|
||||
with open(user_defaults_path, 'wb') as user_defaults:
|
||||
user_defaults.write('''
|
||||
<?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>
|
||||
<key>defaultBazelURL</key>
|
||||
<string>{}</string>
|
||||
</dict>
|
||||
</plist>
|
||||
'''.format(bazel_wrapper_path).encode('utf-8'))
|
||||
|
||||
bazel_build_arguments = []
|
||||
bazel_build_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
|
||||
if disable_extensions:
|
||||
bazel_build_arguments += ['--//{}:disableExtensions'.format(app_target)]
|
||||
if disable_provisioning_profiles:
|
||||
bazel_build_arguments += ['--//{}:disableProvisioningProfiles'.format(app_target)]
|
||||
if generate_dsym:
|
||||
bazel_build_arguments += ['--apple_generate_dsym']
|
||||
bazel_build_arguments += ['--//{}:disableStripping'.format('Telegram')]
|
||||
bazel_build_arguments += ['--strip=never']
|
||||
|
||||
call_executable([
|
||||
tulsi_path,
|
||||
'--',
|
||||
'--verbose',
|
||||
'--create-tulsiproj', app_target_clean,
|
||||
'--workspaceroot', './',
|
||||
'--bazel', bazel_wrapper_path,
|
||||
'--outputfolder', project_path,
|
||||
'--target', '{target_spec}'.format(target_spec=app_target_spec),
|
||||
'--build-options', ' '.join(bazel_build_arguments)
|
||||
])
|
||||
|
||||
additional_arguments = []
|
||||
additional_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)]
|
||||
additional_arguments += bazel_app_arguments
|
||||
if disable_extensions:
|
||||
additional_arguments += ['--//{}:disableExtensions'.format(app_target)]
|
||||
|
||||
additional_arguments_string = ' '.join(additional_arguments)
|
||||
|
||||
tulsi_config_path = 'build-input/gen/project/{target}.tulsiproj/Configs/{target}.tulsigen'.format(target=app_target_clean)
|
||||
with open(tulsi_config_path, 'rb') as tulsi_config:
|
||||
tulsi_config_json = json.load(tulsi_config)
|
||||
for category in ['BazelBuildOptionsDebug', 'BazelBuildOptionsRelease']:
|
||||
tulsi_config_json['optionSet'][category]['p'] += ' {}'.format(additional_arguments_string)
|
||||
tulsi_config_json['sourceFilters'] = [
|
||||
'{}/...'.format(app_target),
|
||||
'submodules/...',
|
||||
'third-party/...'
|
||||
]
|
||||
with open(tulsi_config_path, 'wb') as tulsi_config:
|
||||
tulsi_config.write(json.dumps(tulsi_config_json, indent=2).encode('utf-8'))
|
||||
|
||||
call_executable([
|
||||
tulsi_path,
|
||||
'--',
|
||||
'--verbose',
|
||||
'--genconfig', '{project}/{target}.tulsiproj:{target}'.format(project=project_path, target=app_target_clean),
|
||||
'--bazel', bazel_wrapper_path,
|
||||
'--outputfolder', project_path,
|
||||
'--no-open-xcode'
|
||||
])
|
||||
|
||||
xcodeproj_path = '{project}/{target}.xcodeproj'.format(project=project_path, target=app_target_clean)
|
||||
|
||||
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)
|
||||
#generate_tulsi(build_environment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name)
|
||||
|
||||
def generate(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name):
|
||||
generate_xcodeproj(build_environment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name)
|
||||
|
@ -6,7 +6,7 @@ public final class LoggingSettings: Codable {
|
||||
public let redactSensitiveData: Bool
|
||||
|
||||
#if DEBUG
|
||||
public static var defaultSettings = LoggingSettings(logToFile: true, logToConsole: true, redactSensitiveData: true)
|
||||
public static var defaultSettings = LoggingSettings(logToFile: false, logToConsole: false, redactSensitiveData: true)
|
||||
#else
|
||||
public static var defaultSettings = LoggingSettings(logToFile: false, logToConsole: false, redactSensitiveData: true)
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user