xref: /xnu-8792.81.2/makedefs/MakeInc.color (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions# -*- mode: makefile;-*-
2*19c3b8c2SApple OSS Distributions#
3*19c3b8c2SApple OSS Distributions# Copyright (C) 2020 Apple Inc. All rights reserved.
4*19c3b8c2SApple OSS Distributions#
5*19c3b8c2SApple OSS Distributions# MakeInc.color defines macros used to enable
6*19c3b8c2SApple OSS Distributions# colored output of the build log.
7*19c3b8c2SApple OSS Distributions#
8*19c3b8c2SApple OSS Distributions
9*19c3b8c2SApple OSS Distributionsdefine _setup_build_log_colors
10*19c3b8c2SApple OSS Distributionsifeq ($${XNU_LOGCOLORS},y)
11*19c3b8c2SApple OSS Distributions    LOGCOLORS ?= y
12*19c3b8c2SApple OSS Distributionsendif
13*19c3b8c2SApple OSS Distributionsifeq ($$(LOGCOLORS),y)
14*19c3b8c2SApple OSS Distributions    # Get a nice list of device code names associated with the build platform
15*19c3b8c2SApple OSS Distributions    ifndef CDevs
16*19c3b8c2SApple OSS Distributions        #ifdef EMBEDDED_DEVICE_MAP
17*19c3b8c2SApple OSS Distributions        #    export CDevs := $$(shell $$(EMBEDDED_DEVICE_MAP) -db $$(EDM_DBPATH) -query "SELECT DISTINCT TargetType FROM Targets WHERE KernelPlatform = '$$(CURRENT_MACHINE_CONFIG_LC)'" | tr '[\r\n]' ':' | sed 's,:$$$$,,')
18*19c3b8c2SApple OSS Distributions        #endif
19*19c3b8c2SApple OSS Distributions    endif
20*19c3b8c2SApple OSS Distributions    ifndef MACHINE_PFX
21*19c3b8c2SApple OSS Distributions        export _MACHINE := $$(CURRENT_MACHINE_CONFIG_LC)
22*19c3b8c2SApple OSS Distributions        ifeq ($$(CURRENT_MACHINE_CONFIG),NONE)
23*19c3b8c2SApple OSS Distributions            export _MACHINE := $$(subst OSX,,$$(PLATFORM))
24*19c3b8c2SApple OSS Distributions        endif
25*19c3b8c2SApple OSS Distributions        export MACHINE_PFX := $$(shell __A="$$(CURRENT_ARCH_CONFIG_LC)"; \
26*19c3b8c2SApple OSS Distributions                                         __As=$$$$((6-$$$${\#__A})); \
27*19c3b8c2SApple OSS Distributions                                         printf "%-.6s%*.*s %9.9s" \
28*19c3b8c2SApple OSS Distributions                                                "$$$${__A}" \
29*19c3b8c2SApple OSS Distributions                                                $$$${__As} $$$${__As} " " \
30*19c3b8c2SApple OSS Distributions                                                "$$(_MACHINE)")
31*19c3b8c2SApple OSS Distributions    endif
32*19c3b8c2SApple OSS Distributions    override LOG_PFX_LEN := 30
33*19c3b8c2SApple OSS Distributions    override LOG_PFX_LEN_ADJ := $$(shell __TMP="$$(MACHINE_PFX)"; \
34*19c3b8c2SApple OSS Distributions            printf "%d" $$$$(($$(LOG_PFX_LEN) - $$$${\#__TMP} - 3)))
35*19c3b8c2SApple OSS Distributions    MACHINE_PFX_COL = $$(shell printf "\\033[1m%s\\033[m" "$$(MACHINE_PFX)")
36*19c3b8c2SApple OSS Distributions    # Turn off colored output
37*19c3b8c2SApple OSS Distributions    Color0:=$$(shell printf "\\033[m")
38*19c3b8c2SApple OSS Distributions    # Start a host command: bold text
39*19c3b8c2SApple OSS Distributions    ColorH:=$$(shell printf "\\033[1m")
40*19c3b8c2SApple OSS Distributions    # Start a compilation-related command: blue text
41*19c3b8c2SApple OSS Distributions    ColorC:=$$(shell printf "[$$(MACHINE_PFX_COL)] \\033[1;34m")
42*19c3b8c2SApple OSS Distributions    # Start a MIG command: green text
43*19c3b8c2SApple OSS Distributions    ColorM:=$$(shell printf "[$$(MACHINE_PFX_COL)] \\033[1;32m")
44*19c3b8c2SApple OSS Distributions    # Start a linking command: purple text
45*19c3b8c2SApple OSS Distributions    ColorL:=$$(shell printf "[$$(MACHINE_PFX_COL)] \\033[1;35m")
46*19c3b8c2SApple OSS Distributions    # Start a filename
47*19c3b8c2SApple OSS Distributions    ColorF:=$$(shell printf "")
48*19c3b8c2SApple OSS Distributions    # Start a linked file name: italic text
49*19c3b8c2SApple OSS Distributions    ColorLF:=$$(shell printf "\\033[3m")
50*19c3b8c2SApple OSS Distributions    # Error strings: red text
51*19c3b8c2SApple OSS Distributions    ColorErr:=$$(shell printf "\033[31m")
52*19c3b8c2SApple OSS Distributionsendif
53*19c3b8c2SApple OSS Distributionsendef
54*19c3b8c2SApple OSS Distributions
55*19c3b8c2SApple OSS Distributions# vim: set ft=make:
56