(self, tool, allowed_toolchains=None)
| 747 | return ret |
| 748 | |
| 749 | def get_toolchain_prefix(self, tool, allowed_toolchains=None): |
| 750 | buildroot_full_prefix = os.path.join(self.env['host_bin_dir'], self.env['buildroot_toolchain_prefix']) |
| 751 | buildroot_exists = os.path.exists('{}-{}'.format(buildroot_full_prefix, tool)) |
| 752 | crosstool_ng_full_prefix = os.path.join(self.env['crosstool_ng_bin_dir'], self.env['crosstool_ng_toolchain_prefix']) |
| 753 | crosstool_ng_exists = os.path.exists('{}-{}'.format(crosstool_ng_full_prefix, tool)) |
| 754 | host_tool = '{}-{}'.format(self.env['ubuntu_toolchain_prefix'], tool) |
| 755 | host_path = shutil.which(host_tool) |
| 756 | if host_path is not None: |
| 757 | host_exists = True |
| 758 | host_full_prefix = host_path[:-(len(tool)+1)] |
| 759 | else: |
| 760 | host_exists = False |
| 761 | host_full_prefix = None |
| 762 | known_toolchains = { |
| 763 | 'crosstool-ng': (crosstool_ng_exists, crosstool_ng_full_prefix), |
| 764 | 'buildroot': (buildroot_exists, buildroot_full_prefix), |
| 765 | 'host': (host_exists, host_full_prefix), |
| 766 | } |
| 767 | if allowed_toolchains is None: |
| 768 | if self.env['baremetal'] is None: |
| 769 | allowed_toolchains = ['buildroot', 'crosstool-ng', 'host'] |
| 770 | else: |
| 771 | allowed_toolchains = ['crosstool-ng', 'buildroot', 'host'] |
| 772 | tried = [] |
| 773 | for toolchain in allowed_toolchains: |
| 774 | exists, prefix = known_toolchains[toolchain] |
| 775 | tried.append('{}-{}'.format(prefix, tool)) |
| 776 | if exists: |
| 777 | return prefix |
| 778 | error_message = 'Tool not found. Tried:\n' + '\n'.join(tried) |
| 779 | if self.env['dry_run']: |
| 780 | self.log_error(error_message) |
| 781 | return '' |
| 782 | else: |
| 783 | raise Exception(error_message) |
| 784 | |
| 785 | def get_toolchain_tool(self, tool, allowed_toolchains=None): |
| 786 | return '{}-{}'.format(self.get_toolchain_prefix(tool, allowed_toolchains), tool) |
no test coverage detected