-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Homebrew formula using Makefile
See details in this blog post: https://nshipster.com/homebrew/
- Loading branch information
Showing
2 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
class Beak < Formula | ||
desc "A command line interface for your Swift scripts" | ||
homepage "https://github.com/yonaskolb/Beak" | ||
url "https://github.com/yonaskolb/Beak/archive/0.4.0.tar.gz" | ||
sha256 "c306292c94aadd648437a2334936231baaa9ba195738aeeb28379fcb34900d41" | ||
head "https://github.com/yonaskolb/Beak.git" | ||
desc "Command-line interface for your Swift scripts" | ||
homepage "https://github.com/Dschee/Beak" | ||
url "https://github.com/Dschee/Beak.git", :tag => "0.4.0", :revision => "8508e02da82c279b3cf1719bd226dc8c94538a71" | ||
|
||
depends_on :xcode | ||
depends_on :xcode => ["10.0", :build] | ||
|
||
def install | ||
|
||
# fixes an issue an issue in homebrew when both Xcode 9.3+ and command line tools are installed | ||
# see more details here https://github.com/Homebrew/brew/pull/4147 | ||
ENV["CC"] = Utils.popen_read("xcrun -find clang").chomp | ||
system "make", "install", "prefix=#{prefix}" | ||
end | ||
|
||
build_path = "#{buildpath}/.build/release/beak" | ||
ohai "Building Beak" | ||
system("swift build --disable-sandbox -c release -Xswiftc -static-stdlib") | ||
bin.install build_path | ||
test do | ||
system bin/"beak", "version" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
SHELL = /bin/bash | ||
|
||
prefix ?= /usr/local | ||
bindir ?= $(prefix)/bin | ||
libdir ?= $(prefix)/lib | ||
srcdir = Sources | ||
|
||
REPODIR = $(shell pwd) | ||
BUILDDIR = $(REPODIR)/.build | ||
SOURCES = $(wildcard $(srcdir)/**/*.swift) | ||
|
||
.DEFAULT_GOAL = all | ||
|
||
.PHONY: all | ||
all: beak | ||
|
||
beak: $(SOURCES) | ||
@swift build \ | ||
-c release \ | ||
--disable-sandbox \ | ||
--build-path "$(BUILDDIR)" | ||
|
||
.PHONY: install | ||
install: beak | ||
@install -d "$(bindir)" "$(libdir)" | ||
@install "$(BUILDDIR)/release/beak" "$(bindir)" | ||
|
||
.PHONY: uninstall | ||
uninstall: | ||
@rm -rf "$(bindir)/beak" | ||
|
||
.PHONY: clean | ||
distclean: | ||
@rm -f $(BUILDDIR)/release | ||
|
||
.PHONY: clean | ||
clean: distclean | ||
@rm -rf $(BUILDDIR) |