From 27455638aa308ae943f51ad380e7144ba559ec93 Mon Sep 17 00:00:00 2001 From: "Lvv.me" Date: Sun, 14 Nov 2021 17:29:33 +0800 Subject: [PATCH 1/2] Support Swift Package Manager --- Package.swift | 36 ++++++++++++++++++++++++++++++++++++ lib/include/zstd.h | 1 + 2 files changed, 37 insertions(+) create mode 100644 Package.swift create mode 120000 lib/include/zstd.h diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..33587029a --- /dev/null +++ b/Package.swift @@ -0,0 +1,36 @@ +// swift-tools-version:5.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "zstd", + platforms: [ + .macOS(.v10_10), .iOS(.v9), .tvOS(.v9) + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "zstd", + targets: [ "zstd" ]) + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "zstd", + path: "lib", + sources: [ "common", "compress", "decompress", "dictBuilder" ], + publicHeadersPath: "include", + cSettings: [ + .headerSearchPath(".") + ]) + ], + swiftLanguageVersions: [.v5], + cLanguageStandard: .gnu11, + cxxLanguageStandard: .gnucxx14 +) diff --git a/lib/include/zstd.h b/lib/include/zstd.h new file mode 120000 index 000000000..61fb36420 --- /dev/null +++ b/lib/include/zstd.h @@ -0,0 +1 @@ +../zstd.h \ No newline at end of file From 81b96205afb5b70dcbf292d48e07c0c66945285b Mon Sep 17 00:00:00 2001 From: "Lvv.me" Date: Mon, 15 Nov 2021 13:23:50 +0800 Subject: [PATCH 2/2] Using `module.modulemap` replace symbol link for public header --- Package.swift | 8 ++++---- lib/include/zstd.h | 1 - lib/modulemap/module.modulemap | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) delete mode 120000 lib/include/zstd.h create mode 100644 lib/modulemap/module.modulemap diff --git a/Package.swift b/Package.swift index 33587029a..75a5a0b33 100644 --- a/Package.swift +++ b/Package.swift @@ -11,8 +11,8 @@ let package = Package( products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( - name: "zstd", - targets: [ "zstd" ]) + name: "libzstd", + targets: [ "libzstd" ]) ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -22,10 +22,10 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( - name: "zstd", + name: "libzstd", path: "lib", sources: [ "common", "compress", "decompress", "dictBuilder" ], - publicHeadersPath: "include", + publicHeadersPath: "modulemap", cSettings: [ .headerSearchPath(".") ]) diff --git a/lib/include/zstd.h b/lib/include/zstd.h deleted file mode 120000 index 61fb36420..000000000 --- a/lib/include/zstd.h +++ /dev/null @@ -1 +0,0 @@ -../zstd.h \ No newline at end of file diff --git a/lib/modulemap/module.modulemap b/lib/modulemap/module.modulemap new file mode 100644 index 000000000..5e09fca9e --- /dev/null +++ b/lib/modulemap/module.modulemap @@ -0,0 +1,4 @@ +module libzstd { + umbrella header "../zstd.h" + export * +}