Compare commits

..

No commits in common. "10767638ca795513ef5a63c98cedba060958687a" and "b33b2a98aca87f1bdd53e4cf703c1f9ae533ea02" have entirely different histories.

1 changed files with 21 additions and 26 deletions

View File

@ -54,37 +54,39 @@ PATH_PREFIX := /home/build/.local/bin:/home/build/$(CACHE_DIR)/bin:/home/build/$
PREFIX := $(HOME)/.local
XDG_CONFIG_HOME := $(HOME)/.config
# MacOS users do not have a 'date' command that supports milliseconds
# This is what we are forced to do. Other ideas welcome
define epochms
$$(python3 -c 'from time import time; print(int(round(time() * 1000)))')
endef
ifneq ($(TOOLCHAIN_PROFILE),false)
TOOLCHAIN_PROFILE_DIR := .toolchain/profiles
mkc := $(shell mkdir -p $(TOOLCHAIN_PROFILE_DIR))
ifndef TOOLCHAIN_PROFILE_RUNNING
TOOLCHAIN_PROFILE_INIT := $(shell printf $(call epochms))
TOOLCHAIN_PROFILE_INIT := $(shell date +%s)
TOOLCHAIN_PROFILE_START := 0
TOOLCHAIN_PROFILE_TOTAL := 0
TOOLCHAIN_PROFILE_TRACKED := 0
TOOLCHAIN_PROFILE_UNTRACKED := 0
TOOLCHAIN_PROFILE_RUNNING := true
TOOLCHAIN_PROFILE_FILE := \
$(TOOLCHAIN_PROFILE_DIR)/$(HOSTNAME)-$(USERNAME)-$(HOST_OS)-$(HOST_ARCH).$(shell date -u -d @$$(($(TOOLCHAIN_PROFILE_INIT) / 1000)) +%Y%m%dT%H%M%S).csv
$(TOOLCHAIN_PROFILE_DIR)/$(HOSTNAME)-$(USERNAME)-$(HOST_OS)-$(HOST_ARCH).$(shell date -u -d @$(TOOLCHAIN_PROFILE_INIT) +%Y%m%dT%H%M%S).csv
endif
.PHONY: toolchain-profile
toolchain-profile:
$(call toolchain-profile-total)
$(call toolchain-profile-tracked)
$(call toolchain-profile-untracked)
@printf "unprofiled,%s\n" "$(TOOLCHAIN_PROFILE_UNTRACKED)" \
>> $(TOOLCHAIN_PROFILE_FILE)
@printf "total,%s\n" "$(TOOLCHAIN_PROFILE_TOTAL)" \
>> $(TOOLCHAIN_PROFILE_FILE)
@echo Build times:
@bash -c ' \
while IFS=, read -r target ms_start ms_stop; do \
ms_diff=$$(($$ms_stop - $$ms_start)); \
echo - $$target,$$(date -u -d @$$(( $$ms_diff / 1000 )) +%T); \
while IFS=, read -r target seconds; do \
echo $$target,$$(date -u -d @$$seconds +%T); \
done < $(TOOLCHAIN_PROFILE_FILE)' \
| column -c 80 -s, -t
@echo "Total: $$(date -u -d @$$(( $(TOOLCHAIN_PROFILE_TOTAL) / 1000 )) +%T)";
endif
define toolchain-profile-total
$(eval TOOLCHAIN_PROFILE_TOTAL=$(shell expr $(call epochms) - $(TOOLCHAIN_PROFILE_INIT)) )
$(eval TOOLCHAIN_PROFILE_TOTAL=$(shell expr $(shell date +%s) - $(TOOLCHAIN_PROFILE_INIT)) )
endef
define toolchain-profile-tracked
@ -96,17 +98,13 @@ define toolchain-profile-untracked
endef
define toolchain-profile-start
printf "%s,$(call epochms),\n" "$@" >> $(TOOLCHAIN_PROFILE_FILE);
$(eval TOOLCHAIN_PROFILE_START=$(shell date +%s))
printf "%s," "$@" >> $(TOOLCHAIN_PROFILE_FILE)
endef
define toolchain-profile-stop
tmpfile=$$(mktemp -q "$(TOOLCHAIN_PROFILE_DIR)/tmp.XXXXXXXXX") \
&& cp $(TOOLCHAIN_PROFILE_FILE) $$tmpfile \
&& awk \
-v ms="$(call epochms)" \
'/^$(@),/ {$$0=$$0ms} 1' \
$$tmpfile \
> $(TOOLCHAIN_PROFILE_FILE)
printf "%s\n" "$$(($$(date +%s)-$(TOOLCHAIN_PROFILE_START)))" \
>> $(TOOLCHAIN_PROFILE_FILE)
endef
export
@ -152,7 +150,7 @@ toolchain-restore-mtime:
for d in $$(git ls-files | xargs -n 1 dirname | uniq); do \
mkdir -p "$$d"; \
done; \
for f in $$((git ls-files --modified; git ls-files) | sort | uniq -u); do \
for f in $$(git ls-tree -r -t --full-name --name-only "HEAD"); do \
( test -f "$$f" || test -d "$$f" ) \
&& touch -t \
$$(git log \
@ -409,10 +407,7 @@ define fetch_pgp_key
endef
define toolchain
( test -f $(CACHE_DIR_ROOT)/toolchain.state || { \
echo "Error: toolchain.state not found. Check dependencies!"; \
exit 1; \
};) \
$(MAKE) toolchain \
&& docker run \
--rm \
--tty \