]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py
1 # @file LinuxGcc5ToolChain.py
2 # Plugin to configures paths for GCC5 ARM/AARCH64 Toolchain
4 # This plugin works in conjuncture with the tools_def
6 # Copyright (c) Microsoft Corporation
7 # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
8 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from edk2toolext
.environment
.plugintypes
.uefi_build_plugin
import IUefiBuildPlugin
13 from edk2toolext
.environment
import shell_environment
16 class LinuxGcc5ToolChain(IUefiBuildPlugin
):
18 def do_post_build(self
, thebuilder
):
21 def do_pre_build(self
, thebuilder
):
22 self
.Logger
= logging
.getLogger("LinuxGcc5ToolChain")
25 # GCC5 - The ARM and AARCH64 compilers need their paths set if available
26 if thebuilder
.env
.GetValue("TOOL_CHAIN_TAG") == "GCC5":
28 # Start with AARACH64 compiler
29 ret
= self
._check
_aarch
64()
31 self
.Logger
.critical("Failed in check aarch64")
35 ret
= self
._check
_arm
()
37 self
.Logger
.critical("Failed in check arm")
40 # Check RISCV64 compiler
41 ret
= self
._check
_riscv
64()
43 self
.Logger
.critical("Failed in check riscv64")
49 # check to see if full path already configured
50 if shell_environment
.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") is not None:
51 self
.Logger
.info("GCC5_ARM_PREFIX is already set.")
54 # now check for install dir. If set then set the Prefix
55 install_path
= shell_environment
.GetEnvironment().get_shell_var("GCC5_ARM_INSTALL")
56 if install_path
is None:
59 # make GCC5_ARM_PREFIX to align with tools_def.txt
60 prefix
= os
.path
.join(install_path
, "bin", "arm-linux-gnueabihf-")
61 shell_environment
.GetEnvironment().set_shell_var("GCC5_ARM_PREFIX", prefix
)
63 # now confirm it exists
64 if not os
.path
.exists(shell_environment
.GetEnvironment().get_shell_var("GCC5_ARM_PREFIX") + "gcc"):
65 self
.Logger
.error("Path for GCC5_ARM_PREFIX toolchain is invalid")
70 def _check_aarch64(self
):
71 # check to see if full path already configured
72 if shell_environment
.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") is not None:
73 self
.Logger
.info("GCC5_AARCH64_PREFIX is already set.")
76 # now check for install dir. If set then set the Prefix
77 install_path
= shell_environment
.GetEnvironment(
78 ).get_shell_var("GCC5_AARCH64_INSTALL")
79 if install_path
is None:
82 # make GCC5_AARCH64_PREFIX to align with tools_def.txt
83 prefix
= os
.path
.join(install_path
, "bin", "aarch64-linux-gnu-")
84 shell_environment
.GetEnvironment().set_shell_var("GCC5_AARCH64_PREFIX", prefix
)
86 # now confirm it exists
87 if not os
.path
.exists(shell_environment
.GetEnvironment().get_shell_var("GCC5_AARCH64_PREFIX") + "gcc"):
89 "Path for GCC5_AARCH64_PREFIX toolchain is invalid")
94 def _check_riscv64(self
):
95 # now check for install dir. If set then set the Prefix
96 install_path
= shell_environment
.GetEnvironment(
97 ).get_shell_var("GCC5_RISCV64_INSTALL")
98 if install_path
is None:
101 # check to see if full path already configured
102 if shell_environment
.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") is not None:
103 self
.Logger
.info("GCC5_RISCV64_PREFIX is already set.")
106 # make GCC5_RISCV64_PREFIX to align with tools_def.txt
107 prefix
= os
.path
.join(install_path
, "bin", "riscv64-unknown-elf-")
108 shell_environment
.GetEnvironment().set_shell_var("GCC5_RISCV64_PREFIX", prefix
)
110 # now confirm it exists
111 if not os
.path
.exists(shell_environment
.GetEnvironment().get_shell_var("GCC5_RISCV64_PREFIX") + "gcc"):
113 "Path for GCC5_RISCV64_PREFIX toolchain is invalid")
116 # Check if LD_LIBRARY_PATH is set for the libraries of RISC-V GCC toolchain
117 if shell_environment
.GetEnvironment().get_shell_var("LD_LIBRARY_PATH") is not None:
118 self
.Logger
.info("LD_LIBRARY_PATH is already set.")
120 prefix
= os
.path
.join(install_path
, "lib")
121 shell_environment
.GetEnvironment().set_shell_var("LD_LIBRARY_PATH", prefix
)