]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
BaseTools: Avoid "is" with a literal Python 3.8 warnings
[mirror_edk2.git] / BaseTools / Plugin / LinuxGcc5ToolChain / LinuxGcc5ToolChain.py
CommitLineData
de4ce46d
SB
1# @file LinuxGcc5ToolChain.py\r
2# Plugin to configures paths for GCC5 ARM/AARCH64 Toolchain\r
3##\r
4# This plugin works in conjuncture with the tools_def\r
5#\r
6# Copyright (c) Microsoft Corporation\r
7# SPDX-License-Identifier: BSD-2-Clause-Patent\r
8##\r
9import os\r
10import logging\r
11from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin\r
12from edk2toolext.environment import shell_environment\r
13\r
14\r
15class LinuxGcc5ToolChain(IUefiBuildPlugin):\r
16\r
17 def do_post_build(self, thebuilder):\r
18 return 0\r
19\r
20 def do_pre_build(self, thebuilder):\r
21 self.Logger = logging.getLogger("LinuxGcc5ToolChain")\r
22\r
23 #\r
24 # GCC5 - The ARM and AARCH64 compilers need their paths set if available\r
25 if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "GCC5":\r
26\r
27 # Start with AARACH64 compiler\r
28 ret = self._check_aarch64()\r
29 if ret != 0:\r
30 self.Logger.critical("Failed in check aarch64")\r
31 return ret\r
32\r
33 # Check arm compiler\r
34 ret = self._check_arm()\r
35 if ret != 0:\r
36 self.Logger.critical("Failed in check arm")\r
37 return ret\r
38\r
39 return 0\r
40\r
41 def _check_arm(self):\r
42 # check to see if full path already configured\r
43 if shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") is not None:\r
44 self.Logger.info("GCC5_ARM_PREFIX is already set.")\r
45\r
46 else:\r
47 # now check for install dir. If set then set the Prefix\r
48 install_path = shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_INSTALL")\r
49 if install_path is None:\r
50 return 0\r
51\r
52 # make GCC5_ARM_PREFIX to align with tools_def.txt\r
53 prefix = os.path.join(install_path, "bin", "arm-linux-gnueabihf-")\r
54 shell_environment.GetEnvironment().set_shell_var("GCC5_ARM_PREFIX", prefix)\r
55\r
56 # now confirm it exists\r
57 if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") + "gcc"):\r
58 self.Logger.error("Path for GCC5_ARM_PREFIX toolchain is invalid")\r
59 return -2\r
60\r
61 return 0\r
62\r
63 def _check_aarch64(self):\r
64 # check to see if full path already configured\r
65 if shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") is not None:\r
66 self.Logger.info("GCC5_AARCH64_PREFIX is already set.")\r
67\r
68 else:\r
69 # now check for install dir. If set then set the Prefix\r
70 install_path = shell_environment.GetEnvironment(\r
71 ).get_shell_var("GCC5_AARCH64_INSTALL")\r
72 if install_path is None:\r
73 return 0\r
74\r
75 # make GCC5_AARCH64_PREFIX to align with tools_def.txt\r
76 prefix = os.path.join(install_path, "bin", "aarch64-linux-gnu-")\r
77 shell_environment.GetEnvironment().set_shell_var("GCC5_AARCH64_PREFIX", prefix)\r
78\r
79 # now confirm it exists\r
80 if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") + "gcc"):\r
81 self.Logger.error(\r
82 "Path for GCC5_AARCH64_PREFIX toolchain is invalid")\r
83 return -2\r
84\r
85 return 0\r