Skip to content

Commit

Permalink
Remove usages of the colorama module, inline. (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey authored Dec 8, 2023
1 parent 60536f6 commit e0aa3ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
17 changes: 5 additions & 12 deletions build/android/gyp/javac.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import distutils.spawn
import fnmatch
import optparse
import os
import shutil
import re
import subprocess
import sys
import textwrap

from util import ansi_colors
from util import build_utils
from util import md5_check

import jar

sys.path.append(build_utils.COLORAMA_ROOT)
import colorama


def ColorJavacOutput(output):
fileline_prefix = r'(?P<fileline>(?P<file>[-.\w/\\]+.java):(?P<line>[0-9]+):)'
warning_re = re.compile(
Expand All @@ -31,17 +26,17 @@ def ColorJavacOutput(output):
fileline_prefix + r'(?P<full_message> (?P<message>.*))$')
marker_re = re.compile(r'\s*(?P<marker>\^)\s*$')

warning_color = ['full_message', colorama.Fore.YELLOW + colorama.Style.DIM]
error_color = ['full_message', colorama.Fore.MAGENTA + colorama.Style.BRIGHT]
marker_color = ['marker', colorama.Fore.BLUE + colorama.Style.BRIGHT]
warning_color = ['full_message', ansi_colors.FOREGROUND_YELLOW + ansi_colors.STYLE_DIM]
error_color = ['full_message', ansi_colors.FOREGROUND_MAGENTA + ansi_colors.STYLE_BRIGHT]
marker_color = ['marker', ansi_colors.FOREGROUND_BLUE + ansi_colors.STYLE_BRIGHT]

def Colorize(line, regex, color):
match = regex.match(line)
start = match.start(color[0])
end = match.end(color[0])
return (line[:start]
+ color[1] + line[start:end]
+ colorama.Fore.RESET + colorama.Style.RESET_ALL
+ ansi_colors.FOREGROUND_RESET + ansi_colors.STYLE_RESET_ALL
+ line[end:])

def ApplyColor(line):
Expand Down Expand Up @@ -158,8 +153,6 @@ def CreateManifest(manifest_path, classpath, main_class=None,


def main(argv):
colorama.init()

argv = build_utils.ExpandFileArgs(argv)

parser = optparse.OptionParser()
Expand Down
14 changes: 14 additions & 0 deletions build/android/gyp/util/ansi_colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# The following are unicode (string) constants that were previously defined in
# "colorama". They are inlined here to avoid a dependency, as this is the only
# call site and it's unlikely we'll need to change them.
FOREGROUND_YELLOW = '\x1b[33m'
FOREGROUND_MAGENTA = '\x1b[35m'
FOREGROUND_BLUE = '\x1b[34m'
FOREGROUND_RESET = '\x1b[39m'
STYLE_RESET_ALL = '\x1b[0m'
STYLE_DIM = '\x1b[2m'
STYLE_BRIGHT = '\x1b[1m'
5 changes: 0 additions & 5 deletions build/android/gyp/util/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, os.pardir, os.pardir)))

CHROMIUM_SRC = os.path.normpath(
os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, os.pardir, os.pardir))
COLORAMA_ROOT = os.path.join(CHROMIUM_SRC,
'third_party', 'colorama', 'src')
# aapt should ignore OWNERS files in addition the default ignore pattern.
AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' +
'!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp')
Expand Down

0 comments on commit e0aa3ae

Please sign in to comment.