diff --git a/.gitignore b/.gitignore index 814bab40..925ae7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ -/build*/ -!cmake/build/ -tags +/build* +/doc/config +/include/settings.hpp +/polybar +/polybar-msg +/tags *.bak *.pyc -*.tmp *.swp -include/settings.hpp +*.tmp .tags -doc/config diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..70472178 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# +# Polybar development tasks +# +BUILDDIR ?= build +GENERATOR ?= $(shell command -vp ninja make | xargs basename | sed "s/ninja/Ninja/;s/make/Unix Makefiles/") + +all: configure build link + +configure: + @echo "\033[32;1m**\033[0m Configuring..." + @mkdir -p $(BUILDDIR) + @cd $(BUILDDIR) && cmake -G "$(GENERATOR)" .. + +build: + @echo "\033[32;1m**\033[0m Building..." + @cmake --build $(BUILDDIR) + +install: + @echo "\033[32;1m**\033[0m Installing..." + @cmake --build $(BUILDDIR) --target install + +link: + @echo "\033[32;1m**\033[0m Linking executable..." + @if [ -x $(BUILDDIR)/bin/polybar ]; then ln -sfv $(BUILDDIR)/bin/polybar; fi + @if [ -x $(BUILDDIR)/bin/polybar-msg ]; then ln -sfv $(BUILDDIR)/bin/polybar-msg; fi + +clean: + @echo "\033[32;1m**\033[0m Cleaning up..." + @if [ -d $(BUILDDIR) ]; then rm -rf $(BUILDDIR); fi + @if [ -L polybar ]; then rm -v polybar; fi + @if [ -L polybar-msg ]; then rm -v polybar-msg; fi + +.PHONY: configure build link clean + +# vim:ts=2 sw=2 noet nolist diff --git a/bump.sh b/bump.sh deleted file mode 100755 index de4d1ad4..00000000 --- a/bump.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -# Use passed argument as new tag -if [ $# -eq 0 ]; then - version=$(git describe --tags --abbrev=0) - patch=${version##*.} - set -- "${version%.*}.$((patch+1))" -fi - -git tag "$@" || exit 1 - -tag_curr="$(git tag --sort=version:refname | tail -1)" -tag_prev="$(git tag --sort=version:refname | tail -2 | head -1)" - -./version.sh "$tag_curr" - -sed -r "s/${tag_prev}/${tag_curr}/g" -i \ - README.md CMakeLists.txt \ - contrib/polybar.aur/PKGBUILD contrib/polybar.aur/.SRCINFO \ - contrib/polybar-git.aur/PKGBUILD contrib/polybar-git.aur/.SRCINFO - -git add -u README.md CMakeLists.txt \ - contrib/polybar.aur/PKGBUILD contrib/polybar.aur/.SRCINFO \ - contrib/polybar-git.aur/PKGBUILD contrib/polybar-git.aur/.SRCINFO \ - include/version.hpp - -git commit -m "build: Bump version to ${tag_curr}" - -# Recreate the tag to include the last commit -[ $# -eq 1 ] && git tag -f "$@" diff --git a/common/bump.sh b/common/bump.sh new file mode 100755 index 00000000..cef51502 --- /dev/null +++ b/common/bump.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +main() { + if [ $# -eq 0 ]; then + version=$(git describe --tags --abbrev=0) + set -- "${version%.*}.${version##*.}" + fi + + git tag "$@" || exit 1 + + tag_curr="$(git tag --sort=version:refname | tail -1)" + tag_prev="$(git tag --sort=version:refname | tail -2 | head -1)" + + ./version.sh "$tag_curr" + + sed -r "s/${tag_prev}/${tag_curr}/g" -i \ + README.md CMakeLists.txt \ + contrib/polybar.aur/PKGBUILD contrib/polybar.aur/.SRCINFO \ + contrib/polybar-git.aur/PKGBUILD contrib/polybar-git.aur/.SRCINFO + + git add -u README.md CMakeLists.txt \ + contrib/polybar.aur/PKGBUILD contrib/polybar.aur/.SRCINFO \ + contrib/polybar-git.aur/PKGBUILD contrib/polybar-git.aur/.SRCINFO \ + include/version.hpp + + git commit -m "build: Bump version to ${tag_curr}" + + # Recreate the tag to include the last commit + [ $# -eq 1 ] && git tag -f "$@" +} + +main "$@" diff --git a/common/clang-format.sh b/common/clang-format.sh index b24db0a1..a4edfed6 100755 --- a/common/clang-format.sh +++ b/common/clang-format.sh @@ -2,10 +2,9 @@ main() { if [ $# -lt 1 ]; then - echo "$0 DIR..." 1>&2 + printf "%s DIR...\n" "$0" 1>&2 exit 1 fi - search="${*:-.}" [ -d "$search" ] || search="$(dirname "$search")" diff --git a/common/version.sh b/common/version.sh new file mode 100755 index 00000000..db88e141 --- /dev/null +++ b/common/version.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +msg() { + if [ -t 1 ]; then + printf " \033[1;32m**\033[0m %s\n" "$@" + else + printf "** %s\n" "$@" + fi +} + +main() { + if [ $# -eq 0 ]; then + set -- "$(git describe --tags --dirty=-dev)" + fi + + msg "Current version: $1" + sed -r "/#define GIT_TAG/s/GIT_TAG .*/GIT_TAG \"$1\"/" -i include/version.hpp + + if git diff include/version.hpp 2>/dev/null | grep -q .; then + msg "Updated include/version.hpp" + else + msg " is already up-to-date" + fi +} + +main "$@" diff --git a/version.sh b/version.sh deleted file mode 100755 index a2428f66..00000000 --- a/version.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -msg() { - echo " \033[1;32m**\033[0m" "$@" -} - -main() { - version="$1" - - [ "$version" ] || { - version="$(git describe --tags --dirty=-dev)" - } - - msg "Current version: ${version}" - - sed -r "/#define GIT_TAG/s/GIT_TAG .*/GIT_TAG \"${version}\"/" -i include/version.hpp - - if [ "$(git diff include/version.hpp 2>/dev/null)" ]; then - msg "Updated include/version.hpp" - else - msg " is already up-to-date" - fi -} - -main "$@"