Functor of get_target_triple that can get the target triple using compiler. Parameters ---------- compiler : Optional[str] The compiler. Returns ------- out: Callable A function that can get target triple according to dumpmachine option of compiler.
(compiler)
| 224 | |
| 225 | |
| 226 | def get_target_by_dump_machine(compiler): |
| 227 | """Functor of get_target_triple that can get the target triple using compiler. |
| 228 | |
| 229 | Parameters |
| 230 | ---------- |
| 231 | compiler : Optional[str] |
| 232 | The compiler. |
| 233 | |
| 234 | Returns |
| 235 | ------- |
| 236 | out: Callable |
| 237 | A function that can get target triple according to dumpmachine option of compiler. |
| 238 | """ |
| 239 | |
| 240 | def get_target_triple(): |
| 241 | """Get target triple according to dumpmachine option of compiler.""" |
| 242 | if compiler: |
| 243 | cmd = [compiler, "-dumpmachine"] |
| 244 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 245 | (out, _) = proc.communicate() |
| 246 | if proc.returncode != 0: |
| 247 | msg = "dumpmachine error:\n" |
| 248 | msg += out.decode("utf-8", errors="replace") |
| 249 | return None |
| 250 | return out.decode("utf-8", errors="replace") |
| 251 | return None |
| 252 | |
| 253 | return get_target_triple |
| 254 | |
| 255 | |
| 256 | # assign so as default output format |