diff --git a/.jazzy.yaml b/.jazzy.yaml index 90e1a3cb..2a57f2b1 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -3,11 +3,11 @@ sourcekitten_sourcefile: docs.json clean: true author: Timofey Solomko module: SWCompression -module_version: 4.5.8 +module_version: 4.5.9 copyright: '© 2021 Timofey Solomko' readme: README.md github_url: https://github.com/tsolomko/SWCompression -github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.7 +github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.9 theme: fullwidth custom_categories: diff --git a/.travis.yml b/.travis.yml index ce7ad876..2feceae2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,23 @@ git: submodules: false jobs: include: - # We cannot test with Swift 4.2 on macOS since Carthage doesn't work with multiple Swift versions. + # We test only building using SPM with Swift 4.2 on macos since Carthage doesn't support multiple Swift language versions. + - stage: test + language: swift + os: osx + osx_image: xcode10.1 # Swift 4.2 + script: + - swift --version + - swift build + - swift build -c release - stage: test language: swift os: osx osx_image: xcode10.3 # Swift 5.0 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean build' + - WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm' before_install: - brew update install: @@ -25,6 +35,8 @@ jobs: osx_image: xcode11.3 # Swift 5.1 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean build' + - WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm' before_install: - brew update install: @@ -39,6 +51,8 @@ jobs: osx_image: xcode11.4 # Swift 5.2 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean build' + - WATCHOS_SIMULATOR='Apple Watch Series 4 - 44mm' before_install: - brew update install: @@ -54,6 +68,8 @@ jobs: osx_image: xcode12 # Swift 5.3 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean build' + - WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm' before_install: - brew update install: @@ -79,70 +95,90 @@ jobs: osx_image: xcode12.4 # Swift 5.3.2 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean build' + - WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm' before_install: - brew update install: - ./utils.py ci install-macos before_script: - # TODO: Move this line into ./utils.py prepare-workspace macos when the old Swift versions and non-xcf installation - # method with Carthage are no longer supported. - - carthage bootstrap --use-xcframeworks --no-use-binaries - - git submodule update --init --recursive - - cp "Tests/Test Files/gitattributes-copy" "Tests/Test Files/.gitattributes" - - cd "Tests/Test Files/" - - git lfs pull - - git lfs checkout - - cd - + - ./utils.py prepare-workspace macos --xcf + script: + - ./utils.py ci script-macos + - stage: test + language: swift + os: osx + osx_image: xcode12.5 # Swift 5.4 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 + - WATCHOS_ACTIONS='clean test' + - WATCHOS_SIMULATOR='Apple Watch Series 6 - 44mm' + before_install: + - brew update + install: + - ./utils.py ci install-macos + before_script: + - ./utils.py prepare-workspace macos --xcf script: - ./utils.py ci script-macos - stage: test language: generic os: linux - dist: xenial + dist: bionic env: - SWIFT_VERSION=4.2.3 install: - - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + - ./utils.py ci install-linux script: - ./utils.py ci script-linux - stage: test language: generic os: linux - dist: xenial + dist: bionic env: - SWIFT_VERSION=5.0.3 install: - - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + - ./utils.py ci install-linux script: - ./utils.py ci script-linux - stage: test language: generic os: linux - dist: xenial + dist: bionic env: - SWIFT_VERSION=5.1.5 install: - - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + - ./utils.py ci install-linux script: - ./utils.py ci script-linux - stage: test language: generic os: linux - dist: xenial + dist: bionic env: - SWIFT_VERSION=5.2.5 install: - - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + - ./utils.py ci install-linux script: - ./utils.py ci script-linux - stage: test language: generic os: linux - dist: xenial + dist: bionic env: - SWIFT_VERSION=5.3.3 install: - - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + - ./utils.py ci install-linux + script: + - ./utils.py ci script-linux + - stage: test + language: generic + os: linux + dist: bionic + env: + - SWIFT_VERSION=5.4 + install: + - ./utils.py ci install-linux script: - ./utils.py ci script-linux - stage: deploy @@ -167,6 +203,8 @@ jobs: - ./utils.py ci before-deploy deploy: - provider: pages - skip_cleanup: true github_token: $GITHUB_TOKEN local_dir: docs + skip_cleanup: true + on: + tags: true diff --git a/CHANGELOG.md b/CHANGELOG.md index e4767c8b..989429ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.5.9 + +- Improved performance of LZMA/LZMA2 and, consequently, of XZ. +- Fixed a rare crash when processing a BZip2 archive which uses non-standard (but allowed) run length values. + ## 4.5.8 - Fixed incompatibility with Carthage `--use-xcframeworks` method of installation. diff --git a/SWCompression.podspec b/SWCompression.podspec index ac193438..719ef789 100644 --- a/SWCompression.podspec +++ b/SWCompression.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SWCompression" - s.version = "4.5.8" + s.version = "4.5.9" s.summary = "A framework with functions for working with compression, archives and containers." s.description = "A framework with (de)compression algorithms and functions for processing various archives and containers." diff --git a/SWCompression.xcodeproj/SWCompression.plist b/SWCompression.xcodeproj/SWCompression.plist index 38b0f04e..ccfd150a 100644 --- a/SWCompression.xcodeproj/SWCompression.plist +++ b/SWCompression.xcodeproj/SWCompression.plist @@ -15,10 +15,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.5.8 + 4.5.9 CFBundleVersion - 75 + 76 NSHumanReadableCopyright - Copyright © 2021 Timofey Solomko. All rights reserved. + Copyright © 2021 Timofey Solomko diff --git a/SWCompression.xcodeproj/TestSWCompression.plist b/SWCompression.xcodeproj/TestSWCompression.plist index 00e0c5d4..fbfd44a0 100644 --- a/SWCompression.xcodeproj/TestSWCompression.plist +++ b/SWCompression.xcodeproj/TestSWCompression.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 4.5.8 + 4.5.9 CFBundleVersion - 75 + 76 diff --git a/SWCompression.xcodeproj/project.pbxproj b/SWCompression.xcodeproj/project.pbxproj index 249fea7d..e445fdd4 100644 --- a/SWCompression.xcodeproj/project.pbxproj +++ b/SWCompression.xcodeproj/project.pbxproj @@ -213,6 +213,8 @@ 06F066771FFB763400312A82 /* test8.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 06F066111FFB763300312A82 /* test8.bz2 */; }; 06F276DF1F2BAB4A00E67335 /* 7zEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F276DE1F2BAB4900E67335 /* 7zEntry.swift */; }; 06FEAD921F54B9CD00AD016E /* EncodingTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FEAD911F54B9CD00AD016E /* EncodingTree.swift */; }; + E652D8F3263D670900FC229B /* test_nonstandard_runlength.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */; }; + E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */ = {isa = PBXBuildFile; fileRef = E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */; }; E66F36242538726E00076A6E /* test_empty.lzma in Resources */ = {isa = PBXBuildFile; fileRef = E66F36232538726E00076A6E /* test_empty.lzma */; }; E66F362C2538E2B700076A6E /* test_empty.zlib in Resources */ = {isa = PBXBuildFile; fileRef = E66F362B2538E2B700076A6E /* test_empty.zlib */; }; /* End PBXBuildFile section */ @@ -435,6 +437,8 @@ 06F276DE1F2BAB4900E67335 /* 7zEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 7zEntry.swift; sourceTree = ""; }; 06FEAD911F54B9CD00AD016E /* EncodingTree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EncodingTree.swift; path = Sources/Common/CodingTree/EncodingTree.swift; sourceTree = SOURCE_ROOT; }; 06FED40B1DD7717E0013DFB2 /* BZip2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BZip2.swift; sourceTree = ""; }; + E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.bz2; sourceTree = ""; }; + E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_nonstandard_runlength.answer; sourceTree = ""; }; E66F36232538726E00076A6E /* test_empty.lzma */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.lzma; sourceTree = ""; }; E66F362B2538E2B700076A6E /* test_empty.zlib */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_empty.zlib; sourceTree = ""; }; /* End PBXFileReference section */ @@ -723,6 +727,7 @@ 06F065B31FFB763300312A82 /* test7.answer */, 06F065B51FFB763300312A82 /* test8.answer */, 06F065B11FFB763300312A82 /* test9.answer */, + E652D8F4263D678000FC229B /* test_nonstandard_runlength.answer */, ); path = Answers; sourceTree = ""; @@ -886,6 +891,7 @@ 06F0660C1FFB763300312A82 /* test7.bz2 */, 06F066111FFB763300312A82 /* test8.bz2 */, 06F066101FFB763300312A82 /* test9.bz2 */, + E652D8F2263D670900FC229B /* test_nonstandard_runlength.bz2 */, ); path = BZip2; sourceTree = ""; @@ -934,7 +940,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1240; + LastUpgradeCheck = 1250; ORGANIZATIONNAME = "Timofey Solomko"; TargetAttributes = { 06BE1AC71DB410F100EE0F59 = { @@ -980,6 +986,7 @@ 06F066661FFB763400312A82 /* test3.7z in Resources */, 06F0664B1FFB763400312A82 /* test.tar in Resources */, 06F066501FFB763400312A82 /* test_gnu.tar in Resources */, + E652D8F5263D678000FC229B /* test_nonstandard_runlength.answer in Resources */, 06F066341FFB763400312A82 /* test1.xz in Resources */, 06F0665F1FFB763400312A82 /* test_multi_blocks.7z in Resources */, 068D070421368617002A6C3B /* test_delta_filter.7z in Resources */, @@ -1051,6 +1058,7 @@ 0698B10F2106344200A7C551 /* test_negative_mtime.tar in Resources */, 06F066561FFB763400312A82 /* SWCompressionSourceCode.tar in Resources */, 069864CA21403CE700755D9B /* test_sha256.xz in Resources */, + E652D8F3263D670900FC229B /* test_nonstandard_runlength.bz2 in Resources */, 06F0663D1FFB763400312A82 /* test2.xz in Resources */, 06F066351FFB763400312A82 /* test5.xz in Resources */, 06F066631FFB763400312A82 /* test_complicated_coding_scheme.7z in Resources */, @@ -1090,7 +1098,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "if [[ ${SDK_NAME} == iphone* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == iphonesimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-arm64_armv7/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/iOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == appletv* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == appletvsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-arm64/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/tvOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == watch* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == watchossimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-arm64_32_armv7k/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/watchOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == macos* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/macos-*/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/Mac/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\nfi\n\nxattr -rc ${BUILT_PRODUCTS_DIR}\n"; + shellScript = "if [[ ${SDK_NAME} == iphone* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == iphonesimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ios-arm64_armv7/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/iOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == appletv* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == appletvsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/tvos-arm64/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/tvOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == watch* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n if [[ ${SDK_NAME} == watchsimulator* ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-*-simulator/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/watchos-arm64_32_armv7k/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/watchOS/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Frameworks/\n fi\nelif [[ ${SDK_NAME} == macos* ]]; then\n if [[ ! -d ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/ ]]; then\n mkdir -p ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\n if [[ -d ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/ ]]; then\n cp -a ${PROJECT_DIR}/Carthage/Build/BitByteData.xcframework/macos-*/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n else\n cp -a ${PROJECT_DIR}/Carthage/Build/Mac/BitByteData.framework ${BUILT_PRODUCTS_DIR}/TestSWCompression.xctest/Contents/Frameworks/\n fi\nfi\n\nxattr -rc ${BUILT_PRODUCTS_DIR}\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -1250,7 +1258,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1331,7 +1339,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; "FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = ( @@ -1377,7 +1385,7 @@ BitByteData, ); SDKROOT = macosx; - SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; + SUPPORTED_PLATFORMS = "macosx watchsimulator iphonesimulator appletvsimulator watchos appletvos iphoneos"; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -1392,7 +1400,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1419,7 +1427,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme index 0987e3ca..d423d3f1 100644 --- a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme +++ b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme @@ -1,6 +1,6 @@ Int { return Int(truncatingIfNeeded: self) } + } extension Int { diff --git a/Sources/LZMA/LZMA.swift b/Sources/LZMA/LZMA.swift index a2b8ffe6..574ed0e8 100644 --- a/Sources/LZMA/LZMA.swift +++ b/Sources/LZMA/LZMA.swift @@ -63,7 +63,7 @@ public class LZMA: DecompressionAlgorithm { static func decompress(_ byteReader: ByteReader, _ properties: LZMAProperties, _ uncompSize: Int?) throws -> Data { - let decoder = LZMADecoder(byteReader) + var decoder = LZMADecoder(byteReader) decoder.properties = properties decoder.resetStateAndDecoders() decoder.uncompressedSize = uncompSize ?? -1 diff --git a/Sources/LZMA/LZMABitTreeDecoder.swift b/Sources/LZMA/LZMABitTreeDecoder.swift index 8b760e07..577c6373 100644 --- a/Sources/LZMA/LZMABitTreeDecoder.swift +++ b/Sources/LZMA/LZMABitTreeDecoder.swift @@ -6,7 +6,7 @@ import Foundation /// Used to decode symbols that need several bits for storing. -final class LZMABitTreeDecoder { +struct LZMABitTreeDecoder { var probs: [Int] let numBits: Int @@ -17,7 +17,7 @@ final class LZMABitTreeDecoder { self.numBits = numBits } - func decode(with rangeDecoder: LZMARangeDecoder) -> Int { + mutating func decode(with rangeDecoder: inout LZMARangeDecoder) -> Int { var m = 1 for _ in 0.. Int { + mutating func reverseDecode(with rangeDecoder: inout LZMARangeDecoder) -> Int { return LZMABitTreeDecoder.bitTreeReverseDecode(probs: &self.probs, startIndex: 0, - bits: self.numBits, rangeDecoder) + bits: self.numBits, &rangeDecoder) } static func bitTreeReverseDecode(probs: inout [Int], startIndex: Int, bits: Int, - _ rangeDecoder: LZMARangeDecoder) -> Int { + _ rangeDecoder: inout LZMARangeDecoder) -> Int { var m = 1 var symbol = 0 for i in 0.. Int { + mutating func decode(with rangeDecoder: inout LZMARangeDecoder, posState: Int) -> Int { // There can be one of three options. // We need one or two bits to find out which decoding scheme to use. // `choice` is used to decode first bit. // `choice2` is used to decode second bit. // If binary sequence starts with 0 then: if rangeDecoder.decode(bitWithProb: &self.choice) == 0 { - return self.lowCoder[posState].decode(with: rangeDecoder) + return self.lowCoder[posState].decode(with: &rangeDecoder) } // If binary sequence starts with 1 0 then: if rangeDecoder.decode(bitWithProb: &self.choice2) == 0 { - return 8 + self.midCoder[posState].decode(with: rangeDecoder) + return 8 + self.midCoder[posState].decode(with: &rangeDecoder) } // If binary sequence starts with 1 1 then: - return 16 + self.highCoder.decode(with: rangeDecoder) + return 16 + self.highCoder.decode(with: &rangeDecoder) } } diff --git a/Sources/LZMA/LZMARangeDecoder.swift b/Sources/LZMA/LZMARangeDecoder.swift index 645c9c7f..cff405fa 100644 --- a/Sources/LZMA/LZMARangeDecoder.swift +++ b/Sources/LZMA/LZMARangeDecoder.swift @@ -6,9 +6,9 @@ import Foundation import BitByteData -final class LZMARangeDecoder { +struct LZMARangeDecoder { - private var byteReader: ByteReader + private let byteReader: ByteReader private var range = 0xFFFFFFFF as UInt32 private var code = 0 as UInt32 @@ -18,10 +18,10 @@ final class LZMARangeDecoder { return self.code == 0 } - init?(_ byteReader: ByteReader) { + init(_ byteReader: ByteReader) throws { // To initialize rande decoder at least 5 bytes are necessary. guard byteReader.bytesLeft >= 5 - else { return nil } + else { throw LZMAError.rangeDecoderInitError } self.byteReader = byteReader @@ -29,9 +29,8 @@ final class LZMARangeDecoder { for _ in 0..<4 { self.code = (self.code << 8) | UInt32(self.byteReader.byte()) } - if byte != 0 || self.code == self.range { - return nil - } + guard byte == 0 && self.code != self.range + else { throw LZMAError.rangeDecoderInitError } } init() { @@ -39,15 +38,15 @@ final class LZMARangeDecoder { } /// `range` property cannot be smaller than `(1 << 24)`. This function keeps it bigger. - func normalize() { - if self.range < UInt32(LZMAConstants.topValue) { + mutating func normalize() { + if self.range < LZMAConstants.topValue { self.range <<= 8 self.code = (self.code << 8) | UInt32(byteReader.byte()) } } /// Decodes sequence of direct bits (binary symbols with fixed and equal probabilities). - func decode(directBits: Int) -> Int { + mutating func decode(directBits: Int) -> Int { var res: UInt32 = 0 var count = directBits repeat { @@ -70,7 +69,7 @@ final class LZMARangeDecoder { } /// Decodes binary symbol (bit) with predicted (estimated) probability. - func decode(bitWithProb prob: inout Int) -> Int { + mutating func decode(bitWithProb prob: inout Int) -> Int { let bound = (self.range >> UInt32(LZMAConstants.numBitModelTotalBits)) * UInt32(prob) let symbol: Int if self.code < bound { diff --git a/Sources/LZMA2/LZMA2.swift b/Sources/LZMA2/LZMA2.swift index 614c93da..6bf16dfd 100644 --- a/Sources/LZMA2/LZMA2.swift +++ b/Sources/LZMA2/LZMA2.swift @@ -28,7 +28,7 @@ public class LZMA2: DecompressionAlgorithm { } static func decompress(_ byteReader: ByteReader, _ dictSizeByte: UInt8) throws -> Data { - let decoder = try LZMA2Decoder(byteReader, dictSizeByte) + var decoder = try LZMA2Decoder(byteReader, dictSizeByte) try decoder.decode() return Data(decoder.out) } diff --git a/Sources/LZMA2/LZMA2Decoder.swift b/Sources/LZMA2/LZMA2Decoder.swift index 3fa8aa73..46f5f81a 100644 --- a/Sources/LZMA2/LZMA2Decoder.swift +++ b/Sources/LZMA2/LZMA2Decoder.swift @@ -6,10 +6,10 @@ import Foundation import BitByteData -final class LZMA2Decoder { +struct LZMA2Decoder { private let byteReader: ByteReader - private let decoder: LZMADecoder + private var decoder: LZMADecoder var out: [UInt8] { return self.decoder.out @@ -32,7 +32,7 @@ final class LZMA2Decoder { } /// Main LZMA2 decoder function. - func decode() throws { + mutating func decode() throws { mainLoop: while true { let controlByte = byteReader.byte() switch controlByte { @@ -54,7 +54,7 @@ final class LZMA2Decoder { } /// Function which dispatches LZMA2 decoding process based on `controlByte`. - private func dispatch(_ controlByte: UInt8) throws { + private mutating func dispatch(_ controlByte: UInt8) throws { let uncompressedSizeBits = controlByte & 0x1F let reset = (controlByte & 0x60) >> 5 let unpackSize = (uncompressedSizeBits.toInt() << 16) + @@ -82,7 +82,7 @@ final class LZMA2Decoder { else { throw LZMA2Error.wrongSizes } } - private func decodeUncompressed() { + private mutating func decodeUncompressed() { let dataSize = self.byteReader.byte().toInt() << 8 + self.byteReader.byte().toInt() + 1 for _ in 0../dev/null; then + HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade "git-lfs" + else + HOMEBREW_NO_AUTO_UPDATE=1 brew install "git-lfs" + fi""" + _sprun_shell(script) _sprun(["git", "lfs", "install"]) - _sprun(["gem", "install", "-N", "xcpretty-travis-formatter"]) -def _ci_script_linux(): - _sprun(["swift", "build"]) - _sprun(["swift", "build", "-c", "release"]) +def _ci_install_linux(): + _sprun_shell("eval \"$(curl -sL https://swiftenv.fuller.li/install.sh)\"") def _ci_script_macos(): - xcodebuild_command_parts = ["xcodebuild", "-project", "SWCompression.xcodeproj", "-scheme", "SWCompression"] - destinations_actions = [(["-destination 'platform=OS X'"], ["clean", "test"]), - (["-destination 'platform=iOS Simulator,name=iPhone 8'"], ["clean", "test"]), - (["-destination 'platform=watchOS Simulator,name=Apple Watch - 38mm'"], ["clean", "build"]), + _sprun_shell("xcodebuild -version") + _sprun(["swift", "--version"]) + xcodebuild_command_parts = ["xcodebuild", "-quiet", "-project", "SWCompression.xcodeproj", "-scheme", "SWCompression"] + destinations_actions = [(["-destination 'platform=OS X'"], ["clean", "test"]), + (["-destination 'platform=iOS Simulator,name=iPhone 8'"], ["clean", "test"]), + (["-destination 'platform=watchOS Simulator,name=" + os.environ["WATCHOS_SIMULATOR"] + "'"], [os.environ["WATCHOS_ACTIONS"]]), (["-destination 'platform=tvOS Simulator,name=Apple TV'"], ["clean", "test"])] - - for destination, action in destinations_actions: - xcodebuild_command = xcodebuild_command_parts + destination + action - print("+ {0} | xcpretty -f `xcpretty-travis-formatter`".format(" ".join(xcodebuild_command))) - xcodebuild_process = subprocess.Popen(xcodebuild_command, stdout=subprocess.PIPE) - xcpretty_command = ["xcpretty", "-f", "`xcpretty-travis-formatter`"] - subprocess.run(xcpretty_command, stdin=xcodebuild_process.stdout, shell=True, check=True) + + for destination, actions in destinations_actions: + xcodebuild_command = xcodebuild_command_parts + destination + actions + # If xcodebuild is not run inside shell, then destination parameters are ignored for some reason. + _sprun_shell(" ".join(xcodebuild_command)) + +def _ci_script_linux(): + env = os.environ.copy() + env["SWIFTENV_ROOT"] = env["HOME"] +"/.swiftenv" + env["PATH"] = env["SWIFTENV_ROOT"] + "/bin:" + env["SWIFTENV_ROOT"] + "/shims:"+ env["PATH"] + _sprun(["swift", "--version"], env=env) + _sprun(["swift", "build"], env=env) + _sprun(["swift", "build", "-c", "release"], env=env) def action_ci(args): if args.cmd == "before-deploy": _ci_before_deploy() elif args.cmd == "install-macos": _ci_install_macos() - elif args.cmd == "script-linux": - _ci_script_linux() + elif args.cmd == "install-linux": + _ci_install_linux() elif args.cmd == "script-macos": _ci_script_macos() + elif args.cmd == "script-linux": + _ci_script_linux() else: raise Exception("Unknown CI command") @@ -60,13 +78,18 @@ def action_cw(args): _sprun(["rm", "-f", "Package.resolved"]) _sprun(["rm", "-f", "SWCompression.framework.zip"]) -def _pw_macos(): +def _pw_macos(debug, xcf): print("=> Downloading dependency (BitByteData) using Carthage") - _sprun(["carthage", "bootstrap", "--no-use-binaries"]) - + script = ["carthage", "bootstrap", "--no-use-binaries"] + if debug: + script += ["--configuration", "Debug"] + if xcf: + script += ["--use-xcframeworks"] + _sprun(script) + def action_pw(args): if args.os == "macos": - _pw_macos() + _pw_macos(args.debug, args.xcf) elif args.os == "other": pass else: @@ -84,7 +107,7 @@ def action_pw(args): # Parser for 'ci' command. parser_ci = subparsers.add_parser("ci", help="a subset of commands used by CI", description="a subset of commands used by CI") -parser_ci.add_argument("cmd", choices=["before-deploy", "install-macos", "script-linux", "script-macos"], +parser_ci.add_argument("cmd", choices=["before-deploy", "install-macos", "install-linux", "script-macos", "script-linux"], help="a command to perform on CI", metavar="CI_CMD") parser_ci.set_defaults(func=action_ci) @@ -99,6 +122,10 @@ def action_pw(args): parser_pw.add_argument("os", choices=["macos", "other"], help="development operating system", metavar="OS") parser_pw.add_argument("--no-test-files", "-T", action="store_true", dest="no_test_files", help="don't download example files used for testing") +parser_pw.add_argument("--debug", "-d", action="store_true", dest="debug", + help="build BitByteData in Debug configuration") +parser_pw.add_argument("--xcf", action="store_true", dest="xcf", + help="build BitByteData as a XCFramework") parser_pw.set_defaults(func=action_pw) args = parser.parse_args()