From 662bc9519117f3c1cba41e5a5a598b2cf7bd7931 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 6 Apr 2020 12:54:19 +0300 Subject: [PATCH 01/13] Small changes to README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cedf1722..6bb0f8b7 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ let decompressedData = try? GzipArchive.unarchive(archive: data) ### Handling Errors Most SWCompression functions can throw an error and you are responsible for handling them. -If you look at list of available error types and their cases, you may be frightened by their number. +If you look at the list of available error types and their cases, you may be frightened by their number. However, most of these cases (such as `XZError.wrongMagic`) exist for diagnostic purposes. Thus, you only need to handle the most common type of error for your archive/algorithm. For example: @@ -146,9 +146,9 @@ do { // let data = let decompressedData = try XZArchive.unarchive(archive: data) } catch let error as XZError { - + // } catch let error { - + // } ``` From 515317a8c0f2210108ab49b604444c77833bce66 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 6 Apr 2020 12:57:27 +0300 Subject: [PATCH 02/13] Replace ci bash scripts with a python tool --- .travis.yml | 18 ++++++---- Utils/ci-before-deploy.sh | 16 --------- Utils/ci-install-macos.sh | 7 ---- Utils/ci-script-linux.sh | 6 ---- Utils/ci-script-macos.sh | 8 ----- utils.py | 71 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 43 deletions(-) delete mode 100755 Utils/ci-before-deploy.sh delete mode 100755 Utils/ci-install-macos.sh delete mode 100755 Utils/ci-script-linux.sh delete mode 100755 Utils/ci-script-macos.sh create mode 100755 utils.py diff --git a/.travis.yml b/.travis.yml index 3bf75bab..4134b4f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,26 +7,30 @@ jobs: language: swift os: osx osx_image: xcode10.3 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 before_install: - brew update install: - - Utils/ci-install-macos.sh + - ./utils.py ci install-macos before_script: - Utils/prepare-workspace-macos.sh script: - - Utils/ci-script-macos.sh + - ./utils.py ci script-macos - stage: test language: swift os: osx osx_image: xcode11.3 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 before_install: - brew update install: - - Utils/ci-install-macos.sh + - ./utils.py ci install-macos before_script: - Utils/prepare-workspace-macos.sh script: - - Utils/ci-script-macos.sh + - ./utils.py ci script-macos - stage: test language: generic os: linux @@ -36,12 +40,14 @@ jobs: install: - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" script: - - Utils/ci-script-linux.sh + - ./utils.py ci script-linux - stage: deploy if: tag IS present language: generic os: osx osx_image: xcode11.3 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 env: secure: iavIkrus2Xd3b086nz2srMGl52yqzLuCdhyEAhMODVqkzqMQ17s10y1TNb+vkepd0HgxI9j57d5X7tfChjWuWDwE2hZKjr/Kx2DfiUr1AKQD6ymuGrq/0Vv6yL9dfPU8goFArcrsBcyVKczLtTuLCKL498ZqokkQc/3kGvzW74lv+z410MfHS9/tvToO/yXJckL6qJ2XBAiElfOO0rEkllTeCo6N3bjcHZ2o7PE0K+CHYxwNKj0TmPmuNWZ3U4fzoWzkk01re1C1l5cpSb20g+2aGyi0yYX+PomX7fIIqNq9vmmyoeNdr35yqoQv/0zFeFnps83NKmZLAjSUhiUdhlbuBLBE+w8544LOaZnMDlFmpDjgyaVnRrOh0NrBB1FwU48aGfX5ljRQmk/07FTEUjvwvGGoOpz8lrLZi148FMHEospL3Sf7d8K+Q9WdtLTGk7HCnbOVcxS6oB/SWF/Cj6n5wu+EI1floBaZEsNPR40Gd4eM/Ik/E3lDrZThGDCWQsao981wm7IfEDBR1nuMME8gpZINFANNS1+5miFaGdTnDTp4Yd5MGEFZm+K8x+TG1891NwNH1ZmKXlypJXiUzvSjbh2ViNJGekdQj9q2gj2ZFlCfHJ05adwJ4w9qRuF00HpAOD6At6EnsjDXFJeTZS5dj8fi2YsU9or8KfTFoNY= addons: @@ -58,7 +64,7 @@ jobs: if ! [ "$BEFORE_DEPLOY_RUN" ]; then export BEFORE_DEPLOY_RUN=1; Utils/prepare-workspace-macos.sh -T; - Utils/ci-before-deploy.sh; + - ./utils.py ci before-deploy; fi deploy: - provider: releases diff --git a/Utils/ci-before-deploy.sh b/Utils/ci-before-deploy.sh deleted file mode 100755 index 67977edd..00000000 --- a/Utils/ci-before-deploy.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -(set +x; echo "=> Removing bcsymbolmap files for dependencies.") -rm -f Carthage/Build/Mac/*.bcsymbolmap -rm -f Carthage/Build/watchOS/*.bcsymbolmap -rm -f Carthage/Build/tvOS/*.bcsymbolmap -rm -f Carthage/Build/iOS/*.bcsymbolmap -(set +x; echo "=> Removing checkouts for dependencies.") -rm -rf Carthage/Checkouts -(set +x; echo "=> Preparing deployment files.") -carthage build --no-skip-current -carthage archive SWCompression -sourcekitten doc --spm-module SWCompression > docs.json -jazzy diff --git a/Utils/ci-install-macos.sh b/Utils/ci-install-macos.sh deleted file mode 100755 index e765a7c8..00000000 --- a/Utils/ci-install-macos.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -brew install git-lfs -git lfs install -gem install -N xcpretty-travis-formatter diff --git a/Utils/ci-script-linux.sh b/Utils/ci-script-linux.sh deleted file mode 100755 index 9e78f922..00000000 --- a/Utils/ci-script-linux.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -swift build -swift build -c release diff --git a/Utils/ci-script-macos.sh b/Utils/ci-script-macos.sh deleted file mode 100755 index cda1458a..00000000 --- a/Utils/ci-script-macos.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -xcodebuild -project SWCompression.xcodeproj -scheme SWCompression -destination "platform=OS X" clean test | xcpretty -f `xcpretty-travis-formatter` -xcodebuild -project SWCompression.xcodeproj -scheme SWCompression -destination "platform=iOS Simulator,name=iPhone 8" clean test | xcpretty -f `xcpretty-travis-formatter` -xcodebuild -project SWCompression.xcodeproj -scheme SWCompression -destination "platform=watchOS Simulator,name=Apple Watch - 38mm" clean build | xcpretty -f `xcpretty-travis-formatter` -xcodebuild -project SWCompression.xcodeproj -scheme SWCompression -destination "platform=tvOS Simulator,name=Apple TV" clean test | xcpretty -f `xcpretty-travis-formatter` diff --git a/utils.py b/utils.py new file mode 100755 index 00000000..7c1f9f0c --- /dev/null +++ b/utils.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +import argparse +import subprocess +import sys + +def _sprun(cmd, *args, **kwargs): + print("+ " + " ".join(cmd)) + subprocess.run(cmd, check=True, *args, **kwargs) + +def _ci_before_deploy(): + print("=> Removing bcsymbolmap files for dependencies.") + platforms = ["Mac", "watchOS", "tvOS", "iOS"] + for platform in platforms: + _sprun(["rm", "-f", "Carthage/Build/{0}/*.bcsymbolmap".format(platform)]) + print("=> Removing checkouts for dependencies.") + _sprun(["rm", "-rf", "Carthage/Checkouts"]) + print("=> Preparing deployment files.") + _sprun(["carthage", "build", "--no-skip-current"]) + _sprun(["carthage", "archive", "SWCompression"]) + docs_json_file = open("docs.json", "w") + _sprun(["sourcekitten", "doc", "--spm-module", "SWCompression"], stdout=docs_json_file) + docs_json_file.close() + _sprun(["jazzy"]) + +def _ci_install_macos(): + _sprun(["brew", "install", "git-lfs"]) + _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_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"]), + (["-destination 'platform=tvOS Simulator,name=Apple TV'"], ["clean", "test"])] + + for destination, action in destinations_actions: + xcodebuild_command = xcodebuild_command_parts + destination + action + print("+ {0}".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) + +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 == "script-macos": + _ci_script_macos() + else: + raise Exception("Unknown CI command") + +parser = argparse.ArgumentParser(description="A tool with useful commands for developing SWCompression") +subparsers = parser.add_subparsers(title="commands", help="a command to perform", metavar="CMD") + +# Parser for 'ci' command. +parser_ci = subparsers.add_parser("ci", help="a set of commands used by CI", description="a set of commands used by CI") +parser_ci.add_argument("cmd", choices=["before-deploy", "install-macos", "script-linux", "script-macos"], + help="a command to perform on CI", metavar="CI_CMD") +parser_ci.set_defaults(func=action_ci) + +args = parser.parse_args() +args.func(args) From fa3aeece25f4789d297ef5886688cf49acb2c53f Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 6 Apr 2020 19:01:34 +0300 Subject: [PATCH 03/13] Convert remaining Utils bash scripts into utils.py commands --- .travis.yml | 8 +++--- Utils/cleanup-workspace.sh | 39 ----------------------------- Utils/prepare-workspace-macos.sh | 16 ------------ utils.py | 42 ++++++++++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 61 deletions(-) delete mode 100755 Utils/cleanup-workspace.sh delete mode 100755 Utils/prepare-workspace-macos.sh diff --git a/.travis.yml b/.travis.yml index 4134b4f9..63c5d936 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ jobs: install: - ./utils.py ci install-macos before_script: - - Utils/prepare-workspace-macos.sh + - ./utils.py prepare-workspace macos script: - ./utils.py ci script-macos - stage: test @@ -28,7 +28,7 @@ jobs: install: - ./utils.py ci install-macos before_script: - - Utils/prepare-workspace-macos.sh + - ./utils.py prepare-workspace macos script: - ./utils.py ci script-macos - stage: test @@ -63,8 +63,8 @@ jobs: - > if ! [ "$BEFORE_DEPLOY_RUN" ]; then export BEFORE_DEPLOY_RUN=1; - Utils/prepare-workspace-macos.sh -T; - - ./utils.py ci before-deploy; + ./utils.py prepare-workspace macos -T + ./utils.py ci before-deploy; fi deploy: - provider: releases diff --git a/Utils/cleanup-workspace.sh b/Utils/cleanup-workspace.sh deleted file mode 100755 index f53029e1..00000000 --- a/Utils/cleanup-workspace.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -if [[ -d "build/" ]]; then - (set -x; rm -rf build/) -fi - -if [[ -d "Carthage/" ]]; then - (set -x; rm -rf Carthage/) -fi - -if [[ -d "docs/" ]]; then - (set -x; rm -rf docs/) -fi - -if [[ -d "Pods/" ]]; then - (set -x; rm -rf Pods/) -fi - -if [[ -d ".build/" ]]; then - (set -x; rm -rf .build/) -fi - -if [[ -f "Cartfile.resolved" ]]; then - (set -x; rm Cartfile.resolved) -fi - -if [[ -f "docs.json" ]]; then - (set -x; rm docs.json) -fi - -if [[ -f "Package.resolved" ]]; then - (set -x; rm Package.resolved) -fi - -if [[ -f "SWCompression.framework.zip" ]]; then - (set -x; rm SWCompression.framework.zip) -fi diff --git a/Utils/prepare-workspace-macos.sh b/Utils/prepare-workspace-macos.sh deleted file mode 100755 index 57289385..00000000 --- a/Utils/prepare-workspace-macos.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -if [[ $# -ne 1 || $1 != "-T" ]]; then - echo "=> Downloading files used for testing" - - (set -x ; git submodule update --init --recursive) - if [ $? -ne 0 ]; then - echo "ERROR: unable to update git submodule" - exit 1 - fi -fi - -echo "=> Downloading dependency (BitByteData) using Carthage" -(set -x; carthage bootstrap) diff --git a/utils.py b/utils.py index 7c1f9f0c..17b6cff5 100755 --- a/utils.py +++ b/utils.py @@ -41,7 +41,7 @@ def _ci_script_macos(): for destination, action in destinations_actions: xcodebuild_command = xcodebuild_command_parts + destination + action - print("+ {0}".format(" ".join(xcodebuild_command))) + 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) @@ -58,14 +58,52 @@ def action_ci(args): else: raise Exception("Unknown CI command") +def action_cw(args): + _sprun(["rm", "-rf", "build/"]) + _sprun(["rm", "-rf", "Carthage/"]) + _sprun(["rm", "-rf", "docs/"]) + _sprun(["rm", "-rf", "Pods/"]) + _sprun(["rm", "-rf", ".build/"]) + _sprun(["rm", "-f", "Cartfile.resolved"]) + _sprun(["rm", "-f", "docs.json"]) + _sprun(["rm", "-f", "Package.resolved"]) + _sprun(["rm", "-f", "SWCompression.framework.zip"]) + +def _pw_macos(): + print("=> Downloading dependency (BitByteData) using Carthage") + _sprun(["carthage", "bootstrap"]) + +def action_pw(args): + if args.os == "macos": + _pw_macos() + else: + raise Exception("Unknown OS") + if not args.no_test_files: + print("=> Downloading files used for testing") + _sprun(["git", "submodule", "update", "--init", "--recursive"]) + parser = argparse.ArgumentParser(description="A tool with useful commands for developing SWCompression") subparsers = parser.add_subparsers(title="commands", help="a command to perform", metavar="CMD") # Parser for 'ci' command. -parser_ci = subparsers.add_parser("ci", help="a set of commands used by CI", description="a set of commands used by CI") +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"], help="a command to perform on CI", metavar="CI_CMD") parser_ci.set_defaults(func=action_ci) +# Parser for 'cleanup-workspace' command. +parser_cw = subparsers.add_parser("cleanup-workspace", help="cleanup workspace", + description="cleans workspace from files produced by various build systems") +parser_cw.set_defaults(func=action_cw) + +# Parser for 'prepare-workspace' command. +parser_pw = subparsers.add_parser("prepare-workspace", help="prepare workspace", + description="prepares workspace for developing SWCompression") +parser_pw.add_argument("os", choices=["macos"], 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.set_defaults(func=action_pw) + args = parser.parse_args() args.func(args) From c1f283e1f725b60ce23c99f9412461e6b4ddc66c Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Tue, 7 Apr 2020 22:25:34 +0300 Subject: [PATCH 04/13] Perform the download of test files manually via a utils.py command and a copy of gitattributes file --- Tests/Test Files | 2 +- utils.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/Test Files b/Tests/Test Files index 543e5bc9..dfcec032 160000 --- a/Tests/Test Files +++ b/Tests/Test Files @@ -1 +1 @@ -Subproject commit 543e5bc90d065c9cac22e501cff97d5c4489ce45 +Subproject commit dfcec032712aea0be1b42998d1a3837c21f75285 diff --git a/utils.py b/utils.py index 17b6cff5..04cd660d 100755 --- a/utils.py +++ b/utils.py @@ -81,6 +81,9 @@ def action_pw(args): if not args.no_test_files: print("=> Downloading files used for testing") _sprun(["git", "submodule", "update", "--init", "--recursive"]) + _sprun(["cp", "-f", "Tests/Test Files/gitattributes-copy", "Tests/Test Files/.gitattributes"]) + _sprun(["git", "lfs", "pull"], cwd="Tests/Test Files/") + _sprun(["git", "lfs", "checkout"], cwd="Tests/Test Files/") parser = argparse.ArgumentParser(description="A tool with useful commands for developing SWCompression") subparsers = parser.add_subparsers(title="commands", help="a command to perform", metavar="CMD") From 3c788aac585db6e4f2c45e88b198316b44627bd1 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 8 Apr 2020 12:19:06 +0300 Subject: [PATCH 05/13] Add Swift 5.x badge to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6bb0f8b7..eff40e2f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # SWCompression [![Swift 4.2](https://img.shields.io/badge/Swift-4.2-blue.svg)](https://developer.apple.com/swift/) +[![Swift 5.X](https://img.shields.io/badge/Swift-5.X-blue.svg)](https://developer.apple.com/swift/) [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/tsolomko/SWCompression/master/LICENSE) [![Build Status](https://travis-ci.com/tsolomko/SWCompression.svg?branch=develop)](https://travis-ci.com/tsolomko/SWCompression) From 4cb8b694b3b8771221bf59c989a322701744e580 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 8 Apr 2020 12:23:47 +0300 Subject: [PATCH 06/13] CI changes: add testing for Swift 4.2, 5.1 and 5.2 --- .travis.yml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 63c5d936..d4dfa53e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +# TODO: There is probably a way to simplify this very explicit build matrix. git: depth: 1 submodules: false @@ -6,7 +7,7 @@ jobs: - stage: test language: swift os: osx - osx_image: xcode10.3 + osx_image: xcode10.1 # Swift 4.2 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 before_install: @@ -20,7 +21,35 @@ jobs: - stage: test language: swift os: osx - osx_image: xcode11.3 + osx_image: xcode10.3 # Swift 5.0 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 + before_install: + - brew update + install: + - ./utils.py ci install-macos + before_script: + - ./utils.py prepare-workspace macos + script: + - ./utils.py ci script-macos + - stage: test + language: swift + os: osx + osx_image: xcode11.3 # Swift 5.1 + env: + - HOMEBREW_NO_INSTALL_CLEANUP=1 + before_install: + - brew update + install: + - ./utils.py ci install-macos + before_script: + - ./utils.py prepare-workspace macos + script: + - ./utils.py ci script-macos + - stage: test + language: swift + os: osx + osx_image: xcode11.4 # Swift 5.2 env: - HOMEBREW_NO_INSTALL_CLEANUP=1 before_install: @@ -31,6 +60,16 @@ jobs: - ./utils.py prepare-workspace macos script: - ./utils.py ci script-macos + - stage: test + language: generic + os: linux + dist: xenial + env: + - SWIFT_VERSION=4.2 + install: + - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + script: + - ./utils.py ci script-linux - stage: test language: generic os: linux @@ -41,6 +80,26 @@ jobs: - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" script: - ./utils.py ci script-linux + - stage: test + language: generic + os: linux + dist: xenial + env: + - SWIFT_VERSION=5.1 + install: + - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + script: + - ./utils.py ci script-linux + - stage: test + language: generic + os: linux + dist: xenial + env: + - SWIFT_VERSION=5.2 + install: + - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" + script: + - ./utils.py ci script-linux - stage: deploy if: tag IS present language: generic From 3fe5efc0ec3be42047d40ee188a32030775c99cd Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 8 Apr 2020 12:36:37 +0300 Subject: [PATCH 07/13] Add other OS to utils.py prepare-workspace command --- utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 04cd660d..173012ac 100755 --- a/utils.py +++ b/utils.py @@ -76,6 +76,8 @@ def _pw_macos(): def action_pw(args): if args.os == "macos": _pw_macos() + elif args.os == "other": + pass else: raise Exception("Unknown OS") if not args.no_test_files: @@ -103,7 +105,7 @@ parser_cw.set_defaults(func=action_cw) # Parser for 'prepare-workspace' command. parser_pw = subparsers.add_parser("prepare-workspace", help="prepare workspace", description="prepares workspace for developing SWCompression") -parser_pw.add_argument("os", choices=["macos"], help="development operating system", metavar="OS") +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.set_defaults(func=action_pw) From 6746752d655a89f4fb08fef639539b91b7dcdd0c Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 8 Apr 2020 12:39:50 +0300 Subject: [PATCH 08/13] Add SPM package manifest for Swift 4.2 --- Package@swift-4.2.swift | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Package@swift-4.2.swift diff --git a/Package@swift-4.2.swift b/Package@swift-4.2.swift new file mode 100644 index 00000000..ff86bc92 --- /dev/null +++ b/Package@swift-4.2.swift @@ -0,0 +1,32 @@ +// swift-tools-version:4.0 +import PackageDescription + +let package = Package( + name: "SWCompression", + products: [ + .library( + name: "SWCompression", + targets: ["SWCompression"]), + ], + dependencies: [ + // SWCOMP: Uncomment the line below to build swcomp example program. + // .package(url: "https://github.com/jakeheis/SwiftCLI", + // from: "5.2.0"), + .package(url: "https://github.com/tsolomko/BitByteData", + from: "1.4.2"), + ], + targets: [ + // SWCOMP: Uncomment the lines below to build swcomp example program. + // .target( + // name: "swcomp", + // dependencies: ["SWCompression", "SwiftCLI"], + // path: "Sources", + // sources: ["swcomp"]), + .target( + name: "SWCompression", + dependencies: ["BitByteData"], + path: "Sources", + sources: ["Common", "7-Zip", "BZip2", "Deflate", "GZip", "LZMA", "LZMA2", "TAR", "XZ", "ZIP", "Zlib"]), + ], + swiftLanguageVersions: [4] +) From b8a3592da730c9e64a7f3b6e2288e7c8ae3677a9 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Thu, 9 Apr 2020 13:21:15 +0300 Subject: [PATCH 09/13] Increase the version lower bound of BBD to 1.4.3 This version of BBD improves compatibility with Swift 4.2. --- Cartfile | 2 +- Package.swift | 2 +- Package@swift-4.2.swift | 2 +- SWCompression.podspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cartfile b/Cartfile index e879c41f..934643de 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "tsolomko/BitByteData" ~> 1.4.2 +github "tsolomko/BitByteData" ~> 1.4.3 diff --git a/Package.swift b/Package.swift index b831b146..d957f93e 100644 --- a/Package.swift +++ b/Package.swift @@ -13,7 +13,7 @@ let package = Package( // .package(url: "https://github.com/jakeheis/SwiftCLI", // from: "5.2.0"), .package(url: "https://github.com/tsolomko/BitByteData", - from: "1.4.2"), + from: "1.4.3"), ], targets: [ // SWCOMP: Uncomment the lines below to build swcomp example program. diff --git a/Package@swift-4.2.swift b/Package@swift-4.2.swift index ff86bc92..33ca19c7 100644 --- a/Package@swift-4.2.swift +++ b/Package@swift-4.2.swift @@ -13,7 +13,7 @@ let package = Package( // .package(url: "https://github.com/jakeheis/SwiftCLI", // from: "5.2.0"), .package(url: "https://github.com/tsolomko/BitByteData", - from: "1.4.2"), + from: "1.4.3"), ], targets: [ // SWCOMP: Uncomment the lines below to build swcomp example program. diff --git a/SWCompression.podspec b/SWCompression.podspec index 1066f298..6b64dd08 100644 --- a/SWCompression.podspec +++ b/SWCompression.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.swift_versions = ["4", "5"] - s.dependency "BitByteData", "~> 1.4.2" + s.dependency "BitByteData", "~> 1.4.3" s.subspec "Deflate" do |sp| sp.source_files = "Sources/{Deflate/*,Common/*,Common/CodingTree/*}.swift" From e8a0745431f32a6549292d708d7520c9f319dad3 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Thu, 9 Apr 2020 13:22:11 +0300 Subject: [PATCH 10/13] CI changes: don't test with Swift 4.2 It isn't possible to automatically test on Swift 4.2 since carthage/xcode don't support projects with multiple Swift versions. --- .travis.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4dfa53e..79e81c0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,7 @@ git: submodules: false jobs: include: - - stage: test - language: swift - os: osx - osx_image: xcode10.1 # Swift 4.2 - env: - - HOMEBREW_NO_INSTALL_CLEANUP=1 - before_install: - - brew update - install: - - ./utils.py ci install-macos - before_script: - - ./utils.py prepare-workspace macos - script: - - ./utils.py ci script-macos + # We cannot test with Swift 4.2 on macOS since Carthage doesn't work with multiple Swift versions. - stage: test language: swift os: osx From bfd0b5e770d001f158c684df5340051de11ab7f6 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 10 Apr 2020 23:58:10 +0300 Subject: [PATCH 11/13] Open TimeProfiler automatically when using profile action in xcode --- .../xcshareddata/xcschemes/SWCompression.xcscheme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme index 6273a6a1..0f4b19d0 100644 --- a/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme +++ b/SWCompression.xcodeproj/xcshareddata/xcschemes/SWCompression.xcscheme @@ -78,7 +78,7 @@ From 1dfd960765ccb1e9cec8de9e37617888a2fb35bc Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 11 Apr 2020 00:45:57 +0300 Subject: [PATCH 12/13] Update README --- README.md | 111 ++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index eff40e2f..f115dafd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/tsolomko/SWCompression/master/LICENSE) [![Build Status](https://travis-ci.com/tsolomko/SWCompression.svg?branch=develop)](https://travis-ci.com/tsolomko/SWCompression) -A framework with (de)compression algorithms and functions for processing various archives and containers. +A framework with (de)compression algorithms and functions for working with various archives and containers. ## What is this? @@ -17,8 +17,7 @@ SWCompression — is a framework with a collection of functions for: It also works both on Apple platforms and __Linux__. -All features are listed in the tables below. -"TBD" means that feature is planned but not implemented (yet). +All features are listed in the tables below. "TBD" means that feature is planned but not implemented (yet). | | Deflate | BZip2 | LZMA/LZMA2 | | ------------- | ------- | ----- | ---------- | @@ -38,7 +37,7 @@ SWCompression can be integrated into your project using Swift Package Manager, C ### Swift Package Manager -Add SWCompression to you package dependencies and specify it as a dependency for your target, e.g.: +To install using SPM, add SWCompression to you package dependencies and specify it as a dependency for your target, e.g.: ```swift import PackageDescription @@ -62,12 +61,11 @@ More details you can find in [Swift Package Manager's Documentation](https://git ### CocoaPods -Add `pod 'SWCompression', '~> 4.5'` and `use_frameworks!` to your Podfile. +Add `pod 'SWCompression', '~> 4.5'` and `use_frameworks!` lines to your Podfile. To complete installation, run `pod install`. -If you need only some parts of framework, you can install only them using sub-podspecs. -Available subspecs: +If you need only some parts of framework, you can install only them using sub-podspecs. Available subspecs: - SWCompression/BZip2 - SWCompression/Deflate @@ -82,15 +80,15 @@ Available subspecs: #### "Optional Dependencies" -For both ZIP and 7-Zip there is a most commonly used compression method. This is Deflate for ZIP and LZMA/LZMA2 for -7-Zip. Thus, SWCompression/ZIP subspec has SWCompression/Deflate subspec as a dependency and SWCompression/LZMA subspec -is a dependency for SWCompression/SevenZip. +For both ZIP and 7-Zip there is the most commonly used compression method: Deflate and LZMA/LZMA2 correspondingly. Thus, +SWCompression/ZIP subspec has SWCompression/Deflate subspec as a dependency and SWCompression/LZMA subspec is a +dependency for SWCompression/SevenZip. -But both of these formats support other compression methods as well, and some of them are implemented in SWCompression. +But both of these formats also support other compression methods, and some of them are implemented in SWCompression. For CocoaPods configurations there are some sort of 'optional dependencies' for such compression methods. -"Optional dependency" in this context means that SWCompression/ZIP or SWCompression/7-Zip will support particular -compression methods only if a corresponding subspec is expicitly specified in your Podfile and installed. +"Optional dependency" in this context means that SWCompression/ZIP or SWCompression/7-Zip will support a compression +method only if a corresponding subspec is expicitly specified in your Podfile and installed. List of "optional dependecies": @@ -106,29 +104,31 @@ BZip2 and LZMA/LZMA2 support). ### Carthage +__Important:__ Only Swift 5.x is supported when installing BitByteData via Carthage. + Add to your Cartfile `github "tsolomko/SWCompression" ~> 4.5`. Then run `carthage update`. -Finally, drag and drop `SWCompression.framework` from `Carthage/Build` folder -into the "Embedded Binaries" section on your targets' "General" tab in Xcode. +Finally, drag and drop `SWCompression.framework` from the `Carthage/Build` directory into the "Embedded Binaries" section +on your targets' "General" tab in Xcode. SWCompression uses [BitByteData](https://github.com/tsolomko/BitByteData) framework, so Carthage will also download it, -and you should drag and drop `BitByteData.framework` file into the "Embedded Binaries" as well. +and you should put the `BitByteData.framework` file into the "Embedded Binaries" as well. ## Usage ### Basic Example -If you'd like to decompress "deflated" data just use: +For example, if you want to decompress "deflated" data just use: ```swift // let data = let decompressedData = try? Deflate.decompress(data: data) ``` -However, it is unlikely that you will encounter deflated data outside of any archive. -So, in case of GZip archive you should use: +However, it is unlikely that you will encounter deflated data outside of any archive. So, in the case of GZip archive +you should use: ```swift let decompressedData = try? GzipArchive.unarchive(archive: data) @@ -136,9 +136,9 @@ let decompressedData = try? GzipArchive.unarchive(archive: data) ### Handling Errors -Most SWCompression functions can throw an error and you are responsible for handling them. -If you look at the list of available error types and their cases, you may be frightened by their number. -However, most of these cases (such as `XZError.wrongMagic`) exist for diagnostic purposes. +Most SWCompression functions can throw errors and you are responsible for handling them. If you look at the list of +available error types and their cases, you may be frightened by their number. However, most of the cases (such as +`XZError.wrongMagic`) exist for diagnostic purposes. Thus, you only need to handle the most common type of error for your archive/algorithm. For example: @@ -153,67 +153,67 @@ do { } ``` -Or, if you don't care about errors at all, use `try?`. - ### Documentation -Every function or type of SWCompression's public API is documented. -This documentation can be found at its own [website](http://tsolomko.github.io/SWCompression). +Every function or type of SWCompression's public API is documented. This documentation can be found at its own +[website](http://tsolomko.github.io/SWCompression). ### Sophisticated example -There is a small command-line program, "swcomp", which is included in this repository in "Sources/swcomp". -To build it you need to uncomment several lines in "Package.swift" and run `swift build -c release`. +There is a small command-line program, "swcomp", which is included in this repository in "Sources/swcomp". To build it +you need to uncomment several lines in "Package.swift" and run `swift build -c release`. ## Contributing -Whether you find a bug, have a suggestion, idea or something else, -please [create an issue](https://github.com/tsolomko/SWCompression/issues) on GitHub. +Whether you find a bug, have a suggestion, idea, feedback or something else, please +[create an issue](https://github.com/tsolomko/SWCompression/issues) on GitHub. -In case you have encoutered a bug, it would be especially helpful if you attach a file (archive, etc.) -that caused the bug to happen. +In the case of a bug, it will be especially helpful if you attach a file (archive, etc.) that caused the bug to occur. -If you'd like to contribute code, please [create a pull request](https://github.com/tsolomko/SWCompression/pulls) on GitHub. +If you'd like to contribute, please [create a pull request](https://github.com/tsolomko/SWCompression/pulls) on GitHub. __Note:__ If you are considering working on SWCompression, please note that Xcode project (SWCompression.xcodeproj) was created manually and you shouldn't use `swift package generate-xcodeproj` command. ### Executing tests locally -If you'd like to run tests on your computer, you need to do an additional step after cloning this repository: +If you want to run tests on your computer, you need to do an additional step after cloning the repository: ```bash -git submodule update --init --recursive +./utils.py prepare-workspace {macos|other} ``` -This command downloads files which are used for testing. These files are stored in a -[separate repository](https://github.com/tsolomko/SWCompression-Test-Files). -Git LFS is used for storing them which is the reason for having them in the separate repository, -since Swift Package Manager have some problems with Git LFS-enabled repositories -(installing git-lfs _locally_ with `--skip-smudge` option is required to solve these problems). +The argument of this function is an operating system that you're using. This command will download files used in tests, +and on macOS it will also try to download BitByteData dependency, which requires having Carthage installed. -__Note:__ You can also use "Utils/prepare-workspace-macos.sh" script from the repository, -which not only downloads test files but also downloads dependencies. +Test files are stored in a [separate repository](https://github.com/tsolomko/SWCompression-Test-Files), using Git LFS. +There are two reasons for this complicated setup. Firstly, some of these files can be quite big, and it would be +unfortunate if the users of SWCompression had to download them every time during the installation. Secondly, Swift +Package Manager and contemporary versions of Xcode don't always work well with git-lfs-enabled repositories. To prevent +any potential problems test files were moved into another repository. Additionaly, the custom command line tool `utils.py` +is used to work around issues occuring on certain user systems (see, for example, #9). + +Please note, that if you want to add a new _type_ of test files, in addition to running `git lfs track`, you have to +also copy into the "Tests/Test Files/gitattributes-copy" file a line this command adds to the "Tests/Test Files/.gitattributes" +file. __Do not commit the ".gitattributes" file to the git history. It is git-ignored for a reason!__ ## Performance -Usage of whole module optimizations is recommended for best performance. -These optimizations are enabled by default for Release configurations. +Using whole module optimizations is recommended for the best performance. They are enabled by default in the Release build +configuration. [Tests Results](Tests/Results.md) document contains results of benchmarking of various functions. ## Why? -First of all, existing solutions for work with compression, archives and containers have certain disadvantages. -They might not support a particular compression algorithm or archive format and they all have different APIs, -which sometimes can be slightly confusing for users. -This project attempts to provide missing (and sometimes existing) functionality through unified API -which is easy to use and remember. +First of all, existing solutions for working with compression, archives and containers have certain disadvantages. They +might not support a particular compression algorithm or archive format and they all have different APIs, which sometimes +can be slightly confusing for users, especially when you mix different libraries in one project. This project attempts to +provide missing (and sometimes existing) functionality through the unified API which is easy to use and remember. -Secondly, it may be important to have a compression framework written completely in Swift, -without relying on either system libraries or solutions implemented in different languages. -Additionaly, since SWCompression is written fully in Swift without Objective-C, -it can also be used on __Linux__. +Secondly, in some cases it may be important to have a compression framework written entirely in Swift, without relying +on either system libraries or solutions implemented in other languages. Additionaly, since SWCompression is written +completely in Swift without Objective-C, it can also be used on __Linux__. ## Future plans @@ -224,11 +224,6 @@ new features. - Better Deflate compression. - Something else... -## Support Financially - -If you would like to support this project or me financially you can do so via PayPal using -[this link](https://paypal.me/tsolomko). - ## License [MIT licensed](LICENSE) From b1d9b4450a7dd1eb098fe8529371ce8f670f8b8a Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 11 Apr 2020 00:54:43 +0300 Subject: [PATCH 13/13] Prepare for 4.5.4 release --- .jazzy.yaml | 4 ++-- CHANGELOG.md | 5 +++++ SWCompression.podspec | 2 +- SWCompression.xcodeproj/SWCompression.plist | 4 ++-- SWCompression.xcodeproj/TestSWCompression.plist | 4 ++-- SWCompression.xcodeproj/project.pbxproj | 8 ++++---- Sources/swcomp/main.swift | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.jazzy.yaml b/.jazzy.yaml index b7bac020..3c32f440 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.3 +module_version: 4.5.4 copyright: '© 2020 Timofey Solomko' readme: README.md github_url: https://github.com/tsolomko/SWCompression -github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.3 +github_file_prefix: https://github.com/tsolomko/SWCompression/tree/4.5.4 theme: fullwidth custom_categories: diff --git a/CHANGELOG.md b/CHANGELOG.md index c464b966..79aeac08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.5.4 + +- Fixed issues when installing using SPM or Xcode in certain situations. +- Fixed incompatibility with Swift Package Manager from Swift 4.2. + ## 4.5.3 - Improved compatibility with the latest versions of Swift (5.x) and Xcode. diff --git a/SWCompression.podspec b/SWCompression.podspec index 6b64dd08..f8021c02 100644 --- a/SWCompression.podspec +++ b/SWCompression.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SWCompression" - s.version = "4.5.3" + s.version = "4.5.4" 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 cad806c9..1f365055 100644 --- a/SWCompression.xcodeproj/SWCompression.plist +++ b/SWCompression.xcodeproj/SWCompression.plist @@ -15,9 +15,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.5.3 + 4.5.4 CFBundleVersion - 70 + 71 NSHumanReadableCopyright Copyright © 2020 Timofey Solomko. All rights reserved. diff --git a/SWCompression.xcodeproj/TestSWCompression.plist b/SWCompression.xcodeproj/TestSWCompression.plist index 5f17fa96..ab28948b 100644 --- a/SWCompression.xcodeproj/TestSWCompression.plist +++ b/SWCompression.xcodeproj/TestSWCompression.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 4.5.3 + 4.5.4 CFBundleVersion - 70 + 71 diff --git a/SWCompression.xcodeproj/project.pbxproj b/SWCompression.xcodeproj/project.pbxproj index b9d3593d..5c533063 100644 --- a/SWCompression.xcodeproj/project.pbxproj +++ b/SWCompression.xcodeproj/project.pbxproj @@ -1236,7 +1236,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 70; + CURRENT_PROJECT_VERSION = 71; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1295,7 +1295,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CURRENT_PROJECT_VERSION = 70; + CURRENT_PROJECT_VERSION = 71; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; "FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = "\"$(SRCROOT)/Carthage/Build/tvOS\""; @@ -1335,7 +1335,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 70; + DYLIB_CURRENT_VERSION = 71; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1362,7 +1362,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 70; + DYLIB_CURRENT_VERSION = 71; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = SWCompression.xcodeproj/SWCompression.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/Sources/swcomp/main.swift b/Sources/swcomp/main.swift index 389facee..123f7971 100644 --- a/Sources/swcomp/main.swift +++ b/Sources/swcomp/main.swift @@ -7,7 +7,7 @@ import Foundation import SWCompression import SwiftCLI -let cli = CLI(name: "swcomp", version: "4.5.3", +let cli = CLI(name: "swcomp", version: "4.5.4", description: """ swcomp - small command-line client for SWCompression framework. Serves as an example of SWCompression usage.