Skip to content

Commit 1847cd2

Browse files
nguyenhuygarrettmoon
authored andcommitted
Buck improvements: (pinterest#156)
- Merge PINCacheCore, PINCache and PINCacheMacOS targets into a single one. - Compile PINDishCache.m with -fobjc-arc-exceptions flag. - Move test targets to a separate BUCK file. The main BUCK file can be re-used by users in their own projects after dependency resolution (i.e via CocoaPods). - Remove unnecessary preprocessor flags. - Now that we have multiple BUCK files, parse them in parallel. - Specify default xctool destination.
1 parent 373cd45 commit 1847cd2

File tree

3 files changed

+59
-89
lines changed

3 files changed

+59
-89
lines changed

.buckconfig

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
iphonesimulator_target_sdk_version = 5.0
77
iphoneos_target_sdk_version = 5.0
88
macosx_target_sdk_version = 10.7
9+
xctool_default_destination_specifier = platform=iOS Simulator, name=iPhone 6, OS=10.2
910

1011
[alias]
11-
library = //:PINCache
12+
lib = //:PINCache
13+
tests = //tests:Tests
1214

1315
[project]
16+
parallel_parsing = true
1417
ide = xcode
1518
ignore = .buckd, \
1619
.hg, \

BUCK

+9-88
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,23 @@
1-
COMMON_PREPROCESSOR_FLAGS = ['-fobjc-arc', '-Wno-deprecated-declarations', '-Wignored-attributes']
2-
31
apple_library(
4-
name = 'PINCacheCore',
5-
exported_headers = glob([
6-
'PINCache/*.h',
7-
]),
8-
header_path_prefix = 'PINCache',
9-
srcs = glob([
10-
'PINCache/*.m',
11-
]),
2+
name = 'PINCache',
3+
exported_headers = glob(['PINCache/*.h']),
4+
# PINDiskCache.m should be compiled with '-fobjc-arc-exceptions' (#105)
5+
srcs =
6+
glob(['PINCache/*.m'], excludes = ['PINCache/PINDiskCache.m']) +
7+
[('PINCache/PINDiskCache.m', ['-fobjc-arc-exceptions'])],
8+
preprocessor_flags = ['-fobjc-arc'],
129
lang_preprocessor_flags = {
1310
'C': ['-std=gnu99'],
14-
'CXX': ['-std=gnu++11'],
11+
'CXX': ['-std=gnu++11', '-stdlib=libc++'],
1512
},
16-
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS,
17-
frameworks = [
18-
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
19-
],
20-
visibility = [
21-
'PUBLIC',
22-
],
23-
)
24-
25-
#PINCache iOS
26-
apple_library(
27-
name = 'PINCache',
28-
deps = [':PINCacheCore'],
2913
linker_flags = [
3014
'-weak_framework',
3115
'UIKit',
32-
],
33-
visibility = [
34-
'PUBLIC',
35-
],
36-
)
37-
38-
#PINCache MacOS
39-
apple_library(
40-
name = 'PINCacheMacOS',
41-
deps = [':PINCacheCore'],
42-
linker_flags = [
4316
'-weak_framework',
4417
'AppKit',
4518
],
46-
visibility = [
47-
'PUBLIC',
48-
],
49-
)
50-
51-
apple_resource(
52-
name = 'TestAppResources',
53-
files = glob(['tests/PINCache/*.png']),
54-
dirs = [],
55-
)
56-
57-
apple_bundle(
58-
name = 'TestApp',
59-
binary = ':TestAppBinary',
60-
extension = 'app',
61-
info_plist = 'tests/PINCache/PINCache-Info.plist',
62-
tests = [':Tests'],
63-
)
64-
65-
apple_binary(
66-
name = 'TestAppBinary',
67-
prefix_header = 'tests/PINCache/PINCache-Prefix.pch',
68-
headers = glob([
69-
'tests/PINCache/*.h',
70-
]),
71-
srcs = glob([
72-
'tests/PINCache/*.m',
73-
]),
74-
deps = [
75-
':TestAppResources',
76-
':PINCache',
77-
],
78-
frameworks = [
79-
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
80-
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
81-
],
82-
)
83-
84-
apple_package(
85-
name = 'TestAppPackage',
86-
bundle = ':TestApp',
87-
)
88-
89-
apple_test(
90-
name = 'Tests',
91-
test_host_app = ':TestApp',
92-
srcs = glob([
93-
'tests/PINCacheTests/*.m'
94-
]),
95-
info_plist = 'tests/PINCacheTests/PINCacheTests-Info.plist',
96-
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS,
9719
frameworks = [
9820
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
99-
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
100-
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
10121
],
22+
visibility = ['PUBLIC'],
10223
)

tests/BUCK

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apple_resource(
2+
name = 'TestAppResources',
3+
files = glob(['PINCache/*.png']),
4+
dirs = [],
5+
)
6+
7+
apple_bundle(
8+
name = 'TestApp',
9+
binary = ':TestAppBinary',
10+
extension = 'app',
11+
info_plist = 'PINCache/PINCache-Info.plist',
12+
tests = [':Tests'],
13+
)
14+
15+
apple_binary(
16+
name = 'TestAppBinary',
17+
prefix_header = 'PINCache/PINCache-Prefix.pch',
18+
headers = glob(['PINCache/*.h']),
19+
srcs = glob(['PINCache/*.m']),
20+
deps = [
21+
':TestAppResources',
22+
'//:PINCache',
23+
],
24+
frameworks = [
25+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
26+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
27+
],
28+
)
29+
30+
apple_package(
31+
name = 'TestAppPackage',
32+
bundle = ':TestApp',
33+
)
34+
35+
apple_test(
36+
name = 'Tests',
37+
test_host_app = ':TestApp',
38+
srcs = glob(['PINCacheTests/*.m']),
39+
info_plist = 'PINCacheTests/PINCacheTests-Info.plist',
40+
preprocessor_flags = ['-fobjc-arc'],
41+
frameworks = [
42+
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
43+
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
44+
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
45+
],
46+
)

0 commit comments

Comments
 (0)