Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_env_setup / py / pw_env_setup / windows_env_start.py
1 # -*- coding: utf-8 -*-
2
3 # Copyright 2020 The Pigweed Authors
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 # use this file except in compliance with the License. You may obtain a copy of
7 # the License at
8 #
9 #     https://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations under
15 # the License.
16 """Prints the env_setup banner for cmd.exe.
17
18 This is done from Python as activating colors and printing ASCII art are not
19 easy to do in cmd.exe. Activated colors also don't persist in the parent
20 process.
21 """
22
23 from __future__ import print_function
24
25 import argparse
26 import os
27 import sys
28
29 from colors import Color, enable_colors  # type: ignore
30
31 _PIGWEED_BANNER = u'''
32  ▒█████▄   █▓  ▄███▒  ▒█    ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
33   ▒█░  █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█  ▒█   ▀  ▒█   ▀  ▒█  ▀█▌
34   ▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█  ▒███    ▒███    ░█   █▌
35   ▒█▀     ░█░ ▓█   █▓ ░█░ █ ▒█  ▒█   ▄  ▒█   ▄  ░█  ▄█▌
36   ▒█      ░█░ ░▓███▀   ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
37 '''
38
39
40 def print_banner(bootstrap, no_shell_file):
41     """Print the Pigweed or project-specific banner"""
42     enable_colors()
43
44     print(Color.green('\n  WELCOME TO...'))
45     print(Color.magenta(_PIGWEED_BANNER))
46
47     if bootstrap:
48         print(
49             Color.green('\n  BOOTSTRAP! Bootstrap may take a few minutes; '
50                         'please be patient'))
51         print(
52             Color.green(
53                 '  On Windows, this stage is extremely slow (~10 minutes).\n'))
54     else:
55         print(
56             Color.green(
57                 '\n  ACTIVATOR! This sets your console environment variables.\n'
58             ))
59
60         if no_shell_file:
61             print(Color.bold_red('Error!\n'))
62             print(
63                 Color.red('  Your Pigweed environment does not seem to be'
64                           ' configured.'))
65             print(Color.red('  Run bootstrap.bat to perform initial setup.'))
66
67     return 0
68
69
70 def parse():
71     """Parse command-line arguments."""
72     parser = argparse.ArgumentParser()
73     parser.add_argument('--bootstrap', action='store_true')
74     parser.add_argument('--no-shell-file', action='store_true')
75     return parser.parse_args()
76
77
78 def main():
79     """Script entry point."""
80     if os.name != 'nt':
81         return 1
82     return print_banner(**vars(parse()))
83
84
85 if __name__ == '__main__':
86     sys.exit(main())