From b9cbaf7343550ca9a9f4fb581ca41b070368d847 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sun, 13 Aug 2017 15:52:08 -0400 Subject: [PATCH] Cross-compile fixes for iOS. --- platform-darwin/External/libjson-c | 2 +- .../project.pbxproj | 14 +++--- platform-darwin/Scripts/build_libjson-c-ios | 48 +++++++++--------- platform-darwin/Scripts/build_libsodium-ios | 49 ++++++++++--------- .../Source/iOS/MPEmergencyViewController.m | 4 +- .../Source/iOS/MPTypeViewController.m | 2 +- 6 files changed, 62 insertions(+), 57 deletions(-) diff --git a/platform-darwin/External/libjson-c b/platform-darwin/External/libjson-c index ac00e62d..105891a5 160000 --- a/platform-darwin/External/libjson-c +++ b/platform-darwin/External/libjson-c @@ -1 +1 @@ -Subproject commit ac00e62db35bdb4ac141f3ba888a43efe15b07d6 +Subproject commit 105891a553f5a812a44ef12269ca5c815f74a767 diff --git a/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj b/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj index 25c22931..a3997528 100644 --- a/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/platform-darwin/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -4333,8 +4333,8 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "\"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/$(PLATFORM_NAME)/include\"", - "\"$(PROJECT_DIR)/External/libsodium/libsodium-osx/include\"", - "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-osx/include\"", + "\"$(PROJECT_DIR)/External/libsodium/libsodium-ios/include\"", + "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-ios/include\"", "$(inherited)", ); IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -4518,8 +4518,8 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "\"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/$(PLATFORM_NAME)/include\"", - "\"$(PROJECT_DIR)/External/libsodium/libsodium-osx/include\"", - "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-osx/include\"", + "\"$(PROJECT_DIR)/External/libsodium/libsodium-ios/include\"", + "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-ios/include\"", "$(inherited)", ); IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -4608,8 +4608,8 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "\"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/$(PLATFORM_NAME)/include\"", - "\"$(PROJECT_DIR)/External/libsodium/libsodium-osx/include\"", - "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-osx/include\"", + "\"$(PROJECT_DIR)/External/libsodium/libsodium-ios/include\"", + "\"$(PROJECT_DIR)/External/libjson-c/libjson-c-ios/include\"", "$(inherited)", ); IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -4948,6 +4948,7 @@ DAB7AE401F3D464A00C856B1 /* Test */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Test; }; DAB7AE481F3D468300C856B1 /* Build configuration list for PBXLegacyTarget "libsodium-ios" */ = { isa = XCConfigurationList; @@ -4957,6 +4958,7 @@ DAB7AE4B1F3D468300C856B1 /* Test */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Test; }; DAC632651486805C0075AEA5 /* Build configuration list for PBXNativeTarget "uicolor-utilities" */ = { isa = XCConfigurationList; diff --git a/platform-darwin/Scripts/build_libjson-c-ios b/platform-darwin/Scripts/build_libjson-c-ios index fd3829db..2ee72ec9 100755 --- a/platform-darwin/Scripts/build_libjson-c-ios +++ b/platform-darwin/Scripts/build_libjson-c-ios @@ -13,47 +13,49 @@ mkdir -p "$prefix/lib" \ "${prefix_armv7s=$prefix/tmp/armv7s}" \ "${prefix_arm64=$prefix/tmp/arm64}" -# SDK: iOS Simulator -sdkPath="$(xcrun --show-sdk-path --sdk iphonesimulator)" -platformPath="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)" +# Targets ( ## ARCH: x86_64 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-arch x86_64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-arch x86_64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)/usr/bin:$PATH" + export CFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s clean - ./configure --host=x86_64-apple-darwin10 --disable-shared --prefix="$prefix_x86_64" + ./configure --host=x86_64-apple --disable-shared --prefix="$prefix_x86_64" make -j3 install ) - -# SDK: iOS Device -sdkPath="$(xcrun --show-sdk-path --sdk iphoneos)" -platformPath="$(xcrun --show-sdk-platform-path --sdk iphoneos)" ( ## ARCH: armv7 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch armv7 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch armv7 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s clean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_armv7" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7" make -j3 install ) ( ## ARCH: armv7s - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch armv7s -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch armv7s -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s clean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_armv7s" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7s" make -j3 install ) ( ## ARCH: arm64 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch arm64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch arm64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s clean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_arm64" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_arm64" make -j3 install ) diff --git a/platform-darwin/Scripts/build_libsodium-ios b/platform-darwin/Scripts/build_libsodium-ios index 39228441..167640a7 100755 --- a/platform-darwin/Scripts/build_libsodium-ios +++ b/platform-darwin/Scripts/build_libsodium-ios @@ -4,7 +4,6 @@ set -e cd "${BASH_SOURCE%/*}/../External/libsodium" [[ -d libsodium-ios ]] && exit -# Inspired by libsodium/dist-build/ios.sh # Prepare autoreconf --verbose --install --symlink --force 2>&1 | sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /' rm -rf "${prefix=$PWD/libsodium-ios}" @@ -14,47 +13,49 @@ mkdir -p "$prefix/lib" \ "${prefix_armv7s=$prefix/tmp/armv7s}" \ "${prefix_arm64=$prefix/tmp/arm64}" -# SDK: iOS Simulator -sdkPath="$(xcrun --show-sdk-path --sdk iphonesimulator)" -platformPath="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)" +# Targets ( ## ARCH: x86_64 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-arch x86_64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-arch x86_64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)/usr/bin:$PATH" + export CFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s distclean - ./configure --host=x86_64-apple-darwin10 --disable-shared --prefix="$prefix_x86_64" + ./configure --host=x86_64-apple --disable-shared --prefix="$prefix_x86_64" make -j3 install ) - -# SDK: iOS Device -sdkPath="$(xcrun --show-sdk-path --sdk iphoneos)" -platformPath="$(xcrun --show-sdk-platform-path --sdk iphoneos)" ( ## ARCH: armv7 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch armv7 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch armv7 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s distclean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_armv7" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7" make -j3 install ) ( ## ARCH: armv7s - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch armv7s -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch armv7s -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s distclean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_armv7s" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7s" make -j3 install ) ( ## ARCH: arm64 - export PATH="$platformPath/usr/bin:$platformPath/usr/sbin:$PATH" - export CFLAGS="-mthumb -arch arm64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" - export LDFLAGS="-mthumb -arch arm64 -isysroot $sdkPath -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)" + export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH" + export CFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS" + export LDFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS" + export CPPFLAGS="$CFLAGS $CPPFLAGS" [[ -e Makefile ]] && make -s distclean - ./configure --host=arm-apple-darwin10 --disable-shared --prefix="$prefix_arm64" + ./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_arm64" make -j3 install ) diff --git a/platform-darwin/Source/iOS/MPEmergencyViewController.m b/platform-darwin/Source/iOS/MPEmergencyViewController.m index a425f564..66da1fdb 100644 --- a/platform-darwin/Source/iOS/MPEmergencyViewController.m +++ b/platform-darwin/Source/iOS/MPEmergencyViewController.m @@ -138,8 +138,8 @@ NSString *siteName = self.siteField.text; MPResultType siteType = [self siteType]; - NSUInteger siteCounter = (NSUInteger)self.counterStepper.value; - self.counterLabel.text = strf( @"%lu", (unsigned long)siteCounter ); + MPCounterValue siteCounter = (MPCounterValue)self.counterStepper.value; + self.counterLabel.text = strf( @"%u", siteCounter ); [self.passwordButton setTitle:nil forState:UIControlStateNormal]; [self.activity startAnimating]; diff --git a/platform-darwin/Source/iOS/MPTypeViewController.m b/platform-darwin/Source/iOS/MPTypeViewController.m index 9a59b3ea..9fe8098f 100644 --- a/platform-darwin/Source/iOS/MPTypeViewController.m +++ b/platform-darwin/Source/iOS/MPTypeViewController.m @@ -83,7 +83,7 @@ [(UITextField *)[cell viewWithTag:2] setText:@"..."]; NSString *name = selectedSite.name; - NSUInteger counter = 0; + MPCounterValue counter = 0; if ([selectedSite isKindOfClass:[MPGeneratedSiteEntity class]]) counter = ((MPGeneratedSiteEntity *)selectedSite).counter;