MCPcopy Index your code
hub / github.com/cirosantilli/linux-kernel-module-cheat / get_toolchain_prefix

Method get_toolchain_prefix

common.py:749–783  ·  view source on GitHub ↗
(self, tool, allowed_toolchains=None)

Source from the content-addressed store, hash-verified

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)

Callers 1

get_toolchain_toolMethod · 0.95

Calls 2

log_errorMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected