external-toolchain.bbclass 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # This class provides everything necessary for a recipe to pull bits from an
  2. # external toolchain:
  3. # - Automatically sets LIC_FILES_CHKSUM based on LICENSE if appropriate
  4. # - Searches the external toolchain sysroot and alternate locations for the
  5. # patterns specified in the FILES variables, with support for checking
  6. # alternate locations within the sysroot as well
  7. # - Automatically PROVIDES/RPROVIDES the non-external-suffixed names
  8. # - Usual bits to handle packaging of existing binaries
  9. # - Automatically skips the recipe if its files aren't available in the
  10. # external toolchain
  11. # - Automatically grabs all the .debug files for everything included
  12. # Since these are prebuilt binaries, there are no source files to checksum for
  13. # LIC_FILES_CHKSUM, so use the license from common-licenses
  14. inherit common-license
  15. # We don't extract anything which will create S, and we don't want to see the
  16. # warning about it
  17. S = "${WORKDIR}"
  18. # Prebuilt binaries, no need for any default dependencies
  19. INHIBIT_DEFAULT_DEPS = "1"
  20. # Missing build deps don't matter when we don't build anything
  21. INSANE_SKIP_${PN} += "build-deps"
  22. EXTERNAL_PN ?= "${@PN.replace('-external', '')}"
  23. PROVIDES += "${EXTERNAL_PN}"
  24. LICENSE = "CLOSED"
  25. LIC_FILES_CHKSUM = "${COMMON_LIC_CHKSUM}"
  26. do_configure[noexec] = "1"
  27. do_compile[noexec] = "1"
  28. EXTERNAL_PV_PREFIX ?= ""
  29. EXTERNAL_PV_SUFFIX ?= ""
  30. PV_prepend = "${@'${EXTERNAL_PV_PREFIX}' if '${EXTERNAL_PV_PREFIX}' else ''}"
  31. PV_append = "${@'${EXTERNAL_PV_SUFFIX}' if '${EXTERNAL_PV_SUFFIX}' else ''}"
  32. EXTERNAL_EXTRA_FILES ?= ""
  33. # Skip this recipe if we don't have files in the external toolchain
  34. EXTERNAL_AUTO_PROVIDE ?= "0"
  35. EXTERNAL_AUTO_PROVIDE[type] = "boolean"
  36. EXTERNAL_AUTO_PROVIDE_class-target ?= "1"
  37. # We don't care if this path references other variables
  38. EXTERNAL_TOOLCHAIN[vardepvalue] = "${EXTERNAL_TOOLCHAIN}"
  39. # We don't want to rebuild if the path to the toolchain changes, only if the
  40. # toolchain changes
  41. external_toolchain_do_install[vardepsexclude] += "EXTERNAL_TOOLCHAIN"
  42. EXTERNAL_INSTALL_SOURCE_PATHS[vardepsexclude] += "EXTERNAL_TOOLCHAIN"
  43. python () {
  44. # Skipping only matters up front
  45. if d.getVar('BB_WORKERCONTEXT', True) == '1':
  46. return
  47. # We're not an available provider if there's no external toolchain
  48. if not d.getVar("EXTERNAL_TOOLCHAIN"):
  49. raise bb.parse.SkipPackage("External toolchain not configured (EXTERNAL_TOOLCHAIN not set).")
  50. if not oe.data.typed_value('EXTERNAL_AUTO_PROVIDE', d):
  51. return
  52. sysroots, mirrors = oe.external.get_file_search_metadata(d)
  53. pattern = d.getVar('EXTERNAL_PROVIDE_PATTERN', True)
  54. if pattern is None:
  55. files = list(oe.external.gather_pkg_files(d))
  56. files = filter(lambda f: '.debug' not in f, files)
  57. expanded = oe.external.expand_paths(files, mirrors)
  58. paths = oe.external.search_sysroots(expanded, sysroots)
  59. if not any(f for p, f in paths):
  60. raise bb.parse.SkipPackage('No files found in external toolchain sysroot for `{}`'.format(', '.join(files)))
  61. elif not pattern:
  62. return
  63. else:
  64. expanded = oe.external.expand_paths([pattern], mirrors)
  65. paths = oe.external.search_sysroots(expanded, sysroots)
  66. if not any(f for p, f in paths):
  67. raise bb.parse.SkipPackage('No files found in external toolchain sysroot for `{}`'.format(pattern))
  68. }
  69. python do_install () {
  70. bb.build.exec_func('external_toolchain_do_install', d)
  71. if 'do_install_extra' in d:
  72. bb.build.exec_func('do_install_extra', d)
  73. }
  74. python external_toolchain_do_install () {
  75. import subprocess
  76. installdest = d.getVar('D', True)
  77. sysroots, mirrors = oe.external.get_file_search_metadata(d)
  78. files = oe.external.gather_pkg_files(d)
  79. oe.external.copy_from_sysroots(files, sysroots, mirrors, installdest)
  80. subprocess.check_call(['chown', '-R', 'root:root', installdest])
  81. }
  82. external_toolchain_do_install[vardeps] += "${@' '.join('FILES_%s' % pkg for pkg in '${PACKAGES}'.split())}"
  83. # Change do_install's CWD to EXTERNAL_TOOLCHAIN for convenience
  84. do_install[dirs] = "${D} ${EXTERNAL_TOOLCHAIN}"
  85. # Debug files are likely already split out
  86. INHIBIT_PACKAGE_STRIP = "1"
  87. # Toolchain shipped binaries weren't necessarily built ideally
  88. WARN_QA_remove = "ldflags textrel"
  89. ERROR_QA_remove = "ldflags textrel"
  90. RPROVIDES_${PN} += "${EXTERNAL_PN}"
  91. RPROVIDES_${PN}-dev += "${EXTERNAL_PN}-dev"
  92. RPROVIDES_${PN}-staticdev += "${EXTERNAL_PN}-staticdev"
  93. RPROVIDES_${PN}-dbg += "${EXTERNAL_PN}-dbg"
  94. RPROVIDES_${PN}-doc += "${EXTERNAL_PN}-doc"
  95. RPROVIDES_${PN}-locale += "${EXTERNAL_PN}-locale"
  96. LOCALEBASEPN = "${EXTERNAL_PN}"
  97. FILES_${PN} = ""
  98. FILES_${PN}-dev = ""
  99. FILES_${PN}-staticdev = ""
  100. FILES_${PN}-doc = ""
  101. FILES_${PN}-locale = ""
  102. # do_package[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
  103. # do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
  104. # do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
  105. # do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata"