Merge commit '3e3d91909d565e3f4aa15212af83a0c7eefb07da' into beta
38
.buckconfig
Normal file
@ -0,0 +1,38 @@
|
||||
[cxx]
|
||||
default_platform = iphonesimulator-x86_64
|
||||
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 -enable-batch-mode -g -Onone $(config custom.other_swift_compiler_flags)
|
||||
use_filelist = true
|
||||
|
||||
[apple]
|
||||
use_swift_delegate = false
|
||||
use_header_maps_in_xcode = false
|
||||
generate_missing_umbrella_headers = true
|
||||
iphonesimulator_target_sdk_version = 8.0
|
||||
iphoneos_target_sdk_version = 8.0
|
||||
provisioning_profile_read_command = security cms -Di
|
||||
xctool_default_destination_specifier = platform=iOS Simulator,OS=latest
|
||||
;provisioning_profile_search_path = ./
|
||||
;xctool_path = tools/xctool/bin/xctool
|
||||
|
||||
[parser]
|
||||
polyglot_parsing_enabled = true
|
||||
default_build_file_syntax = SKYLARK
|
||||
|
||||
[project]
|
||||
ide_force_kill = always
|
||||
project_schemes = true
|
||||
ide = xcode
|
||||
allow_symlinks = forbid
|
||||
ignore = tools, \
|
||||
.git, \
|
||||
|
||||
[build]
|
||||
thread_core_ratio = 2.0
|
2
.gitmodules
vendored
@ -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=git@gitlab.com:peter-iakovlev/libtgvoip.git
|
||||
[submodule "submodules/lottie-ios"]
|
||||
path = submodules/lottie-ios
|
||||
url=../lottie-ios.git
|
||||
|
150
BUCK
Normal file
@ -0,0 +1,150 @@
|
||||
load('//tools:buck_utils.bzl', 'config_with_updated_linker_flags', 'configs_with_config')
|
||||
load('//tools:buck_defs.bzl', 'SHARED_CONFIGS')
|
||||
|
||||
# Adding `-all_load` to our binaries works around https://bugs.swift.org/browse/SR-6004. See the
|
||||
# longer comment in `ViewController.swift` for more details.
|
||||
ALL_LOAD_LINKER_FLAG = '-all_load'
|
||||
|
||||
APP_CONFIGS = {
|
||||
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES': 'YES',
|
||||
'DEVELOPMENT_LANGUAGE': 'Swift',
|
||||
'PRODUCT_BUNDLE_IDENTIFIER': 'ph.telegra.Telegraph',
|
||||
'PROVISIONING_PROFILE_SPECIFIER': 'match Development ph.telegra.Telegraph',
|
||||
'TARGETED_DEVICE_FAMILY': '1,2',
|
||||
}
|
||||
APP_CONFIGS.update(SHARED_CONFIGS)
|
||||
|
||||
apple_resource(
|
||||
name = 'LaunchScreenXib',
|
||||
files = [
|
||||
'Telegram-iOS/Base.lproj/LaunchScreen.xib',
|
||||
],
|
||||
)
|
||||
|
||||
apple_asset_catalog(
|
||||
name = 'Images',
|
||||
dirs = [
|
||||
'Telegram-iOS/Images.xcassets',
|
||||
],
|
||||
app_icon = 'AppIconLLC',
|
||||
)
|
||||
|
||||
apple_library(
|
||||
name = 'BuildConfig',
|
||||
srcs = glob([
|
||||
'Telegram-iOS/BuildConfig.m',
|
||||
]),
|
||||
headers = [
|
||||
'Telegram-iOS/BuildConfig.h',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-w',
|
||||
'-DAPP_CONFIG_IS_INTERNAL_BUILD=false',
|
||||
'-DAPP_CONFIG_IS_APPSTORE_BUILD=true',
|
||||
'-DAPP_CONFIG_APPSTORE_ID=686449807',
|
||||
'-DAPP_SPECIFIC_URL_SCHEME=\"tgapp\"',
|
||||
'-DAPP_CONFIG_API_ID=8',
|
||||
'-DAPP_CONFIG_API_HASH=\"7245de8e747a0d6fbe11f7cc14fcc0bb\"',
|
||||
'-DAPP_CONFIG_HOCKEYAPP_ID=\"ad8831329ffc8f8aff9a2b0b86558b24\"',
|
||||
],
|
||||
header_namespace = 'BuildConfig',
|
||||
exported_headers = [
|
||||
'Telegram-iOS/BuildConfig.h',
|
||||
],
|
||||
modular = True,
|
||||
visibility = ['PUBLIC'],
|
||||
deps = [
|
||||
'//submodules/MtProtoKit:MtProtoKit',
|
||||
],
|
||||
)
|
||||
|
||||
apple_library(
|
||||
name = 'AppBinaryPrivate',
|
||||
srcs = glob([
|
||||
'Telegram-iOS/TGBridgeServer.m',
|
||||
'Telegram-iOS/TGAutoDownloadPreferences.m',
|
||||
'Telegram-iOS/TGPresentationAutoNightPreferences.m',
|
||||
'Telegram-iOS/TGProxyItem.m',
|
||||
'Telegram-iOS/UIImage+ImageEffects.m',
|
||||
]),
|
||||
headers = [
|
||||
],
|
||||
header_namespace = 'AppBinaryPrivate',
|
||||
exported_headers = [
|
||||
'Telegram-iOS/TGBridgeServer.h',
|
||||
'Telegram-iOS/TGAutoDownloadPreferences.h',
|
||||
'Telegram-iOS/TGPresentationAutoNightPreferences.h',
|
||||
'Telegram-iOS/TGProxyItem.h',
|
||||
'Telegram-iOS/UIImage+ImageEffects.h',
|
||||
],
|
||||
modular = True,
|
||||
#visibility = ['//submodules/TelegramUI:TelegramUI'],
|
||||
visibility = ['PUBLIC'],
|
||||
deps = [
|
||||
'//submodules/SSignalKit:SSignalKit',
|
||||
'//Watch:WatchUtils',
|
||||
'//submodules/LegacyComponents:LegacyComponents',
|
||||
],
|
||||
)
|
||||
|
||||
apple_binary(
|
||||
name = 'AppBinary',
|
||||
configs = configs_with_config(config_with_updated_linker_flags(APP_CONFIGS, ALL_LOAD_LINKER_FLAG)),
|
||||
srcs = glob([
|
||||
'Telegram-iOS/*.swift',
|
||||
]) + [
|
||||
'Telegram-iOS/main.m',
|
||||
],
|
||||
entitlements_file = 'Telegram-iOS/Telegram-iOS-AppStoreLLC.entitlements',
|
||||
deps = [
|
||||
':LaunchScreenXib',
|
||||
':Images',
|
||||
'//submodules/AsyncDisplayKit:AsyncDisplayKit',
|
||||
'//submodules/MtProtoKit:MtProtoKit',
|
||||
'//submodules/SSignalKit:SwiftSignalKit',
|
||||
'//submodules/SSignalKit:SSignalKit',
|
||||
'//submodules/Display:Display',
|
||||
'//submodules/Postbox:Postbox',
|
||||
'//submodules/TelegramCore:TelegramCore',
|
||||
'//submodules/LegacyComponents:LegacyComponents',
|
||||
'//submodules/HockeySDK-iOS:HockeySDK',
|
||||
'//submodules/lottie-ios:Lottie',
|
||||
'//submodules/libtgvoip:tgvoip',
|
||||
'//submodules/webp:WebP',
|
||||
'//submodules/ffmpeg:FFMpeg',
|
||||
'//submodules/TelegramUI:TelegramUI',
|
||||
'//submodules/TelegramUI:TelegramUIPrivateModule',
|
||||
'//Watch:WatchUtils',
|
||||
':BuildConfig',
|
||||
':AppBinaryPrivate',
|
||||
],
|
||||
)
|
||||
|
||||
xcode_workspace_config(
|
||||
name = "workspace",
|
||||
workspace_name = "Telegram_BUCK",
|
||||
src_target = ":AppBinary",
|
||||
)
|
||||
|
||||
apple_bundle(
|
||||
name = 'AppBundle',
|
||||
extension = 'app',
|
||||
binary = ':AppBinary',
|
||||
product_name = 'Telegram',
|
||||
info_plist = 'Telegram-iOS/Info.plist',
|
||||
info_plist_substitutions = {
|
||||
'DEVELOPMENT_LANGUAGE': 'en-us',
|
||||
'APP_NAME': 'Telegram',
|
||||
'EXECUTABLE_NAME': 'Telegram',
|
||||
'PRODUCT_BUNDLE_IDENTIFIER': 'ph.telegra.Telegraph',
|
||||
'PRODUCT_NAME': 'Telegram',
|
||||
'APP_SPECIFIC_URL_SCHEME': 'tgapp',
|
||||
'VERSION': '5.8',
|
||||
'BUILD_NUMBER': '2001',
|
||||
},
|
||||
)
|
||||
|
||||
apple_package(
|
||||
name = 'AppPackage',
|
||||
bundle = ':AppBundle',
|
||||
)
|
@ -1,5 +1,9 @@
|
||||
import Foundation
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
|
||||
struct ImageResource {
|
||||
let datacenterId: Int
|
||||
|
@ -1,6 +1,10 @@
|
||||
import Foundation
|
||||
import UserNotifications
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
import WebP
|
||||
|
||||
private var sharedLogger: Logger?
|
||||
|
@ -1,5 +1,9 @@
|
||||
import Foundation
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
|
||||
public class BoxedMessage: NSObject {
|
||||
public let body: Any
|
||||
@ -10,7 +14,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 100
|
||||
return 102
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
@ -2,7 +2,11 @@ import Foundation
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
import Display
|
||||
import TelegramUI
|
||||
|
||||
|
@ -7,6 +7,10 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
090E777422A6945900CD99F5 /* BlackClassicIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 090E777022A6945800CD99F5 /* BlackClassicIcon@2x.png */; };
|
||||
090E777522A6945900CD99F5 /* BlueClassicIcon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 090E777122A6945800CD99F5 /* BlueClassicIcon@3x.png */; };
|
||||
090E777622A6945900CD99F5 /* BlackClassicIcon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 090E777222A6945800CD99F5 /* BlackClassicIcon@3x.png */; };
|
||||
090E777722A6945900CD99F5 /* BlueClassicIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 090E777322A6945800CD99F5 /* BlueClassicIcon@2x.png */; };
|
||||
092F368521542D6C001A9F49 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 092F368321542D6C001A9F49 /* Localizable.strings */; };
|
||||
0956AF2C217B4642008106D0 /* WatchCommunicationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0956AF2B217B4642008106D0 /* WatchCommunicationManager.swift */; };
|
||||
0956AF2F217B8109008106D0 /* TGNeoUnsupportedMessageViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0956AF2E217B8109008106D0 /* TGNeoUnsupportedMessageViewModel.m */; };
|
||||
@ -564,6 +568,10 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
090E777022A6945800CD99F5 /* BlackClassicIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "BlackClassicIcon@2x.png"; sourceTree = "<group>"; };
|
||||
090E777122A6945800CD99F5 /* BlueClassicIcon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "BlueClassicIcon@3x.png"; sourceTree = "<group>"; };
|
||||
090E777222A6945800CD99F5 /* BlackClassicIcon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "BlackClassicIcon@3x.png"; sourceTree = "<group>"; };
|
||||
090E777322A6945800CD99F5 /* BlueClassicIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "BlueClassicIcon@2x.png"; sourceTree = "<group>"; };
|
||||
092F368421542D6C001A9F49 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Share/en.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
|
||||
0956AF2B217B4642008106D0 /* WatchCommunicationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WatchCommunicationManager.swift; sourceTree = "<group>"; };
|
||||
0956AF2D217B8109008106D0 /* TGNeoUnsupportedMessageViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TGNeoUnsupportedMessageViewModel.h; sourceTree = "<group>"; };
|
||||
@ -1053,6 +1061,8 @@
|
||||
D073E51E21FF7CE900742DDD /* Crypto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Crypto.h; sourceTree = "<group>"; };
|
||||
D073E51F21FF7CE900742DDD /* Crypto.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Crypto.m; sourceTree = "<group>"; };
|
||||
D073E52122003E1E00742DDD /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = "<group>"; };
|
||||
D07477B522A72B1F002737C4 /* TempRoot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TempRoot.swift; sourceTree = "<group>"; };
|
||||
D07477B722A732F1002737C4 /* TempMain.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TempMain.m; sourceTree = "<group>"; };
|
||||
D079FD001F06BBD10038FADE /* Telegram-iOS-AppStore.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "Telegram-iOS-AppStore.entitlements"; sourceTree = "<group>"; };
|
||||
D084023120E1883500065674 /* ApplicationShortcutItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationShortcutItem.swift; sourceTree = "<group>"; };
|
||||
D08410431FABDC5B008FFE92 /* TGItemProviderSignals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGItemProviderSignals.h; sourceTree = "<group>"; };
|
||||
@ -1329,6 +1339,10 @@
|
||||
09A218E122A14E5600DE6898 /* App Icons */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
090E777022A6945800CD99F5 /* BlackClassicIcon@2x.png */,
|
||||
090E777222A6945800CD99F5 /* BlackClassicIcon@3x.png */,
|
||||
090E777322A6945800CD99F5 /* BlueClassicIcon@2x.png */,
|
||||
090E777122A6945800CD99F5 /* BlueClassicIcon@3x.png */,
|
||||
09A218EA22A1570900DE6898 /* BlackFilledIcon@2x.png */,
|
||||
09A218EB22A1570900DE6898 /* BlackFilledIcon@3x.png */,
|
||||
09A218EC22A1570900DE6898 /* BlueFilledIcon@2x.png */,
|
||||
@ -2000,6 +2014,8 @@
|
||||
D0B21B0E220438E9003F741D /* SharedNotificationManager.swift */,
|
||||
D09B79C42219C784003B1F9D /* SharedAccountInfo.swift */,
|
||||
D09B79C72219C7AE003B1F9D /* ManageSharedAccountInfo.swift */,
|
||||
D07477B522A72B1F002737C4 /* TempRoot.swift */,
|
||||
D07477B722A732F1002737C4 /* TempMain.m */,
|
||||
);
|
||||
path = "Telegram-iOS";
|
||||
sourceTree = "<group>";
|
||||
@ -2897,6 +2913,7 @@
|
||||
D04DCC211F71C80000B021D7 /* 0.m4a in Resources */,
|
||||
D04DCC261F71C80000B021D7 /* 103.m4a in Resources */,
|
||||
09A218F222A1570A00DE6898 /* BlueFilledIcon@2x.png in Resources */,
|
||||
090E777722A6945900CD99F5 /* BlueClassicIcon@2x.png in Resources */,
|
||||
D0CE6F69213EDA4400BCD44B /* AppIntentVocabulary.plist in Resources */,
|
||||
D0338736223A9A9A007A2CE4 /* Config-Hockeyapp-Internal.xcconfig in Resources */,
|
||||
D08DB0C0213F4D1D00F2ADBF /* telegram_sphere@2x.png in Resources */,
|
||||
@ -2947,6 +2964,7 @@
|
||||
D0CE6F59213EDA4400BCD44B /* InfoPlist.strings in Resources */,
|
||||
D08DB0B9213F4D1D00F2ADBF /* powerful_star@2x.png in Resources */,
|
||||
D04DCC271F71C80000B021D7 /* 104.m4a in Resources */,
|
||||
090E777522A6945900CD99F5 /* BlueClassicIcon@3x.png in Resources */,
|
||||
09A218F122A1570A00DE6898 /* BlackFilledIcon@3x.png in Resources */,
|
||||
D04DCC2A1F71C80000B021D7 /* 107.m4a in Resources */,
|
||||
D08DB0BA213F4D1D00F2ADBF /* private_door@2x.png in Resources */,
|
||||
@ -2981,8 +2999,10 @@
|
||||
D04DCC251F71C80000B021D7 /* 102.m4a in Resources */,
|
||||
D021D4D9219CAEDD0064BEBA /* Config-Fork.xcconfig in Resources */,
|
||||
D08DB0AD213F4D1D00F2ADBF /* ic_cam@2x.png in Resources */,
|
||||
090E777622A6945900CD99F5 /* BlackClassicIcon@3x.png in Resources */,
|
||||
D08DB0BF213F4D1D00F2ADBF /* telegram_plane1@2x.png in Resources */,
|
||||
D0E8B8B02044496C00605593 /* voip_ringback.caf in Resources */,
|
||||
090E777422A6945900CD99F5 /* BlackClassicIcon@2x.png in Resources */,
|
||||
D00ED75A1FE94630001F38BD /* AppIntentVocabulary.plist in Resources */,
|
||||
D04DCC221F71C80000B021D7 /* 1.m4a in Resources */,
|
||||
D0E8C2E02285EA6A009F26E8 /* BlackIcon@3x.png in Resources */,
|
||||
|
@ -11,6 +11,10 @@ import PushKit
|
||||
import AsyncDisplayKit
|
||||
import CloudKit
|
||||
|
||||
#if BUCK
|
||||
import BuildConfig
|
||||
#endif
|
||||
|
||||
private let handleVoipNotifications = false
|
||||
|
||||
private var testIsLaunched = false
|
||||
@ -559,6 +563,8 @@ final class SharedApplicationContext {
|
||||
if #available(iOS 10.3, *) {
|
||||
return [PresentationAppIcon(name: "Blue", imageName: "BlueIcon", isDefault: false),
|
||||
PresentationAppIcon(name: "Black", imageName: "BlackIcon", isDefault: false),
|
||||
PresentationAppIcon(name: "BlueClassic", imageName: "BlueClassicIcon", isDefault: false),
|
||||
PresentationAppIcon(name: "BlackClassic", imageName: "BlackClassicIcon", isDefault: false),
|
||||
PresentationAppIcon(name: "BlueFilled", imageName: "BlueFilledIcon", isDefault: false),
|
||||
PresentationAppIcon(name: "BlackFilled", imageName: "BlackFilledIcon", isDefault: false)]
|
||||
} else {
|
||||
@ -970,14 +976,12 @@ final class SharedApplicationContext {
|
||||
}
|
||||
self.mainWindow.forEachViewController({ controller in
|
||||
if let controller = controller as? TabBarAccountSwitchController {
|
||||
var dismissed = false
|
||||
if let rootController = self.mainWindow.viewController as? TelegramRootController {
|
||||
if let tabsController = rootController.viewControllers.first as? TabBarController {
|
||||
for i in 0 ..< tabsController.controllers.count {
|
||||
if let _ = tabsController.controllers[i] as? (SettingsController & ViewController) {
|
||||
let sourceNodes = tabsController.sourceNodesForController(at: i)
|
||||
if let sourceNodes = sourceNodes {
|
||||
dismissed = true
|
||||
controller.dismiss(sourceNodes: sourceNodes)
|
||||
}
|
||||
return false
|
||||
@ -985,9 +989,6 @@ final class SharedApplicationContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
if dismissed {
|
||||
controller.dismiss()
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
@ -1144,7 +1145,7 @@ final class SharedApplicationContext {
|
||||
BITHockeyManager.shared().configure(withIdentifier: hockeyAppId, delegate: self)
|
||||
BITHockeyManager.shared().crashManager.crashManagerStatus = .alwaysAsk
|
||||
BITHockeyManager.shared().start()
|
||||
BITHockeyManager.shared().authenticator.authenticateInstallation()
|
||||
//BITHockeyManager.shared().authenticator.authenticateInstallation()
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIWindowDidBecomeHidden, object: nil, queue: nil, using: { notification in
|
||||
|
@ -7,6 +7,11 @@ import TelegramCore
|
||||
import Display
|
||||
import LegacyComponents
|
||||
|
||||
#if BUCK
|
||||
import BuildConfig
|
||||
import AppBinaryPrivate
|
||||
#endif
|
||||
|
||||
func isAccessLocked(data: PostboxAccessChallengeData, at timestamp: Int32) -> Bool {
|
||||
if data.isLockable, let autolockDeadline = data.autolockDeadline, autolockDeadline <= timestamp {
|
||||
return true
|
||||
@ -342,7 +347,7 @@ final class AuthorizedApplicationContext {
|
||||
|
||||
self.notificationMessagesDisposable.set((context.account.stateManager.notificationMessages
|
||||
|> deliverOn(Queue.mainQueue())).start(next: { [weak self] messageList in
|
||||
if let strongSelf = self, let (messages, groupId, notify) = messageList.last, let firstMessage = messages.first {
|
||||
if let strongSelf = self, let (messages, _, notify) = messageList.last, let firstMessage = messages.first {
|
||||
if UIApplication.shared.applicationState == .active {
|
||||
var chatIsVisible = false
|
||||
if let topController = strongSelf.rootController.topViewController as? ChatController, topController.traceVisibility() {
|
||||
|
BIN
Telegram-iOS/BlackClassicIcon@2x.png
Executable file
After Width: | Height: | Size: 9.0 KiB |
BIN
Telegram-iOS/BlackClassicIcon@3x.png
Executable file
After Width: | Height: | Size: 16 KiB |
BIN
Telegram-iOS/BlackFilledIcon@2x.png
Normal file → Executable file
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 9.7 KiB |
BIN
Telegram-iOS/BlackFilledIcon@3x.png
Normal file → Executable file
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 17 KiB |
BIN
Telegram-iOS/BlackIcon@2x.png
Normal file → Executable file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.8 KiB |
BIN
Telegram-iOS/BlackIcon@3x.png
Normal file → Executable file
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 15 KiB |
BIN
Telegram-iOS/BlueClassicIcon@2x.png
Executable file
After Width: | Height: | Size: 8.4 KiB |
BIN
Telegram-iOS/BlueClassicIcon@3x.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
Telegram-iOS/BlueFilledIcon@2x.png
Normal file → Executable file
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 8.5 KiB |
BIN
Telegram-iOS/BlueFilledIcon@3x.png
Normal file → Executable file
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 16 KiB |
BIN
Telegram-iOS/BlueIcon@2x.png
Normal file → Executable file
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 8.1 KiB |
BIN
Telegram-iOS/BlueIcon@3x.png
Normal file → Executable file
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 14 KiB |
@ -10,7 +10,11 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef BUCK
|
||||
#import <MtProtoKit/MtProtoKit.h>
|
||||
#else
|
||||
#import <MtProtoKitDynamic/MtProtoKitDynamic.h>
|
||||
#endif
|
||||
|
||||
static uint32_t funcSwap32(uint32_t input)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ private func readSecretChatData(reader: BufferReader) -> SecretChatData? {
|
||||
guard let accessHash = reader.readInt64() else {
|
||||
return nil
|
||||
}
|
||||
guard let keyFingerprint = reader.readInt64() else {
|
||||
guard let _ = reader.readInt64() else {
|
||||
return nil
|
||||
}
|
||||
guard let handshakeState = reader.readInt32() else {
|
||||
@ -267,7 +267,7 @@ private func loadLegacyPeerCustomProperyData(database: SqliteInterface, peerId:
|
||||
let keyHash: Int32
|
||||
switch key {
|
||||
case let .string(string):
|
||||
keyHash = murMurHashString32(string)
|
||||
keyHash = HashFunctions.murMurHash32(string)
|
||||
case let .hash(hash):
|
||||
keyHash = hash
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
|
||||
enum AccountImportError: Error {
|
||||
case generic
|
||||
|
@ -1,10 +1,19 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
#if BUCK
|
||||
import MtProtoKit
|
||||
#else
|
||||
import MtProtoKitDynamic
|
||||
#endif
|
||||
import TelegramUI
|
||||
|
||||
#if BUCK
|
||||
import AppBinaryPrivate
|
||||
#endif
|
||||
|
||||
import LegacyComponents
|
||||
|
||||
@objc(TGPresentationState) private final class TGPresentationState: NSObject, NSCoding {
|
||||
@ -41,7 +50,7 @@ private enum PreferencesProvider {
|
||||
|
||||
private func loadLegacyCustomProperyData(database: SqliteInterface, key: String) -> Data? {
|
||||
var result: Data?
|
||||
database.select("SELECT value FROM service_v29 WHERE key=\(murMurHash32(key))", { cursor in
|
||||
database.select("SELECT value FROM service_v29 WHERE key=\(HashFunctions.murMurHash32(key))", { cursor in
|
||||
result = cursor.getData(at: 0)
|
||||
return false
|
||||
})
|
||||
@ -97,7 +106,6 @@ func importLegacyPreferences(accountManager: AccountManager, account: TemporaryA
|
||||
let vibrationEnabled: Bool? = preferencesProvider["vibrationEnabled"] as? Bool
|
||||
let bannerEnabled: Bool? = preferencesProvider["bannerEnabled"] as? Bool
|
||||
let callsDataUsageMode: Int? = preferencesProvider["callsDataUsageMode"] as? Int
|
||||
let callsDisableP2P: Bool? = preferencesProvider["callsDisableP2P"] as? Bool
|
||||
let callsDisableCallKit: Bool? = preferencesProvider["callsDisableCallKit"] as? Bool
|
||||
let callsUseProxy: Bool? = preferencesProvider["callsUseProxy"] as? Bool
|
||||
let contactsInhibitSync: Bool? = preferencesProvider["contactsInhibitSync"] as? Bool
|
||||
@ -362,7 +370,7 @@ func importLegacyPreferences(accountManager: AccountManager, account: TemporaryA
|
||||
})
|
||||
|
||||
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.instantPagePresentationSettings, { current in
|
||||
var settings: InstantPagePresentationSettings = current as? InstantPagePresentationSettings ?? .defaultSettings
|
||||
let settings: InstantPagePresentationSettings = current as? InstantPagePresentationSettings ?? .defaultSettings
|
||||
if let instantPageFontSize = instantPageFontSize {
|
||||
switch instantPageFontSize {
|
||||
case 0.85:
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
@ -315,7 +315,10 @@ final class SharedNotificationManager {
|
||||
isAnnouncement = true
|
||||
}
|
||||
|
||||
if let body = body {
|
||||
if let _ = body {
|
||||
let _ = title
|
||||
let _ = apnsSound
|
||||
|
||||
if isAnnouncement {
|
||||
//presentAnnouncement
|
||||
} else {
|
||||
|
@ -1,11 +1,15 @@
|
||||
#import "TGBridgeServer.h"
|
||||
#import "TGBridgeCommon.h"
|
||||
|
||||
#import <LegacyComponents/LegacyComponents.h>
|
||||
#import <WatchConnectivity/WatchConnectivity.h>
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#ifdef BUCK
|
||||
#import <WatchUtils/WatchUtils.h>
|
||||
#else
|
||||
#import "TGBridgeCommon.h"
|
||||
#import "TGBridgeContext.h"
|
||||
#endif
|
||||
|
||||
@interface TGBridgeSignalManager : NSObject
|
||||
|
||||
|
7
Telegram-iOS/TempMain.m
Normal file
@ -0,0 +1,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, @"Application", @"AppDelegate");
|
||||
}
|
||||
}
|
32
Telegram-iOS/TempRoot.swift
Normal file
@ -0,0 +1,32 @@
|
||||
import Foundation
|
||||
import AsyncDisplayKit
|
||||
import MtProtoKit
|
||||
import SwiftSignalKit
|
||||
import SSignalKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import LegacyComponents
|
||||
import HockeySDK
|
||||
import Lottie
|
||||
import WebP
|
||||
import FFMpeg
|
||||
import TelegramUIPrivateModule
|
||||
|
||||
func test() {
|
||||
let _ = ASDisplayNode()
|
||||
let _ = MTProto()
|
||||
let _ = Signal<Never, NoError> { subscriber in
|
||||
return ActionDisposable {
|
||||
}
|
||||
}
|
||||
let _ = SSignal(generator: { subscriber in
|
||||
return SBlockDisposable {
|
||||
}
|
||||
})
|
||||
let _ = ListView()
|
||||
let _ = SqliteValueBox(basePath: "", queue: .mainQueue(), encryptionParameters: nil, upgradeProgress: { _ in }, inMemory: true)
|
||||
initializeAccountManagement()
|
||||
BITHockeyManager.shared().crashManager.crashManagerStatus = .alwaysAsk
|
||||
let _ = LOTComposition(json: [:])
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramUI
|
||||
#if BUCK
|
||||
import WatchUtils
|
||||
#endif
|
||||
|
||||
func makePeerIdFromBridgeIdentifier(_ identifier: Int64) -> PeerId? {
|
||||
if identifier < 0 && identifier > Int32.min {
|
||||
|
@ -4,6 +4,11 @@ import Postbox
|
||||
import TelegramCore
|
||||
import TelegramUI
|
||||
|
||||
#if BUCK
|
||||
import WatchUtils
|
||||
import AppBinaryPrivate
|
||||
#endif
|
||||
|
||||
final class WatchCommunicationManager {
|
||||
private let queue: Queue
|
||||
private let allowBackgroundTimeExtension: (Double) -> Void
|
||||
|
@ -5,6 +5,9 @@ import Display
|
||||
import TelegramCore
|
||||
import TelegramUI
|
||||
import LegacyComponents
|
||||
#if BUCK
|
||||
import WatchUtils
|
||||
#endif
|
||||
|
||||
let allWatchRequestHandlers: [AnyClass] = [
|
||||
WatchChatListHandler.self,
|
||||
@ -695,7 +698,7 @@ final class WatchAudioHandler: WatchRequestHandler {
|
||||
}
|
||||
}
|
||||
//let outputPath = manager.watchTemporaryStorePath + "/\(key).opus"
|
||||
} else if let args = subscription as? TGBridgeAudioSentSubscription {
|
||||
} else if let _ = subscription as? TGBridgeAudioSentSubscription {
|
||||
|
||||
}
|
||||
return SSignal.fail(nil)
|
||||
|
@ -4337,10 +4337,62 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"Appearance.AppIcon" = "App Icon";
|
||||
"Appearance.AppIconDefault" = "Default";
|
||||
"Appearance.AppIconDefaultX" = "Default X";
|
||||
"Appearance.AppIconClassic" = "Classic";
|
||||
"Appearance.AppIconClassicX" = "Classic X";
|
||||
"Appearance.AppIconFilled" = "Filled";
|
||||
"Appearance.AppIconFilledX" = "Filled X";
|
||||
|
||||
"Appearance.ThemeCarouselClassic" = "Classic";
|
||||
"Appearance.ThemeCarouselDay" = "Filled";
|
||||
"Appearance.ThemeCarouselNightBlue" = "Dark";
|
||||
"Appearance.ThemeCarouselDay" = "Day";
|
||||
"Appearance.ThemeCarouselNightBlue" = "Night Blue";
|
||||
"Appearance.ThemeCarouselNight" = "Monochrome";
|
||||
|
||||
"Notification.Exceptions.DeleteAll" = "Delete All";
|
||||
"Notification.Exceptions.Add" = "Add";
|
||||
"Exceptions.AddToExceptions" = "ADD TO EXCEPTIONS";
|
||||
|
||||
"Notification.Exceptions.NewException.MessagePreviewHeader" = "MESSAGE PREVIEW";
|
||||
"Notification.Exceptions.PreviewAlwaysOn" = "Show Preview";
|
||||
"Notification.Exceptions.PreviewAlwaysOff" = "Hide Preview";
|
||||
"Notification.Exceptions.RemoveFromExceptions" = "Remove from Exceptions";
|
||||
"Conversation.Block" = "Block";
|
||||
"Conversation.ShareMyPhoneNumber" = "Share My Phone Number";
|
||||
"Conversation.AddToContacts" = "Add to Contacts";
|
||||
|
||||
"AddContact.ContactWillBeSharedNow" = "When you tap **Done**, your phone number will become visible to %@.";
|
||||
"AddContact.ContactWillBeSharedAfterMutual" = "Phone number vill be visible once %1$@ adds you as a contact. Your phone number will become visible to %1$@.";
|
||||
"AddContact.StatusSuccess" = "%@ is now in your contacts list.";
|
||||
"Conversation.ShareMyPhoneNumber.StatusSuccess" = "%@ can now see your phone number.";
|
||||
|
||||
"Group.EditAdmin.TransferOwnership" = "Transfer Group Ownership";
|
||||
"Channel.EditAdmin.TransferOwnership" = "Transfer Channel Ownership";
|
||||
|
||||
"OwnershipTransfer.SecurityCheck" = "Security Check";
|
||||
"OwnershipTransfer.SecurityRequirements" = "Ownership transfers are available if:\n\n• 2-Step verification was enabled for your account more than **7 days** ago.\n\n• You have logged in on this device more than **24 hours** ago.";
|
||||
"OwnershipTransfer.ComeBackLater" = "\n\nPlease come back later.";
|
||||
"OwnershipTransfer.SetupTwoStepAuth" = "Enable 2-Step Verification";
|
||||
|
||||
"Channel.OwnershipTransfer.Title" = "Transfer Channel Ownership";
|
||||
"Channel.OwnershipTransfer.DescriptionInfo" = "This will transfer the full **owner rights** for **%1$@** to **%2$@**.\n\nYou will no longer be considered the creator of the channel. The new owner will be free to remove any of your admin privileges or even ban you.";
|
||||
"Group.OwnershipTransfer.Title" = "Transfer Group Ownership";
|
||||
"Group.OwnershipTransfer.DescriptionInfo" = "This will transfer the full **owner rights** for **%1$@** to **%2$@**.\n\nYou will no longer be considered the creator of the group. The new owner will be free to remove any of your admin privileges or even ban you.";
|
||||
"Channel.OwnershipTransfer.ChangeOwner" = "Change Owner";
|
||||
|
||||
"Channel.OwnershipTransfer.EnterPassword" = "Enter Password";
|
||||
"Channel.OwnershipTransfer.EnterPasswordText" = "Please enter your 2-Step Verification password to complete the transfer.";
|
||||
"Channel.OwnershipTransfer.PasswordPlaceholder" = "Password";
|
||||
|
||||
"Channel.OwnershipTransfer.TransferCompleted" = "**%1$@** is now the owner of **%2$@**";
|
||||
|
||||
"Contacts.AddPeopleNearby" = "Add People Nearby";
|
||||
|
||||
"PeopleNearby.Title" = "People Nearby";
|
||||
"PeopleNearby.Description" = "Use this section to quickly find people and groups near you.";
|
||||
"PeopleNearby.Users" = "People Around You";
|
||||
"PeopleNearby.UsersEmpty" = "No one else is viewing \"People Nearby\" around you now";
|
||||
"PeopleNearby.Groups" = "Groups Around You";
|
||||
"PeopleNearby.CreateGroup" = "Start a Group Chat Here";
|
||||
"PeopleNearby.Channels" = "Channels Around You";
|
||||
|
||||
"Channel.Management.LabelOwner" = "Owner";
|
||||
"Channel.Management.LabelAdministrator" = "Administrator";
|
||||
|
76
Watch/BUCK
Normal file
@ -0,0 +1,76 @@
|
||||
load('//tools:buck_utils.bzl', 'config_with_updated_linker_flags', 'configs_with_config')
|
||||
load('//tools:buck_defs.bzl', 'combined_config', 'SHARED_CONFIGS', 'LIB_SPECIFIC_CONFIG')
|
||||
|
||||
apple_library(
|
||||
name = 'WatchUtils',
|
||||
srcs = [
|
||||
'Bridge/TGBridgeCommon.m',
|
||||
'Bridge/TGBridgeContactMediaAttachment.m',
|
||||
'Bridge/TGBridgeVideoMediaAttachment.m',
|
||||
'Bridge/TGBridgeSubscriptions.m',
|
||||
'Bridge/TGBridgeLocationVenue.m',
|
||||
'Bridge/TGBridgeImageMediaAttachment.m',
|
||||
'Bridge/TGBridgeBotInfo.m',
|
||||
'Bridge/TGBridgeChatMessages.m',
|
||||
'Bridge/TGBridgeMessage.m',
|
||||
'Bridge/TGBridgeUnsupportedMediaAttachment.m',
|
||||
'Bridge/TGBridgeChat.m',
|
||||
'Bridge/TGBridgeForwardedMessageMediaAttachment.m',
|
||||
'Bridge/TGBridgeMessageEntities.m',
|
||||
'Bridge/TGBridgeLocationMediaAttachment.m',
|
||||
'Bridge/TGBridgeMessageEntitiesAttachment.m',
|
||||
'Bridge/TGBridgeReplyMarkupMediaAttachment.m',
|
||||
'Bridge/TGBridgeWebPageMediaAttachment.m',
|
||||
'Bridge/TGBridgeDocumentMediaAttachment.m',
|
||||
'Bridge/TGBridgeActionMediaAttachment.m',
|
||||
'Bridge/TGBridgeContext.m',
|
||||
'Bridge/TGBridgeMediaAttachment.m',
|
||||
'Bridge/TGBridgeUser.m',
|
||||
'Bridge/TGBridgeBotCommandInfo.m',
|
||||
'Bridge/TGBridgeAudioMediaAttachment.m',
|
||||
'Bridge/TGBridgeReplyMessageMediaAttachment.m',
|
||||
],
|
||||
headers = glob([
|
||||
'Bridge/*.h',
|
||||
'Extension/*.h',
|
||||
]),
|
||||
header_namespace = 'WatchUtils',
|
||||
exported_headers = [
|
||||
'Bridge/TGBridgeCommon.h',
|
||||
'Bridge/TGBridgeContactMediaAttachment.h',
|
||||
'Bridge/TGBridgeVideoMediaAttachment.h',
|
||||
'Bridge/TGBridgeSubscriptions.h',
|
||||
'Bridge/TGBridgeLocationVenue.h',
|
||||
'Bridge/TGBridgeImageMediaAttachment.h',
|
||||
'Bridge/TGBridgeBotInfo.h',
|
||||
'Bridge/TGBridgeChatMessages.h',
|
||||
'Bridge/TGBridgeMessage.h',
|
||||
'Bridge/TGBridgeUnsupportedMediaAttachment.h',
|
||||
'Bridge/TGBridgeChat.h',
|
||||
'Bridge/TGBridgeForwardedMessageMediaAttachment.h',
|
||||
'Bridge/TGBridgeMessageEntities.h',
|
||||
'Bridge/TGBridgeLocationMediaAttachment.h',
|
||||
'Bridge/TGBridgeMessageEntitiesAttachment.h',
|
||||
'Bridge/TGBridgeReplyMarkupMediaAttachment.h',
|
||||
'Bridge/TGBridgeWebPageMediaAttachment.h',
|
||||
'Bridge/TGBridgeDocumentMediaAttachment.h',
|
||||
'Bridge/TGBridgeActionMediaAttachment.h',
|
||||
'Bridge/TGBridgeContext.h',
|
||||
'Bridge/TGBridgeMediaAttachment.h',
|
||||
'Bridge/TGBridgeUser.h',
|
||||
'Bridge/TGBridgeBotCommandInfo.h',
|
||||
'Bridge/TGBridgeAudioMediaAttachment.h',
|
||||
'Bridge/TGBridgeReplyMessageMediaAttachment.h',
|
||||
],
|
||||
modular = True,
|
||||
configs = configs_with_config(combined_config([SHARED_CONFIGS, LIB_SPECIFIC_CONFIG])),
|
||||
compiler_flags = [
|
||||
'-w',
|
||||
],
|
||||
preprocessor_flags = ['-fobjc-arc'],
|
||||
visibility = ['PUBLIC'],
|
||||
frameworks = [
|
||||
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
|
||||
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
||||
],
|
||||
)
|
@ -1 +1 @@
|
||||
Subproject commit 884a0159bc310c6aea0dfa774a59e62e391f0226
|
||||
Subproject commit 0c179e7b4f550a477fba8dbe0eaecf0e8d1b6e5d
|
@ -1 +1 @@
|
||||
Subproject commit 0495e4606b6a109f951f963c95b3d57ed5e031ff
|
||||
Subproject commit d70c897a5c565f789a7f185233d18ff541acca27
|
20
tools/buck_defs.bzl
Normal file
@ -0,0 +1,20 @@
|
||||
SHARED_CONFIGS = {
|
||||
'IPHONEOS_DEPLOYMENT_TARGET': '8.0', # common target version
|
||||
'SDKROOT': 'iphoneos', # platform
|
||||
'GCC_OPTIMIZATION_LEVEL': '0', # clang optimization
|
||||
'SWIFT_OPTIMIZATION_LEVEL': '-Onone', # swiftc optimization
|
||||
'SWIFT_WHOLE_MODULE_OPTIMIZATION': 'NO', # for build performance
|
||||
'ONLY_ACTIVE_ARCH': 'YES',
|
||||
'LD_RUNPATH_SEARCH_PATHS': '@executable_path/Frameworks', # To allow source files in binary
|
||||
}
|
||||
|
||||
LIB_SPECIFIC_CONFIG = {
|
||||
'SKIP_INSTALL': 'YES',
|
||||
'APPLICATION_EXTENSION_API_ONLY': 'YES',
|
||||
}
|
||||
|
||||
def combined_config(dicts):
|
||||
result = dict()
|
||||
for d in dicts:
|
||||
result.update(d)
|
||||
return result
|
108
tools/buck_utils.bzl
Normal file
@ -0,0 +1,108 @@
|
||||
OTHER_LINKER_FLAGS_KEY = 'OTHER_LDFLAGS'
|
||||
|
||||
# Either appends or assigns `other_linker_flags` to `config` under `config_key`.
|
||||
# Params:
|
||||
# - config: A dictionary of config names and their values
|
||||
# - additional_linker_flags: A string-representable value of additional linker flags
|
||||
# - config_key: The key to which to append or assign the additional linker flags
|
||||
def config_with_updated_linker_flags(config, other_linker_flags, config_key=OTHER_LINKER_FLAGS_KEY):
|
||||
new_config = { }
|
||||
config_key_found = False
|
||||
for key in config:
|
||||
if key == config_key:
|
||||
new_config[key] = config[key] + (" %s" % other_linker_flags)
|
||||
config_key_found = True
|
||||
else:
|
||||
new_config[key] = config[key]
|
||||
|
||||
if config_key_found == False:
|
||||
# If `config` does not currently contain `config_key`, add it. Inherit for good measure.
|
||||
new_config[config_key] = '$(inherited) ' + other_linker_flags
|
||||
|
||||
return new_config
|
||||
|
||||
# Creates a dictionary where the top level keys are the supported build configurations and the value of each key is `config`.
|
||||
def configs_with_config(config):
|
||||
return {
|
||||
"Debug": config,
|
||||
"Profile": config,
|
||||
"Release": config,
|
||||
}
|
||||
|
||||
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], d[key]),
|
||||
)
|
||||
result.update(d)
|
||||
return result
|
||||
|
||||
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]
|
||||
|
||||
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
|