feat(build): Development tasks
This commit is contained in:
parent
042d385015
commit
dc366079ae
13
.gitignore
vendored
13
.gitignore
vendored
@ -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
|
||||
|
35
Makefile
Normal file
35
Makefile
Normal file
@ -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
|
30
bump.sh
30
bump.sh
@ -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 "$@"
|
32
common/bump.sh
Executable file
32
common/bump.sh
Executable file
@ -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 "$@"
|
@ -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")"
|
||||
|
26
common/version.sh
Executable file
26
common/version.sh
Executable file
@ -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 "<include/version.hpp> is already up-to-date"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
25
version.sh
25
version.sh
@ -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 "<include/version.hpp> is already up-to-date"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue
Block a user