makelinux.zsh: Various Updates

* Fixes to color output
* Added an option to cross compile for i686
* Use the new $COLORS variable for the location of the colors script

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2023-07-18 16:16:01 -04:00
parent 2373f06ea7
commit 941308e246
2 changed files with 24 additions and 17 deletions

View File

@ -21,15 +21,19 @@ add_color_attr("DESCEND", "white", "dark")
add_color_attr("objtool", "yellow", "dark", "bold")
add_color_attr("LD", "yellow")
for line in sys.stdin:
if line[0] == "#":
termcolor.cprint(line, "blue", attrs=["dark", "bold"], end="")
else:
for part in re.split(r'(\s+)', line):
if "/" in part or "(#" in part or os.path.exists(part):
color = "magenta" if re.match("module", part, re.I) else "white"
attrs = ["bold"]
else:
color = make_colors.get(part, "green")
attrs = make_attrs.get(part, [])
termcolor.cprint(part, color, attrs=attrs, end="")
text = ""
while c := sys.stdin.read(1):
text += c
if text[0] == "#":
if re.match("^#(.*?)\n", text):
termcolor.cprint(text, "blue", attrs=["dark", "bold"], end="")
text = ""
elif c in (" ", "\n"):
if "/" in text or "(#" in text or os.path.exists(text):
color = "magenta" if re.match("module", text, re.I) else "white"
attrs = ["bold"]
else:
color = make_colors.get(text.strip(), "green")
attrs = make_attrs.get(text.strip(), [])
termcolor.cprint(text, color, attrs=attrs, end="")
text = ""

View File

@ -1,13 +1,13 @@
#!/bin/zsh
source common.zsh
set -eo pipefail
let jobs=$(nproc)-2
ARCH=$(uname -m)
CROSS_COMPILE=
CC=
OPTS=(--clang)
zparseopts -D -K -clang+=OPTS -gcc+=OPTS -arm64+=OPTS
zparseopts -D -K -clang+=OPTS -gcc+=OPTS -arm64+=OPTS -i686+=OPTS -env+=OPTS
[[ -z "$ARCH" ]] && ARCH=$(uname -m)
case ${OPTS[-1]} in
--clang) CC=clang ;;
@ -16,6 +16,9 @@ case ${OPTS[-1]} in
CC=gcc
CROSS_COMPILE=aarch64-linux-gnu-
;;
--i686) ARCH=i386
CC=gcc
;;
esac
if [ -f .git/config ] && [ -f .git/HEAD ]; then
@ -23,7 +26,7 @@ if [ -f .git/config ] && [ -f .git/HEAD ]; then
scripts/config --set-str CONFIG_LOCALVERSION "-g$REV"
fi
make -j$jobs CC=$CC ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $* | python -u /home/anna/bin/colors/make.py
make -j$jobs CC=$CC ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $* | python -u $COLORS/make.py
if [[ "$CC" == "clang" ]]; then
scripts/clang-tools/gen_compile_commands.py &