MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / GccToolchain

Class GccToolchain

tools/ng/toolchain.py:65–164  ·  view source on GitHub ↗

GCC toolchain implementation.

Source from the content-addressed store, hash-verified

63
64
65class GccToolchain(Toolchain):
66 """GCC toolchain implementation."""
67
68 def __init__(self, prefix: str = ""):
69 super().__init__()
70 self.prefix = prefix or "arm-none-eabi-"
71
72 def get_name(self) -> str:
73 return "gcc"
74
75 def detect(self) -> bool:
76 """Detect GCC toolchain."""
77 gcc_path = shutil.which(self.prefix + "gcc")
78 if not gcc_path:
79 return False
80
81 # Get version
82 ret, stdout, _ = self._run_command([gcc_path, "--version"])
83 if ret == 0:
84 lines = stdout.split('\n')
85 if lines:
86 version = lines[0].split()[-1]
87 self.info = ToolchainInfo(
88 name="gcc",
89 version=version,
90 path=os.path.dirname(gcc_path),
91 prefix=self.prefix
92 )
93 return True
94
95 return False
96
97 def configure_environment(self, env) -> None:
98 """Configure environment for GCC."""
99 env['CC'] = self.prefix + 'gcc'
100 env['CXX'] = self.prefix + 'g++'
101 env['AS'] = self.prefix + 'gcc'
102 env['AR'] = self.prefix + 'ar'
103 env['LINK'] = self.prefix + 'gcc'
104 env['SIZE'] = self.prefix + 'size'
105 env['OBJDUMP'] = self.prefix + 'objdump'
106 env['OBJCPY'] = self.prefix + 'objcopy'
107
108 # Set default flags
109 env['ARFLAGS'] = '-rc'
110 env['ASFLAGS'] = '-x assembler-with-cpp'
111
112 # Path
113 if self.info and self.info.path:
114 env.PrependENVPath('PATH', self.info.path)
115
116 def get_compile_flags(self, cpu: str, fpu: str = None, float_abi: str = None) -> Dict[str, str]:
117 """Get GCC compilation flags."""
118 flags = {
119 'CFLAGS': [],
120 'CXXFLAGS': [],
121 'ASFLAGS': [],
122 'LDFLAGS': []

Callers 1

select_toolchainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected