nokeedev / gradle-native

The home of anything about Gradle support for natively compiled languages
https://nokee.dev
Apache License 2.0
47 stars 8 forks source link

Deep understanding of the Xcodebuild output #648

Open lacasseio opened 2 years ago

lacasseio commented 2 years ago

Xcodebuild's output is somewhat structured (to some extent, similar to Gradle with section headers). It would be ideal if we could tap into the stage start/output/end events which we could wrap into Gradle build operations and possibly capture the events in a build scan. At the very least, we could output them into a chrome trace. A deeper understanding of the output can help show relevant information such as failed stages, or warnings.

Each stage is split into blocks containing a header, stage commands and output. Generally, a block is preceded by a new line. The header starts with the stage type (which seems to not contain spaces) followed by some payload information specific to the stage type. Each stage's command is indented by 4 spaces. The command's output is not indented and follows the command as-is. This means there may be some new line causing confusion as to where a new block starts.

There are a couple of projects in the wild that parses Xcodebuild outputs which could be an inspiration for this work.

lacasseio commented 2 years ago

There are some very good information about Xcodebuild output here (XCLogParser) and here (xcpretty).

lacasseio commented 2 years ago

So far, there are four different xcodebuild "output": 1) Raw CLI output 2) xcresult bundle (generated by -resultBundlePath) 3) JSON stream (generated by -resultStreamPath) 4) xcactivitylog (requires -resultBundlePath flag)

We could streamline the output processing using only the raw CLI output but it may be quite fragile. Antlr, our processor of choice, doesn't seem to be able to stream a file. Both xcresult and xcactivitylog are most likely only available after the build finishes. This leaves us with the JSON stream which we haven't yet found any information. At a first glance, it seems to be pretty a best effort at creating a stream of events. We need more investigations.

lacasseio commented 2 years ago

The project xcbeautify seems to supersede xcpretty.