rust.mk 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ################################################################################
  2. #
  3. # rust
  4. #
  5. ################################################################################
  6. # When updating this version, check whether support/download/cargo-post-process
  7. # still generates the same archives.
  8. RUST_VERSION = 1.67.0
  9. RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz
  10. RUST_SITE = https://static.rust-lang.org/dist
  11. RUST_LICENSE = Apache-2.0 or MIT
  12. RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
  13. HOST_RUST_PROVIDES = host-rustc
  14. HOST_RUST_DEPENDENCIES = \
  15. toolchain \
  16. host-pkgconf \
  17. host-python3 \
  18. host-rust-bin \
  19. host-openssl \
  20. $(BR2_CMAKE_HOST_DEPENDENCY)
  21. HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0)
  22. # Some vendor crates contain Cargo.toml.orig files. The associated
  23. # .cargo-checksum.json file will contain a checksum for Cargo.toml.orig but
  24. # support/scripts/apply-patches.sh will delete them. This will cause the build
  25. # to fail, as Cargo will not be able to find the file and verify the checksum.
  26. # So, remove all Cargo.toml.orig entries from the affected .cargo-checksum.json
  27. # files
  28. define HOST_RUST_EXCLUDE_ORIG_FILES
  29. for file in $$(find $(@D) -name '*.orig'); do \
  30. crate=$$(dirname $${file}); \
  31. fn=$${crate}/.cargo-checksum.json; \
  32. sed -i -e 's/"Cargo.toml.orig":"[a-z0-9]\+",//g' $${fn}; \
  33. done
  34. endef
  35. HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_EXCLUDE_ORIG_FILES
  36. define HOST_RUST_CONFIGURE_CMDS
  37. ( \
  38. echo '[build]'; \
  39. echo 'target = ["$(RUSTC_TARGET_NAME)"]'; \
  40. echo 'cargo = "$(HOST_RUST_BIN_DIR)/cargo/bin/cargo"'; \
  41. echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \
  42. echo 'python = "$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR)"'; \
  43. echo 'submodules = false'; \
  44. echo 'vendor = true'; \
  45. echo 'extended = true'; \
  46. echo 'tools = ["cargo"]'; \
  47. echo 'compiler-docs = false'; \
  48. echo 'docs = false'; \
  49. echo 'verbose = $(HOST_RUST_VERBOSITY)'; \
  50. echo '[install]'; \
  51. echo 'prefix = "$(HOST_DIR)"'; \
  52. echo 'sysconfdir = "$(HOST_DIR)/etc"'; \
  53. echo '[rust]'; \
  54. echo 'channel = "stable"'; \
  55. echo 'musl-root = "$(STAGING_DIR)"' ; \
  56. echo '[target.$(RUSTC_TARGET_NAME)]'; \
  57. echo 'cc = "$(TARGET_CROSS)gcc"'; \
  58. echo '[llvm]'; \
  59. echo 'ninja = false'; \
  60. ) > $(@D)/config.toml
  61. endef
  62. define HOST_RUST_BUILD_CMDS
  63. cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py build
  64. endef
  65. HOST_RUST_INSTALL_OPTS = \
  66. --prefix=$(HOST_DIR) \
  67. --disable-ldconfig
  68. define HOST_RUST_INSTALL_RUSTC
  69. cd $(@D)/build/tmp/tarball/rust/$(RUSTC_HOST_NAME)/rust-$(RUST_VERSION)-$(RUSTC_HOST_NAME); \
  70. ./install.sh $(HOST_RUST_INSTALL_OPTS) --components=rustc,cargo,rust-std-$(RUSTC_HOST_NAME)
  71. endef
  72. ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
  73. define HOST_RUST_INSTALL_LIBSTD_TARGET
  74. cd $(@D)/build/tmp/tarball/rust-std/$(RUSTC_TARGET_NAME)/rust-std-$(RUST_VERSION)-$(RUSTC_TARGET_NAME); \
  75. ./install.sh $(HOST_RUST_INSTALL_OPTS)
  76. endef
  77. endif
  78. define HOST_RUST_INSTALL_CMDS
  79. cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py dist
  80. $(HOST_RUST_INSTALL_RUSTC)
  81. $(HOST_RUST_INSTALL_LIBSTD_TARGET)
  82. endef
  83. $(eval $(host-generic-package))