-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Makefile - Add PKGBUILD for Archlinux - Add notice about PNG supporting only
- Loading branch information
Showing
5 changed files
with
219 additions
and
1 deletion.
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,3 +1,4 @@ | ||
.idea | ||
.go | ||
vendor | ||
vendor | ||
build/bin |
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,29 @@ | ||
Contribution Guide | ||
================== | ||
|
||
## Requirements | ||
|
||
- If you don't use docker-wrapped commands, make sure that tools you use have the same version as in docker-wrapped | ||
commands. It's latest version, mainly. | ||
|
||
## Operations | ||
|
||
Take a look at [`Makefile`][1] for commands usage details. | ||
|
||
### Dependencies | ||
|
||
To preload project dependencies use docker-wrapped command from [`Makefile`][1]: | ||
|
||
```bash | ||
make deps | ||
``` | ||
|
||
### Building | ||
|
||
To build/rebuild binaries use command from [`Makefile`][1]: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
[1]: Makefile |
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,143 @@ | ||
#!/usr/bin/env make | ||
|
||
env.file ?= | ||
|
||
ifdef env.file | ||
include $(env.file) | ||
export $(shell sed 's/=.*//' $(env.file)) | ||
endif | ||
|
||
############################### | ||
# Common defaults/definitions # | ||
############################### | ||
|
||
comma := , | ||
|
||
# Checks two given strings for equality. | ||
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ | ||
$(findstring $(2),$(1))),1) | ||
|
||
|
||
|
||
|
||
############### | ||
# Git Section # | ||
############### | ||
|
||
MAINLINE_BRANCH := dev | ||
CURRENT_BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2) | ||
|
||
# Squash changes of the current Git branch onto another Git branch. | ||
# | ||
# WARNING: You must merge `onto` branch in the current branch before squash! | ||
# | ||
# Usage: | ||
# make squash [onto=] [del=(no|yes)] | ||
|
||
onto ?= $(MAINLINE_BRANCH) | ||
del ?= no | ||
upstream ?= origin | ||
|
||
squash: | ||
ifeq ($(CURRENT_BRANCH),$(onto)) | ||
@echo "--> Current branch is '$(onto)' already" && false | ||
endif | ||
git checkout $(onto) | ||
git branch -m $(CURRENT_BRANCH) orig-$(CURRENT_BRANCH) | ||
git checkout -b $(CURRENT_BRANCH) | ||
git branch --set-upstream-to $(upstream)/$(CURRENT_BRANCH) | ||
git merge --squash orig-$(CURRENT_BRANCH) | ||
ifeq ($(del),yes) | ||
git branch -d orig-$(CURRENT_BRANCH) | ||
endif | ||
|
||
|
||
|
||
|
||
########### | ||
# Aliases # | ||
########### | ||
|
||
build: | ||
@make go.build | ||
|
||
clean: go.clean | ||
|
||
# Resolve all project dependencies. | ||
# | ||
# Usage: | ||
# make deps | ||
|
||
deps: go.deps | ||
|
||
|
||
|
||
############### | ||
# Go commands # | ||
############### | ||
|
||
pkgname = blurhash-cli | ||
pkgver ?= 1.0.0 | ||
builddir ?= ./build/bin | ||
mainpath ?= ./cmd/cli/main.go | ||
|
||
go.build: | ||
mkdir -p ${builddir} | ||
export CGO_CPPFLAGS="${CPPFLAGS}" | ||
export CGO_CFLAGS="${CFLAGS}" | ||
export CGO_CXXFLAGS="${CXXFLAGS}" | ||
export CGO_LDFLAGS="${LDFLAGS}" | ||
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" | ||
GOARCH=amd64 GOOS=darwin go build -o ${builddir}/${pkgname}-${pkgver}-darwin ${mainpath} | ||
GOARCH=amd64 GOOS=linux go build -o ${builddir}/${pkgname}-${pkgver}-linux ${mainpath} | ||
GOARCH=amd64 GOOS=windows go build -o ${builddir}/${pkgname}-${pkgver}-windows ${mainpath} | ||
|
||
go.clean: | ||
go clean | ||
rm -rf ${builddir} | ||
|
||
go.deps: | ||
go mod download | ||
|
||
|
||
|
||
|
||
################### | ||
# Docker commands # | ||
################### | ||
|
||
# Execute docker command with needed params. | ||
# | ||
# Usage: | ||
docker.run: | ||
|
||
# Stop project in Docker Compose development environment | ||
# and remove all related containers. | ||
# | ||
# Usage: | ||
# make docker.down | ||
|
||
docker.down: | ||
CURRENT_UID=$(shell id -u):$(shell id -g) docker compose down --rmi=local -v | ||
|
||
# Run Docker Compose development environment. | ||
# | ||
# Usage: | ||
# make docker.up [rebuild=(yes|no)] | ||
# [background=(no|yes)] | ||
|
||
rebuild ?= yes | ||
background ?= no | ||
|
||
docker.up: | ||
CURRENT_UID=$(shell id -u):$(shell id -g) docker compose up \ | ||
$(if $(call eq,$(rebuild),no),,--build) \ | ||
$(if $(call eq,$(background),yes),-d,--abort-on-container-exit) | ||
|
||
|
||
|
||
|
||
.PHONY: squash \ | ||
go.clean go.build go.deps \ | ||
clean deps build up down \ | ||
docker.up docker.down |
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
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,35 @@ | ||
pkgname=blurhash-cli | ||
pkgver=v1.0.0 | ||
pkgrel=1 | ||
pkgdesc='BlurHash CLI tool' | ||
arch=('x86_64') | ||
url="https://github.com/alersrt/go-blurhash-cli/archive/refs/tags" | ||
license=('MIT') | ||
makedepends=('go') | ||
source=("$url/$pkgname-$pkgver.tar.gz") | ||
# sha256sums=('...') | ||
|
||
prepare(){ | ||
cd "$pkgname-$pkgver" | ||
mkdir -p build/ | ||
} | ||
|
||
build() { | ||
cd "$pkgname-$pkgver" | ||
export CGO_CPPFLAGS="${CPPFLAGS}" | ||
export CGO_CFLAGS="${CFLAGS}" | ||
export CGO_CXXFLAGS="${CXXFLAGS}" | ||
export CGO_LDFLAGS="${LDFLAGS}" | ||
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" | ||
go build -o build/bin/$pkgname ./cmd/cli/main.go | ||
} | ||
|
||
check() { | ||
cd "$pkgname-$pkgver" | ||
go test ./... | ||
} | ||
|
||
package() { | ||
cd "$pkgname-$pkgver" | ||
install -Dm755 build/bin/$pkgname "$pkgdir"/usr/bin/$pkgname | ||
} |