Skip to content

Commit eb60038

Browse files
committed
Move swift-parser-cli to its own package
1 parent 3eb344c commit eb60038

15 files changed

+100
-21
lines changed

Package.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ let package = Package(
257257
dependencies: ["_SwiftSyntaxTestSupport", "SwiftRefactor"]
258258
),
259259

260-
// MARK: - Executable targets
261-
262-
.executableTarget(
263-
name: "swift-parser-cli",
264-
dependencies: [
265-
"_InstructionCounter", "SwiftBasicFormat", "SwiftDiagnostics", "SwiftOperators", "SwiftParser", "SwiftParserDiagnostics", "SwiftSyntax",
266-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
267-
]
268-
),
269-
270260
// MARK: - Deprecated targets
271261

272262
// MARK: PerformanceTest
@@ -295,14 +285,3 @@ package.targets.append(
295285
}
296286
)
297287
)
298-
299-
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
300-
// Building standalone.
301-
package.dependencies += [
302-
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2")
303-
]
304-
} else {
305-
package.dependencies += [
306-
.package(path: "../swift-argument-parser")
307-
]
308-
}

SwiftParserCLI/Package.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "SwiftParserCLI",
6+
platforms: [
7+
.macOS(.v10_15)
8+
],
9+
products: [
10+
.executable(name: "swift-parser-cli", targets: ["swift-parser-cli"])
11+
],
12+
dependencies: [
13+
.package(path: "..")
14+
],
15+
targets: [
16+
.target(
17+
name: "_InstructionCounter"
18+
),
19+
20+
.executableTarget(
21+
name: "swift-parser-cli",
22+
dependencies: [
23+
"_InstructionCounter",
24+
.product(name: "SwiftBasicFormat", package: "swift-syntax"),
25+
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
26+
.product(name: "SwiftOperators", package: "swift-syntax"),
27+
.product(name: "SwiftParser", package: "swift-syntax"),
28+
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
29+
.product(name: "SwiftSyntax", package: "swift-syntax"),
30+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
31+
]
32+
),
33+
]
34+
)
35+
36+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
37+
// Building standalone.
38+
package.dependencies += [
39+
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2")
40+
]
41+
} else {
42+
package.dependencies += [
43+
.package(path: "../../swift-argument-parser")
44+
]
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include <stdint.h>
14+
15+
/// On macOS returns the number of instructions the process has executed since
16+
/// it was launched, on all other platforms returns 0.
17+
uint64_t getInstructionsExecuted();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#if __APPLE__
14+
#include <TargetConditionals.h>
15+
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
16+
#define TARGET_IS_MACOS 1
17+
#endif
18+
#endif
19+
20+
#include "InstructionsExecuted.h"
21+
22+
#ifdef TARGET_IS_MACOS
23+
#include <libproc.h>
24+
#include <sys/resource.h>
25+
#include <unistd.h>
26+
27+
uint64_t getInstructionsExecuted() {
28+
struct rusage_info_v4 ru;
29+
if (proc_pid_rusage(getpid(), RUSAGE_INFO_V4, (rusage_info_t *)&ru) == 0) {
30+
return ru.ri_instructions;
31+
}
32+
return 0;
33+
}
34+
#else
35+
uint64_t getInstructionsExecuted() {
36+
return 0;
37+
}
38+
#endif

0 commit comments

Comments
 (0)