gbuild trace: make it work nicer on macOS (seconds-only accuracy)

the finish-gbuild-trace.py matches a nanoseconds timestamp and truncates
it to milliseconds, so could also adjust that and look for the unchanged
%N for mac in the tracefile and handle it that way, but since there is
another conditional needed for the lack of flock on macOS doing it in
the makefile seemd like the more natural choice. (well, not trictly
needed unless you mind the thousands of command not found messages :-))

Change-Id: I768bc9dd8be232567644ae000b6419bb87f58509
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144590
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
diff --git a/solenv/gbuild/Trace.mk b/solenv/gbuild/Trace.mk
index 8d41615..5ff0d0b 100644
--- a/solenv/gbuild/Trace.mk
+++ b/solenv/gbuild/Trace.mk
@@ -28,11 +28,15 @@ gb_TRACE := $(abspath $(GBUILD_TRACE))
endif

ifneq ($(gb_TRACE),)

# call gb_Trace_AddMark,marktype,detail,type,extra
# macOS date doesn't know about nanoseconds switch, and instead of resorting to perl or python
# to create a millisecond timestamp, just avoid the overhead and live with seconds-only accuracy
gb_Trace_Timestamp := $(if $(filter MACOSX,$(OS)),$$(date +%s)000000000,$(date +%s%N))
# macOS also doesn't provide flock, so skip that part on mac
# The (flock;cat) part is to minimize lock time.
gb_Trace_Flock := $(if $(filter MACOSX,$(OS)),,| ( flock 1; cat ))
# call gb_Trace_AddMark,marktype,detail,type,extra
define gb_Trace__AddMark
echo "{\"name\": \"$(3)\", \"ph\": \"$(1)\", \"pid\": 1, \"tid\": 1, \"ts\": $$(date +%s%N),\"args\":{\"message\":\"[$(3)]: $(2)\"}}," | ( flock 1; cat ) >>$(gb_TRACE)
echo "{\"name\": \"$(3)\", \"ph\": \"$(1)\", \"pid\": 1, \"tid\": 1, \"ts\": $(gb_Trace_Timestamp),\"args\":{\"message\":\"[$(3)]: $(2)\"}}," $(gb_Trace_Flock) >>$(gb_TRACE)
endef

# call gb_Trace_StartRange,detail,type