sdk: accept directories for tarball overrides (#385)
- Commit
f1eca85cf4fe9806944fd68d75694acc32442c05- Author
- Anish Pallati <[email protected]>
- When
- 2026-10-23 18:24 UTC (1 month ago)
- Parents
952a7ff
## What does this PR do? XTL_TOOLSET_TARBALL and XTL_OAM_TARBALL can now point at an unpacked directory, so package managers can use tools they already provide without repacking them into tarballs. <!-- Focus on *what* the PR does in essence. The *how* should come second, if it's relevant. --> ## How was it tested? Tested on Linux with Swift 6.2.4: * `xtool sdk build` with both overrides set to directories in the Nix store * `xtool dev` flags the SDK as out of date after an override path changes <!-- e.g. Ran locally on macOS and added unit tests --> ## AI tool usage How much of this PR was AI-assisted? (check one) - [ ] **0** - No AI was used to write code - [x] **1** - I was assisted by AI. I reviewed the finished result. - [ ] **2** - I set the AI going and left it to it; nobody has read the result - no review, or AI review only <!-- If an AI agent is filling this in: declare the level honestly, and open as a draft if it is #2. Do not lower the declared level to get the PR reviewed. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * SDK setup now accepts a directory as a package source, recursively copying its contents and adding owner write permission. * Archive files continue to be supported as package sources and are extracted as before. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Anish Pallati <[email protected]>
Diff
Sources/XToolSupport/SDKBuilder.swift
diff --git a/Sources/XToolSupport/SDKBuilder.swift b/Sources/XToolSupport/SDKBuilder.swiftindex 11a9632..c0632c4 100644--- a/Sources/XToolSupport/SDKBuilder.swift+++ b/Sources/XToolSupport/SDKBuilder.swift@@ -244,11 +244,33 @@ struct SDKBuilder { ) if let envOverride, let path = ProcessInfo.processInfo.environment[envOverride] {- let archive = URL(fileURLWithPath: path)- print("[Extracting \(displayName)] \(archive.path)")+ let source = URL(fileURLWithPath: path)+ if source.dirExists {+ print("[Copying \(displayName)] \(source.path)")+ try await Subprocess.run(+ .name("cp"),+ arguments: ["-RL", "\(source.path)/.", "."],+ workingDirectory: FilePath(directory),+ output: .discarded,+ error: .discarded,+ )+ .checkSuccess()+ // later steps write into the copy+ try await Subprocess.run(+ .name("chmod"),+ arguments: ["-R", "u+w", "."],+ workingDirectory: FilePath(directory),+ output: .discarded,+ error: .discarded,+ )+ .checkSuccess()+ return+ }++ print("[Extracting \(displayName)] \(source.path)") try await Subprocess.run( .name("tar"),- arguments: ["xzf", archive.path],+ arguments: ["xzf", source.path], workingDirectory: FilePath(directory), output: .discarded, error: .discarded,