Improve logging for SwiftPM build

This commit is contained in:
Yuta Saito 2024-02-27 01:55:44 +09:00
parent e4ea08a05b
commit 3086e5fd48
2 changed files with 13 additions and 4 deletions

View File

@ -45,6 +45,10 @@ struct CartonBundlePlugin: CommandPlugin {
configuration: options.debug ? .debug : .release,
logging: .verbose
)
#if compiler(>=5.11) || compiler(>=6)
parameters.echoLogs = true
parameters.logging = .concise
#endif
applyExtraBuildFlags(from: &extractor, parameters: &parameters)
print("Building \"\(productName)\"")
let build = try self.packageManager.build(.product(productName), parameters: parameters)

View File

@ -20,11 +20,13 @@ struct CartonDevPlugin: CommandPlugin {
struct Options {
var product: String?
var release: Bool
var verbose: Bool
static func parse(from extractor: inout ArgumentExtractor) throws -> Options {
let product = extractor.extractOption(named: "product").last
let release = extractor.extractFlag(named: "release")
return Options(product: product, release: release != 0)
let verbose = extractor.extractFlag(named: "verbose")
return Options(product: product, release: release != 0, verbose: verbose != 0)
}
}
@ -42,8 +44,11 @@ struct CartonDevPlugin: CommandPlugin {
// Build products
var parameters = PackageManager.BuildParameters(
configuration: options.release ? .release : .debug,
logging: .verbose
logging: options.verbose ? .verbose : .concise
)
#if compiler(>=5.11) || compiler(>=6)
parameters.echoLogs = true
#endif
Environment.browser.applyBuildParameters(&parameters)
applyExtraBuildFlags(from: &extractor, parameters: &parameters)
@ -77,17 +82,17 @@ struct CartonDevPlugin: CommandPlugin {
let buildRequestPipe = try createFifo(hint: "build-request", directory: tempDirectory)
let buildResponsePipe = try createFifo(hint: "build-response", directory: tempDirectory)
let frontend = try! makeCartonFrontendProcess(
let frontend = try makeCartonFrontendProcess(
context: context,
arguments: [
"dev",
"--verbose",
"--main-wasm-path", productArtifact.path.string,
"--build-request", buildRequestPipe,
"--build-response", buildResponsePipe,
]
+ resourcesPaths.flatMap { ["--resources", $0.string] }
+ pathsToWatch.flatMap { ["--watch-path", $0] }
+ (options.verbose ? ["--verbose"] : [])
+ extractor.remainingArguments
)
frontend.forwardTerminationSignals()