gen-bootlin-toolchains 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. #!/usr/bin/env python3
  2. import os.path
  3. import re
  4. import requests
  5. import textwrap
  6. BASE_URL = "https://toolchains.bootlin.com/downloads/releases/toolchains"
  7. AUTOGENERATED_COMMENT = """# This file was auto-generated by support/scripts/gen-bootlin-toolchains
  8. # Do not edit
  9. """
  10. # In the below dict:
  11. # - 'conditions' indicate the cumulative conditions under which the
  12. # toolchain will be made available. In several situations, a given
  13. # toolchain is usable on several architectures variants (for
  14. # example, an ARMv6 toolchain can be used on ARMv7)
  15. # - 'test_options' indicate one specific configuration where the
  16. # toolchain can be used. It is used to create the runtime test
  17. # cases. If 'test_options' does not exist, the code assumes it can
  18. # be made equal to 'conditions'
  19. # - 'prefix' is the prefix of the cross-compilation toolchain tools
  20. arches = {
  21. 'aarch64': {
  22. 'conditions': ['BR2_aarch64'],
  23. 'prefix': 'aarch64',
  24. },
  25. 'aarch64be': {
  26. 'conditions': ['BR2_aarch64_be'],
  27. 'prefix': 'aarch64_be',
  28. },
  29. 'arcle-750d': {
  30. 'conditions': ['BR2_arcle', 'BR2_arc750d'],
  31. 'prefix': 'arc',
  32. },
  33. 'arcle-hs38': {
  34. 'conditions': ['BR2_arcle', 'BR2_archs38'],
  35. 'prefix': 'arc',
  36. },
  37. 'armv5-eabi': {
  38. 'conditions': ['BR2_arm', 'BR2_ARM_CPU_ARMV5', 'BR2_ARM_EABI'],
  39. 'test_options': ['BR2_arm', 'BR2_arm926t', 'BR2_ARM_EABI'],
  40. 'prefix': 'arm',
  41. },
  42. 'armv6-eabihf': {
  43. 'conditions': ['BR2_arm', 'BR2_ARM_CPU_ARMV6', 'BR2_ARM_EABIHF'],
  44. 'test_options': ['BR2_arm', 'BR2_arm1176jzf_s', 'BR2_ARM_EABIHF'],
  45. 'prefix': 'arm',
  46. },
  47. 'armv7-eabihf': {
  48. 'conditions': ['BR2_arm', 'BR2_ARM_CPU_ARMV7A', 'BR2_ARM_EABIHF'],
  49. 'test_options': ['BR2_arm', 'BR2_cortex_a8', 'BR2_ARM_EABIHF'],
  50. 'prefix': 'arm',
  51. },
  52. 'armv7m': {
  53. 'conditions': ['BR2_arm', 'BR2_ARM_CPU_ARMV7M'],
  54. 'test_options': ['BR2_arm', 'BR2_cortex_m4'],
  55. 'prefix': 'arm',
  56. },
  57. 'm68k-68xxx': {
  58. 'conditions': ['BR2_m68k_m68k'],
  59. 'test_options': ['BR2_m68k', 'BR2_m68k_68040'],
  60. 'prefix': 'm68k',
  61. },
  62. 'm68k-coldfire': {
  63. 'conditions': ['BR2_m68k_cf'],
  64. 'test_options': ['BR2_m68k', 'BR2_m68k_cf5208'],
  65. 'prefix': 'm68k',
  66. },
  67. 'microblazebe': {
  68. 'conditions': ['BR2_microblazebe'],
  69. 'prefix': 'microblaze',
  70. 'gdbserver': False
  71. },
  72. 'microblazeel': {
  73. 'conditions': ['BR2_microblazeel'],
  74. 'prefix': 'microblazeel',
  75. 'gdbserver': False
  76. },
  77. 'mips32': {
  78. # Not sure it could be used by other mips32 variants?
  79. 'conditions': ['BR2_mips', 'BR2_mips_32', '!BR2_MIPS_SOFT_FLOAT'],
  80. 'prefix': 'mips',
  81. },
  82. 'mips32el': {
  83. # Not sure it could be used by other mips32el variants?
  84. 'conditions': ['BR2_mipsel', 'BR2_mips_32', '!BR2_MIPS_SOFT_FLOAT'],
  85. 'prefix': 'mipsel',
  86. },
  87. 'mips32r5el': {
  88. 'conditions': ['BR2_mipsel', 'BR2_mips_32r5', '!BR2_MIPS_SOFT_FLOAT'],
  89. 'prefix': 'mipsel',
  90. },
  91. 'mips32r6el': {
  92. 'conditions': ['BR2_mipsel', 'BR2_mips_32r6', '!BR2_MIPS_SOFT_FLOAT'],
  93. 'prefix': 'mipsel',
  94. },
  95. 'mips64': {
  96. # Not sure it could be used by other mips64 variants?
  97. 'conditions': ['BR2_mips64', 'BR2_mips_64', '!BR2_MIPS_SOFT_FLOAT'],
  98. 'prefix': 'mips64',
  99. },
  100. 'mips64-n32': {
  101. # Not sure it could be used by other mips64 variants?
  102. 'conditions': ['BR2_mips64', 'BR2_mips_64', 'BR2_MIPS_NABI32', '!BR2_MIPS_SOFT_FLOAT'],
  103. 'prefix': 'mips64',
  104. },
  105. 'mips64el-n32': {
  106. # Not sure it could be used by other mips64el variants?
  107. 'conditions': ['BR2_mips64el', 'BR2_mips_64', 'BR2_MIPS_NABI32', '!BR2_MIPS_SOFT_FLOAT'],
  108. 'prefix': 'mips64el',
  109. },
  110. 'mips64r6el-n32': {
  111. 'conditions': ['BR2_mips64el', 'BR2_mips_64r6', 'BR2_MIPS_NABI32', '!BR2_MIPS_SOFT_FLOAT'],
  112. 'prefix': 'mips64el',
  113. },
  114. 'nios2': {
  115. 'conditions': ['BR2_nios2'],
  116. 'prefix': 'nios2',
  117. },
  118. 'openrisc': {
  119. 'conditions': ['BR2_or1k'],
  120. 'prefix': 'or1k',
  121. 'gdbserver': False,
  122. },
  123. 'powerpc-440fp': {
  124. # Not sure it could be used by other powerpc variants?
  125. 'conditions': ['BR2_powerpc', 'BR2_powerpc_440fp'],
  126. 'prefix': 'powerpc',
  127. },
  128. 'powerpc-e300c3': {
  129. # Not sure it could be used by other powerpc variants?
  130. 'conditions': ['BR2_powerpc', 'BR2_powerpc_e300c3'],
  131. 'prefix': 'powerpc',
  132. },
  133. 'powerpc-e500mc': {
  134. # Not sure it could be used by other powerpc variants?
  135. 'conditions': ['BR2_powerpc', 'BR2_powerpc_e500mc'],
  136. 'prefix': 'powerpc',
  137. },
  138. 'powerpc64-e5500': {
  139. 'conditions': ['BR2_powerpc64', 'BR2_powerpc_e5500'],
  140. 'prefix': 'powerpc64',
  141. },
  142. 'powerpc64-e6500': {
  143. 'conditions': ['BR2_powerpc64', 'BR2_powerpc_e6500'],
  144. 'prefix': 'powerpc64',
  145. },
  146. 'powerpc64-power8': {
  147. 'conditions': ['BR2_powerpc64', 'BR2_powerpc_power8'],
  148. 'prefix': 'powerpc64',
  149. },
  150. 'powerpc64le-power8': {
  151. 'conditions': ['BR2_powerpc64le', 'BR2_powerpc_power8'],
  152. 'prefix': 'powerpc64le',
  153. },
  154. 'riscv32-ilp32d': {
  155. 'conditions': ['BR2_riscv', 'BR2_riscv_g', 'BR2_RISCV_32', 'BR2_RISCV_ABI_ILP32D'],
  156. 'prefix': 'riscv32',
  157. },
  158. 'riscv64-lp64d': {
  159. 'conditions': ['BR2_riscv', 'BR2_riscv_g', 'BR2_RISCV_64', 'BR2_RISCV_ABI_LP64D', 'BR2_USE_MMU'],
  160. 'prefix': 'riscv64',
  161. },
  162. 'sh-sh4': {
  163. 'conditions': ['BR2_sh', 'BR2_sh4'],
  164. 'prefix': 'sh4',
  165. },
  166. 'sh-sh4aeb': {
  167. 'conditions': ['BR2_sh', 'BR2_sh4aeb'],
  168. 'prefix': 'sh4aeb',
  169. },
  170. 'sparc64': {
  171. 'conditions': ['BR2_sparc64', 'BR2_sparc_v9'],
  172. 'prefix': 'sparc64',
  173. },
  174. 'sparcv8': {
  175. 'conditions': ['BR2_sparc', 'BR2_sparc_v8'],
  176. 'prefix': 'sparc',
  177. },
  178. 'x86-64': {
  179. 'conditions': ['BR2_x86_64',
  180. 'BR2_X86_CPU_HAS_MMX',
  181. 'BR2_X86_CPU_HAS_SSE',
  182. 'BR2_X86_CPU_HAS_SSE2'],
  183. 'test_options': ['BR2_x86_64', 'BR2_x86_x86_64'],
  184. 'prefix': 'x86_64',
  185. },
  186. 'x86-64-v2': {
  187. 'conditions': ['BR2_x86_64',
  188. 'BR2_X86_CPU_HAS_MMX',
  189. 'BR2_X86_CPU_HAS_SSE',
  190. 'BR2_X86_CPU_HAS_SSE2',
  191. 'BR2_X86_CPU_HAS_SSE3',
  192. 'BR2_X86_CPU_HAS_SSSE3',
  193. 'BR2_X86_CPU_HAS_SSE4',
  194. 'BR2_X86_CPU_HAS_SSE42'],
  195. 'test_options': ['BR2_x86_64', 'BR2_x86_x86_64_v2'],
  196. 'prefix': 'x86_64',
  197. },
  198. 'x86-64-v3': {
  199. 'conditions': ['BR2_x86_64',
  200. 'BR2_X86_CPU_HAS_MMX',
  201. 'BR2_X86_CPU_HAS_SSE',
  202. 'BR2_X86_CPU_HAS_SSE2',
  203. 'BR2_X86_CPU_HAS_SSE3',
  204. 'BR2_X86_CPU_HAS_SSSE3',
  205. 'BR2_X86_CPU_HAS_SSE4',
  206. 'BR2_X86_CPU_HAS_SSE42',
  207. 'BR2_X86_CPU_HAS_AVX',
  208. 'BR2_X86_CPU_HAS_AVX2'],
  209. 'test_options': ['BR2_x86_64', 'BR2_x86_x86_64_v3'],
  210. 'prefix': 'x86_64',
  211. },
  212. 'x86-64-v4': {
  213. 'conditions': ['BR2_x86_64',
  214. 'BR2_X86_CPU_HAS_MMX',
  215. 'BR2_X86_CPU_HAS_SSE',
  216. 'BR2_X86_CPU_HAS_SSE2',
  217. 'BR2_X86_CPU_HAS_SSE3',
  218. 'BR2_X86_CPU_HAS_SSSE3',
  219. 'BR2_X86_CPU_HAS_SSE4',
  220. 'BR2_X86_CPU_HAS_SSE42',
  221. 'BR2_X86_CPU_HAS_AVX',
  222. 'BR2_X86_CPU_HAS_AVX2',
  223. 'BR2_X86_CPU_HAS_AVX512'],
  224. 'test_options': ['BR2_x86_64', 'BR2_x86_x86_64_v4'],
  225. 'prefix': 'x86_64',
  226. },
  227. 'x86-64-core-i7': {
  228. 'conditions': ['BR2_x86_64',
  229. 'BR2_X86_CPU_HAS_MMX',
  230. 'BR2_X86_CPU_HAS_SSE',
  231. 'BR2_X86_CPU_HAS_SSE2',
  232. 'BR2_X86_CPU_HAS_SSE3',
  233. 'BR2_X86_CPU_HAS_SSSE3',
  234. 'BR2_X86_CPU_HAS_SSE4',
  235. 'BR2_X86_CPU_HAS_SSE42'],
  236. 'test_options': ['BR2_x86_64', 'BR2_x86_corei7'],
  237. 'prefix': 'x86_64',
  238. },
  239. 'x86-core2': {
  240. 'conditions': ['BR2_i386',
  241. 'BR2_X86_CPU_HAS_MMX',
  242. 'BR2_X86_CPU_HAS_SSE',
  243. 'BR2_X86_CPU_HAS_SSE2',
  244. 'BR2_X86_CPU_HAS_SSE3',
  245. 'BR2_X86_CPU_HAS_SSSE3'],
  246. 'test_options': ['BR2_i386', 'BR2_x86_core2'],
  247. 'prefix': 'i686',
  248. },
  249. 'x86-i686': {
  250. 'conditions': ['BR2_i386',
  251. '!BR2_x86_i486',
  252. '!BR2_x86_i586',
  253. '!BR2_x86_x1000',
  254. '!BR2_x86_pentium_mmx',
  255. '!BR2_x86_geode',
  256. '!BR2_x86_c3',
  257. '!BR2_x86_winchip_c6',
  258. '!BR2_x86_winchip2'],
  259. 'test_options': ['BR2_i386',
  260. 'BR2_x86_i686'],
  261. 'prefix': 'i686',
  262. },
  263. 'xtensa-lx60': {
  264. 'conditions': ['BR2_xtensa', 'BR2_XTENSA_CUSTOM', 'BR2_XTENSA_LITTLE_ENDIAN'],
  265. 'prefix': 'xtensa',
  266. },
  267. }
  268. class Toolchain:
  269. def __init__(self, arch, libc, variant, version):
  270. self.arch = arch
  271. self.libc = libc
  272. self.variant = variant
  273. self.version = version
  274. self.fname_prefix = "%s--%s--%s-%s" % (self.arch, self.libc, self.variant, self.version)
  275. self.option_name = "BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_%s_%s_%s" % \
  276. (self.arch.replace("-", "_").upper(), self.libc.upper(), self.variant.replace("-", "_").upper())
  277. self.fragment = requests.get(self.fragment_url).text.split("\n")
  278. self.sha256 = requests.get(self.hash_url).text.split(" ")[0]
  279. @property
  280. def tarball_url(self):
  281. return os.path.join(BASE_URL, self.arch, "tarballs",
  282. self.fname_prefix + ".tar.bz2")
  283. @property
  284. def hash_url(self):
  285. return os.path.join(BASE_URL, self.arch, "tarballs",
  286. self.fname_prefix + ".sha256")
  287. @property
  288. def fragment_url(self):
  289. return os.path.join(BASE_URL, self.arch, "fragments",
  290. self.fname_prefix + ".frag")
  291. def gen_config_in_options(self, f):
  292. f.write("config %s\n" % self.option_name)
  293. f.write("\tbool \"%s %s %s %s\"\n" %
  294. (self.arch, self.libc, self.variant, self.version))
  295. depends = []
  296. selects = []
  297. for c in arches[self.arch]['conditions']:
  298. depends.append(c)
  299. if not arches[self.arch].get('gdbserver', True):
  300. selects.append("BR2_TOOLCHAIN_EXTERNAL_HAS_NO_GDBSERVER")
  301. for frag in self.fragment:
  302. # libc type
  303. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC"):
  304. selects.append("BR2_TOOLCHAIN_EXTERNAL_UCLIBC")
  305. elif frag.startswith("BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC"):
  306. # glibc needs mmu support
  307. if "BR2_USE_MMU" not in depends:
  308. depends.append("BR2_USE_MMU")
  309. # glibc doesn't support static only configuration
  310. depends.append("!BR2_STATIC_LIBS")
  311. selects.append("BR2_TOOLCHAIN_EXTERNAL_GLIBC")
  312. elif frag.startswith("BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL"):
  313. # musl needs mmu support
  314. if "BR2_USE_MMU" not in depends:
  315. depends.append("BR2_USE_MMU")
  316. selects.append("BR2_TOOLCHAIN_EXTERNAL_MUSL")
  317. # gcc version
  318. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_GCC_"):
  319. m = re.match("^BR2_TOOLCHAIN_EXTERNAL_GCC_([0-9_]*)=y$", frag)
  320. assert m, "Cannot get gcc version for toolchain %s" % self.fname_prefix
  321. selects.append("BR2_TOOLCHAIN_GCC_AT_LEAST_%s" % m[1])
  322. # kernel headers version
  323. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HEADERS_"):
  324. m = re.match("^BR2_TOOLCHAIN_EXTERNAL_HEADERS_([0-9_]*)=y$", frag)
  325. assert m, "Cannot get kernel headers version for toolchain %s" % self.fname_prefix
  326. selects.append("BR2_TOOLCHAIN_HEADERS_AT_LEAST_%s" % m[1])
  327. # C++
  328. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_CXX"):
  329. selects.append("BR2_INSTALL_LIBSTDCPP")
  330. # SSP
  331. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HAS_SSP"):
  332. selects.append("BR2_TOOLCHAIN_HAS_SSP")
  333. # wchar
  334. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_WCHAR"):
  335. selects.append("BR2_USE_WCHAR")
  336. # locale
  337. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_LOCALE"):
  338. # locale implies the availability of wchar
  339. selects.append("BR2_USE_WCHAR")
  340. selects.append("BR2_ENABLE_LOCALE")
  341. # thread support
  342. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS"):
  343. selects.append("BR2_TOOLCHAIN_HAS_THREADS")
  344. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG"):
  345. selects.append("BR2_TOOLCHAIN_HAS_THREADS_DEBUG")
  346. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_NPTL"):
  347. selects.append("BR2_TOOLCHAIN_HAS_THREADS_NPTL")
  348. # RPC
  349. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_INET_RPC"):
  350. selects.append("BR2_TOOLCHAIN_HAS_NATIVE_RPC")
  351. # D language
  352. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_DLANG"):
  353. selects.append("BR2_TOOLCHAIN_HAS_DLANG")
  354. # fortran
  355. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_FORTRAN"):
  356. selects.append("BR2_TOOLCHAIN_HAS_FORTRAN")
  357. # OpenMP
  358. if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_OPENMP"):
  359. selects.append("BR2_TOOLCHAIN_HAS_OPENMP")
  360. for depend in depends:
  361. f.write("\tdepends on %s\n" % depend)
  362. for select in selects:
  363. f.write("\tselect %s\n" % select)
  364. f.write("\thelp\n")
  365. desc = "Bootlin toolchain for the %s architecture, using the %s C library. " % \
  366. (self.arch, self.libc)
  367. if self.variant == "stable":
  368. desc += "This is a stable version, which means it is using stable and proven versions of gcc, gdb and binutils."
  369. else:
  370. desc += "This is a bleeding-edge version, which means it is using the latest versions of gcc, gdb and binutils."
  371. f.write(textwrap.fill(desc, width=62, initial_indent="\t ", subsequent_indent="\t ") + "\n")
  372. f.write("\n")
  373. f.write("\t https://toolchains.bootlin.com/\n")
  374. f.write("\n")
  375. def gen_mk(self, f):
  376. f.write("ifeq ($(%s),y)\n" % self.option_name)
  377. f.write("TOOLCHAIN_EXTERNAL_BOOTLIN_VERSION = %s\n" % self.version)
  378. f.write("TOOLCHAIN_EXTERNAL_BOOTLIN_SOURCE = %s--%s--%s-$(TOOLCHAIN_EXTERNAL_BOOTLIN_VERSION).tar.bz2\n" %
  379. (self.arch, self.libc, self.variant))
  380. f.write("TOOLCHAIN_EXTERNAL_BOOTLIN_SITE = %s\n" %
  381. os.path.join(BASE_URL, self.arch, "tarballs"))
  382. f.write("endif\n\n")
  383. pass
  384. def gen_hash(self, f):
  385. f.write("# From %s\n" % self.hash_url)
  386. f.write("sha256 %s %s\n" % (self.sha256, os.path.basename(self.tarball_url)))
  387. def gen_test(self, f):
  388. if self.variant == "stable":
  389. variant = "Stable"
  390. else:
  391. variant = "BleedingEdge"
  392. testname = "TestExternalToolchainBootlin" + \
  393. self.arch.replace("-", "").capitalize() + \
  394. self.libc.capitalize() + variant
  395. f.write("\n\n")
  396. f.write("class %s(TestExternalToolchain):\n" % testname)
  397. f.write(" config = \"\"\"\n")
  398. if 'test_options' in arches[self.arch]:
  399. test_options = arches[self.arch]['test_options']
  400. else:
  401. test_options = arches[self.arch]['conditions']
  402. for opt in test_options:
  403. if opt.startswith("!"):
  404. f.write(" # %s is not set\n" % opt[1:])
  405. else:
  406. f.write(" %s=y\n" % opt)
  407. f.write(" BR2_TOOLCHAIN_EXTERNAL=y\n")
  408. f.write(" BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y\n")
  409. f.write(" %s=y\n" % self.option_name)
  410. f.write(" # BR2_TARGET_ROOTFS_TAR is not set\n")
  411. f.write(" \"\"\"\n")
  412. f.write(" toolchain_prefix = \"%s-linux\"\n" % arches[self.arch]['prefix'])
  413. f.write("\n")
  414. f.write(" def test_run(self):\n")
  415. f.write(" TestExternalToolchain.common_check(self)\n")
  416. def __repr__(self):
  417. return "Toolchain(arch=%s libc=%s variant=%s version=%s, option=%s)" % \
  418. (self.arch, self.libc, self.variant, self.version, self.option_name)
  419. def get_toolchains():
  420. toolchains = list()
  421. for arch, details in arches.items():
  422. print(arch)
  423. url = os.path.join(BASE_URL, arch, "available_toolchains")
  424. page = requests.get(url).text
  425. fnames = sorted(re.findall(r'<td><a href="(\w[^"]+)"', page))
  426. # This dict will allow us to keep only the latest version for
  427. # each toolchain.
  428. tmp = dict()
  429. for fname in fnames:
  430. parts = fname.split('--')
  431. assert parts[0] == arch, "Arch does not match: %s vs. %s" % (parts[0], arch)
  432. libc = parts[1]
  433. if parts[2].startswith("stable-"):
  434. variant = "stable"
  435. version = parts[2][len("stable-"):]
  436. elif parts[2].startswith("bleeding-edge-"):
  437. variant = "bleeding-edge"
  438. version = parts[2][len("bleeding-edge-"):]
  439. tmp[(arch, libc, variant)] = version
  440. toolchains += [Toolchain(k[0], k[1], k[2], v) for k, v in tmp.items()]
  441. return toolchains
  442. def gen_config_in_options(toolchains, fpath):
  443. with open(fpath, "w") as f:
  444. f.write(AUTOGENERATED_COMMENT)
  445. f.write("config BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARCH_SUPPORTS\n")
  446. f.write("\tbool\n")
  447. for arch, details in arches.items():
  448. conditions = details['conditions'].copy()
  449. if set([t.libc for t in toolchains if t.arch == arch]) == set(['glibc']):
  450. conditions.append("!BR2_STATIC_LIBS")
  451. f.write("\tdefault y if %s\n" % " && ".join(conditions))
  452. f.write("\n")
  453. f.write("if BR2_TOOLCHAIN_EXTERNAL_BOOTLIN\n\n")
  454. f.write("config BR2_TOOLCHAIN_EXTERNAL_PREFIX\n")
  455. f.write("\tdefault \"$(ARCH)-linux\"\n")
  456. f.write("\n")
  457. f.write("config BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL\n")
  458. f.write("\tdefault \"toolchain-external-bootlin\"\n")
  459. f.write("\n")
  460. f.write("choice\n")
  461. f.write("\tprompt \"Bootlin toolchain variant\"\n")
  462. for toolchain in toolchains:
  463. toolchain.gen_config_in_options(f)
  464. f.write("endchoice\n")
  465. f.write("endif\n")
  466. def gen_mk(toolchains, fpath):
  467. with open(fpath, "w") as f:
  468. f.write("#" * 80 + "\n")
  469. f.write("#\n")
  470. f.write("# toolchain-external-bootlin\n")
  471. f.write("#\n")
  472. f.write("#" * 80 + "\n")
  473. f.write("\n")
  474. f.write(AUTOGENERATED_COMMENT)
  475. for toolchain in toolchains:
  476. toolchain.gen_mk(f)
  477. f.write("$(eval $(toolchain-external-package))\n")
  478. def gen_hash(toolchains, fpath):
  479. with open(fpath, "w") as f:
  480. f.write(AUTOGENERATED_COMMENT)
  481. for toolchain in toolchains:
  482. toolchain.gen_hash(f)
  483. def gen_runtime_test(toolchains, fpath):
  484. with open(fpath, "w") as f:
  485. f.write(AUTOGENERATED_COMMENT)
  486. f.write("from tests.toolchain.test_external import TestExternalToolchain\n")
  487. for toolchain in toolchains:
  488. toolchain.gen_test(f)
  489. def gen_toolchains(toolchains):
  490. maindir = "toolchain/toolchain-external/toolchain-external-bootlin"
  491. gen_config_in_options(toolchains, os.path.join(maindir, "Config.in.options"))
  492. gen_mk(toolchains, os.path.join(maindir, "toolchain-external-bootlin.mk"))
  493. gen_hash(toolchains, os.path.join(maindir, "toolchain-external-bootlin.hash"))
  494. gen_runtime_test(toolchains,
  495. os.path.join("support", "testing", "tests", "toolchain", "test_external_bootlin.py"))
  496. toolchains = get_toolchains()
  497. gen_toolchains(toolchains)