diff --git a/.buckconfig b/.buckconfig index 4c0639e003..20904c7a22 100644 --- a/.buckconfig +++ b/.buckconfig @@ -1,14 +1,14 @@ [cxx] default_platform = iphonesimulator-x86_64 - cflags = -g -fmodules -fobjc-arc -D BUCK -w $(config custom.other_cflags) - cxxflags = -fobjc-arc -std=c++14 -D DEBUG -g $(config custom.other_cxxflags) + cflags = -g -fmodules -fobjc-arc -D BUCK -D DEBUG -w $(config custom.other_cflags) + cxxflags = -fobjc-arc -std=c++14 -D BUCK -D DEBUG -g $(config custom.other_cxxflags) combined_preprocess_and_compile = true pch_enabled = false ldflags = -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime $(config custom.other_cxxflags) [swift] version = 4.0 - compiler_flags = -DBUCK -enable-testing -g -Onone $(config custom.other_swift_compiler_flags) + compiler_flags = -DBUCK -enable-testing -enable-batch-mode -g -Onone $(config custom.other_swift_compiler_flags) use_filelist = true [apple] diff --git a/.gitmodules b/.gitmodules index 3be500ea39..eef423b020 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,7 @@ url=../Display.git url=../HockeySDK-iOS.git [submodule "submodules/libtgvoip"] path = submodules/libtgvoip -url=https://github.com/grishka/libtgvoip.git +url=../libtgvoip.git [submodule "submodules/lottie-ios"] path = submodules/lottie-ios url=../lottie-ios.git diff --git a/BUCK b/BUCK index 12802a3a90..a4922fc0d9 100644 --- a/BUCK +++ b/BUCK @@ -51,6 +51,10 @@ apple_binary( '//submodules/HockeySDK-iOS:HockeySDK', '//submodules/lottie-ios:Lottie', '//submodules/libtgvoip:tgvoip', + '//submodules/webp:WebP', + '//submodules/ffmpeg:FFMpeg', + '//submodules/TelegramUI:TelegramUI', + '//submodules/TelegramUI:TelegramUIPrivateModule', ], ) diff --git a/NotificationService/ImageData.swift b/NotificationService/ImageData.swift index 883b2b0ad3..e0be7d7b2b 100644 --- a/NotificationService/ImageData.swift +++ b/NotificationService/ImageData.swift @@ -1,5 +1,9 @@ import Foundation +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif struct ImageResource { let datacenterId: Int diff --git a/NotificationService/NotificationService.swift b/NotificationService/NotificationService.swift index e775de192e..55904efda0 100644 --- a/NotificationService/NotificationService.swift +++ b/NotificationService/NotificationService.swift @@ -1,6 +1,10 @@ import Foundation import UserNotifications +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif import WebP private var sharedLogger: Logger? diff --git a/NotificationService/Serialization.swift b/NotificationService/Serialization.swift index c0f90c192d..5e93f7806c 100644 --- a/NotificationService/Serialization.swift +++ b/NotificationService/Serialization.swift @@ -1,5 +1,9 @@ import Foundation +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif public class BoxedMessage: NSObject { public let body: Any diff --git a/Share/ShareItems.swift b/Share/ShareItems.swift index 41e9cab2f7..f266e7d7ee 100644 --- a/Share/ShareItems.swift +++ b/Share/ShareItems.swift @@ -2,7 +2,11 @@ import Foundation import SwiftSignalKit import Postbox import TelegramCore +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif import Display import TelegramUI diff --git a/Telegram-iOS/LegacyDataImport.swift b/Telegram-iOS/LegacyDataImport.swift index 612dfd8c95..5fa9c42eb4 100644 --- a/Telegram-iOS/LegacyDataImport.swift +++ b/Telegram-iOS/LegacyDataImport.swift @@ -2,7 +2,11 @@ import Foundation import TelegramCore import SwiftSignalKit import Postbox +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif enum AccountImportError: Error { case generic diff --git a/Telegram-iOS/LegacyPreferencesImport.swift b/Telegram-iOS/LegacyPreferencesImport.swift index 20f86715d4..563791f2a2 100644 --- a/Telegram-iOS/LegacyPreferencesImport.swift +++ b/Telegram-iOS/LegacyPreferencesImport.swift @@ -2,7 +2,11 @@ import Foundation import TelegramCore import SwiftSignalKit import Postbox +#if BUCK +import MtProtoKit +#else import MtProtoKitDynamic +#endif import TelegramUI import LegacyComponents diff --git a/Telegram-iOS/TempRoot.swift b/Telegram-iOS/TempRoot.swift index c0f69cf9ad..2678d48e09 100644 --- a/Telegram-iOS/TempRoot.swift +++ b/Telegram-iOS/TempRoot.swift @@ -9,6 +9,9 @@ import TelegramCore import LegacyComponents import HockeySDK import Lottie +import WebP +import FFMpeg +import TelegramUIPrivateModule func test() { let _ = ASDisplayNode() diff --git a/submodules/Display b/submodules/Display index a9e3741319..4fe76fd53b 160000 --- a/submodules/Display +++ b/submodules/Display @@ -1 +1 @@ -Subproject commit a9e374131912f68bb599f6c87b9da26a3687513e +Subproject commit 4fe76fd53bb0b561fde9aad5e32bd4d0ddca305c diff --git a/submodules/TelegramCore b/submodules/TelegramCore index a56806593c..242ad146b0 160000 --- a/submodules/TelegramCore +++ b/submodules/TelegramCore @@ -1 +1 @@ -Subproject commit a56806593c21485c474f1077feb588dfd2adc4a9 +Subproject commit 242ad146b04051d6ff4ec5300d4c63dc457e5d8e diff --git a/submodules/TelegramUI b/submodules/TelegramUI index 33a1ee7e9e..36e789c884 160000 --- a/submodules/TelegramUI +++ b/submodules/TelegramUI @@ -1 +1 @@ -Subproject commit 33a1ee7e9ee60a7393ef58a3103cc6bce213bfe4 +Subproject commit 36e789c8847a62fd9c369aa0a86376b0d6178893 diff --git a/submodules/ffmpeg b/submodules/ffmpeg index 0495e4606b..66818a3563 160000 --- a/submodules/ffmpeg +++ b/submodules/ffmpeg @@ -1 +1 @@ -Subproject commit 0495e4606b6a109f951f963c95b3d57ed5e031ff +Subproject commit 66818a3563789f475899ad9dd2e3c88e6af82895 diff --git a/submodules/libtgvoip b/submodules/libtgvoip index 16711e2023..a1ddd03c71 160000 --- a/submodules/libtgvoip +++ b/submodules/libtgvoip @@ -1 +1 @@ -Subproject commit 16711e202393ae7e1b160436f4291c5f06a3d375 +Subproject commit a1ddd03c71fd318a3c81820c431a0a5e6563f9d4 diff --git a/tools/buck_utils.bzl b/tools/buck_utils.bzl index 988198f143..2c6058d22a 100644 --- a/tools/buck_utils.bzl +++ b/tools/buck_utils.bzl @@ -29,69 +29,80 @@ def configs_with_config(config): "Release": config, } -def subdir_glob(glob_specs, exclude = None, prefix = ""): - """Returns a dict of sub-directory relative paths to full paths. - - The subdir_glob() function is useful for defining header maps for C/C++ - libraries which should be relative the given sub-directory. - Given a list of tuples, the form of (relative-sub-directory, glob-pattern), - it returns a dict of sub-directory relative paths to full paths. - - Please refer to native.glob() for explanations and examples of the pattern. - - Args: - glob_specs: The array of tuples in form of - (relative-sub-directory, glob-pattern inside relative-sub-directory). - type: List[Tuple[str, str]] - exclude: A list of patterns to identify files that should be removed - from the set specified by the first argument. Defaults to []. - type: Optional[List[str]] - prefix: If is not None, prepends it to each key in the dictionary. - Defaults to None. - type: Optional[str] - - Returns: - A dict of sub-directory relative paths to full paths. - """ - if exclude == None: - exclude = [] - - results = [] - - for dirpath, glob_pattern in glob_specs: - results.append( - _single_subdir_glob(dirpath, glob_pattern, exclude, prefix), - ) - - return _merge_maps(*results) - -def _merge_maps(*file_maps): - result = {} - for file_map in file_maps: - for key in file_map: - if key in result and result[key] != file_map[key]: +def merge_maps(dicts): + result = dict() + for d in dicts: + for key in d: + if key in result and result[key] != d[key]: fail( "Conflicting files in file search paths. " + "\"%s\" maps to both \"%s\" and \"%s\"." % - (key, result[key], file_map[key]), + (key, result[key], d[key]), ) - - result[key] = file_map[key] - + result.update(d) return result -def _single_subdir_glob(dirpath, glob_pattern, exclude = None, prefix = None): - if exclude == None: - exclude = [] - results = {} - files = native.glob([dirpath + '/' + glob_pattern], exclude = exclude) - for f in files: - if dirpath: - key = f[len(dirpath) + 1:] - else: - key = f - if prefix: - key =prefix + '/' + key - results[key] = f +def basename(p): + """Returns the basename (i.e., the file portion) of a path. + Note that if `p` ends with a slash, this function returns an empty string. + This matches the behavior of Python's `os.path.basename`, but differs from + the Unix `basename` command (which would return the path segment preceding + the final slash). + Args: + p: The path whose basename should be returned. + Returns: + The basename of the path, which includes the extension. + """ + return p.rpartition("/")[-1] - return results \ No newline at end of file +def glob_map(glob_results): + result = dict() + for path in glob_results: + file_name = basename(path) + if file_name in result: + fail('\"%s\" maps to both \"%s\" and \"%s\"' % (file_name, result[file_name], path)) + result[file_name] = path + return result + +def glob_sub_map(prefix, glob_specs): + result = dict() + for path in native.glob(glob_specs): + if not path.startswith(prefix): + fail('\"%s\" does not start with \"%s\"' % (path, prefix)) + file_key = path[len(prefix):] + if file_key in result: + fail('\"%s\" maps to both \"%s\" and \"%s\"' % (file_key, result[file_key], path)) + result[file_key] = path + return result + +def gen_header_targets(header_paths, prefix, source_rule, source_path): + result = dict() + for header_path in header_paths: + name = prefix + header_path.replace('/', '_sub_') + native.genrule( + name = name, + cmd = 'cp $(location :' + source_rule + ')/' + source_path + '/' + header_path + ' $OUT', + out = name, + ) + result[header_path] = ':' + name + return result + +def lib_basename(name): + result = name + if result.startswith('lib'): + result = result[3:] + if result.endswith('.a'): + result = result[:-2] + return result + +def gen_lib_targets(lib_paths, prefix, source_rule, source_path): + result = [] + for lib_path in lib_paths: + name = lib_path.replace('/', '_sub_') + native.genrule( + name = name, + cmd = 'cp $(location :' + source_rule + ')/' + source_path + '/' + lib_path + ' $OUT', + out = name + ) + result.append(name) + return result