diff --git a/.buckconfig b/.buckconfig new file mode 100644 index 0000000000..821cb2c82f --- /dev/null +++ b/.buckconfig @@ -0,0 +1,22 @@ +[cxx] + default_platform = iphonesimulator-x86_64 + combined_preprocess_and_compile = true + +[apple] + iphonesimulator_target_sdk_version = 8.0 + iphoneos_target_sdk_version = 8.0 + xctool_default_destination_specifier = platform=iOS Simulator, name=iPhone 6, OS=10.2 + +[alias] + lib = //:AsyncDisplayKit + tests = //:Tests + +[httpserver] + port = 8080 + +[project] + ide = xcode + ignore = .buckd, \ + .hg, \ + .git, \ + buck-out, \ diff --git a/.buckversion b/.buckversion new file mode 100644 index 0000000000..5dab7b7198 --- /dev/null +++ b/.buckversion @@ -0,0 +1 @@ +c948c20ebb155904909af05cfd16428a6992b98d diff --git a/.gitignore b/.gitignore index 7669d5a445..adb7e5eecc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,8 @@ build timeline.xctimeline playground.xcworkspace +# Buck +/buck-out +/.buckconfig.local +/.buckd + diff --git a/AsyncDisplayKit.podspec b/AsyncDisplayKit.podspec index dbe5b7abbd..ed06972a21 100644 --- a/AsyncDisplayKit.podspec +++ b/AsyncDisplayKit.podspec @@ -26,7 +26,7 @@ Pod::Spec.new do |spec| 'AsyncDisplayKit/Layout/*.h', 'Base/*.h', 'AsyncDisplayKit/Debug/ASLayoutElementInspectorNode.h', - 'AsyncDisplayKit/TextKit/ASTextNodeTypes.h', + 'AsyncDisplayKit/TextKit/ASTextNodeTypes.h', 'AsyncDisplayKit/TextKit/ASTextKitComponents.h' ] diff --git a/AsyncDisplayKitTests/ASLayoutElementStyleTests.m b/AsyncDisplayKitTests/ASLayoutElementStyleTests.m index 5a7e7cbe8b..bbcf1fe78b 100644 --- a/AsyncDisplayKitTests/ASLayoutElementStyleTests.m +++ b/AsyncDisplayKitTests/ASLayoutElementStyleTests.m @@ -8,6 +8,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // +#import #import "ASXCTExtensions.h" #import "ASLayoutElement.h" diff --git a/AsyncDisplayKitTests/ASTableViewThrashTests.m b/AsyncDisplayKitTests/ASTableViewThrashTests.m index 07f23f5f8e..eea003b7b0 100644 --- a/AsyncDisplayKitTests/ASTableViewThrashTests.m +++ b/AsyncDisplayKitTests/ASTableViewThrashTests.m @@ -6,7 +6,7 @@ // Copyright © 2016 Facebook. All rights reserved. // -@import XCTest; +#import #import #import "ASTableViewInternal.h" #import "ASTableView+Undeprecated.h" diff --git a/BUCK b/BUCK new file mode 100755 index 0000000000..dc31a9beaf --- /dev/null +++ b/BUCK @@ -0,0 +1,204 @@ +##################################### +# Defines +##################################### +COMMON_PREPROCESSOR_FLAGS = [ + '-fobjc-arc', + '-DDEBUG=1', +] + +COMMON_LANG_PREPROCESSOR_FLAGS = { + 'C': ['-std=gnu99'], + 'CXX': ['-std=c++11', '-stdlib=libc++'], + 'OBJCXX': ['-std=c++11', '-stdlib=libc++'], +} + +COMMON_LINKER_FLAGS = ['-ObjC++'] + +ASYNCDISPLAYKIT_EXPORTED_HEADERS = glob([ + 'AsyncDisplayKit/*.h', + 'AsyncDisplayKit/Details/**/*.h', + 'AsyncDisplayKit/Layout/*.h', + 'Base/*.h', + 'AsyncDisplayKit/Debug/ASLayoutElementInspectorNode.h', + # Most TextKit components are not public because the C++ content + # in the headers will cause build errors when using + # `use_frameworks!` on 0.39.0 & Swift 2.1. + # See https://github.com/facebook/AsyncDisplayKit/issues/1153 + 'AsyncDisplayKit/TextKit/ASTextNodeTypes.h', + 'AsyncDisplayKit/TextKit/ASTextKitComponents.h' +]) + +ASYNCDISPLAYKIT_PRIVATE_HEADERS = glob([ + 'AsyncDisplayKit/**/*.h' + ], + excludes = ASYNCDISPLAYKIT_EXPORTED_HEADERS, +) + +def asyncdisplaykit_library( + name, + additional_preprocessor_flags = [], + deps = [], + additional_frameworks = []): + + apple_library( + name = name, + prefix_header = 'AsyncDisplayKit/AsyncDisplayKit-Prefix.pch', + header_path_prefix = 'AsyncDisplayKit', + exported_headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS, + headers = ASYNCDISPLAYKIT_PRIVATE_HEADERS, + srcs = glob([ + 'AsyncDisplayKit/**/*.m', + 'AsyncDisplayKit/**/*.mm', + 'Base/*.m' + ]), + preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + additional_preprocessor_flags, + lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS, + linker_flags = COMMON_LINKER_FLAGS + [ + '-weak_framework', + 'Photos', + '-weak_framework', + 'MapKit', + ], + deps = deps, + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + '$SDKROOT/System/Library/Frameworks/UIKit.framework', + '$SDKROOT/System/Library/Frameworks/AssetsLibrary.framework', + + '$SDKROOT/System/Library/Frameworks/QuartzCore.framework', + '$SDKROOT/System/Library/Frameworks/CoreMedia.framework', + '$SDKROOT/System/Library/Frameworks/CoreText.framework', + '$SDKROOT/System/Library/Frameworks/CoreGraphics.framework', + '$SDKROOT/System/Library/Frameworks/CoreLocation.framework', + '$SDKROOT/System/Library/Frameworks/AVFoundation.framework', + ] + additional_frameworks, + visibility = ['PUBLIC'], + ) + +##################################### +# AsyncDisplayKit targets +##################################### +asyncdisplaykit_library( + name = 'AsyncDisplayKit-Core', +) + +# (Default) AsyncDisplayKit and AsyncDisplayKit-PINRemoteImage targets are basically the same library with different names +for name in ['AsyncDisplayKit', 'AsyncDisplayKit-PINRemoteImage']: + asyncdisplaykit_library( + name = name, + additional_preprocessor_flags = ['-DPIN_REMOTE_IMAGE=1'], + deps = [ + '//Pods/PINRemoteImage:PINRemoteImage-PINCache', + ], + additional_frameworks = [ + '$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework', + ] + ) + +##################################### +# Test Host +# TODO: Split to smaller BUCK files and parse in parallel +##################################### +apple_resource( + name = 'TestHostResources', + files = ['Default-568h@2x.png'], + dirs = [], +) + +apple_bundle( + name = 'TestHost', + binary = ':TestHostBinary', + extension = 'app', + info_plist = 'AsyncDisplayKitTestHost/Info.plist', + info_plist_substitutions = { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTestHost', + }, + tests = [':Tests'], +) + +apple_binary( + name = 'TestHostBinary', + headers = glob(['AsyncDisplayKitTestHost/*.h']), + srcs = glob([ + 'AsyncDisplayKitTestHost/*.m', + 'AsyncDisplayKitTestHost/*.mm', + ]), + lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS, + linker_flags = COMMON_LINKER_FLAGS, + deps = [ + ':TestHostResources', + ':AsyncDisplayKit-Core', + ], + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Photos.framework', + '$SDKROOT/System/Library/Frameworks/MapKit.framework', + ], +) + +apple_package( + name = 'TestHostPackage', + bundle = ':TestHost', +) + +##################################### +# Tests +##################################### +apple_resource( + name = 'TestsResources', + files = ['AsyncDisplayKitTests/en.lproj/InfoPlist.strings'], + dirs = ['AsyncDisplayKitTests/TestResources'], +) + +apple_resource( + name = 'SnapshotTestsResources', + files = [], + dirs = [ + 'AsyncDisplayKitTests/ReferenceImages_32', + 'AsyncDisplayKitTests/ReferenceImages_64', + 'AsyncDisplayKitTests/ReferenceImages_iOS_10', + ], +) + +apple_test( + name = 'Tests', + test_host_app = ':TestHost', + info_plist = 'AsyncDisplayKitTests/AsyncDisplayKitTests-Info.plist', + info_plist_substitutions = { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTests', + }, + prefix_header = 'AsyncDisplayKitTests/AsyncDisplayKitTests-Prefix.pch', + # Expose all ASDK headers to tests + headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob([ + 'AsyncDisplayKitTests/*.h', + ]), + srcs = glob([ + 'AsyncDisplayKitTests/*.m', + 'AsyncDisplayKitTests/*.mm' + ], + # ASTextNodePerformanceTests are excluded (#2173) + excludes = ['AsyncDisplayKitTests/ASTextNodePerformanceTests.m*'] + ), + preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [ + '-Wno-implicit-function-declaration', + ], + lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS, + linker_flags = COMMON_LINKER_FLAGS, + deps = [ + ':TestsResources', + ':SnapshotTestsResources', + '//Pods/OCMock:OCMock', + '//Pods/FBSnapshotTestCase:FBSnapshotTestCase', + '//Pods/JGMethodSwizzler:JGMethodSwizzler', + ], + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + '$SDKROOT/System/Library/Frameworks/UIKit.framework', + + '$SDKROOT/System/Library/Frameworks/CoreMedia.framework', + '$SDKROOT/System/Library/Frameworks/CoreText.framework', + '$SDKROOT/System/Library/Frameworks/CoreGraphics.framework', + '$SDKROOT/System/Library/Frameworks/AVFoundation.framework', + + '$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework', + ], +) diff --git a/Podfile b/Podfile index d1b954c71b..5d2d0b7435 100644 --- a/Podfile +++ b/Podfile @@ -2,8 +2,31 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' -target :'AsyncDisplayKitTests' do - pod 'OCMock', '~> 2.2' - pod 'FBSnapshotTestCase/Core', '~> 2.1' - pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master' +#TODO CocoaPods plugin instead? +abstract_target 'Buck' do + pod 'PINRemoteImage', '3.0.0-beta.7' + + target :'AsyncDisplayKitTests' do + pod 'OCMock', '~> 2.2' + pod 'FBSnapshotTestCase/Core', '~> 2.1' + pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master' + end + + post_install do |installer| + require 'fileutils' + + # Assuming we're at the root dir + buck_files_dir = 'buck-files' + if File.directory?(buck_files_dir) + installer.pod_targets.flat_map do |pod_target| + pod_name = pod_target.pod_name + # Copy the file at buck-files/BUCK_pod_name to Pods/pod_name/BUCK, + # override existing file if needed + buck_file = buck_files_dir + '/BUCK_' + pod_name + if File.file?(buck_file) + FileUtils.cp(buck_file, 'Pods/' + pod_name + '/BUCK', :preserve => false) + end + end + end + end end diff --git a/buck-files/BUCK_FBSnapshotTestCase b/buck-files/BUCK_FBSnapshotTestCase new file mode 100755 index 0000000000..c8b969639e --- /dev/null +++ b/buck-files/BUCK_FBSnapshotTestCase @@ -0,0 +1,12 @@ +apple_library( + name = 'FBSnapshotTestCase', + exported_headers = glob(['FBSnapshotTestCase' + '/**/*.h']), + srcs = glob(['FBSnapshotTestCase' + '/**/*.m']), + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + '$SDKROOT/System/Library/Frameworks/UIKit.framework', + '$SDKROOT/System/Library/Frameworks/QuartzCore.framework', + '$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework', + ], + visibility = ['PUBLIC'], +) diff --git a/buck-files/BUCK_FLAnimatedImage b/buck-files/BUCK_FLAnimatedImage new file mode 100755 index 0000000000..f04abd396b --- /dev/null +++ b/buck-files/BUCK_FLAnimatedImage @@ -0,0 +1,18 @@ +apple_library( + name = 'FLAnimatedImage', + exported_headers = glob(['FLAnimatedImage/*.h']), + srcs = glob(['FLAnimatedImage/*.m']), + preprocessor_flags = ['-fobjc-arc', '-Wno-deprecated-declarations'], + lang_preprocessor_flags = { + 'C': ['-std=gnu99'], + 'CXX': ['-std=gnu++11', '-stdlib=libc++'], + }, + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + '$SDKROOT/System/Library/Frameworks/UIKit.framework', + '$SDKROOT/System/Library/Frameworks/ImageIO.framework', + '$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework', + '$SDKROOT/System/Library/Frameworks/QuartzCore.framework', + ], + visibility = ['PUBLIC'], +) diff --git a/buck-files/BUCK_JGMethodSwizzler b/buck-files/BUCK_JGMethodSwizzler new file mode 100755 index 0000000000..169cfa1e01 --- /dev/null +++ b/buck-files/BUCK_JGMethodSwizzler @@ -0,0 +1,9 @@ +apple_library( + name = 'JGMethodSwizzler', + exported_headers = ['JGMethodSwizzler' + '/JGMethodSwizzler.h'], + srcs = ['JGMethodSwizzler' + '/JGMethodSwizzler.m'], + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + ], + visibility = ['PUBLIC'], +) diff --git a/buck-files/BUCK_OCMock b/buck-files/BUCK_OCMock new file mode 100755 index 0000000000..666f844582 --- /dev/null +++ b/buck-files/BUCK_OCMock @@ -0,0 +1,9 @@ +apple_library( + name = 'OCMock', + exported_headers = glob(['Source/OCMock' + '/*.h']), + srcs = glob(['Source/OCMock' + '/*.m']), + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + ], + visibility = ['PUBLIC'], +) diff --git a/buck-files/BUCK_PINCache b/buck-files/BUCK_PINCache new file mode 100755 index 0000000000..660b69f716 --- /dev/null +++ b/buck-files/BUCK_PINCache @@ -0,0 +1,23 @@ +apple_library( + name = 'PINCache', + exported_headers = glob(['PINCache/*.h']), + # PINDiskCache.m should be compiled with '-fobjc-arc-exceptions' (#105) + srcs = + glob(['PINCache/*.m'], excludes = ['PINCache/PINDiskCache.m']) + + [('PINCache/PINDiskCache.m', ['-fobjc-arc-exceptions'])], + preprocessor_flags = ['-fobjc-arc'], + lang_preprocessor_flags = { + 'C': ['-std=gnu99'], + 'CXX': ['-std=gnu++11', '-stdlib=libc++'], + }, + linker_flags = [ + '-weak_framework', + 'UIKit', + '-weak_framework', + 'AppKit', + ], + frameworks = [ + '$SDKROOT/System/Library/Frameworks/Foundation.framework', + ], + visibility = ['PUBLIC'], +) diff --git a/buck-files/BUCK_PINRemoteImage b/buck-files/BUCK_PINRemoteImage new file mode 100755 index 0000000000..95825e4d95 --- /dev/null +++ b/buck-files/BUCK_PINRemoteImage @@ -0,0 +1,93 @@ +##################################### +# Defines +##################################### +COMMON_PREPROCESSOR_FLAGS = ['-fobjc-arc'] + +COMMON_LANG_PREPROCESSOR_FLAGS = { + 'C': ['-std=gnu99'], + 'CXX': ['-std=gnu++11', '-stdlib=libc++'], +} + +FLANIMATEDIMAGE_HEADER_FILES = ['Pod/Classes/Image Categories/FLAnimatedImageView+PINRemoteImage.h'] +FLANIMATEDIMAGE_SOURCE_FILES = ['Pod/Classes/Image Categories/FLAnimatedImageView+PINRemoteImage.m'] + +PINCACHE_HEADER_FILES = glob(['Pod/Classes/PINCache/**/*.h']) +PINCACHE_SOURCE_FILES = glob(['Pod/Classes/PINCache/**/*.m']) + +##################################### +# PINRemoteImage core targets +##################################### +apple_library( + name = 'PINRemoteImage-Core', + header_path_prefix = 'PINRemoteImage', + exported_headers = glob([ + 'Pod/Classes/**/*.h', + ], + excludes = FLANIMATEDIMAGE_HEADER_FILES + PINCACHE_HEADER_FILES + ), + srcs = glob([ + 'Pod/Classes/**/*.m', + ], + excludes = FLANIMATEDIMAGE_SOURCE_FILES + PINCACHE_SOURCE_FILES + ), + preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [ + '-DPIN_TARGET_IOS=(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_TV)', + '-DPIN_TARGET_MAC=(TARGET_OS_MAC)', + ], + lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS, + linker_flags = [ + '-weak_framework', + 'UIKit', + '-weak_framework', + 'MobileCoreServices', + '-weak_framework', + 'Cocoa', + '-weak_framework', + 'CoreServices', + ], + frameworks = [ + '$SDKROOT/System/Library/Frameworks/ImageIO.framework', + '$SDKROOT/System/Library/Frameworks/Accelerate.framework', + ], + visibility = ['PUBLIC'], +) + +apple_library( + name = 'PINRemoteImage', + deps = [ + ':PINRemoteImage-FLAnimatedImage', + ':PINRemoteImage-PINCache' + ], + visibility = ['PUBLIC'], +) + +##################################### +# Other PINRemoteImage targets +##################################### +apple_library( + name = 'PINRemoteImage-FLAnimatedImage', + header_path_prefix = 'PINRemoteImage', + exported_headers = FLANIMATEDIMAGE_HEADER_FILES, + srcs = FLANIMATEDIMAGE_SOURCE_FILES, + preprocessor_flags = COMMON_PREPROCESSOR_FLAGS, + deps = [ + ':PINRemoteImage-Core', + '//Pods/FLAnimatedImage:FLAnimatedImage' + ], + visibility = ['PUBLIC'], +) + +apple_library( + name = 'PINRemoteImage-PINCache', + header_path_prefix = 'PINRemoteImage', + exported_headers = PINCACHE_HEADER_FILES, + srcs = PINCACHE_SOURCE_FILES, + preprocessor_flags = COMMON_PREPROCESSOR_FLAGS, + deps = [ + ':PINRemoteImage-Core', + '//Pods/PINCache:PINCache' + ], + visibility = ['PUBLIC'], +) + +#TODO WebP variants