Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

List Meson's build folders in Build Artifacts, never selected

Țugui Dragoș00e89460a283
diff --git a/GUIDE.md b/GUIDE.md
index 500570fb..857538ee 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -99,12 +99,13 @@ a password database inside. Nothing is selected for you.
`__pycache__`, Unity's `Library`, and any folder its tool tagged as a cache (`CACHEDIR.TAG`), each only when a file of
the tool that makes it proves it. Nothing is selected for you, and Select Recommended passes by a project changed in the
last 7 days, installed packages (a Python environment, `vendor`, Terraform's `.terraform`), a folder like `target` whose
-name says nothing on its own, and a folder Git tracks files in, such as a `Pods` folder kept in the repository, which is
-part of the project. Until you choose a folder, Peel offers `~/Developer`, `~/Projects`, `~/Code`, or `~/src` when you
-have one, and adds it only when you say so. A chosen folder Peel can't search, such as one on a disk that isn't
-connected, is named at the top of the page with the reason, never taken for one with nothing built in it. Peel never
-searches a hidden folder, a Library, or a folder a tool fills, such as `node_modules`, where apps and tools keep what
-they install, so choosing one, or a folder inside one, is refused.
+name says nothing on its own, a Meson build folder, which also keeps the options its build was set up with, and a folder
+Git tracks files in, such as a `Pods` folder kept in the repository, which is part of the project. Until you choose a
+folder, Peel offers `~/Developer`, `~/Projects`, `~/Code`, or `~/src` when you have one, and adds it only when you say
+so. A chosen folder Peel can't search, such as one on a disk that isn't connected, is named at the top of the page with
+the reason, never taken for one with nothing built in it. Peel never searches a hidden folder, a Library, or a folder a
+tool fills, such as `node_modules`, where apps and tools keep what they install, so choosing one, or a folder inside
+one, is refused.
**Space:** what's taking up room, and which app it belongs to. What an app manages itself, such as Xcode's
simulators, Docker's disk, Rust's toolchains, or Android's NDK versions, Space measures and leaves to that tool,
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index e0276b73..cd8d757c 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -88351,6 +88351,112 @@
}
}
},
+ "Not selected: it also keeps the options this build was set up with, which nothing else in the project holds." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nevybráno: uchovává také volby, se kterými bylo toto sestavení nastaveno a které nejsou uložené nikde jinde v projektu."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht ausgewählt: Er bewahrt auch die Optionen auf, mit denen dieser Build eingerichtet wurde und die es nirgendwo sonst im Projekt gibt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sin seleccionar: también guarda las opciones con las que se configuró esta compilación, que no están en ningún otro sitio del proyecto."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non sélectionné : ce dossier conserve aussi les options avec lesquelles cette compilation a été configurée, qui ne figurent nulle part ailleurs dans le projet."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non selezionato: conserva anche le opzioni con cui è stata configurata questa build, che nient’altro nel progetto contiene."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選択: このビルドの設定時に指定したオプションも含まれていて、これらはプロジェクト内のほかのどこにも保存されていません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "선택되지 않음: 이 빌드를 설정할 때 지정한 옵션도 들어 있으며, 이는 프로젝트의 다른 어디에도 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet geselecteerd: dit bevat ook de opties waarmee deze build is geconfigureerd, die nergens anders in het project staan."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie zaznaczono: przechowuje też opcje, z którymi skonfigurowano tę kompilację, a których nie zawiera nic innego w projekcie."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não selecionado: também guarda as opções com que esta compilação foi configurada, que não estão em nenhum outro lugar do projeto."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neselectat: păstrează și opțiunile cu care a fost configurată această compilare, pe care nu le conține nimic altceva din proiect."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не выбрано: здесь также хранятся параметры, с которыми была настроена эта сборка и которых больше нигде в проекте нет."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inte markerad: den innehåller också de alternativ som det här bygget konfigurerades med, och de finns inte någon annanstans i projektet."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seçilmedi: bu derlemenin ayarlandığı seçenekleri de tutar; projede bunları içeren başka bir şey yok."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вибрано: тут також зберігаються параметри, з якими налаштовано цю збірку, і більше ніде в проєкті їх немає."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未选择:它还存有配置此构建时所用的选项,而项目中的其他任何地方都没有这些选项。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選取:其中也存有設定此建置時所用的選項,而計畫案中沒有其他地方保存這些選項。"
+ }
+ }
+ }
+ },
"Not selected: it belongs to an app macOS keeps, so it is in use." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 63690bd1..01975db4 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -314,6 +314,7 @@ extension HoldBack {
case .holdsRepository: "holds a repository"
case .trackedByGit: "Git tracks files in it"
case .gitTrackingNotKnown: "in a Git repository whose tracked files couldn't be read"
+ case .keepsItsSetup: "keeps the options its build was set up with"
case .sharedWithEveryone: "belongs to everyone on this Mac"
case .holdsWhatOthersPut: "holds files something besides this package put there"
case .namedLikeTheApp: "claimed on the app's name alone"
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 7415dbad..7a947798 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -79,6 +79,7 @@ public enum ProjectArtifacts {
let source: String
/// What the folder holds that only its tool writes, for a kind no project file stands beside.
var proof: Proof?
+ var keepsItsSetup = false
/// The artifacts this kind names among a folder's entries: a name ending in `*` is a prefix, as CLion names
/// a build folder for each profile, and a path names a folder inside one of them, as Rails keeps `tmp/cache`.
@@ -91,13 +92,9 @@ public enum ProjectArtifacts {
return [name]
}
- func matches(_ url: URL, in folder: URL, besides names: Set<String>) -> Bool {
- guard markers.isEmpty || hasMarker(besides: names, in: folder) else { return false }
- return proof?.holds(at: url) ?? true
- }
-
- private func hasMarker(besides names: Set<String>, in folder: URL) -> Bool {
- markers.contains { marker in
+ /// Whether a file of the tool stands in `folder`, or the kind needs none.
+ func hasMarker(besides names: Set<String>, in folder: URL) -> Bool {
+ markers.isEmpty || markers.contains { marker in
if marker.hasPrefix("*") {
let suffix = marker.dropFirst()
return names.contains { $0.hasSuffix(suffix) && $0.count > suffix.count }
@@ -467,6 +464,13 @@ public enum ProjectArtifacts {
name: ".import", markers: ["project.godot"], tool: "Godot", isGeneric: false,
source: "https://docs.godotengine.org/en/3.6/tutorials/best_practices/version_control_systems.html"
),
+ // Meson's own test for its build folder, whatever its name. The folder also keeps the options it was set up
+ // with, which Meson's `--wipe` carries over and nothing else in the project holds.
+ Definition(
+ name: "*", markers: ["meson.build"], tool: "Meson", isGeneric: false,
+ source: "https://github.com/mesonbuild/meson/blob/d73f48d3b421a25112cc23e5ab629dc68f3d3791/mesonbuild/mcompile.py#L30-L35",
+ proof: .holds("meson-private/coredata.dat"), keepsItsSetup: true
+ ),
Definition(
name: "build", markers: ["CMakeLists.txt"], tool: "CMake", isGeneric: true,
source: "https://cmake.org/cmake/help/latest/manual/cmake.1.html"
@@ -781,7 +785,8 @@ public enum ProjectArtifacts {
hasGenericName: artifact.definition?.isGeneric ?? false,
isEnvironment: artifact.definition?.isEnvironment ?? false,
// A tool that tags its folder as a cache makes everything in it again, its own clones included.
- heldBack: heldBack == .holdsRepository && artifact.isTaggedAsACache ? nil : heldBack
+ heldBack: (heldBack == .holdsRepository && artifact.isTaggedAsACache ? nil : heldBack)
+ ?? (artifact.definition?.keepsItsSetup == true ? .keepsItsSetup : nil)
))
}
@@ -815,9 +820,11 @@ public enum ProjectArtifacts {
var artifactNames: Set<String> = []
var found: [Found] = []
for definition in definitions {
- for name in definition.candidates(among: names) {
+ let candidates = definition.candidates(among: names)
+ guard !candidates.isEmpty, definition.hasMarker(besides: names, in: folder) else { continue }
+ for name in candidates {
let url = folder.appending(path: name)
- guard isRealFolder(url), definition.matches(url, in: folder, besides: names) else { continue }
+ guard isRealFolder(url), definition.proof?.holds(at: url) ?? true else { continue }
guard !exclusions.excludes(url), !exclusions.holds(url) else { continue }
guard artifactNames.insert(name).inserted else { continue }
found.append(Found(name: name, definition: definition, isTaggedAsACache: isTaggedAsACache(url)))
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index cc0002f2..8adccbcf 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -45,6 +45,8 @@ public enum HoldBack: String, Sendable, Hashable {
case trackedByGit
/// Inside a Git repository whose index could not be read, so whether Git tracks files inside is not known.
case gitTrackingNotKnown
+ /// A build folder that also keeps the options its build was set up with, which nothing else in the project holds.
+ case keepsItsSetup
/// `/Users/Shared`, which belongs to every account on the Mac rather than to one app.
case sharedWithEveryone
/// A folder a package made, offered whole while it holds what something else put there: another package's
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index d206912e..411aa895 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -263,6 +263,23 @@ struct ProjectArtifactsTests {
])
}
+ @Test func listsMesonsBuildFolderWhateverItsNameAndKeepsItsSetup() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("lib/meson.build", bytes: 16)
+ try directory.file("lib/builddir/meson-private/coredata.dat", bytes: 400_000)
+ try directory.file("lib/build/meson-private/coredata.dat", bytes: 400_000)
+ let tag = "Signature: 8a477f597d28d172789f06886806bc55\n# This file is a cache directory tag created by meson.\n"
+ try directory.file("lib/build/CACHEDIR.TAG", contents: Data(tag.utf8))
+ try directory.file("lib/out/notes.txt", bytes: 400_000)
+ try directory.file("lib/subprojects/zlib/meson.build", bytes: 16)
+ try age(directory.url, days: 60)
+
+ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts
+
+ #expect(found.map(\.name).sorted() == ["build", "builddir"])
+ #expect(found.allSatisfy { $0.tool == "Meson" && $0.heldBack == .keepsItsSetup && !$0.isRecommended })
+ }
+
@Test func listsPDMsPackagesAndNothingInsideThem() async throws {
let directory = try TemporaryDirectory()
try directory.file("app/pyproject.toml", bytes: 16)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 84c2df8c..75b78f83 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -254,6 +254,8 @@ extension HoldBack {
"Not selected: Git tracks files in this folder, so it is part of the project. Moving it would show them as deleted in Git."
case .gitTrackingNotKnown:
"Not selected: this folder is in a Git repository whose list of tracked files Peel couldn’t read, so it may be part of the project."
+ case .keepsItsSetup:
+ "Not selected: it also keeps the options this build was set up with, which nothing else in the project holds."
case .sharedWithEveryone:
"Not selected: /Users/Shared belongs to every account on this Mac rather than to one app."
case .holdsWhatOthersPut:
diff --git a/SAFETY.md b/SAFETY.md
index 68f0d9ba..0d8b0b6d 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -333,15 +333,16 @@ Peel can't read. Peel reads that list from Git's own index, as Git documents it,
Python environment (`.venv`, `venv`, PDM's `__pypackages__`) is listed and never selected, since packages are often
installed into one by hand, and so is Terraform's `.terraform`, which keeps the workspace you chose, and xwin's
`.xwin-cache`, the Windows SDK a Rust project builds against, which only `xwin splat` with your own options puts back.
-Pixi's `.pixi/envs` can be suggested: Pixi makes it again from `pixi.lock` and never lets it be edited by hand. A folder
-whose name says nothing on its own, such as `target` or `build`, is listed and never selected either. Of a Godot
-project's `.godot`, only the caches Godot makes again are offered, `imported` and `shader_cache`: the folder also holds
-the export passwords and keys (`export_credentials.cfg`), which exist nowhere else. Nx's `.nx` is offered only when it
-holds nothing but the cache and the database beside it, which `nx reset` removes together, since a team can keep its
-release plans there. Build Artifacts never searches a hidden folder, a Library, or a folder a tool fills, such as
-`node_modules`: apps and tools keep there what they install, as an editor keeps each extension's `package.json` beside
-the `node_modules` it runs with. A folder chosen to search that is one of those, or sits inside one, is refused with the
-reason.
+Pixi's `.pixi/envs` can be suggested: Pixi makes it again from `pixi.lock` and never lets it be edited by hand. A Meson
+build folder, whatever its name, is listed and never selected: it also keeps the options its build was set up with,
+which Meson's own `--wipe` carries over and nothing else in the project holds. A folder whose name says nothing on its
+own, such as `target` or `build`, is listed and never selected either. Of a Godot project's `.godot`, only the caches
+Godot makes again are offered, `imported` and `shader_cache`: the folder also holds the export passwords and keys
+(`export_credentials.cfg`), which exist nowhere else. Nx's `.nx` is offered only when it holds nothing but the cache and
+the database beside it, which `nx reset` removes together, since a team can keep its release plans there. Build
+Artifacts never searches a hidden folder, a Library, or a folder a tool fills, such as `node_modules`: apps and tools
+keep there what they install, as an editor keeps each extension's `package.json` beside the `node_modules` it runs with.
+A folder chosen to search that is one of those, or sits inside one, is refused with the reason.
Developer, Build Artifacts, Space, and Installers and Backups select nothing for you: opening a page selects nothing,
and Select Recommended selects what Peel recommends there.