Skip to content

Commit

Permalink
Merge pull request #9 from mtj0928/matsuji
Browse files Browse the repository at this point in the history
Fix value of `appleUniversalBinaryPath`
  • Loading branch information
freddi-kit authored Sep 13, 2024
2 parents 707e4cc + 7171a39 commit 3e136db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
16 changes: 8 additions & 8 deletions Sources/ArtifactBundleGen/ArtifactBundleGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct ArtifactBundleGen {
}

private var appleUniversalBinaryPath: String {
"\(appleUniversalBinaryFolderName)/xcodegen"
"\(appleUniversalBinaryFolderName)/\(name)"
}

private func prepareArtifactBundleFolder() throws {
Expand All @@ -34,7 +34,7 @@ public struct ArtifactBundleGen {
guard fileExistChecker.isExist(path: appleUniversalBinaryPath) else { return [] }

var variants: [Variant] = []
let supoortedArchs = try lipoRunner.chechArch(of: appleUniversalBinaryPath)
let supportedArchs = try lipoRunner.checkArch(of: appleUniversalBinaryPath)

let appBundleUniversalBinaryFolderName = "\(name)-\(version)-macosx"
let destinationUniversalBinaryFolderName = "\(artifactBundleFolderName)/\(appBundleUniversalBinaryFolderName)/bin"
Expand Down Expand Up @@ -65,7 +65,7 @@ public struct ArtifactBundleGen {
variants.append(
Variant(
path: "\(appBundleUniversalBinaryFolderName)/bin/\(name)",
supportedTriples: supoortedArchs.map {
supportedTriples: supportedArchs.map {
"\($0)-apple-macosx"
}
)
Expand All @@ -83,18 +83,18 @@ public struct ArtifactBundleGen {
let executablePath = "\(tripleFolderPath)/\(name)"
guard fileExistChecker.isExist(path: executablePath) else { continue }

let artifactTripleDirectryPath = "\(artifactBundleFolderName)/\(triple)/bin"
try folderCreator.createFolder(name: artifactTripleDirectryPath)
let artifactTripleDirectoryPath = "\(artifactBundleFolderName)/\(triple)/bin"
try folderCreator.createFolder(name: artifactTripleDirectoryPath)

let originExecutableURL = URL(fileURLWithPath: executablePath)
let destinationURL = URL(fileURLWithPath: "\(artifactTripleDirectryPath)/\(name)")
let destinationURL = URL(fileURLWithPath: "\(artifactTripleDirectoryPath)/\(name)")

try fileCopy.copy(from: originExecutableURL, to: destinationURL)
try includeResourcePaths.forEach {
let resourceFileURL = URL(fileURLWithPath: $0)
try fileCopy.copy(
from: resourceFileURL,
to: URL(fileURLWithPath: artifactTripleDirectryPath).appendingPathComponent(resourceFileURL.lastPathComponent)
to: URL(fileURLWithPath: artifactTripleDirectoryPath).appendingPathComponent(resourceFileURL.lastPathComponent)
)
}

Expand All @@ -104,7 +104,7 @@ public struct ArtifactBundleGen {
for bundleName in bundleNames {
try fileCopy.copy(
from: URL(fileURLWithPath: tripleFolderPath).appendingPathComponent(bundleName),
to: URL(fileURLWithPath: artifactTripleDirectryPath).appendingPathComponent(bundleName)
to: URL(fileURLWithPath: artifactTripleDirectoryPath).appendingPathComponent(bundleName)
)
}

Expand Down
7 changes: 0 additions & 7 deletions Sources/ArtifactBundleGen/Error/ArtifactBundleGenError.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// ArtifactBundleGenError.swift
//
//
// Created by JP29872 on 2022/12/07.
//

import Foundation

enum ArtifactBundleGenError: LocalizedError, CustomStringConvertible {
Expand Down
9 changes: 0 additions & 9 deletions Sources/ArtifactBundleGen/Model/ArtifactBundle.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
//
// ArtifactBundle.swift
//
//
// Created by JP29872 on 2022/12/06.
//

import Foundation

struct Variant: Encodable {
var path: String
var supportedTriples: [String]
Expand Down
8 changes: 4 additions & 4 deletions Sources/ArtifactBundleGen/Utils/LipoRunnner.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

class LipoRunnner {
func chechArch(of targetPath: String) throws -> [String] {
struct LipoRunnner {
func checkArch(of targetPath: String) throws -> [String] {
let task = Process()
let pipe = Pipe()

Expand All @@ -19,8 +19,8 @@ class LipoRunnner {
let outputData = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: outputData, encoding: .utf8)

let separaterSet = CharacterSet([" ", "\n"])
guard let supportedCPUs = output?.components(separatedBy: separaterSet)
let separatorSet = CharacterSet([" ", "\n"])
guard let supportedCPUs = output?.components(separatedBy: separatorSet)
.filter({ $0 != "" })
else {
throw ArtifactBundleGenError.lipoEmptyResult
Expand Down

0 comments on commit 3e136db

Please sign in to comment.