File tree Expand file tree Collapse file tree 12 files changed +48
-8
lines changed
PluginGeneratedResources/Plugins/Generator
MySourceGenPlugin/Plugins/MySourceGenPrebuildPlugin
MySourceGenPluginUsingURLBasedAPI/Plugins/MySourceGenPrebuildPlugin Expand file tree Collapse file tree 12 files changed +48
-8
lines changed Original file line number Diff line number Diff line change 1
1
import PackagePlugin
2
2
3
+ #if os(Android)
4
+ let touchExe = " /system/bin/touch "
5
+ #else
6
+ let touchExe = " /usr/bin/touch "
7
+ #endif
8
+
3
9
@main
4
10
struct GeneratorPlugin : BuildToolPlugin {
5
11
func createBuildCommands( context: PluginContext , target: Target ) async throws -> [ Command ] {
6
12
return [
7
13
. prebuildCommand(
8
14
displayName: " Generating empty file " ,
9
- executable: . init( " /usr/bin/touch " ) ,
15
+ executable: . init( touchExe ) ,
10
16
arguments: [ context. pluginWorkDirectory. appending ( " best.txt " ) ] ,
11
17
outputFilesDirectory: context. pluginWorkDirectory
12
18
)
Original file line number Diff line number Diff line change 1
1
import PackagePlugin
2
2
3
+ #if os(Android)
4
+ let touchExe = " /system/bin/touch "
5
+ #else
6
+ let touchExe = " /usr/bin/touch "
7
+ #endif
8
+
3
9
@main
4
10
struct MyPlugin : BuildToolPlugin {
5
11
@@ -15,7 +21,7 @@ struct MyPlugin: BuildToolPlugin {
15
21
displayName:
16
22
" Running prebuild command for target \( target. name) " ,
17
23
executable:
18
- Path ( " /usr/bin/touch " ) ,
24
+ Path ( touchExe ) ,
19
25
arguments:
20
26
outputPaths. map { $0. string } ,
21
27
outputFilesDirectory:
Original file line number Diff line number Diff line change 1
1
import Foundation
2
2
import PackagePlugin
3
3
4
+ #if os(Android)
5
+ let touchExe = " /system/bin/touch "
6
+ #else
7
+ let touchExe = " /usr/bin/touch "
8
+ #endif
9
+
4
10
@main
5
11
struct MyPlugin : BuildToolPlugin {
6
12
@@ -16,7 +22,7 @@ struct MyPlugin: BuildToolPlugin {
16
22
displayName:
17
23
" Running prebuild command for target \( target. name) " ,
18
24
executable:
19
- URL ( fileURLWithPath: " /usr/bin/touch " ) ,
25
+ URL ( fileURLWithPath: touchExe ) ,
20
26
arguments:
21
27
outputPaths. map { $0. path } ,
22
28
outputFilesDirectory:
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import Foundation
15
15
import class TSCBasic. Thread
16
16
#if canImport(WinSDK)
17
17
import WinSDK
18
+ #elseif canImport(Android)
19
+ import Android
18
20
#endif
19
21
20
22
public typealias CancellationHandler = @Sendable ( DispatchTime) throws -> Void
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import Foundation
14
14
15
15
#if os(Windows)
16
16
import TSCLibc
17
+ #elseif canImport(Android)
18
+ import Android
17
19
#endif
18
20
19
21
#if os(Linux)
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ import Musl
19
19
#elseif os(Windows)
20
20
import CRT
21
21
import WinSDK
22
- #elseif canImport(Bionic )
23
- import Bionic
22
+ #elseif canImport(Android )
23
+ import Android
24
24
#else
25
25
import Darwin. C
26
26
#endif
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ import func TSCBasic.exec
22
22
23
23
import enum TSCUtility. Diagnostics
24
24
25
+ #if canImport(Android)
26
+ import Android
27
+ #endif
28
+
25
29
/// An enumeration of the errors that can be generated by the run tool.
26
30
private enum RunError : Swift . Error {
27
31
/// The package manifest has no executable product.
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ import class TSCBasic.Thread
42
42
43
43
#if os(Windows)
44
44
import WinSDK // for ERROR_NOT_FOUND
45
+ #elseif canImport(Android)
46
+ import Android
45
47
#endif
46
48
47
49
private enum TestError : Swift . Error {
@@ -1484,7 +1486,7 @@ private extension Basics.Diagnostic {
1484
1486
/// it duplicates the definition of this constant in its own source. Any changes
1485
1487
/// to this constant in either package must be mirrored in the other.
1486
1488
private var EXIT_NO_TESTS_FOUND : CInt {
1487
- #if os(macOS) || os(Linux)
1489
+ #if os(macOS) || os(Linux) || canImport(Android)
1488
1490
EX_UNAVAILABLE
1489
1491
#elseif os(Windows)
1490
1492
ERROR_NOT_FOUND
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ internal func strerror(_ errno: CInt) -> String? {
36
36
return String ( decodingCString: baseAddress, as: UTF16 . self)
37
37
}
38
38
}
39
+ #elseif canImport(Android)
40
+ import Android
39
41
#endif
40
42
41
43
//
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ private func readpassword(_ prompt: String) throws -> String {
63
63
return password
64
64
}
65
65
#else
66
+ #if canImport(Android)
67
+ import Android
68
+ #endif
69
+
66
70
private func readpassword( _ prompt: String ) throws -> String {
67
71
let password : String
68
72
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class WalkTests: XCTestCase {
38
38
var expected : [ AbsolutePath ] = [
39
39
" \( root) /usr " ,
40
40
" \( root) /bin " ,
41
- " \( root) /xbin " ,
41
+ " \( root) /etc " ,
42
42
]
43
43
#elseif os(Windows)
44
44
let root = ProcessInfo . processInfo. environment [ " SystemRoot " ] !
Original file line number Diff line number Diff line change @@ -208,13 +208,19 @@ final class PluginTests: XCTestCase {
208
208
try localFileSystem. createDirectory ( pluginSourceFile. parentDirectory, recursive: true )
209
209
try localFileSystem. writeFileContents ( pluginSourceFile, string: """
210
210
import PackagePlugin
211
+ #if os(Android)
212
+ let touchExe = " /system/bin/touch "
213
+ #else
214
+ let touchExe = " /usr/bin/touch "
215
+ #endif
216
+
211
217
@main
212
218
struct Plugin: BuildToolPlugin {
213
219
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
214
220
return [
215
221
.buildCommand(
216
222
displayName: " empty " ,
217
- executable: .init( " /usr/bin/touch " ),
223
+ executable: .init(touchExe ),
218
224
arguments: [context.pluginWorkDirectory.appending( " best.txt " )],
219
225
inputFiles: [],
220
226
outputFiles: []
You can’t perform that action at this time.
0 commit comments