]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
BaseTools: Switch to downloading the AARCH64 compiler from Arm's site
[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
ea56fa3d 7# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
de4ce46d
SB
8# SPDX-License-Identifier: BSD-2-Clause-Patent\r
9##\r
10import os\r
11import logging\r
12from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin\r
13from edk2toolext.environment import shell_environment\r
14\r
15\r
16class LinuxGcc5ToolChain(IUefiBuildPlugin):\r
17\r
18 def do_post_build(self, thebuilder):\r
19 return 0\r
20\r
21 def do_pre_build(self, thebuilder):\r
22 self.Logger = logging.getLogger("LinuxGcc5ToolChain")\r
23\r
24 #\r
25 # GCC5 - The ARM and AARCH64 compilers need their paths set if available\r
26 if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "GCC5":\r
27\r
28 # Start with AARACH64 compiler\r
29 ret = self._check_aarch64()\r
30 if ret != 0:\r
31 self.Logger.critical("Failed in check aarch64")\r
32 return ret\r
33\r
34 # Check arm compiler\r
35 ret = self._check_arm()\r
36 if ret != 0:\r
37 self.Logger.critical("Failed in check arm")\r
38 return ret\r
39\r
ea56fa3d
AC
40 # Check RISCV64 compiler\r
41 ret = self._check_riscv64()\r
42 if ret != 0:\r
43 self.Logger.critical("Failed in check riscv64")\r
44 return ret\r
45\r
de4ce46d
SB
46 return 0\r
47\r
48 def _check_arm(self):\r
49 # check to see if full path already configured\r
50 if shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") is not None:\r
51 self.Logger.info("GCC5_ARM_PREFIX is already set.")\r
52\r
53 else:\r
54 # now check for install dir. If set then set the Prefix\r
55 install_path = shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_INSTALL")\r
56 if install_path is None:\r
57 return 0\r
58\r
59 # make GCC5_ARM_PREFIX to align with tools_def.txt\r
2ea0a0a4 60 prefix = os.path.join(install_path, "bin", "arm-none-linux-gnueabihf-")\r
de4ce46d
SB
61 shell_environment.GetEnvironment().set_shell_var("GCC5_ARM_PREFIX", prefix)\r
62\r
63 # now confirm it exists\r
64 if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") + "gcc"):\r
65 self.Logger.error("Path for GCC5_ARM_PREFIX toolchain is invalid")\r
66 return -2\r
67\r
68 return 0\r
69\r
70 def _check_aarch64(self):\r
71 # check to see if full path already configured\r
72 if shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") is not None:\r
73 self.Logger.info("GCC5_AARCH64_PREFIX is already set.")\r
74\r
75 else:\r
76 # now check for install dir. If set then set the Prefix\r
77 install_path = shell_environment.GetEnvironment(\r
78 ).get_shell_var("GCC5_AARCH64_INSTALL")\r
79 if install_path is None:\r
80 return 0\r
81\r
82 # make GCC5_AARCH64_PREFIX to align with tools_def.txt\r
1ce6ceb7 83 prefix = os.path.join(install_path, "bin", "aarch64-none-linux-gnu-")\r
de4ce46d
SB
84 shell_environment.GetEnvironment().set_shell_var("GCC5_AARCH64_PREFIX", prefix)\r
85\r
86 # now confirm it exists\r
87 if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") + "gcc"):\r
88 self.Logger.error(\r
89 "Path for GCC5_AARCH64_PREFIX toolchain is invalid")\r
90 return -2\r
91\r
92 return 0\r
ea56fa3d
AC
93\r
94 def _check_riscv64(self):\r
95 # now check for install dir.  If set then set the Prefix\r
96 install_path = shell_environment.GetEnvironment(\r
97 ).get_shell_var("GCC5_RISCV64_INSTALL")\r
98 if install_path is None:\r
99 return 0\r
100\r
101 # check to see if full path already configured\r
102 if shell_environment.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") is not None:\r
103 self.Logger.info("GCC5_RISCV64_PREFIX is already set.")\r
104\r
105 else:\r
106 # make GCC5_RISCV64_PREFIX to align with tools_def.txt\r
107 prefix = os.path.join(install_path, "bin", "riscv64-unknown-elf-")\r
108 shell_environment.GetEnvironment().set_shell_var("GCC5_RISCV64_PREFIX", prefix)\r
109\r
110 # now confirm it exists\r
111 if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") + "gcc"):\r
112 self.Logger.error(\r
113 "Path for GCC5_RISCV64_PREFIX toolchain is invalid")\r
114 return -2\r
115\r
116 # Check if LD_LIBRARY_PATH is set for the libraries of RISC-V GCC toolchain\r
117 if shell_environment.GetEnvironment().get_shell_var("LD_LIBRARY_PATH") is not None:\r
118 self.Logger.info("LD_LIBRARY_PATH is already set.")\r
119\r
120 prefix = os.path.join(install_path, "lib")\r
121 shell_environment.GetEnvironment().set_shell_var("LD_LIBRARY_PATH", prefix)\r
122\r
123 return 0\r