Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

A bundled tool's row is named by the tool, not by Homebrew

v0lumehifcde2405c019
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index 9742fef0..0c64772b 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -2123,7 +2123,9 @@ final class BuildModel: ObservableObject {
let path = bundled ? nil : installed(binary)
if !bundled && path == nil { needsBrew = true }
if bundled { anyBundled = true }
- rows.append(Dep(id: "brew:" + pkg, name: key, hint: key + ".hint", present: bundled || path != nil,
+ // A bundled tool is named by the tool; "brew: …" says where a Homebrew copy comes from, so it stays for the rows that
+ // refer to one (installed there, or missing with the install button)
+ rows.append(Dep(id: "brew:" + pkg, name: bundled ? "dep.tool." + binary : key, hint: key + ".hint", present: bundled || path != nil,
detail: bundled ? "dep.bundled" : (path ?? ""),
installCmd: [(brew ?? "/opt/homebrew/bin/brew"), "install", pkg]))
}
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index 917e2569..80140f8d 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -523,6 +523,10 @@ enum L10n {
"checks that metal.exe produces a metallib"),
"dep.optionalMissing": ("可选,未安装", "optional, not installed"),
"dep.bundled": ("随 App 附带", "bundled"),
+ "dep.tool.xcodegen": ("xcodegen", "xcodegen"),
+ "dep.tool.zstd": ("zstd", "zstd"),
+ "dep.tool.spirv-cross": ("spirv-cross", "spirv-cross"),
+ "dep.tool.glslangValidator": ("glslangValidator", "glslangValidator"),
"dep.glslang": ("brew: glslang", "brew: glslang"),
"dep.glslang.hint": ("编译 OpenGL 游戏的着色器;打包脚本的环境检查要求它", "compiles OpenGL games' shaders; the NSP script's environment check requires it"),
"dep.installTimeout": ("安装超时(30 分钟)——网络太慢或卡住了",
diff --git a/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift b/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
index 429a0d80..0eada97b 100644
--- a/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
@@ -104,6 +104,10 @@ final class BundledToolsTests: XCTestCase {
XCTAssertNil(rows.first { $0.id == "brew" }, "nothing needs Homebrew")
XCTAssertEqual(rows.count, BuildModel.brewDeps.count)
XCTAssertTrue(rows.allSatisfy { $0.present && $0.detail == "dep.bundled" })
+ XCTAssertEqual(rows.map { $0.name }, BuildModel.brewDeps.map { "dep.tool." + $0.binary }, "named by the tool, not \"brew: …\"")
+ for (_, binary, _) in BuildModel.brewDeps {
+ for lang in [Lang.en, .zh] { XCTAssertEqual(L10n.string("dep.tool." + binary, lang), binary) }
+ }
}
func testBundledWinsOverHomebrews() throws {
@@ -121,6 +125,8 @@ final class BundledToolsTests: XCTestCase {
XCTAssertFalse(rows.first!.present)
XCTAssertEqual(row(rows, "spirv-cross")?.present, false)
XCTAssertEqual(row(rows, "zstd")?.detail, "dep.bundled")
+ XCTAssertEqual(row(rows, "zstd")?.name, "dep.tool.zstd")
+ XCTAssertEqual(row(rows, "spirv-cross")?.name, "dep.spirv", "missing: the Homebrew row keeps its label")
}
func testAMissingBundledToolFallsBackToHomebrewsCopy() throws {
@@ -130,6 +136,7 @@ final class BundledToolsTests: XCTestCase {
brew: "/opt/homebrew/bin/brew")
XCTAssertEqual(row(rows, "xcodegen")?.detail, "/opt/homebrew/bin/xcodegen")
XCTAssertEqual(row(rows, "xcodegen")?.present, true)
+ XCTAssertEqual(row(rows, "xcodegen")?.name, "dep.xcodegen", "a Homebrew copy keeps the Homebrew label")
XCTAssertNil(rows.first { $0.id == "brew" }, "every tool is bundled or installed")
}