Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit be6faa1

Browse files
nguyenhuyAdlai Holler
authored andcommitted
Support Buck build (#2849)
* Support Buck build * Simplify pod_install hook and buck-file dir's structure * Update PINRemoteImage's BUCK * Frameworks linking: - Weak linking Photos and MapKit. - Revisit //:Tests' list.
1 parent 513b9f4 commit be6faa1

14 files changed

Lines changed: 426 additions & 6 deletions

.buckconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[cxx]
2+
default_platform = iphonesimulator-x86_64
3+
combined_preprocess_and_compile = true
4+
5+
[apple]
6+
iphonesimulator_target_sdk_version = 8.0
7+
iphoneos_target_sdk_version = 8.0
8+
xctool_default_destination_specifier = platform=iOS Simulator, name=iPhone 6, OS=10.2
9+
10+
[alias]
11+
lib = //:AsyncDisplayKit
12+
tests = //:Tests
13+
14+
[httpserver]
15+
port = 8080
16+
17+
[project]
18+
ide = xcode
19+
ignore = .buckd, \
20+
.hg, \
21+
.git, \
22+
buck-out, \

.buckversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c948c20ebb155904909af05cfd16428a6992b98d

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ build
2929
timeline.xctimeline
3030
playground.xcworkspace
3131

32+
# Buck
33+
/buck-out
34+
/.buckconfig.local
35+
/.buckd
36+

AsyncDisplayKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Pod::Spec.new do |spec|
2626
'AsyncDisplayKit/Layout/*.h',
2727
'Base/*.h',
2828
'AsyncDisplayKit/Debug/ASLayoutElementInspectorNode.h',
29-
'AsyncDisplayKit/TextKit/ASTextNodeTypes.h',
29+
'AsyncDisplayKit/TextKit/ASTextNodeTypes.h',
3030
'AsyncDisplayKit/TextKit/ASTextKitComponents.h'
3131
]
3232

AsyncDisplayKitTests/ASLayoutElementStyleTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// of patent rights can be found in the PATENTS file in the same directory.
99
//
1010

11+
#import <XCTest/XCTest.h>
1112
#import "ASXCTExtensions.h"
1213
#import "ASLayoutElement.h"
1314

AsyncDisplayKitTests/ASTableViewThrashTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2016 Facebook. All rights reserved.
77
//
88

9-
@import XCTest;
9+
#import <XCTest/XCTest.h>
1010
#import <AsyncDisplayKit/AsyncDisplayKit.h>
1111
#import "ASTableViewInternal.h"
1212
#import "ASTableView+Undeprecated.h"

BUCK

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
#####################################
2+
# Defines
3+
#####################################
4+
COMMON_PREPROCESSOR_FLAGS = [
5+
'-fobjc-arc',
6+
'-DDEBUG=1',
7+
]
8+
9+
COMMON_LANG_PREPROCESSOR_FLAGS = {
10+
'C': ['-std=gnu99'],
11+
'CXX': ['-std=c++11', '-stdlib=libc++'],
12+
'OBJCXX': ['-std=c++11', '-stdlib=libc++'],
13+
}
14+
15+
COMMON_LINKER_FLAGS = ['-ObjC++']
16+
17+
ASYNCDISPLAYKIT_EXPORTED_HEADERS = glob([
18+
'AsyncDisplayKit/*.h',
19+
'AsyncDisplayKit/Details/**/*.h',
20+
'AsyncDisplayKit/Layout/*.h',
21+
'Base/*.h',
22+
'AsyncDisplayKit/Debug/ASLayoutElementInspectorNode.h',
23+
# Most TextKit components are not public because the C++ content
24+
# in the headers will cause build errors when using
25+
# `use_frameworks!` on 0.39.0 & Swift 2.1.
26+
# See https://github.com/facebook/AsyncDisplayKit/issues/1153
27+
'AsyncDisplayKit/TextKit/ASTextNodeTypes.h',
28+
'AsyncDisplayKit/TextKit/ASTextKitComponents.h'
29+
])
30+
31+
ASYNCDISPLAYKIT_PRIVATE_HEADERS = glob([
32+
'AsyncDisplayKit/**/*.h'
33+
],
34+
excludes = ASYNCDISPLAYKIT_EXPORTED_HEADERS,
35+
)
36+
37+
def asyncdisplaykit_library(
38+
name,
39+
additional_preprocessor_flags = [],
40+
deps = [],
41+
additional_frameworks = []):
42+
43+
apple_library(
44+
name = name,
45+
prefix_header = 'AsyncDisplayKit/AsyncDisplayKit-Prefix.pch',
46+
header_path_prefix = 'AsyncDisplayKit',
47+
exported_headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS,
48+
headers = ASYNCDISPLAYKIT_PRIVATE_HEADERS,
49+
srcs = glob([
50+
'AsyncDisplayKit/**/*.m',
51+
'AsyncDisplayKit/**/*.mm',
52+
'Base/*.m'
53+
]),
54+
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + additional_preprocessor_flags,
55+
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
56+
linker_flags = COMMON_LINKER_FLAGS + [
57+
'-weak_framework',
58+
'Photos',
59+
'-weak_framework',
60+
'MapKit',
61+
],
62+
deps = deps,
63+
frameworks = [
64+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
65+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
66+
'$SDKROOT/System/Library/Frameworks/AssetsLibrary.framework',
67+
68+
'$SDKROOT/System/Library/Frameworks/QuartzCore.framework',
69+
'$SDKROOT/System/Library/Frameworks/CoreMedia.framework',
70+
'$SDKROOT/System/Library/Frameworks/CoreText.framework',
71+
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
72+
'$SDKROOT/System/Library/Frameworks/CoreLocation.framework',
73+
'$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
74+
] + additional_frameworks,
75+
visibility = ['PUBLIC'],
76+
)
77+
78+
#####################################
79+
# AsyncDisplayKit targets
80+
#####################################
81+
asyncdisplaykit_library(
82+
name = 'AsyncDisplayKit-Core',
83+
)
84+
85+
# (Default) AsyncDisplayKit and AsyncDisplayKit-PINRemoteImage targets are basically the same library with different names
86+
for name in ['AsyncDisplayKit', 'AsyncDisplayKit-PINRemoteImage']:
87+
asyncdisplaykit_library(
88+
name = name,
89+
additional_preprocessor_flags = ['-DPIN_REMOTE_IMAGE=1'],
90+
deps = [
91+
'//Pods/PINRemoteImage:PINRemoteImage-PINCache',
92+
],
93+
additional_frameworks = [
94+
'$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework',
95+
]
96+
)
97+
98+
#####################################
99+
# Test Host
100+
# TODO: Split to smaller BUCK files and parse in parallel
101+
#####################################
102+
apple_resource(
103+
name = 'TestHostResources',
104+
files = ['Default-568h@2x.png'],
105+
dirs = [],
106+
)
107+
108+
apple_bundle(
109+
name = 'TestHost',
110+
binary = ':TestHostBinary',
111+
extension = 'app',
112+
info_plist = 'AsyncDisplayKitTestHost/Info.plist',
113+
info_plist_substitutions = {
114+
'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTestHost',
115+
},
116+
tests = [':Tests'],
117+
)
118+
119+
apple_binary(
120+
name = 'TestHostBinary',
121+
headers = glob(['AsyncDisplayKitTestHost/*.h']),
122+
srcs = glob([
123+
'AsyncDisplayKitTestHost/*.m',
124+
'AsyncDisplayKitTestHost/*.mm',
125+
]),
126+
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
127+
linker_flags = COMMON_LINKER_FLAGS,
128+
deps = [
129+
':TestHostResources',
130+
':AsyncDisplayKit-Core',
131+
],
132+
frameworks = [
133+
'$SDKROOT/System/Library/Frameworks/Photos.framework',
134+
'$SDKROOT/System/Library/Frameworks/MapKit.framework',
135+
],
136+
)
137+
138+
apple_package(
139+
name = 'TestHostPackage',
140+
bundle = ':TestHost',
141+
)
142+
143+
#####################################
144+
# Tests
145+
#####################################
146+
apple_resource(
147+
name = 'TestsResources',
148+
files = ['AsyncDisplayKitTests/en.lproj/InfoPlist.strings'],
149+
dirs = ['AsyncDisplayKitTests/TestResources'],
150+
)
151+
152+
apple_resource(
153+
name = 'SnapshotTestsResources',
154+
files = [],
155+
dirs = [
156+
'AsyncDisplayKitTests/ReferenceImages_32',
157+
'AsyncDisplayKitTests/ReferenceImages_64',
158+
'AsyncDisplayKitTests/ReferenceImages_iOS_10',
159+
],
160+
)
161+
162+
apple_test(
163+
name = 'Tests',
164+
test_host_app = ':TestHost',
165+
info_plist = 'AsyncDisplayKitTests/AsyncDisplayKitTests-Info.plist',
166+
info_plist_substitutions = {
167+
'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTests',
168+
},
169+
prefix_header = 'AsyncDisplayKitTests/AsyncDisplayKitTests-Prefix.pch',
170+
# Expose all ASDK headers to tests
171+
headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob([
172+
'AsyncDisplayKitTests/*.h',
173+
]),
174+
srcs = glob([
175+
'AsyncDisplayKitTests/*.m',
176+
'AsyncDisplayKitTests/*.mm'
177+
],
178+
# ASTextNodePerformanceTests are excluded (#2173)
179+
excludes = ['AsyncDisplayKitTests/ASTextNodePerformanceTests.m*']
180+
),
181+
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [
182+
'-Wno-implicit-function-declaration',
183+
],
184+
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
185+
linker_flags = COMMON_LINKER_FLAGS,
186+
deps = [
187+
':TestsResources',
188+
':SnapshotTestsResources',
189+
'//Pods/OCMock:OCMock',
190+
'//Pods/FBSnapshotTestCase:FBSnapshotTestCase',
191+
'//Pods/JGMethodSwizzler:JGMethodSwizzler',
192+
],
193+
frameworks = [
194+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
195+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
196+
197+
'$SDKROOT/System/Library/Frameworks/CoreMedia.framework',
198+
'$SDKROOT/System/Library/Frameworks/CoreText.framework',
199+
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
200+
'$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
201+
202+
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
203+
],
204+
)

Podfile

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,31 @@ source 'https://github.com/CocoaPods/Specs.git'
22

33
platform :ios, '7.0'
44

5-
target :'AsyncDisplayKitTests' do
6-
pod 'OCMock', '~> 2.2'
7-
pod 'FBSnapshotTestCase/Core', '~> 2.1'
8-
pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master'
5+
#TODO CocoaPods plugin instead?
6+
abstract_target 'Buck' do
7+
pod 'PINRemoteImage', '3.0.0-beta.7'
8+
9+
target :'AsyncDisplayKitTests' do
10+
pod 'OCMock', '~> 2.2'
11+
pod 'FBSnapshotTestCase/Core', '~> 2.1'
12+
pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master'
13+
end
14+
15+
post_install do |installer|
16+
require 'fileutils'
17+
18+
# Assuming we're at the root dir
19+
buck_files_dir = 'buck-files'
20+
if File.directory?(buck_files_dir)
21+
installer.pod_targets.flat_map do |pod_target|
22+
pod_name = pod_target.pod_name
23+
# Copy the file at buck-files/BUCK_pod_name to Pods/pod_name/BUCK,
24+
# override existing file if needed
25+
buck_file = buck_files_dir + '/BUCK_' + pod_name
26+
if File.file?(buck_file)
27+
FileUtils.cp(buck_file, 'Pods/' + pod_name + '/BUCK', :preserve => false)
28+
end
29+
end
30+
end
31+
end
932
end

buck-files/BUCK_FBSnapshotTestCase

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apple_library(
2+
name = 'FBSnapshotTestCase',
3+
exported_headers = glob(['FBSnapshotTestCase' + '/**/*.h']),
4+
srcs = glob(['FBSnapshotTestCase' + '/**/*.m']),
5+
frameworks = [
6+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
7+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
8+
'$SDKROOT/System/Library/Frameworks/QuartzCore.framework',
9+
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
10+
],
11+
visibility = ['PUBLIC'],
12+
)

buck-files/BUCK_FLAnimatedImage

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apple_library(
2+
name = 'FLAnimatedImage',
3+
exported_headers = glob(['FLAnimatedImage/*.h']),
4+
srcs = glob(['FLAnimatedImage/*.m']),
5+
preprocessor_flags = ['-fobjc-arc', '-Wno-deprecated-declarations'],
6+
lang_preprocessor_flags = {
7+
'C': ['-std=gnu99'],
8+
'CXX': ['-std=gnu++11', '-stdlib=libc++'],
9+
},
10+
frameworks = [
11+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
12+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
13+
'$SDKROOT/System/Library/Frameworks/ImageIO.framework',
14+
'$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework',
15+
'$SDKROOT/System/Library/Frameworks/QuartzCore.framework',
16+
],
17+
visibility = ['PUBLIC'],
18+
)

0 commit comments

Comments
 (0)