Skip to content

Commit

Permalink
Fix glob to build logging library (#558)
Browse files Browse the repository at this point in the history
* Fix glob to build logging library
* Add usage help to configure script
  • Loading branch information
desyncr authored Jun 20, 2017
1 parent dec9b32 commit 47a99ad
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 37 deletions.
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
WITH_LOCK=yes
WITH_DEFER=yes
WITH_CACHE=yes
WITH_DEBUG=yes
WITH_PARALLEL=yes
WITH_EXTENSIONS=yes
WITH_COMPLETION=yes
DEBUG=yes
######################################################################
SHELL ?= sh
PREFIX ?= /usr/local
Expand All @@ -29,10 +29,10 @@ CONTAINER_IMAGE ?= desyncr/zsh-docker-

TARGET ?= ${BIN}/antigen.zsh
SRC ?= ${SRC}
DEBUG ?= yes
EXTENSIONS ?=
GLOB ?=

WITH_DEBUG ?= yes
WITH_EXTENSIONS ?= yes
WITH_DEFER ?= yes
WITH_LOCK ?= yes
Expand All @@ -57,14 +57,16 @@ GLOB += ${SRC}/boot.zsh
EXTENSIONS += ${SRC}/ext/cache.zsh
endif

GLOB += ${SRC}/antigen.zsh $(sort $(wildcard ${PWD}/src/helpers/*.zsh)) \
${SRC}/lib/*.zsh $(sort $(wildcard ${PWD}/src/commands/*.zsh)) ${EXTENSIONS}
LIB = $(filter-out ${SRC}/lib/log.zsh,$(sort $(wildcard ${PWD}/src/lib/*.zsh)))
HELPERS = $(sort $(wildcard ${PWD}/src/helpers/*.zsh))
COMMANDS= $(sort $(wildcard ${PWD}/src/commands/*.zsh))
GLOB += ${SRC}/antigen.zsh ${HELPERS} ${LIB} ${COMMANDS} ${EXTENSIONS}

ifeq (${WITH_COMPLETION}, yes)
GLOB += ${SRC}/_antigen
endif
# If debug is enabled then load debug functions
ifeq (${DEBUG}, yes)
ifeq (${WITH_DEBUG}, yes)
GLOB += ${SRC}/lib/log.zsh
endif

Expand Down Expand Up @@ -101,9 +103,9 @@ build:
@echo "-antigen-env-setup" >> ${TARGET}
@echo "${VERSION}" > ${VERSION_FILE}
@$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET})
ifeq (${DEBUG}, no)
@$(call isede,"s/(WARN|LOG|ERR|TRA) .*& //",${TARGET})
@$(call isede,"/(WARN|LOG|ERR|TRA) .*/d",${TARGET})
ifeq (${WITH_DEBUG}, no)
@$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET})
@$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET})
endif
@echo Done.
@ls -sh ${TARGET}
Expand Down
16 changes: 9 additions & 7 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ CONTAINER_IMAGE ?= desyncr/zsh-docker-

TARGET ?= ${BIN}/antigen.zsh
SRC ?= ${SRC}
DEBUG ?= yes
EXTENSIONS ?=
GLOB ?=

WITH_DEBUG ?= yes
WITH_EXTENSIONS ?= yes
WITH_DEFER ?= yes
WITH_LOCK ?= yes
Expand All @@ -45,14 +45,16 @@ GLOB += ${SRC}/boot.zsh
EXTENSIONS += ${SRC}/ext/cache.zsh
endif

GLOB += ${SRC}/antigen.zsh $(sort $(wildcard ${PWD}/src/helpers/*.zsh)) \
${SRC}/lib/*.zsh $(sort $(wildcard ${PWD}/src/commands/*.zsh)) ${EXTENSIONS}
LIB = $(filter-out ${SRC}/lib/log.zsh,$(sort $(wildcard ${PWD}/src/lib/*.zsh)))
HELPERS = $(sort $(wildcard ${PWD}/src/helpers/*.zsh))
COMMANDS= $(sort $(wildcard ${PWD}/src/commands/*.zsh))
GLOB += ${SRC}/antigen.zsh ${HELPERS} ${LIB} ${COMMANDS} ${EXTENSIONS}

ifeq (${WITH_COMPLETION}, yes)
GLOB += ${SRC}/_antigen
endif
# If debug is enabled then load debug functions
ifeq (${DEBUG}, yes)
ifeq (${WITH_DEBUG}, yes)
GLOB += ${SRC}/lib/log.zsh
endif

Expand Down Expand Up @@ -89,9 +91,9 @@ build:
@echo "-antigen-env-setup" >> ${TARGET}
@echo "${VERSION}" > ${VERSION_FILE}
@$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET})
ifeq (${DEBUG}, no)
@$(call isede,"s/(WARN|LOG|ERR|TRA) .*& //",${TARGET})
@$(call isede,"/(WARN|LOG|ERR|TRA) .*/d",${TARGET})
ifeq (${WITH_DEBUG}, no)
@$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET})
@$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET})
endif
@echo Done.
@ls -sh ${TARGET}
Expand Down
21 changes: 0 additions & 21 deletions bin/antigen.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -554,27 +554,6 @@ antigen () {
fi
done
}
zmodload zsh/datetime
ANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log}
LOG () {
local PREFIX="[LOG][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}

ERR () {
local PREFIX="[ERR][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}

WARN () {
local PREFIX="[WRN][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}

TRACE () {
local PREFIX="[TRA][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@\n${PREFIX} ${(j:\n:)funcstack}" >> $ANTIGEN_DEBUG_LOG
}
# Usage:
# -antigen-parse-args output_assoc_arr <args...>
-antigen-parse-args () {
Expand Down
35 changes: 34 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ target=Makefile
arguments="$@"
typeset -A opts;
opts=(
debug yes
with-debug yes
with-extensions yes
with-lock yes
with-parallel yes
Expand All @@ -13,6 +13,39 @@ with-defer yes
with-completion yes
)

if [[ $1 == "--help" || $1 == "-h" ]]; then
cat >&1 <<EOH
Usage:
./configure --with-option[=[yes|no]] --[enable|disable]-option
Available options:
- debug - Enable/disable debug library
- extensions - Enable/disable lock, parallel, cache and defer options
- lock - Enable/disable lock
- parallel - Enable/disable parallel
- cache - Enable/disable cache
- defer - Enable/disable defer
- completion - Enable/disable completion
All options are enabled by default.
Example:
# Disable lock, parallel, cache and defer
./configure --disable-extensions
# Disable completion
./configure --disable-completion
# Enable debug
./configure --with-debug
EOH
exit 0
fi


while [[ $# -gt 0 ]]; do
argkey="${1%\=*}"
key="${argkey//--/}"
Expand Down

0 comments on commit 47a99ad

Please sign in to comment.