Skip to content

Commit

Permalink
Merge pull request #21 from rockbruno/homebrew-2
Browse files Browse the repository at this point in the history
Homebrew changes
  • Loading branch information
rockbruno authored May 3, 2019
2 parents 067c7e6 + 3b993b3 commit d63a78a
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 67 deletions.
16 changes: 0 additions & 16 deletions ExampleProject/Podfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion ExampleProject/_CDToMeAndRun.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bundle install
bundle exec pod install
bundle exec fastlane beta
./Pods/SwiftInfo/swiftinfo
./Pods/SwiftInfo/bin/swiftinfo
echo "-------"
echo "This bash script runs SwiftInfo outside of fastlane so you can see the output, but check out the Fastfile to see how you could use this in a real project."
14 changes: 10 additions & 4 deletions Formula/swiftinfo.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
class Swiftinfo < Formula
desc "📊 Extract and analyze the evolution of an iOS app's code."
homepage "https://github.com/rockbruno/SwiftInfo"
url "https://github.com/rockbruno/SwiftInfo.git", :tag => "2.2.0", :revision => "4dc083130a0b519307436c7083e3d417d1aea870"
head "https://github.com/rockbruno/SwiftInfo.git"
version "2.3.0"
url "https://github.com/rockbruno/SwiftInfo/releases/download/#{version}/swiftinfo.zip"
# TODO: Try something to provide a SHA automatically

depends_on :xcode => ["10.2", :build]

def install
system "make", "install", "prefix=#{prefix}"
bin.install Dir["bin/*"]
include.install Dir["include/*"]
end
end

test do
system bin/"swiftinfo", "-version"
end
end
63 changes: 32 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
SHELL = /bin/bash

prefix ?= /usr/local
bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
srcdir = Sources

REPODIR = $(shell pwd)
BUILDDIR = $(REPODIR)/.build
SOURCES = $(wildcard $(srcdir)/**/*.swift)
RELEASEBUILDDIR = $(BUILDDIR)/release
TEMPPRODUCTDIR = $(BUILDDIR)/_PRODUCT
PRODUCTDIR = $(RELEASEBUILDDIR)/_PRODUCT

.DEFAULT_GOAL = all

.PHONY: all
all: swiftinfo
all: build

swiftinfo: $(SOURCES)
.PHONY: build
build:
@swift build \
-c release \
--disable-sandbox \
--build-path "$(BUILDDIR)"

.PHONY: install
install: swiftinfo
@install -d "$(bindir)" "$(libdir)"
@install "$(BUILDDIR)/release/swiftinfo" "$(bindir)"
@cp -a "$(REPODIR)/Sources/Csourcekitd/." "$(bindir)/Csourcekitd"

.PHONY: portable_zip
portable_zip: swiftinfo
rm -f "$(BUILDDIR)/release/portable_swiftinfo.zip"
zip -j "$(BUILDDIR)/release/portable_swiftinfo.zip" "$(BUILDDIR)/release/swiftinfo" "$(REPODIR)/LICENSE"
echo "Portable ZIP created at: $(BUILDDIR)/release/portable_swiftinfo.zip"

.PHONY: uninstall
uninstall:
@rm -rf "$(bindir)/swiftinfo"
@rm -rf "$(bindir)/Csourcekitd"

.PHONY: clean
distclean:
@rm -f $(BUILDDIR)/release
@rm -rf "$(PRODUCTDIR)"
@rm -rf "$(TEMPPRODUCTDIR)"
@mkdir -p "$(TEMPPRODUCTDIR)"
@mkdir -p "$(TEMPPRODUCTDIR)/include/swiftinfo"
@cp -a "$(RELEASEBUILDDIR)/." "$(TEMPPRODUCTDIR)/include/swiftinfo"
@cp -a "$(TEMPPRODUCTDIR)/." "$(PRODUCTDIR)"
@rm -rf "$(TEMPPRODUCTDIR)"
@mkdir -p "$(PRODUCTDIR)/bin"
@rm -rf $(PRODUCTDIR)/include/swiftinfo/*.build
@rm -rf $(PRODUCTDIR)/include/swiftinfo/*.product
@rm -rf $(PRODUCTDIR)/include/swiftinfo/ModuleCache
@rm -f "$(PRODUCTDIR)/include/swiftinfo/SwiftInfo.swiftdoc"
@rm -f "$(PRODUCTDIR)/include/swiftinfo/SwiftInfo.swiftmodule"
@mv "$(PRODUCTDIR)/include/swiftinfo/swiftinfo" "$(PRODUCTDIR)/bin"
@cp -a "$(REPODIR)/Sources/Csourcekitd/." "$(PRODUCTDIR)/include/swiftinfo/Csourcekitd"
@rm -f "$(RELEASEBUILDDIR)/swiftinfo"
@ln -s "$(PRODUCTDIR)/bin/swiftinfo" "$(RELEASEBUILDDIR)/swiftinfo"
@cp "$(REPODIR)/LICENSE" "$(PRODUCTDIR)/LICENSE"

.PHONY: package
package:
rm -f "$(PRODUCTDIR)/swiftinfo.zip"
cd $(PRODUCTDIR) && zip -r ./swiftinfo.zip ./
echo "ZIP created at: $(PRODUCTDIR)/swiftinfo.zip"

.PHONY: clean
clean: distclean
@rm -rf $(BUILDDIR)
clean:
@rm -rf "$(BUILDDIR)"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Documentation of useful types and methods from SwiftInfoCore that you can use wh

## Installation

### [Homebrew](https://brew.sh/) (Recommended)
### [Homebrew](https://brew.sh/)

To install SwiftInfo the first time, simply run these commands:

Expand All @@ -187,7 +187,7 @@ brew tap rockbruno/SwiftInfo https://github.com/rockbruno/SwiftInfo.git
brew install swiftinfo
```

To **update** to the newest version of SwiftINfo when you have an old version already installed run:
To **update** to the newest version of SwiftInfo when you have an old version already installed run:

```bash
brew upgrade swiftinfo
Expand All @@ -197,7 +197,7 @@ brew upgrade swiftinfo

`pod 'SwiftInfo'`

### Manually
### Manual

Download the [latest release](https://github.com/rockbruno/SwiftInfo/releases) and unzip the contents somewhere in your project's folder.

Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftInfo/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ public struct Main {
static func run() {
let fileUtils = FileUtils()
let toolchainPath = getToolchainPath()
log("SwiftInfo")
log("SwiftInfo 2.3.0")
if ProcessInfo.processInfo.arguments.contains("-version") {
exit(0)
}
log("Dylib Folder: \(fileUtils.toolFolder)", verbose: true)
log("Infofile Path: \(try! fileUtils.infofileFolder())", verbose: true)
log("Toolchain Path: \(toolchainPath)", verbose: true)
Expand Down
9 changes: 5 additions & 4 deletions Sources/SwiftInfoCore/Runner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ public enum Runner {
public static func getCoreSwiftCArguments(fileUtils: FileUtils,
toolchainPath: String,
processInfoArgs: [String]) -> [String] {
let include = fileUtils.toolFolder + "/../include/swiftinfo"
return [
"swiftc",
"--driver-mode=swift", // Don't generate a binary, just run directly.
"-L", // Link with SwiftInfoCore manually.
fileUtils.toolFolder,
include,
"-I",
fileUtils.toolFolder,
include,
"-lSwiftInfoCore",
"-Xcc",
"-fmodule-map-file=\(fileUtils.toolFolder)/Csourcekitd/include/module.modulemap",
"-fmodule-map-file=\(include)/Csourcekitd/include/module.modulemap",
"-I",
"\(fileUtils.toolFolder)/Csourcekitd/include",
"\(include)/Csourcekitd/include",
(try! fileUtils.infofileFolder()) + "Infofile.swift",
"-toolchain",
"\(toolchainPath)"] + Array(processInfoArgs.dropFirst()) // Route SwiftInfo args to the sub process
Expand Down
2 changes: 1 addition & 1 deletion SwiftInfo.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'SwiftInfo'
s.module_name = 'SwiftInfo'
s.version = '2.2.0'
s.version = '2.3.0'
s.license = { type: 'MIT', file: 'LICENSE' }
s.summary = 'Extract and analyze the evolution of an iOS app\'s code.'
s.homepage = 'https://github.com/rockbruno/SwiftInfo'
Expand Down
8 changes: 5 additions & 3 deletions Tests/SwiftInfoTests/CoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ final class CoreTests: XCTestCase {
toolchainPath: toolchainPath,
processInfoArgs: exampleRun)
let executionPath = ProcessInfo.processInfo.arguments.first!
let toolFolder = URL(string: executionPath)!.deletingLastPathComponent().absoluteString
let toolFolder = URL(string: executionPath)!
.deletingLastPathComponent()
.absoluteString + "../include/swiftinfo"
XCTAssertEqual(args, ["swiftc",
"--driver-mode=swift",
"-L", toolFolder, "-I", toolFolder, "-lSwiftInfoCore",
"-Xcc",
"-fmodule-map-file=\(toolFolder)Csourcekitd/include/module.modulemap",
"-I", "\(toolFolder)Csourcekitd/include",
"-fmodule-map-file=\(toolFolder)/Csourcekitd/include/module.modulemap",
"-I", "\(toolFolder)/Csourcekitd/include",
"./Infofile.swift", "-toolchain", "\(toolchainPath)", "-v", "-s"])
}

Expand Down
3 changes: 0 additions & 3 deletions prepare_for_release.sh

This file was deleted.

Binary file removed swiftinfo-2.2.0.tar.gz
Binary file not shown.

0 comments on commit d63a78a

Please sign in to comment.