Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen-IR version: 0.5.1 #76

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PIF/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.10
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

<p align="center">
<a href="https://github.com/veracode/gen-ir/actions/workflows/build.yml">
<img src="https://github.com/veracode/gen-ir/actions/workflows/build.yml/badge.svg?branch=main" />
<img src="https://github.com/veracode/gen-ir/actions/workflows/build.yml/badge.svg?branch=main" alt="Badge showing status of the build pipelines"/>
</a>
<a href="">
<img src="https://img.shields.io/github/v/release/veracode/gen-ir" />
<img src="https://img.shields.io/github/v/release/veracode/gen-ir" alt="Badge showing the current release version of Gen IR"/>
</a>
</p>

This tool was heavily inspired by: https://blog.digitalrickshaw.com/2016/03/14/dumping-the-swift-ast-for-an-ios-project-part-2.html ❤️
This tool was heavily inspired by [a DigitalRickshaw blog post](https://blog.digitalrickshaw.com/2016/03/14/dumping-the-swift-ast-for-an-ios-project-part-2.html) ❤️

## Prerequisites

Expand All @@ -41,7 +41,7 @@ brew install gen-ir
brew upgrade gen-ir
```

## 🎉 Done!
## 🎉 Done

All installed! You can now use `gen-ir` on your system - be sure to run `gen-ir --help` to check the available commands and options.

Expand All @@ -54,6 +54,8 @@ All installed! You can now use `gen-ir` on your system - be sure to run `gen-ir
>**This means a clean, fresh build of a project.**
>
>The compiler will **not** make a call for an object that doesn't need to be rebuilt, and we will not be able to parse what doesn't exist. Ensure you do a clean before your build otherwise `gen-ir` may miss some modules.
>
> Due to a bug in Xcode you **must** run the clean and archive commands _separately_. This means you need to do a `xcodebuild clean` and _then_ an `xcodebuild archive` and not `xcodebuild clean archive`.

`gen-ir` takes a Xcode build log by two means, a path to a file or stdin:

Expand All @@ -71,7 +73,7 @@ xcodebuild archive -project TestProject.xcodeproj -scheme TestProject -configura

## Building

`gen-ir` is implemented as a Swift Package, so you can either open [`Package.swift`](Package.swift) in Xcode, or build via the command line:
`gen-ir` is implemented as a Swift Package, so you can either open [`Package.swift`](Package.swift) in an IDE or build via the command line:

```sh
# Debug output: ./.build/debug/gen-ir
Expand Down
12 changes: 6 additions & 6 deletions Sources/GenIR/Extensions/Process+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ extension Process {
/// - stderr: the standard error
/// - code: the exit code
init(stdout: String?, stderr: String?, code: Int32) {
self.stdout = if let stdout, stdout.isEmpty {
nil
if let stdout, stdout.isEmpty {
self.stdout = nil
} else {
stdout
self.stdout = stdout
}

self.stderr = if let stderr, stderr.isEmpty {
nil
if let stderr, stderr.isEmpty {
self.stderr = nil
} else {
stderr
self.stderr = stderr
}

self.code = code
Expand Down
8 changes: 4 additions & 4 deletions Sources/GenIR/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class Target {
init(from baseTarget: PIF.BaseTarget) {
guid = baseTarget.guid
name = baseTarget.name
productName = if let target = baseTarget as? PIF.Target, !target.productName.isEmpty {
target.productName
if let target = baseTarget as? PIF.Target, !target.productName.isEmpty {
productName = target.productName
} else if baseTarget.guid == "PACKAGE-PRODUCT:\(baseTarget.name)" {
// The `PACKAGE-PRODUCT` for a package does not have a product reference name so
// we do not have a proper extension. For now we assume it is a framework and add
// the extension. A better way may be to follow the `dynamicTargetVariantGuid` of
// the `PACKAGE-TARGET` as this appears to provide the correct name if available.
baseTarget.name.appending(".framework")
productName = baseTarget.name.appending(".framework")
} else {
// Fallback to the target's name if we are unable to determine a proper product name.
baseTarget.name
productName = baseTarget.name
}
isBuildable = guid == "PACKAGE-TARGET:\(name)" || !guid.hasPrefix("PACKAGE-")
isPackageProduct = !guid.hasPrefix("PACKAGE-TARGET:")
Expand Down
2 changes: 1 addition & 1 deletion Sources/GenIR/Versions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

enum Versions {
static let version = "0.5.0"
static let version = "0.5.1"
}
2 changes: 1 addition & 1 deletion Tests/GenIRTests/WorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class WorkspaceTests: XCTestCase {

// Check dependencies made it to the right place. All dependencies should be statically
// linked and appear under the .app directory.
let appIRPath = context.archive.appending(path: "IR/App.app/")
let appIRPath = context.archive.appendingPathComponent("IR/App.app/")

let expectedIRFiles = Self.appIRFiles
.union(Self.commonIRFiles)
Expand Down