diff --git a/talk/base/iosfilesystem.mm b/talk/base/iosfilesystem.mm new file mode 100644 index 000000000..aaefcb03f --- /dev/null +++ b/talk/base/iosfilesystem.mm @@ -0,0 +1,70 @@ +/* + * libjingle + * Copyright 2014 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This file only exists because various iOS system APIs are only +// available from Objective-C. See unixfilesystem.cc for the only use +// (enforced by a lack of a header file). + +#import +#import +#include + +#include "talk/base/common.h" +#include "talk/base/pathutils.h" + +// Return a new[]'d |char*| copy of the UTF8 representation of |s|. +// Caller owns the returned memory and must use delete[] on it. +static char* copyString(NSString* s) { + const char* utf8 = [s UTF8String]; + size_t len = strlen(utf8) + 1; + char* copy = new char[len]; + // This uses a new[] + strcpy (instead of strdup) because the + // receiver expects to be able to delete[] the returned pointer + // (instead of free()ing it). + strcpy(copy, utf8); + return copy; +} + +// Return a (leaked) copy of a directory name suitable for application data. +char* IOSDataDirectory() { + NSArray* paths = NSSearchPathForDirectoriesInDomains( + NSApplicationSupportDirectory, NSUserDomainMask, YES); + ASSERT([paths count] == 1); + return copyString([paths objectAtIndex:0]); +} + +// Return a (leaked) copy of a directory name suitable for use as a $TEMP. +char* IOSTempDirectory() { + return copyString(NSTemporaryDirectory()); +} + +// Return the binary's path. +void IOSAppName(talk_base::Pathname* path) { + NSProcessInfo *pInfo = [NSProcessInfo processInfo]; + NSString* argv0 = [[pInfo arguments] objectAtIndex:0]; + path->SetPathname([argv0 UTF8String]); +} diff --git a/talk/base/optionsfile_unittest.cc b/talk/base/optionsfile_unittest.cc index 65861ff49..afb79cf9a 100644 --- a/talk/base/optionsfile_unittest.cc +++ b/talk/base/optionsfile_unittest.cc @@ -25,19 +25,13 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "talk/base/fileutils.h" #include "talk/base/gunit.h" #include "talk/base/optionsfile.h" +#include "talk/base/pathutils.h" namespace talk_base { -#ifdef ANDROID -static const char *kTestFile = "/sdcard/.testfile"; -#elif CHROMEOS -static const char *kTestFile = "/tmp/.testfile"; -#else -static const char *kTestFile = ".testfile"; -#endif - static const std::string kTestOptionA = "test-option-a"; static const std::string kTestOptionB = "test-option-b"; static const std::string kTestString1 = "a string"; @@ -56,122 +50,135 @@ static int kTestInt2 = 67890; static int kNegInt = -634; static int kZero = 0; -TEST(OptionsFile, GetSetString) { - OptionsFile store(kTestFile); +class OptionsFileTest : public testing::Test { + public: + OptionsFileTest() { + Pathname dir; + ASSERT(Filesystem::GetTemporaryFolder(dir, true, NULL)); + test_file_ = Filesystem::TempFilename(dir, ".testfile"); + OpenStore(); + } + + protected: + void OpenStore() { + store_.reset(new OptionsFile(test_file_)); + } + + talk_base::scoped_ptr store_; + + private: + std::string test_file_; +}; + +TEST_F(OptionsFileTest, GetSetString) { // Clear contents of the file on disk. - EXPECT_TRUE(store.Save()); + EXPECT_TRUE(store_->Save()); std::string out1, out2; - EXPECT_FALSE(store.GetStringValue(kTestOptionA, &out1)); - EXPECT_FALSE(store.GetStringValue(kTestOptionB, &out2)); - EXPECT_TRUE(store.SetStringValue(kTestOptionA, kTestString1)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.SetStringValue(kTestOptionB, kTestString2)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetStringValue(kTestOptionA, &out1)); - EXPECT_TRUE(store.GetStringValue(kTestOptionB, &out2)); + EXPECT_FALSE(store_->GetStringValue(kTestOptionA, &out1)); + EXPECT_FALSE(store_->GetStringValue(kTestOptionB, &out2)); + EXPECT_TRUE(store_->SetStringValue(kTestOptionA, kTestString1)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->SetStringValue(kTestOptionB, kTestString2)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetStringValue(kTestOptionA, &out1)); + EXPECT_TRUE(store_->GetStringValue(kTestOptionB, &out2)); EXPECT_EQ(kTestString1, out1); EXPECT_EQ(kTestString2, out2); - EXPECT_TRUE(store.RemoveValue(kTestOptionA)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.RemoveValue(kTestOptionB)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_FALSE(store.GetStringValue(kTestOptionA, &out1)); - EXPECT_FALSE(store.GetStringValue(kTestOptionB, &out2)); + EXPECT_TRUE(store_->RemoveValue(kTestOptionA)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->RemoveValue(kTestOptionB)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_FALSE(store_->GetStringValue(kTestOptionA, &out1)); + EXPECT_FALSE(store_->GetStringValue(kTestOptionB, &out2)); } -TEST(OptionsFile, GetSetInt) { - OptionsFile store(kTestFile); +TEST_F(OptionsFileTest, GetSetInt) { // Clear contents of the file on disk. - EXPECT_TRUE(store.Save()); + EXPECT_TRUE(store_->Save()); int out1, out2; - EXPECT_FALSE(store.GetIntValue(kTestOptionA, &out1)); - EXPECT_FALSE(store.GetIntValue(kTestOptionB, &out2)); - EXPECT_TRUE(store.SetIntValue(kTestOptionA, kTestInt1)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.SetIntValue(kTestOptionB, kTestInt2)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetIntValue(kTestOptionA, &out1)); - EXPECT_TRUE(store.GetIntValue(kTestOptionB, &out2)); + EXPECT_FALSE(store_->GetIntValue(kTestOptionA, &out1)); + EXPECT_FALSE(store_->GetIntValue(kTestOptionB, &out2)); + EXPECT_TRUE(store_->SetIntValue(kTestOptionA, kTestInt1)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->SetIntValue(kTestOptionB, kTestInt2)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetIntValue(kTestOptionA, &out1)); + EXPECT_TRUE(store_->GetIntValue(kTestOptionB, &out2)); EXPECT_EQ(kTestInt1, out1); EXPECT_EQ(kTestInt2, out2); - EXPECT_TRUE(store.RemoveValue(kTestOptionA)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.RemoveValue(kTestOptionB)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_FALSE(store.GetIntValue(kTestOptionA, &out1)); - EXPECT_FALSE(store.GetIntValue(kTestOptionB, &out2)); - EXPECT_TRUE(store.SetIntValue(kTestOptionA, kNegInt)); - EXPECT_TRUE(store.GetIntValue(kTestOptionA, &out1)); + EXPECT_TRUE(store_->RemoveValue(kTestOptionA)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->RemoveValue(kTestOptionB)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_FALSE(store_->GetIntValue(kTestOptionA, &out1)); + EXPECT_FALSE(store_->GetIntValue(kTestOptionB, &out2)); + EXPECT_TRUE(store_->SetIntValue(kTestOptionA, kNegInt)); + EXPECT_TRUE(store_->GetIntValue(kTestOptionA, &out1)); EXPECT_EQ(kNegInt, out1); - EXPECT_TRUE(store.SetIntValue(kTestOptionA, kZero)); - EXPECT_TRUE(store.GetIntValue(kTestOptionA, &out1)); + EXPECT_TRUE(store_->SetIntValue(kTestOptionA, kZero)); + EXPECT_TRUE(store_->GetIntValue(kTestOptionA, &out1)); EXPECT_EQ(kZero, out1); } -TEST(OptionsFile, Persist) { - { - OptionsFile store(kTestFile); - // Clear contents of the file on disk. - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.SetStringValue(kTestOptionA, kTestString1)); - EXPECT_TRUE(store.SetIntValue(kTestOptionB, kNegInt)); - EXPECT_TRUE(store.Save()); - } - { - OptionsFile store(kTestFile); - // Load the saved contents from above. - EXPECT_TRUE(store.Load()); - std::string out1; - int out2; - EXPECT_TRUE(store.GetStringValue(kTestOptionA, &out1)); - EXPECT_TRUE(store.GetIntValue(kTestOptionB, &out2)); - EXPECT_EQ(kTestString1, out1); - EXPECT_EQ(kNegInt, out2); - } +TEST_F(OptionsFileTest, Persist) { + // Clear contents of the file on disk. + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->SetStringValue(kTestOptionA, kTestString1)); + EXPECT_TRUE(store_->SetIntValue(kTestOptionB, kNegInt)); + EXPECT_TRUE(store_->Save()); + + // Load the saved contents from above. + OpenStore(); + EXPECT_TRUE(store_->Load()); + std::string out1; + int out2; + EXPECT_TRUE(store_->GetStringValue(kTestOptionA, &out1)); + EXPECT_TRUE(store_->GetIntValue(kTestOptionB, &out2)); + EXPECT_EQ(kTestString1, out1); + EXPECT_EQ(kNegInt, out2); } -TEST(OptionsFile, SpecialCharacters) { - OptionsFile store(kTestFile); +TEST_F(OptionsFileTest, SpecialCharacters) { // Clear contents of the file on disk. - EXPECT_TRUE(store.Save()); + EXPECT_TRUE(store_->Save()); std::string out; - EXPECT_FALSE(store.SetStringValue(kOptionWithEquals, kTestString1)); - EXPECT_FALSE(store.GetStringValue(kOptionWithEquals, &out)); - EXPECT_FALSE(store.SetStringValue(kOptionWithNewline, kTestString1)); - EXPECT_FALSE(store.GetStringValue(kOptionWithNewline, &out)); - EXPECT_TRUE(store.SetStringValue(kOptionWithUtf8, kValueWithUtf8)); - EXPECT_TRUE(store.SetStringValue(kTestOptionA, kTestString1)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetStringValue(kTestOptionA, &out)); + EXPECT_FALSE(store_->SetStringValue(kOptionWithEquals, kTestString1)); + EXPECT_FALSE(store_->GetStringValue(kOptionWithEquals, &out)); + EXPECT_FALSE(store_->SetStringValue(kOptionWithNewline, kTestString1)); + EXPECT_FALSE(store_->GetStringValue(kOptionWithNewline, &out)); + EXPECT_TRUE(store_->SetStringValue(kOptionWithUtf8, kValueWithUtf8)); + EXPECT_TRUE(store_->SetStringValue(kTestOptionA, kTestString1)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetStringValue(kTestOptionA, &out)); EXPECT_EQ(kTestString1, out); - EXPECT_TRUE(store.GetStringValue(kOptionWithUtf8, &out)); + EXPECT_TRUE(store_->GetStringValue(kOptionWithUtf8, &out)); EXPECT_EQ(kValueWithUtf8, out); - EXPECT_FALSE(store.SetStringValue(kTestOptionA, kValueWithNewline)); - EXPECT_TRUE(store.GetStringValue(kTestOptionA, &out)); + EXPECT_FALSE(store_->SetStringValue(kTestOptionA, kValueWithNewline)); + EXPECT_TRUE(store_->GetStringValue(kTestOptionA, &out)); EXPECT_EQ(kTestString1, out); - EXPECT_TRUE(store.SetStringValue(kTestOptionA, kValueWithEquals)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetStringValue(kTestOptionA, &out)); + EXPECT_TRUE(store_->SetStringValue(kTestOptionA, kValueWithEquals)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetStringValue(kTestOptionA, &out)); EXPECT_EQ(kValueWithEquals, out); - EXPECT_TRUE(store.SetStringValue(kEmptyString, kTestString2)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetStringValue(kEmptyString, &out)); + EXPECT_TRUE(store_->SetStringValue(kEmptyString, kTestString2)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetStringValue(kEmptyString, &out)); EXPECT_EQ(kTestString2, out); - EXPECT_TRUE(store.SetStringValue(kTestOptionB, kEmptyString)); - EXPECT_TRUE(store.Save()); - EXPECT_TRUE(store.Load()); - EXPECT_TRUE(store.GetStringValue(kTestOptionB, &out)); + EXPECT_TRUE(store_->SetStringValue(kTestOptionB, kEmptyString)); + EXPECT_TRUE(store_->Save()); + EXPECT_TRUE(store_->Load()); + EXPECT_TRUE(store_->GetStringValue(kTestOptionB, &out)); EXPECT_EQ(kEmptyString, out); } diff --git a/talk/base/physicalsocketserver.cc b/talk/base/physicalsocketserver.cc index 12c1bccb2..a7f65c57a 100644 --- a/talk/base/physicalsocketserver.cc +++ b/talk/base/physicalsocketserver.cc @@ -501,7 +501,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { } void MaybeRemapSendError() { -#if defined(OSX) +#if defined(OSX) || defined(IOS) // https://developer.apple.com/library/mac/documentation/Darwin/ // Reference/ManPages/man2/sendto.2.html // ENOBUFS - The output queue for a network interface is full. diff --git a/talk/base/physicalsocketserver_unittest.cc b/talk/base/physicalsocketserver_unittest.cc index 329cf5d5f..cbdbd9cad 100644 --- a/talk/base/physicalsocketserver_unittest.cc +++ b/talk/base/physicalsocketserver_unittest.cc @@ -33,6 +33,7 @@ #include "talk/base/physicalsocketserver.h" #include "talk/base/scoped_ptr.h" #include "talk/base/socket_unittest.h" +#include "talk/base/testutils.h" #include "talk/base/thread.h" namespace talk_base { @@ -74,21 +75,11 @@ TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) { } -#ifdef OSX -// This test crashes the OS X kernel on 10.6 (at bsd/netinet/tcp_subr.c:2118). -TEST_F(PhysicalSocketTest, DISABLED_TestConnectWithClosedSocketIPv4) { -#else TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) { -#endif SocketTest::TestConnectWithClosedSocketIPv4(); } -#ifdef OSX -// This test crashes the OS X kernel on 10.6 (at bsd/netinet/tcp_subr.c:2118). -TEST_F(PhysicalSocketTest, DISABLED_TestConnectWithClosedSocketIPv6) { -#else TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv6) { -#endif SocketTest::TestConnectWithClosedSocketIPv6(); } @@ -227,7 +218,7 @@ Thread *PosixSignalDeliveryTest::signaled_thread_ = NULL; // Test receiving a synchronous signal while not in Wait() and then entering // Wait() afterwards. TEST_F(PosixSignalDeliveryTest, RaiseThenWait) { - ss_->SetPosixSignalHandler(SIGTERM, &RecordSignal); + ASSERT_TRUE(ss_->SetPosixSignalHandler(SIGTERM, &RecordSignal)); raise(SIGTERM); EXPECT_TRUE(ss_->Wait(0, true)); EXPECT_TRUE(ExpectSignal(SIGTERM)); diff --git a/talk/base/socket_unittest.cc b/talk/base/socket_unittest.cc index a9c4dbb0d..e76d113b2 100644 --- a/talk/base/socket_unittest.cc +++ b/talk/base/socket_unittest.cc @@ -172,8 +172,8 @@ void SocketTest::TestUdpIPv6() { } void SocketTest::TestUdpReadyToSendIPv4() { -#if !defined(OSX) - // TODO(ronghuawu): Enable this test (currently failed on build bots) on mac. +#if !defined(OSX) && !defined(IOS) + // TODO(ronghuawu): Enable this test on mac/ios. UdpReadyToSend(kIPv4Loopback); #endif } diff --git a/talk/base/unixfilesystem.cc b/talk/base/unixfilesystem.cc index c98769169..8ac749945 100644 --- a/talk/base/unixfilesystem.cc +++ b/talk/base/unixfilesystem.cc @@ -66,6 +66,15 @@ #include "talk/base/stream.h" #include "talk/base/stringutils.h" +#if defined(IOS) +// Defined in iosfilesystem.mm. No header file to discourage use +// elsewhere; other places should use GetApp{Data,Temp}Folder() in +// this file. Don't copy/paste. I mean it. +char* IOSDataDirectory(); +char* IOSTempDirectory(); +void IOSAppName(talk_base::Pathname* path); +#endif + namespace talk_base { #if !defined(ANDROID) && !defined(IOS) @@ -85,6 +94,17 @@ void UnixFilesystem::SetAppTempFolder(const std::string& folder) { } #endif +UnixFilesystem::UnixFilesystem() { +#if defined(IOS) + if (!provided_app_data_folder_) + provided_app_data_folder_ = IOSDataDirectory(); + if (!provided_app_temp_folder_) + provided_app_temp_folder_ = IOSTempDirectory(); +#endif +} + +UnixFilesystem::~UnixFilesystem() {} + bool UnixFilesystem::CreateFolder(const Pathname &path, mode_t mode) { std::string pathname(path.pathname()); int len = pathname.length(); @@ -369,6 +389,9 @@ bool UnixFilesystem::GetAppPathname(Pathname* path) { return success; #elif defined(__native_client__) return false; +#elif IOS + IOSAppName(path); + return true; #else // OSX char buffer[PATH_MAX + 2]; ssize_t len = readlink("/proc/self/exe", buffer, ARRAY_SIZE(buffer) - 1); @@ -521,7 +544,7 @@ bool UnixFilesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { #endif // ANDROID #if defined(LINUX) || defined(ANDROID) *freebytes = static_cast(vfs.f_bsize) * vfs.f_bavail; -#elif defined(OSX) +#elif defined(OSX) || defined(IOS) *freebytes = static_cast(vfs.f_frsize) * vfs.f_bavail; #endif diff --git a/talk/base/unixfilesystem.h b/talk/base/unixfilesystem.h index aa9c920e6..d709115fe 100644 --- a/talk/base/unixfilesystem.h +++ b/talk/base/unixfilesystem.h @@ -36,13 +36,17 @@ namespace talk_base { class UnixFilesystem : public FilesystemInterface { public: + UnixFilesystem(); + virtual ~UnixFilesystem(); #if defined(ANDROID) || defined(IOS) -// Android does not have a native code API to fetch the app data or temp -// folders. That needs to be passed into this class from Java. Similarly, iOS -// only supports an Objective-C API for fetching the folder locations, so that -// needs to be passed in here from Objective-C. - + // Android does not have a native code API to fetch the app data or temp + // folders. That needs to be passed into this class from Java. Similarly, iOS + // only supports an Objective-C API for fetching the folder locations, so that + // needs to be passed in here from Objective-C. Or at least that used to be + // the case; now the ctor will do the work if necessary and possible. + // TODO(fischman): add an Android version that uses JNI and drop the + // SetApp*Folder() APIs once external users stop using them. static void SetAppDataFolder(const std::string& folder); static void SetAppTempFolder(const std::string& folder); #endif diff --git a/talk/build/ios_test.plist b/talk/build/ios_test.plist new file mode 100644 index 000000000..c2fb0617f --- /dev/null +++ b/talk/build/ios_test.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.Google.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + + diff --git a/talk/build/ios_tests.gypi b/talk/build/ios_tests.gypi new file mode 100644 index 000000000..5b8801c9c --- /dev/null +++ b/talk/build/ios_tests.gypi @@ -0,0 +1,55 @@ +# +# libjingle +# Copyright 2014, Google Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Include this .gypi in an ObjC target's definition to allow it to be +# used as an iOS or OS/X application. + +{ + 'conditions': [ + ['OS=="ios" or OS=="mac"', { + 'variables': { + 'infoplist_file': './ios_test.plist', + }, + 'mac_bundle': 1, + 'mac_bundle_resources': [ + '<(infoplist_file)', + ], + # The plist is listed above so that it appears in XCode's file list, + # but we don't actually want to bundle it. + 'mac_bundle_resources!': [ + '<(infoplist_file)', + ], + 'xcode_settings': { + 'CLANG_ENABLE_OBJC_ARC': 'YES', + # common.gypi enables this for mac but we want this to be disabled + # like it is for ios. + 'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO', + 'INFOPLIST_FILE': '<(infoplist_file)', + }, + }], + ], # conditions +} diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index 03d39a39e..eae8bbd54 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -657,6 +657,7 @@ }], ['OS=="ios"', { 'sources': [ + 'base/iosfilesystem.mm', 'base/scoped_autorelease_pool.mm', ], 'dependencies': [ diff --git a/talk/libjingle_tests.gyp b/talk/libjingle_tests.gyp index 781613700..013c22869 100755 --- a/talk/libjingle_tests.gyp +++ b/talk/libjingle_tests.gyp @@ -104,6 +104,7 @@ { 'target_name': 'libjingle_unittest', 'type': 'executable', + 'includes': [ 'build/ios_tests.gypi', ], 'dependencies': [ 'gunit', 'libjingle.gyp:libjingle', @@ -492,51 +493,27 @@ # does just fine on 10.6 too). 'targets': [ { - 'target_name': 'libjingle_peerconnection_objc_test', - 'variables': { - 'infoplist_file': './app/webrtc/objctests/Info.plist', - }, + 'target_name': 'libjingle_peerconnection_objc_test', 'type': 'executable', - 'mac_bundle': 1, - 'mac_bundle_resources': [ - '<(infoplist_file)', - ], - # The plist is listed above so that it appears in XCode's file list, - # but we don't actually want to bundle it. - 'mac_bundle_resources!': [ - '<(infoplist_file)', - ], - 'xcode_settings': { - 'CLANG_ENABLE_OBJC_ARC': 'YES', - # common.gypi enables this for mac but we want this to be disabled - # like it is for ios. - 'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO', - 'INFOPLIST_FILE': '<(infoplist_file)', - }, + 'includes': [ 'build/ios_tests.gypi', ], 'dependencies': [ 'gunit', 'libjingle.gyp:libjingle_peerconnection_objc', ], - 'FRAMEWORK_SEARCH_PATHS': [ - '$(inherited)', - '$(SDKROOT)/Developer/Library/Frameworks', - '$(DEVELOPER_LIBRARY_DIR)/Frameworks', - ], 'sources': [ 'app/webrtc/objctests/RTCPeerConnectionSyncObserver.h', 'app/webrtc/objctests/RTCPeerConnectionSyncObserver.m', 'app/webrtc/objctests/RTCPeerConnectionTest.mm', 'app/webrtc/objctests/RTCSessionDescriptionSyncObserver.h', 'app/webrtc/objctests/RTCSessionDescriptionSyncObserver.m', + # TODO(fischman): figure out if this works for ios or if it + # needs a GUI driver. + 'app/webrtc/objctests/mac/main.mm', ], - 'conditions': [ - ['OS=="mac" or OS=="ios"', { - 'sources': [ - # TODO(fischman): figure out if this works for ios or if it - # needs a GUI driver. - 'app/webrtc/objctests/mac/main.mm', - ], - }], + 'FRAMEWORK_SEARCH_PATHS': [ + '$(inherited)', + '$(SDKROOT)/Developer/Library/Frameworks', + '$(DEVELOPER_LIBRARY_DIR)/Frameworks', ], }, # target libjingle_peerconnection_objc_test ],