Commit b157eba8 authored by Drew's avatar Drew

Add compression support

parent 1b92f541
Pipeline #2260 passed with stage
in 1 minute and 21 seconds
...@@ -21,6 +21,7 @@ private enum ModuleMapType: String { ...@@ -21,6 +21,7 @@ private enum ModuleMapType: String {
private enum Options: String { private enum Options: String {
case InfoPlist = "info-plist" case InfoPlist = "info-plist"
case Name = "name" case Name = "name"
case Compress = "compress"
} }
func env(_ feature: String) -> String? { func env(_ feature: String) -> String? {
...@@ -60,8 +61,13 @@ class PackageFramework { ...@@ -60,8 +61,13 @@ class PackageFramework {
fatalError("Specify a \(Options.InfoPlist.rawValue)") fatalError("Specify a \(Options.InfoPlist.rawValue)")
} }
let compress: Bool
if let c = arg(Options.Compress.rawValue) {
if c == "true" { compress = true } else { compress = false}
} else { compress = false }
var resources: [String] = [infoPlist] var resources: [String] = [infoPlist]
//rm framework if it exists //rm framework if it exists
let frameworkPath = Path("bin/\(name).framework") let frameworkPath = Path("bin/\(name).framework")
...@@ -150,6 +156,23 @@ class PackageFramework { ...@@ -150,6 +156,23 @@ class PackageFramework {
if system(cmd) != 0 { if system(cmd) != 0 {
fatalError("Codesign failed.") fatalError("Codesign failed.")
} }
if compress {
guard let packageVersion = env("ATBUILD_PACKAGE_VERSION") else {
fatalError("No package version / ATBUILD_PACKAGE_VERSION")
}
let tarxz = "bin/\(name)-\(packageVersion).tar.xz"
//detect compression level
let fc: Bool
if env("ATBUILD_CONFIGURATION_FAST_COMPILE")=="1" {
fc = true
} else { fc = false}
let compressionLevel = fc ? "0" :"9"
let cmd = "tar c --options \"xz:compression-level=\(compressionLevel)\" -Jf \(tarxz) bin/\(name).framework -C bin"
if system(cmd) != 0 {
fatalError("compress failed")
}
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment